feat: 智聪记账管理,物价管理-物价记录代码提交。
This commit is contained in:
44
src/api/invest/productPriceRecord.js
Normal file
44
src/api/invest/productPriceRecord.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询物价记录列表
|
||||||
|
export function listProductPriceRecord(query) {
|
||||||
|
return request({
|
||||||
|
url: '/invest/productPriceRecord/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询物价记录详细
|
||||||
|
export function getProductPriceRecord(id) {
|
||||||
|
return request({
|
||||||
|
url: '/invest/productPriceRecord/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增物价记录
|
||||||
|
export function addProductPriceRecord(data) {
|
||||||
|
return request({
|
||||||
|
url: '/invest/productPriceRecord',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改物价记录
|
||||||
|
export function updateProductPriceRecord(data) {
|
||||||
|
return request({
|
||||||
|
url: '/invest/productPriceRecord',
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除物价记录
|
||||||
|
export function delProductPriceRecord(id) {
|
||||||
|
return request({
|
||||||
|
url: '/invest/productPriceRecord/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
424
src/views/invest/productPriceRecord/index.vue
Normal file
424
src/views/invest/productPriceRecord/index.vue
Normal file
@@ -0,0 +1,424 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<div class="search-con">
|
||||||
|
<div class="title">查询条件</div>
|
||||||
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
|
||||||
|
<el-form-item label="类别" prop="category">
|
||||||
|
<el-select v-model="queryParams.category" @change="handleQueryCategoryChange" placeholder="请选择类别" clearable>
|
||||||
|
<el-option v-for="dict in product_category" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="商品名称" prop="productId">
|
||||||
|
<el-select v-model="queryParams.productId" placeholder="请选择商品名称" clearable>
|
||||||
|
<el-option v-for="product in productList" :key="product.id" :label="product.name" :value="product.id" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="子类别" prop="kind">
|
||||||
|
<el-input v-model="queryParams.kind" placeholder="请输入子类别" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="地点" prop="address">
|
||||||
|
<el-input v-model="queryParams.address" placeholder="请输入地点" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<!-- <el-form-item label="商家" prop="merchant">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.merchant"
|
||||||
|
placeholder="请输入商家"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item label="记录时间" prop="time">
|
||||||
|
<el-date-picker v-model="queryParams.time" type="daterange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div class="search-btn-con">
|
||||||
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button type="info" icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="main-con">
|
||||||
|
<div class="title-con">
|
||||||
|
<div class="title">基本信息</div>
|
||||||
|
<div class="operate-btn-con">
|
||||||
|
<el-button @click="handleAdd" icon="Plus" v-hasPermi="['invest:productPriceRecord:add']">新增</el-button>
|
||||||
|
<el-button :disabled="multiple" icon="Delete" @click="handleDelete" v-hasPermi="['invest:productPriceRecord:remove']">删除</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="content-con" v-loading="loading">
|
||||||
|
<el-table v-loading="loading" :data="productPriceRecordList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="类别" align="center" prop="category">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :options="product_category" :value="scope.row.category" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="商品名称" align="center" prop="productName" />
|
||||||
|
<el-table-column label="子类别" align="center" prop="kind" />
|
||||||
|
<el-table-column label="价格" align="center" prop="price" />
|
||||||
|
<el-table-column label="单位" align="center" prop="unit">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :options="product_unit" :value="scope.row.unit" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="记录时间" align="center" prop="recordTime" width="180"> </el-table-column>
|
||||||
|
<el-table-column label="地点" align="center" prop="address" />
|
||||||
|
<el-table-column label="商家" align="center" prop="merchant" />
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<div class="ctrl-btn d-flex">
|
||||||
|
<el-tooltip v-for="item in operateList" :key="item.id" class="item" effect="dark" :content="item.title" placement="top">
|
||||||
|
<el-button :icon="item.icon" :v-hasPermi="item.hasPermi" circle @click="handleOperate(item.id, scope.row)"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<el-pagination small background layout="total, prev, pager, next" :total="total" @current-change="handleCurrentChange" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- 添加或修改物价记录对话框 -->
|
||||||
|
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="productPriceRecordRef" :model="form" :rules="rules" label-width="100px">
|
||||||
|
<el-form-item label="类别" prop="category">
|
||||||
|
<el-select v-model="form.category" placeholder="请选择类别" @change="handleCategoryChange">
|
||||||
|
<el-option v-for="dict in product_category" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="商品名称" prop="productId">
|
||||||
|
<el-select v-model="form.productId" placeholder="请选择商品名称" @change="handleProductChange" clearable>
|
||||||
|
<el-option v-for="product in addProductList" :key="product.id" :label="product.name" :value="product.id" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="子类别" prop="kind">
|
||||||
|
<el-input v-model="form.kind" placeholder="请输入子类别" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="价格" prop="price">
|
||||||
|
<el-input v-model="form.price" type="number" placeholder="请输入总费用">
|
||||||
|
<template #suffix>元</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="单位" prop="unit">
|
||||||
|
<el-select v-model="form.unit" placeholder="请选择单位">
|
||||||
|
<el-option v-for="dict in product_unit" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="记录时间" prop="recordTime">
|
||||||
|
<el-date-picker clearable v-model="form.recordTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择记录时间"> </el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="地点" prop="address">
|
||||||
|
<el-input v-model="form.address" placeholder="请输入地点" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="商家" prop="merchant">
|
||||||
|
<el-input v-model="form.merchant" placeholder="请输入商家" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template v-if="title !== '查看物价记录'" #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="ProductPriceRecord">
|
||||||
|
import {
|
||||||
|
listProductPriceRecord,
|
||||||
|
getProductPriceRecord,
|
||||||
|
delProductPriceRecord,
|
||||||
|
addProductPriceRecord,
|
||||||
|
updateProductPriceRecord
|
||||||
|
} from '@/api/invest/productPriceRecord'
|
||||||
|
import { listProductInfor, getProductInfor } from '@/api/invest/productInfor'
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import { require } from '@/utils/require'
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
const { product_category, product_unit } = proxy.useDict('product_category', 'product_unit')
|
||||||
|
|
||||||
|
const productPriceRecordList = ref([])
|
||||||
|
const open = ref(false)
|
||||||
|
const loading = ref(true)
|
||||||
|
const showSearch = ref(true)
|
||||||
|
const ids = ref([])
|
||||||
|
const single = ref(true)
|
||||||
|
const multiple = ref(true)
|
||||||
|
const total = ref(0)
|
||||||
|
const title = ref('')
|
||||||
|
|
||||||
|
const productList = ref([])
|
||||||
|
const addProductList = ref([])
|
||||||
|
|
||||||
|
const operateList = ref([
|
||||||
|
{ id: 'view', icon: 'View', title: '查看', hasPermi: ['invest:productPriceRecord:query'] },
|
||||||
|
{ id: 'edit', icon: 'Edit', title: '修改', hasPermi: ['invest:productPriceRecord:edit'] },
|
||||||
|
{ id: 'copy', icon: 'Link', title: '复制', hasPermi: ['health:marRecord:edit'] },
|
||||||
|
{ id: 'delete', icon: 'Delete', title: '删除', hasPermi: ['invest:productPriceRecord:remove'] }
|
||||||
|
])
|
||||||
|
const data = reactive({
|
||||||
|
form: {},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
time: '',
|
||||||
|
productId: null,
|
||||||
|
price: null,
|
||||||
|
recordTime: null,
|
||||||
|
address: null,
|
||||||
|
merchant: null,
|
||||||
|
kind: null,
|
||||||
|
category: null
|
||||||
|
},
|
||||||
|
queryProductParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 1000
|
||||||
|
},
|
||||||
|
queryAddProductParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
category: '',
|
||||||
|
pageSize: 1000
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
productId: [{ required: true, message: '商品ID不能为空', trigger: 'blur' }],
|
||||||
|
price: [{ required: true, message: '价格不能为空', trigger: 'blur' }],
|
||||||
|
recordTime: [{ required: true, message: '记录时间不能为空', trigger: 'blur' }],
|
||||||
|
unit: [{ required: true, message: '单位不能为空', trigger: 'blur' }],
|
||||||
|
kind: [{ required: true, message: '子类别不能为空', trigger: 'blur' }],
|
||||||
|
category: [{ required: true, message: '类别不能为空', trigger: 'change' }]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleOperate = (operate, row) => {
|
||||||
|
switch (operate) {
|
||||||
|
case 'view':
|
||||||
|
handleView(row)
|
||||||
|
break
|
||||||
|
case 'edit':
|
||||||
|
handleUpdate(row)
|
||||||
|
break
|
||||||
|
case 'delete':
|
||||||
|
handleDelete(row)
|
||||||
|
break
|
||||||
|
case 'copy':
|
||||||
|
handleCopy(row)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const { queryParams, queryProductParams, queryAddProductParams, form, rules } = toRefs(data)
|
||||||
|
|
||||||
|
const handleProductChange = (productId) => {
|
||||||
|
getProductInfor(productId).then((response) => {
|
||||||
|
form.value.kind = response.data.name
|
||||||
|
form.value.category = response.data.category
|
||||||
|
form.value.unit = response.data.unit
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleQueryCategoryChange = (category) => {
|
||||||
|
queryProductParams.value.category = category
|
||||||
|
queryParams.value.productId = null
|
||||||
|
listProductInfor(queryProductParams.value).then((response) => {
|
||||||
|
productList.value = response.rows
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCategoryChange = (category) => {
|
||||||
|
queryAddProductParams.value.category = category
|
||||||
|
form.value.productId = null
|
||||||
|
form.value.kind = null
|
||||||
|
listProductInfor(queryAddProductParams.value).then((response) => {
|
||||||
|
addProductList.value = response.rows
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询商品管理列表 */
|
||||||
|
function getProductList() {
|
||||||
|
listProductInfor(queryProductParams.value).then((response) => {
|
||||||
|
productList.value = response.rows
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询商品管理列表 */
|
||||||
|
function getAddProductList() {
|
||||||
|
listProductInfor(queryAddProductParams.value).then((response) => {
|
||||||
|
addProductList.value = response.rows
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询物价记录列表 */
|
||||||
|
function getList() {
|
||||||
|
loading.value = true
|
||||||
|
const timeRange = queryParams.value.time
|
||||||
|
let st = ''
|
||||||
|
let et = ''
|
||||||
|
if (timeRange && timeRange.length === 2) {
|
||||||
|
st = dayjs(timeRange[0]).format('YYYY-MM-DD')
|
||||||
|
et = dayjs(timeRange[1]).format('YYYY-MM-DD')
|
||||||
|
}
|
||||||
|
queryParams.value.startTime = st
|
||||||
|
queryParams.value.endTime = et
|
||||||
|
listProductPriceRecord(queryParams.value).then((response) => {
|
||||||
|
productPriceRecordList.value = response.rows
|
||||||
|
total.value = response.total
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消按钮
|
||||||
|
function cancel() {
|
||||||
|
open.value = false
|
||||||
|
reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表单重置
|
||||||
|
function reset() {
|
||||||
|
form.value = {
|
||||||
|
id: null,
|
||||||
|
productId: null,
|
||||||
|
price: null,
|
||||||
|
recordTime: null,
|
||||||
|
remark: null,
|
||||||
|
createTime: null,
|
||||||
|
createBy: null,
|
||||||
|
updateTime: null,
|
||||||
|
updatedBy: null,
|
||||||
|
address: null,
|
||||||
|
delFlag: null,
|
||||||
|
merchant: null,
|
||||||
|
fields: null,
|
||||||
|
unit: null,
|
||||||
|
kind: null,
|
||||||
|
category: null
|
||||||
|
}
|
||||||
|
proxy.resetForm('productPriceRecordRef')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
queryParams.value.pageNum = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function resetQuery() {
|
||||||
|
proxy.resetForm('queryRef')
|
||||||
|
queryProductParams.value.category = null
|
||||||
|
getProductList()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
const handleCurrentChange = (val) => {
|
||||||
|
queryParams.value.pageNum = val
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 多选框选中数据
|
||||||
|
function handleSelectionChange(selection) {
|
||||||
|
ids.value = selection.map((item) => item.id)
|
||||||
|
single.value = selection.length !== 1
|
||||||
|
multiple.value = !selection.length
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查看
|
||||||
|
const handleView = (row) => {
|
||||||
|
title.value = '查看物价记录'
|
||||||
|
form.value = row
|
||||||
|
open.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 复制按钮操作 */
|
||||||
|
function handleCopy(row) {
|
||||||
|
reset()
|
||||||
|
const _id = row.id || ids.value
|
||||||
|
getProductPriceRecord(_id).then((response) => {
|
||||||
|
queryAddProductParams.value.category = response.data.category
|
||||||
|
listProductInfor(queryAddProductParams.value).then((response) => {
|
||||||
|
addProductList.value = response.rows
|
||||||
|
})
|
||||||
|
form.value = response.data
|
||||||
|
form.value.id = null
|
||||||
|
open.value = true
|
||||||
|
title.value = '复制物价记录'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
function handleAdd() {
|
||||||
|
reset()
|
||||||
|
open.value = true
|
||||||
|
title.value = '添加物价记录'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
function handleUpdate(row) {
|
||||||
|
reset()
|
||||||
|
const _id = row.id || ids.value
|
||||||
|
getProductPriceRecord(_id).then((response) => {
|
||||||
|
queryAddProductParams.value.category = response.data.category
|
||||||
|
listProductInfor(queryAddProductParams.value).then((response) => {
|
||||||
|
addProductList.value = response.rows
|
||||||
|
})
|
||||||
|
form.value = response.data
|
||||||
|
open.value = true
|
||||||
|
title.value = '修改物价记录'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
proxy.$refs.productPriceRecordRef.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
if (form.value.id != null) {
|
||||||
|
updateProductPriceRecord(form.value).then((response) => {
|
||||||
|
proxy.$modal.msgSuccess('修改成功')
|
||||||
|
open.value = false
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
addProductPriceRecord(form.value).then((response) => {
|
||||||
|
proxy.$modal.msgSuccess('新增成功')
|
||||||
|
open.value = false
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
function handleDelete(row) {
|
||||||
|
const _ids = row.id || ids.value
|
||||||
|
proxy.$modal
|
||||||
|
.confirm('是否确认删除选中的数据项?')
|
||||||
|
.then(function () {
|
||||||
|
return delProductPriceRecord(_ids)
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
getList()
|
||||||
|
proxy.$modal.msgSuccess('删除成功')
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
function handleExport() {
|
||||||
|
proxy.download(
|
||||||
|
'invest/productPriceRecord/export',
|
||||||
|
{
|
||||||
|
...queryParams.value
|
||||||
|
},
|
||||||
|
`productPriceRecord_${new Date().getTime()}.xlsx`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
getProductList()
|
||||||
|
getAddProductList()
|
||||||
|
getList()
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user