feat: 智聪记账管理,新增物价管理-商品基础信息管理。
This commit is contained in:
44
src/api/invest/productInfor.js
Normal file
44
src/api/invest/productInfor.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询商品基础信息列表
|
||||||
|
export function listProductInfor(query) {
|
||||||
|
return request({
|
||||||
|
url: '/invest/productInfor/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询商品基础信息详细
|
||||||
|
export function getProductInfor(id) {
|
||||||
|
return request({
|
||||||
|
url: '/invest/productInfor/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增商品基础信息
|
||||||
|
export function addProductInfor(data) {
|
||||||
|
return request({
|
||||||
|
url: '/invest/productInfor',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改商品基础信息
|
||||||
|
export function updateProductInfor(data) {
|
||||||
|
return request({
|
||||||
|
url: '/invest/productInfor',
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除商品基础信息
|
||||||
|
export function delProductInfor(id) {
|
||||||
|
return request({
|
||||||
|
url: '/invest/productInfor/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
293
src/views/invest/productInfor/index.vue
Normal file
293
src/views/invest/productInfor/index.vue
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
<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="name">
|
||||||
|
<el-input v-model="queryParams.name" placeholder="请输入商品名称" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="商品编码" prop="code">
|
||||||
|
<el-input v-model="queryParams.code" placeholder="请输入商品编码" clearable @keyup.enter="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="类别" prop="category">
|
||||||
|
<el-select v-model="queryParams.category" 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="unit">
|
||||||
|
<el-select v-model="queryParams.unit" placeholder="请选择单位" clearable>
|
||||||
|
<el-option v-for="dict in product_unit" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||||
|
</el-select>
|
||||||
|
</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:productInfor:add']">新增</el-button>
|
||||||
|
<el-button :disabled="multiple" icon="Delete" @click="handleDelete" v-hasPermi="['invest:productInfor:remove']">删除</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="content-con" v-loading="loading">
|
||||||
|
<el-table v-loading="loading" :data="productInforList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="商品名称" align="center" prop="name" />
|
||||||
|
<el-table-column label="商品编码" align="center" prop="code" />
|
||||||
|
<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="unit">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :options="product_unit" :value="scope.row.unit" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="排序" align="center" prop="ranking" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<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="productInforRef" :model="form" :rules="rules" label-width="120px">
|
||||||
|
<el-form-item label="商品名称" prop="name">
|
||||||
|
<el-input v-model="form.name" placeholder="请输入商品名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="商品编码" prop="code">
|
||||||
|
<el-input v-model="form.code" placeholder="请输入商品编码" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="类别" prop="category">
|
||||||
|
<el-select v-model="form.category" placeholder="请选择类别">
|
||||||
|
<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="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="ranking">
|
||||||
|
<el-input v-model="form.ranking" 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="ProductInfor">
|
||||||
|
import { listProductInfor, getProductInfor, delProductInfor, addProductInfor, updateProductInfor } from '@/api/invest/productInfor'
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
import { require } from '@/utils/require'
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
const { product_category, product_unit } = proxy.useDict('product_category', 'product_unit')
|
||||||
|
|
||||||
|
const productInforList = 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 operateList = ref([
|
||||||
|
{ id: 'view', icon: 'View', title: '查看', hasPermi: ['invest:productInfor:query'] },
|
||||||
|
{ id: 'edit', icon: 'Edit', title: '修改', hasPermi: ['invest:productInfor:edit'] },
|
||||||
|
{ id: 'delete', icon: 'Delete', title: '删除', hasPermi: ['invest:productInfor:remove'] }
|
||||||
|
])
|
||||||
|
const data = reactive({
|
||||||
|
form: {},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
name: null,
|
||||||
|
category: null,
|
||||||
|
unit: null,
|
||||||
|
code: null
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
name: [{ required: true, message: '商品名称不能为空', trigger: 'blur' }],
|
||||||
|
code: [{ required: true, message: '商品编码不能为空', trigger: 'blur' }],
|
||||||
|
category: [{ required: true, message: '类别不能为空', trigger: 'change' }],
|
||||||
|
unit: [{ 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
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data)
|
||||||
|
|
||||||
|
/** 查询商品基础信息列表 */
|
||||||
|
function getList() {
|
||||||
|
loading.value = true
|
||||||
|
listProductInfor(queryParams.value).then((response) => {
|
||||||
|
productInforList.value = response.rows
|
||||||
|
total.value = response.total
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 取消按钮
|
||||||
|
function cancel() {
|
||||||
|
open.value = false
|
||||||
|
reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表单重置
|
||||||
|
function reset() {
|
||||||
|
form.value = {
|
||||||
|
id: null,
|
||||||
|
name: null,
|
||||||
|
category: null,
|
||||||
|
unit: null,
|
||||||
|
remark: null,
|
||||||
|
createTime: null,
|
||||||
|
createBy: null,
|
||||||
|
updateTime: null,
|
||||||
|
updatedBy: null,
|
||||||
|
delFlag: null,
|
||||||
|
fields: null,
|
||||||
|
ranking: null,
|
||||||
|
code: null
|
||||||
|
}
|
||||||
|
proxy.resetForm('productInforRef')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
queryParams.value.pageNum = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function resetQuery() {
|
||||||
|
proxy.resetForm('queryRef')
|
||||||
|
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 handleAdd() {
|
||||||
|
reset()
|
||||||
|
open.value = true
|
||||||
|
title.value = '添加商品基础信息'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
function handleUpdate(row) {
|
||||||
|
reset()
|
||||||
|
const _id = row.id || ids.value
|
||||||
|
getProductInfor(_id).then((response) => {
|
||||||
|
form.value = response.data
|
||||||
|
open.value = true
|
||||||
|
title.value = '修改商品基础信息'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
proxy.$refs.productInforRef.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
if (form.value.id != null) {
|
||||||
|
updateProductInfor(form.value).then((response) => {
|
||||||
|
proxy.$modal.msgSuccess('修改成功')
|
||||||
|
open.value = false
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
addProductInfor(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 delProductInfor(_ids)
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
getList()
|
||||||
|
proxy.$modal.msgSuccess('删除成功')
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
function handleExport() {
|
||||||
|
proxy.download(
|
||||||
|
'invest/productInfor/export',
|
||||||
|
{
|
||||||
|
...queryParams.value
|
||||||
|
},
|
||||||
|
`productInfor_${new Date().getTime()}.xlsx`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
getList()
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user