商品管理
This commit is contained in:
parent
e95562aa37
commit
f12e6e1569
|
|
@ -1,20 +1,20 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 商品类别
|
||||
export function systemMaterialTreeApi(data) {
|
||||
export function shopMaterialTreeApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/menu_material_category/getTree',
|
||||
method: 'post',
|
||||
url: '/smart-canteen/supermarket_material_type/list',
|
||||
method: 'get',
|
||||
headers: {
|
||||
"merchant-id":"378915229716713472",
|
||||
},
|
||||
data: data
|
||||
params: data
|
||||
})
|
||||
}
|
||||
// 新增商品类别
|
||||
export function addMaterialTypeApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/menu_material_category/add',
|
||||
url: '/smart-canteen/supermarket_material_type',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"merchant-id":"378915229716713472",
|
||||
|
|
@ -25,7 +25,7 @@ export function addMaterialTypeApi(data) {
|
|||
//修改商品类别
|
||||
export function updateMaterialTypeApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/menu_material_category/edit',
|
||||
url: '/smart-canteen/supermarket_material_type/edit',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"merchant-id":"378915229716713472",
|
||||
|
|
@ -36,12 +36,11 @@ export function updateMaterialTypeApi(data) {
|
|||
//删除商品类别
|
||||
export function removeMaterialTypeApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/menu_material_category/del',
|
||||
url: '/smart-canteen/supermarket_material_type/del/'+data.materialTypeId,
|
||||
method: 'post',
|
||||
headers: {
|
||||
"merchant-id":"378915229716713472",
|
||||
},
|
||||
data: data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +48,7 @@ export function removeMaterialTypeApi(data) {
|
|||
// 查询商品列表
|
||||
export function getMaterialListApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/supermarket_product/list',
|
||||
url: '/smart-canteen/supermarket_material/list',
|
||||
method: 'get',
|
||||
headers: {
|
||||
"merchant-id":"378915229716713472",
|
||||
|
|
@ -61,7 +60,7 @@ export function getMaterialListApi(data) {
|
|||
// 新增商品
|
||||
export function addMaterialApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/supermarket_product',
|
||||
url: '/smart-canteen/supermarket_material',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"merchant-id":"378915229716713472",
|
||||
|
|
@ -73,7 +72,7 @@ export function addMaterialApi(data) {
|
|||
// 编辑商品
|
||||
export function updateMaterialApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/supermarket_product/edit',
|
||||
url: '/smart-canteen/supermarket_material/edit',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"merchant-id":"378915229716713472",
|
||||
|
|
@ -85,7 +84,7 @@ export function updateMaterialApi(data) {
|
|||
// 删除商品
|
||||
export function removeMaterialApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/supermarket_product/del/'+data.productId,
|
||||
url: '/smart-canteen/supermarket_material/del/'+data.materialId,
|
||||
method: 'post',
|
||||
headers: {
|
||||
"merchant-id":"378915229716713472",
|
||||
|
|
@ -103,23 +102,13 @@ export function batchRemoveMaterialApi(data) {
|
|||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
// 批量修改商品
|
||||
export function batchUpdateMaterialApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/api/v1/menumaterial/material/batch/update/category',
|
||||
method: 'post',
|
||||
headers: {
|
||||
"merchant-id":"378915229716713472",
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 根据区域ID-获取商品单位下拉选
|
||||
//{current: 1, size: -1, ifListUse: 1, areaId: '421488254718578688'}
|
||||
export function getDrpUnitListApi(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/supermarket_unit/list',
|
||||
url: '/smart-canteen/supply_product_unit/list',
|
||||
method: 'get',
|
||||
headers: {
|
||||
"merchant-id":"378915229716713472",
|
||||
|
|
|
|||
|
|
@ -12,10 +12,20 @@
|
|||
<div style="width: 100%;height: 500px;overflow-y: auto;">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="商品名称" prop="productName">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="商品编号" prop="materialCode">
|
||||
<el-input
|
||||
v-model="form.productName"
|
||||
v-model="form.materialCode"
|
||||
placeholder="请输入商品编号"
|
||||
maxlength="40"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="商品名称" prop="materialName">
|
||||
<el-input
|
||||
v-model="form.materialName"
|
||||
placeholder="请输入商品名称"
|
||||
maxlength="40"
|
||||
show-word-limit
|
||||
|
|
@ -23,18 +33,61 @@
|
|||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="条码" prop="barCode">
|
||||
<el-input
|
||||
v-model="form.barCode"
|
||||
placeholder="请输入条码"
|
||||
maxlength="20"
|
||||
show-word-limit
|
||||
/>
|
||||
<el-form-item label="商品类别" prop="materialTypeId">
|
||||
<el-cascader v-model="form.materialTypeId"
|
||||
:options="treeTypeOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
|
||||
:props="{
|
||||
emitPath: false,// 若设置 false,则只返回该节点的值,只返回最后选择的id
|
||||
checkStrictly: false,//来设置父子节点取消选中关联,从而达到选择任意一级选项的目的
|
||||
value:'materialTypeId',label:'materialTypeName'
|
||||
}" clearable >
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="所属区域" prop="areaId">
|
||||
<el-cascader v-model="form.areaId"
|
||||
:options="treeAreaOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
|
||||
:props="{
|
||||
emitPath: false,// 若设置 false,则只返回该节点的值,只返回最后选择的id
|
||||
checkStrictly: false,//来设置父子节点取消选中关联,从而达到选择任意一级选项的目的
|
||||
value:'id',label:'label'
|
||||
}" clearable @change="handleAreaChange">
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计重类型" prop="salesMode" >
|
||||
<el-select v-model="form.salesMode" placeholder="请选择计量类型" style="width: 100%" @change="getDrpUnitList">
|
||||
<el-option label="按份" value="1" />
|
||||
<el-option label="称重" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计量单位" prop="unitId">
|
||||
<el-select v-model="form.unitId" placeholder="请选择商品单位" style="width: 100%">
|
||||
<el-option v-for="item in this.unitOptions"
|
||||
:key="item.unitId"
|
||||
:label="item.unitName"
|
||||
:value="item.unitId"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
|
||||
<el-col :span="12">
|
||||
<el-form-item label="商品进价" prop="unitPrice">
|
||||
<el-input
|
||||
v-model="form.unitPrice"
|
||||
placeholder="请输入商品进价"
|
||||
@input="handleNumericInput('unitPrice', $event)"
|
||||
@blur="formatNumericValue('unitPrice')"
|
||||
>
|
||||
<template slot="append">元</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="零售价" prop="salePrice">
|
||||
<el-input
|
||||
|
|
@ -47,70 +100,16 @@
|
|||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计重类型" prop="salesMode" >
|
||||
<el-select v-model="form.salesMode" placeholder="请选择计量类型" style="width: 100%" @change="getDrpUnitList">
|
||||
<el-option label="按份" value="1" />
|
||||
<el-option label="称重" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="所属区域" prop="areaId">
|
||||
<el-cascader v-model="form.areaId"
|
||||
:options="treeAreaOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
|
||||
:props="{
|
||||
emitPath: false,// 若设置 false,则只返回该节点的值,只返回最后选择的id
|
||||
checkStrictly: false,//来设置父子节点取消选中关联,从而达到选择任意一级选项的目的
|
||||
value:'id',label:'label'
|
||||
}" clearable @change="handleAreaChange">
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="商品单位" prop="unitId">
|
||||
<el-select v-model="form.unitId" placeholder="请选择商品单位" style="width: 100%">
|
||||
<el-option v-for="item in this.unitOptions"
|
||||
:key="item.unitId"
|
||||
:label="item.unitName"
|
||||
:value="item.unitId"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
|
||||
<el-col :span="12">
|
||||
<el-form-item label="商品类别" prop="materialId">
|
||||
<el-cascader v-model="form.materialId"
|
||||
:options="treeTypeOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
|
||||
:props="{
|
||||
emitPath: false,// 若设置 false,则只返回该节点的值,只返回最后选择的id
|
||||
checkStrictly: false,//来设置父子节点取消选中关联,从而达到选择任意一级选项的目的
|
||||
value:'id',label:'categoryName'
|
||||
}" clearable >
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="商品进价" prop="prefPrice">
|
||||
<el-form-item label="条码" prop="barCode">
|
||||
<el-input
|
||||
v-model="form.prefPrice"
|
||||
placeholder="请输入商品进价"
|
||||
@input="handleNumericInput('prefPrice', $event)"
|
||||
@blur="formatNumericValue('prefPrice')"
|
||||
>
|
||||
<template slot="append">元</template>
|
||||
</el-input>
|
||||
v-model="form.barCode"
|
||||
placeholder="请输入条码"
|
||||
maxlength="20"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
</el-col>
|
||||
<!-- <el-col :span="12">
|
||||
<el-form-item label="保质期" prop="qualityNum">
|
||||
<el-select v-model="form.qualityType" style="width: 80px; margin-left: 10px">
|
||||
<el-option label="按年" value="1" />
|
||||
|
|
@ -128,10 +127,8 @@
|
|||
<el-select v-model="form.supplyCertificate" placeholder="请选择供应资格证书" style="width: 100%">
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
</el-col> -->
|
||||
<el-col :span="12">
|
||||
<el-form-item label="商品简介" prop="productRemark">
|
||||
<el-input
|
||||
type="textarea"
|
||||
|
|
@ -173,7 +170,7 @@
|
|||
|
||||
<script>
|
||||
import { systemAreaTreeApi } from "@/api/base/area";
|
||||
import { systemMaterialTreeApi,getDrpUnitListApi } from "@/api/superStore/shopMaterial";
|
||||
import { shopMaterialTreeApi,getDrpUnitListApi } from "@/api/superStore/shopMaterial";
|
||||
import { imgUpLoadTwo } from '@/api/system/upload'
|
||||
export default {
|
||||
name: "MaterialDialog",
|
||||
|
|
@ -194,14 +191,14 @@ export default {
|
|||
treeTypeOptions:[],//类型树
|
||||
unitOptions:[],//单位下拉
|
||||
form: {
|
||||
productName: '',//商品名称
|
||||
materialName: '',//商品名称
|
||||
areaId: null,//所属区域
|
||||
materialId: null,//商品类别
|
||||
materialTypeId: null,//商品类别
|
||||
materialType: 2,
|
||||
salesMode: '1',//计量类型
|
||||
salePrice: '',//零售价(元)
|
||||
unitId: '',//商品单位
|
||||
prefPrice: '',//商品进价(元)
|
||||
unitPrice: '',//商品进价(元)
|
||||
barCode: '',//条码
|
||||
nutritionId:null,//营养信息
|
||||
qualityType:"1",//保质期类型
|
||||
|
|
@ -215,10 +212,11 @@ export default {
|
|||
|
||||
},
|
||||
rules: {
|
||||
productName: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
|
||||
materialCode: [{ required: true, message: '请输入商品编号', trigger: 'blur' }],
|
||||
materialName: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
|
||||
areaId: [{ required: true, message: '请选择所属区域', trigger: 'change' }],
|
||||
salePrice: [{ required: true, message: '请输入零售价', trigger: 'change' }],
|
||||
materialId: [{ required: true, message: '请选择商品类别', trigger: 'change' }],
|
||||
materialTypeId: [{ required: true, message: '请选择商品类别', trigger: 'change' }],
|
||||
salesMode: [{ required: true, message: '请选择计量类型', trigger: 'change' }],
|
||||
unitId: [{ required: true, message: '请选择商品单位', trigger: 'change' }],
|
||||
},
|
||||
|
|
@ -257,30 +255,52 @@ export default {
|
|||
},
|
||||
//基础设置-选择区域
|
||||
handleAreaChange(val){
|
||||
console.log(this.form)
|
||||
this.form.materialId=null
|
||||
console.log(this.form)
|
||||
this.getTypeTreeData()
|
||||
this.getDrpUnitList()
|
||||
},
|
||||
//类型树
|
||||
getTypeTreeData() {
|
||||
let param = {
|
||||
categoryType:2,
|
||||
// ifAdd: 1,
|
||||
// areaId:this.form.areaId
|
||||
}
|
||||
systemMaterialTreeApi(param).then((response) => {
|
||||
this.treeTypeOptions = response.data;
|
||||
shopMaterialTreeApi().then((response) => {
|
||||
this.treeTypeOptions = this.handleTree(response.rows,'materialTypeId');
|
||||
});
|
||||
},
|
||||
handleTree(data, idKey, parentIdKey = 'parentId', childrenKey = 'children') {
|
||||
// 用于存储节点数据的Map,以idKey为键
|
||||
const nodeMap = new Map();
|
||||
// 用于存储根节点的数组
|
||||
const rootNodes = [];
|
||||
|
||||
// 遍历数据,构建nodeMap并找到根节点
|
||||
data.forEach(node => {
|
||||
// 将节点添加到nodeMap中,并初始化children为空数组
|
||||
if(node.parentId==0){
|
||||
nodeMap.set(node[idKey], { ...node, [childrenKey]: [] });
|
||||
}else{
|
||||
nodeMap.set(node[idKey], { ...node });
|
||||
}
|
||||
// 如果parentId为null或父节点不存在于nodeMap中,则该节点为根节点
|
||||
if (node[parentIdKey] === null || !nodeMap.has(node[parentIdKey])) {
|
||||
// 将根节点添加到rootNodes数组中
|
||||
rootNodes.push(nodeMap.get(node[idKey]));
|
||||
} else {
|
||||
// 否则,将当前节点添加到其父节点的children列表中
|
||||
// 获取父节点
|
||||
const parentNode = nodeMap.get(node[parentIdKey]);
|
||||
// 将当前节点添加到父节点的children列表中
|
||||
parentNode[childrenKey].push(nodeMap.get(node[idKey]));
|
||||
}
|
||||
});
|
||||
|
||||
// 返回根节点数组,它现在包含了完整的树形结构
|
||||
return rootNodes;
|
||||
},
|
||||
//单位类型拉下选
|
||||
getDrpUnitList() {
|
||||
let param = {
|
||||
weighType:this.form.salesMode,
|
||||
// areaId: this.form.areaId||""
|
||||
// ifListUse: 1,
|
||||
// current: 1,
|
||||
// size: -1
|
||||
"weighType":this.form.salesMode,
|
||||
"pageNum": 1,
|
||||
"pageSize": 100
|
||||
}
|
||||
this.form.unitId=null
|
||||
getDrpUnitListApi(param).then((response) => {
|
||||
|
|
@ -302,16 +322,16 @@ export default {
|
|||
this.getTypeTreeData()
|
||||
this.getDrpUnitList()
|
||||
this.$set(this.form,"areaName",row.areaName)
|
||||
this.$set(this.form,"materialId",row.materialId)
|
||||
this.$set(this.form,"materialTypeId",row.materialTypeId)
|
||||
this.$set(this.form,"categoryName",row.categoryName)
|
||||
this.$set(this.form,"materialCode",row.materialCode)
|
||||
this.$set(this.form,"materialId",row.materialId)
|
||||
this.$set(this.form,"productName",row.productName)
|
||||
this.$set(this.form,"materialName",row.materialName)
|
||||
this.$set(this.form,"materialType",row.materialType)
|
||||
this.$set(this.form,"salesMode",row.salesMode+'')
|
||||
this.$set(this.form,"unitId",row.unitId)
|
||||
this.$set(this.form,"salePrice",Number((row.salePrice/100).toFixed(2)))
|
||||
this.$set(this.form,"prefPrice",Number((row.prefPrice/100).toFixed(2)))
|
||||
this.$set(this.form,"unitPrice",Number((row.unitPrice/100).toFixed(2)))
|
||||
this.$set(this.form,"barCode",row.barCode)
|
||||
if(row.qualityType){
|
||||
this.$set(this.form,"qualityType",row.qualityType+"")
|
||||
|
|
@ -337,10 +357,10 @@ export default {
|
|||
if (valid) {
|
||||
this.loading=true
|
||||
this.form.salePrice = Number(this.form.salePrice)*100;
|
||||
this.form.prefPrice = Number(this.form.prefPrice)*100;
|
||||
this.form.unitPrice = Number(this.form.unitPrice)*100;
|
||||
setTimeout(()=>{
|
||||
this.$set(this.form,"salePrice",Number((this.form.salePrice/100).toFixed(2)))
|
||||
this.$set(this.form,"prefPrice",Number((this.form.prefPrice/100).toFixed(2)))
|
||||
this.$set(this.form,"unitPrice",Number((this.form.unitPrice/100).toFixed(2)))
|
||||
this.loading=false
|
||||
},2000)
|
||||
this.$emit('submit', this.form);
|
||||
|
|
@ -359,14 +379,13 @@ export default {
|
|||
|
||||
reset() {
|
||||
this.form = {
|
||||
productName: '',//商品名称
|
||||
materialName: '',//商品名称
|
||||
areaId: null,//所属区域
|
||||
materialId: null,//商品类别
|
||||
materialType: 2,
|
||||
materialTypeId: null,//商品类别
|
||||
salesMode: '1',//计量类型
|
||||
unitId: '',//商品单位
|
||||
salePrice: '',//商品售价(元)
|
||||
prefPrice: '',//商品进价(元)
|
||||
unitPrice: '',//商品进价(元)
|
||||
barCode: '',//条码
|
||||
str:[],//营养信息类型
|
||||
nutritionId:null,//营养信息
|
||||
|
|
|
|||
|
|
@ -27,9 +27,10 @@
|
|||
:expand-on-click-node="false"
|
||||
:filter-node-method="filterNode"
|
||||
ref="typeTree"
|
||||
node-key="id"
|
||||
node-key="materialTypeId"
|
||||
highlight-current
|
||||
@node-click="handleNodeClick"
|
||||
@check-change="handleCheckChange"
|
||||
>
|
||||
<span class="custom-tree-node" slot-scope="{ node, data }" @mousemove="onMousemove(data)" @mouseleave="onMouseleave()">
|
||||
<span v-if="isMousemoveId === data.id && node.label.length > 10">{{
|
||||
|
|
@ -41,7 +42,7 @@
|
|||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
icon="el-icon-plus" v-if="data.level<2"
|
||||
icon="el-icon-plus" v-if="data.level<1"
|
||||
@click.stop="() => appendTreeNode(data)"
|
||||
>
|
||||
</el-button>
|
||||
|
|
@ -59,7 +60,7 @@
|
|||
size="mini"
|
||||
icon="el-icon-delete"
|
||||
style="color: #f56c6c"
|
||||
v-if="data.parentId != '-1'"
|
||||
v-if="data.parentId != '0'"
|
||||
@click.stop="() => removeTreeNode(data)"
|
||||
>
|
||||
</el-button>
|
||||
|
|
@ -88,9 +89,18 @@
|
|||
}" clearable>
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品名称" prop="productName">
|
||||
<el-form-item label="商品编码" prop="materialCode">
|
||||
<el-input
|
||||
v-model="queryParams.productName"
|
||||
v-model="queryParams.materialCode"
|
||||
placeholder="请输入商品编码"
|
||||
clearable maxlength="30"
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品名称" prop="materialName">
|
||||
<el-input
|
||||
v-model="queryParams.materialName"
|
||||
placeholder="请输入商品名称"
|
||||
clearable maxlength="30"
|
||||
style="width: 240px"
|
||||
|
|
@ -106,15 +116,7 @@
|
|||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品编码" prop="productCode">
|
||||
<el-input
|
||||
v-model="queryParams.productCode"
|
||||
placeholder="请输入商品编码"
|
||||
clearable maxlength="30"
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item>
|
||||
<el-button
|
||||
|
|
@ -147,16 +149,7 @@
|
|||
:disabled="multiple"
|
||||
@click="handleBatchDel"
|
||||
>批量删除</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="mini" plain
|
||||
:disabled="multiple"
|
||||
@click="handleBatchEdit"
|
||||
>批量修改类别
|
||||
</el-button>
|
||||
</el-col> -->
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
|
|
@ -196,24 +189,22 @@
|
|||
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品编码" align="center" key="productCode" prop="productCode" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="商品名称" align="center" key="productName" prop="productName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="商品编码" align="center" key="materialCode" prop="materialCode" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="商品名称" align="center" key="materialName" prop="materialName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="所属区域" align="center" key="areaName" prop="areaName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="商品类别" align="center" key="categoryName" prop="categoryName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="单位" align="center" key="unitName" prop="unitName" :show-overflow-tooltip="true" width="100"/>
|
||||
<el-table-column label="商品进价(元)" align="center" key="prefPrice" prop="prefPrice" :show-overflow-tooltip="true">
|
||||
<el-table-column label="商品类别" align="center" key="materialTypeName" prop="materialTypeName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="单位" align="center" key="unitName" prop="unitName" :show-overflow-tooltip="true" width="100"/>
|
||||
<el-table-column label="条码" align="center" key="barCode" prop="barCode" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="商品进价(元)" align="center" key="unitPrice" prop="unitPrice" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ (scope.row.prefPrice/100).toFixed(2)||"" }}</span>
|
||||
<span>{{ (scope.row.unitPrice/100).toFixed(2)||"" }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="零售价(元)" align="center" key="salePrice" prop="salePrice" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ (scope.row.salePrice/100).toFixed(2)||"" }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="条码" align="center" key="barCode" prop="barCode" :show-overflow-tooltip="true" />
|
||||
<!-- <el-table-column label="最近进价(元)" align="center" key="recentPrice" prop="recentPrice" :show-overflow-tooltip="true" width="150"/> -->
|
||||
<!-- <el-table-column label="最近入库时间" align="center" key="lastStockTime" prop="lastStockTime" :show-overflow-tooltip="true" width="150"/> -->
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="100" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
|
|
@ -248,11 +239,11 @@
|
|||
<el-dialog
|
||||
:title="title+'-商品类别'"
|
||||
:visible.sync="open"
|
||||
width="500px"
|
||||
width="600px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="140px">
|
||||
<el-form-item label="所属区域" prop="areaId">
|
||||
<el-cascader v-model="form.areaId" :disabled="isEditType"
|
||||
:options="treeAreaOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
|
||||
|
|
@ -266,79 +257,22 @@
|
|||
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="商品类别" prop="categoryName">
|
||||
<el-form-item label="商品类别" prop="materialTypeName">
|
||||
<el-input
|
||||
v-model="form.categoryName"
|
||||
v-model="form.materialTypeName"
|
||||
placeholder="请输入商品类别"
|
||||
maxlength="30"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row v-if="isEditType">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="原商品类别父节点" prop="superAreaName">
|
||||
<el-input
|
||||
v-model="form.superAreaName"
|
||||
disabled
|
||||
placeholder="原商品类别父节点"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="isEditType">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="新商品类别父节点" prop="newParentId">
|
||||
<el-cascader v-model="form.newParentId"
|
||||
:options="treeOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
|
||||
:props="{
|
||||
emitPath: false,// 若设置 false,则只返回该节点的值,只返回最后选择的id
|
||||
checkStrictly: true,//来设置父子节点取消选中关联,从而达到选择任意一级选项的目的
|
||||
value:'id',label:'categoryName'
|
||||
}" clearable >
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="handleSubmit">确 定</el-button>
|
||||
<el-button @click="open=false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 批量修改商品类别对话框 -->
|
||||
<el-dialog title="批量修改商品类别" :visible.sync="openEdit"
|
||||
width="500px" append-to-body :close-on-click-modal="false">
|
||||
<el-form ref="editForm" :model="editForm" :rules="editRules" label-width="120px">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="商品名称" prop="categoryNames">
|
||||
<el-input v-model="editForm.categoryNames" placeholder="请输入商品名称" :readonly="true" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="新类别" prop="categroyId">
|
||||
<el-cascader v-model="editForm.categroyId"
|
||||
:options="treeOptions" :filterable="true" style="width: 100%;" :show-all-levels="false"
|
||||
:props="{
|
||||
emitPath: false,// 若设置 false,则只返回该节点的值,只返回最后选择的id
|
||||
checkStrictly: true,//来设置父子节点取消选中关联,从而达到选择任意一级选项的目的
|
||||
value:'id',label:'categoryName'
|
||||
}" clearable >
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="handleSubmitEdit">确 定</el-button>
|
||||
<el-button @click="openEdit=false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
|
||||
<!-- 添加或修改用户配置对话框 -->
|
||||
<material-dialog :visible.sync="dialogVisible" :title="title" :treeOptions="treeOptions" :treeAreaOptions="treeAreaOptions" @submit="handleDialogSubmit" ref="materialDialog" />
|
||||
|
|
@ -349,8 +283,8 @@
|
|||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
import { systemAreaTreeApi } from "@/api/base/area";
|
||||
import { systemMaterialTreeApi,addMaterialTypeApi,updateMaterialTypeApi,removeMaterialTypeApi} from "@/api/superStore/shopMaterial";
|
||||
import { getMaterialListApi,addMaterialApi, updateMaterialApi, removeMaterialApi,batchRemoveMaterialApi,batchUpdateMaterialApi} from "@/api/superStore/shopMaterial";
|
||||
import { shopMaterialTreeApi,addMaterialTypeApi,updateMaterialTypeApi,removeMaterialTypeApi} from "@/api/superStore/shopMaterial";
|
||||
import { getMaterialListApi,addMaterialApi, updateMaterialApi, removeMaterialApi,batchRemoveMaterialApi} from "@/api/superStore/shopMaterial";
|
||||
import MaterialDialog from './components/MaterialDialog.vue';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { downloadFileByUrl } from '@/utils/download'
|
||||
|
|
@ -378,7 +312,7 @@ export default {
|
|||
isMousemoveId: null,
|
||||
defaultProps: {
|
||||
children: "children",
|
||||
label: "categoryName",
|
||||
label: "materialTypeName",
|
||||
},
|
||||
keyWord:"",//左侧树-关键字查询
|
||||
isEditType:false,//是否编辑
|
||||
|
|
@ -387,11 +321,10 @@ export default {
|
|||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
areaId:null,
|
||||
productName:"",
|
||||
materialName:"",
|
||||
barCode:"",
|
||||
productCode:"",
|
||||
materialType:2, //类型(1商品2商品)
|
||||
categoryIdList:[]
|
||||
materialCode:"",
|
||||
materialTypeIds:[]
|
||||
},
|
||||
// 总条数
|
||||
total: 0,
|
||||
|
|
@ -404,14 +337,13 @@ export default {
|
|||
title: "",
|
||||
// 表单参数
|
||||
form: {
|
||||
categoryName: "",
|
||||
materialTypeName: "",
|
||||
parentId: "",
|
||||
categoryType: "",
|
||||
superAreaName: "",
|
||||
areaId:null
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
categoryName: [
|
||||
materialTypeName: [
|
||||
{
|
||||
required: true,
|
||||
message: "类别名称不能为空",
|
||||
|
|
@ -421,21 +353,7 @@ export default {
|
|||
},
|
||||
parentId: undefined,
|
||||
treeAreaOptions:[],//区域树
|
||||
batchIds:[],
|
||||
openEdit:false,
|
||||
editForm:{
|
||||
categoryNames:"",
|
||||
categroyId:null
|
||||
},
|
||||
editRules: {
|
||||
categroyId: [
|
||||
{
|
||||
required: true,
|
||||
message: "新类别不能为空",
|
||||
trigger: "change",
|
||||
},
|
||||
]
|
||||
},
|
||||
batchIds:[],
|
||||
//导入参数
|
||||
upload: {
|
||||
// 是否禁用上传
|
||||
|
|
@ -461,15 +379,14 @@ export default {
|
|||
// 筛选节点 - 左侧树
|
||||
filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data.categoryName.indexOf(value) !== -1;
|
||||
return data.materialTypeName.indexOf(value) !== -1;
|
||||
},
|
||||
/** 查询新增页面-上级类型下拉树结构 */
|
||||
getTreeData() {
|
||||
systemMaterialTreeApi({categoryType:2}).then((response) => {
|
||||
this.treeOptions = response.data;
|
||||
shopMaterialTreeApi().then((response) => {
|
||||
this.treeOptions = this.handleTree(response.rows,'materialTypeId');
|
||||
this.addLevel(this.treeOptions)
|
||||
console.log("this.treeOptions",this.treeOptions)
|
||||
this.queryParams.materialType=this.treeOptions[0].categoryType;
|
||||
console.log("this.treeOptions",this.treeOptions)
|
||||
if(this.treeOptions && this.treeOptions.length > 0){
|
||||
this.getList();
|
||||
} else {
|
||||
|
|
@ -477,6 +394,32 @@ export default {
|
|||
}
|
||||
});
|
||||
},
|
||||
handleTree(data, idKey, parentIdKey = 'parentId', childrenKey = 'children') {
|
||||
// 用于存储节点数据的Map,以idKey为键
|
||||
const nodeMap = new Map();
|
||||
// 用于存储根节点的数组
|
||||
const rootNodes = [];
|
||||
|
||||
// 遍历数据,构建nodeMap并找到根节点
|
||||
data.forEach(node => {
|
||||
// 将节点添加到nodeMap中,并初始化children为空数组
|
||||
nodeMap.set(node[idKey], { ...node, [childrenKey]: [] });
|
||||
// 如果parentId为null或父节点不存在于nodeMap中,则该节点为根节点
|
||||
if (node[parentIdKey] === null || !nodeMap.has(node[parentIdKey])) {
|
||||
// 将根节点添加到rootNodes数组中
|
||||
rootNodes.push(nodeMap.get(node[idKey]));
|
||||
} else {
|
||||
// 否则,将当前节点添加到其父节点的children列表中
|
||||
// 获取父节点
|
||||
const parentNode = nodeMap.get(node[parentIdKey]);
|
||||
// 将当前节点添加到父节点的children列表中
|
||||
parentNode[childrenKey].push(nodeMap.get(node[idKey]));
|
||||
}
|
||||
});
|
||||
|
||||
// 返回根节点数组,它现在包含了完整的树形结构
|
||||
return rootNodes;
|
||||
},
|
||||
addLevel(nodes, level = 0) {
|
||||
nodes.forEach(node => {
|
||||
node.level = level; // 设置当前节点的层级
|
||||
|
|
@ -490,14 +433,16 @@ export default {
|
|||
console.log(data)
|
||||
// this.handleQuery();
|
||||
},
|
||||
handleCheckChange(data, checked, indeterminate) {
|
||||
this.handleQuery();
|
||||
},
|
||||
/* 树节点增加 */
|
||||
appendTreeNode(data) {
|
||||
console.log(data)
|
||||
this.isEditType=false;
|
||||
this.form={}
|
||||
this.resetForm("form");
|
||||
this.$set(this.form,"parentId",data.id)
|
||||
this.$set(this.form,"categoryType",data.categoryType)
|
||||
this.$set(this.form,"parentId",data.materialTypeId)
|
||||
this.open = true;
|
||||
this.title = "新增";
|
||||
},
|
||||
|
|
@ -507,12 +452,9 @@ export default {
|
|||
this.form={}
|
||||
this.resetForm("form");
|
||||
this.form = {
|
||||
...data,
|
||||
categoryId:data.id,
|
||||
superAreaName: data.parentId === "-1" ? "" : this.getParentCategoryName(data.parentId)
|
||||
...data
|
||||
};
|
||||
console.log(this.form)
|
||||
console.log(this.treeOptions)
|
||||
this.open = true;
|
||||
this.title = "修改";
|
||||
},
|
||||
|
|
@ -520,8 +462,8 @@ export default {
|
|||
getParentCategoryName(parentId) {
|
||||
const findNode = (nodes) => {
|
||||
for (let node of nodes) {
|
||||
if (node.id === parentId) {
|
||||
return node.categoryName;
|
||||
if (node.materialTypeId === parentId) {
|
||||
return node.materialTypeName;
|
||||
}
|
||||
if (node.children) {
|
||||
const result = findNode(node.children);
|
||||
|
|
@ -538,7 +480,7 @@ export default {
|
|||
this.$modal
|
||||
.confirm("是否确认删除数据项?")
|
||||
.then(function () {
|
||||
return removeMaterialTypeApi({"categoryId":data.id});
|
||||
return removeMaterialTypeApi({"materialTypeId":data.materialTypeId});
|
||||
})
|
||||
.then(() => {
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
|
|
@ -557,7 +499,7 @@ export default {
|
|||
handleSubmit() {
|
||||
this.$refs.form.validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.id != undefined) {
|
||||
if (this.form.materialTypeId != undefined) {
|
||||
updateMaterialTypeApi(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
|
|
@ -595,11 +537,10 @@ export default {
|
|||
"pageSize": this.queryParams.pageSize,
|
||||
"pageNum": this.queryParams.pageNum,
|
||||
"areaId": this.queryParams.areaId,
|
||||
"productName": this.queryParams.productName,
|
||||
"materialName": this.queryParams.materialName,
|
||||
"barCode": this.queryParams.barCode,
|
||||
"productCode": this.queryParams.productCode,
|
||||
"materialType": this.queryParams.materialType,//类型(1商品2商品)
|
||||
"categoryIdList": this.$refs.typeTree.getCheckedKeys(),
|
||||
"materialCode": this.queryParams.materialCode,
|
||||
"materialTypeIds": this.$refs.typeTree.getCheckedKeys(),
|
||||
}
|
||||
getMaterialListApi(params).then((response) => {
|
||||
this.tableList = response.rows;
|
||||
|
|
@ -652,7 +593,7 @@ export default {
|
|||
this.$modal
|
||||
.confirm("是否确认删除数据项?")
|
||||
.then(function () {
|
||||
return removeMaterialApi({"productId":row.productId});
|
||||
return removeMaterialApi({"materialId":row.materialId});
|
||||
})
|
||||
.then(() => {
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
|
|
@ -662,42 +603,19 @@ export default {
|
|||
},
|
||||
handleSelectionChange(selection){
|
||||
this.batchIds = []
|
||||
this.batchIds = selection.map((item) => item.productId)
|
||||
// this.editForm.categoryNames = "";
|
||||
// this.editForm.categoryNames = selection.map((item) => item.materialName);
|
||||
this.batchIds = selection.map((item) => item.materialId)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
// 批量删除
|
||||
handleBatchDel(){
|
||||
console.log(this.batchIds)
|
||||
batchRemoveMaterialApi({"productId":this.batchIds.join(",")}).then(response => {
|
||||
batchRemoveMaterialApi({"materialIds":this.batchIds.join(",")}).then(response => {
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
this.$refs.multipleTable.clearSelection()
|
||||
this.getList();
|
||||
});
|
||||
},
|
||||
//批量修改
|
||||
handleBatchEdit(){
|
||||
this.editForm.categroyId=null
|
||||
this.openEdit=true;
|
||||
},
|
||||
handleSubmitEdit(){
|
||||
this.$refs["editForm"].validate(valid => {
|
||||
if (valid) {
|
||||
let param = {
|
||||
materialIdList:this.batchIds,
|
||||
categroyId:this.editForm.categroyId
|
||||
}
|
||||
// batchUpdateMaterialApi(param).then(response => {
|
||||
// this.$modal.msgSuccess("修改成功");
|
||||
// this.openEdit=false
|
||||
// this.$refs.multipleTable.clearSelection()
|
||||
// this.getList();
|
||||
// });
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
//批量导入
|
||||
// /api/v1/menumaterial/batch/import/material
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
|
|
@ -122,7 +123,7 @@
|
|||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
unitName: undefined,
|
||||
unitName: undefined
|
||||
},
|
||||
// 表单参数
|
||||
form: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue