原料商品表合并接口修改

This commit is contained in:
zzyuan 2025-06-30 18:16:08 +08:00
parent 9233f2cb36
commit 2ead883af0
8 changed files with 159 additions and 103 deletions

View File

@ -5,9 +5,6 @@ export function systemMaterialTreeApi(data) {
return request({ return request({
url: '/smart-canteen/cook_material_type/getTree', url: '/smart-canteen/cook_material_type/getTree',
method: 'post', method: 'post',
headers: {
"merchant-id":"378915229716713472",
},
data: data data: data
}) })
} }

View File

@ -3,18 +3,18 @@ import request from '@/utils/request'
// 商品类别 // 商品类别
export function shopMaterialTreeApi(data) { export function shopMaterialTreeApi(data) {
return request({ return request({
url: '/smart-canteen/supermarket_material_type/list', url: '/smart-canteen/cook_material_type/getTree',
method: 'get', method: 'post',
headers: { headers: {
"merchant-id":"378915229716713472", "merchant-id":"378915229716713472",
}, },
params: data data: data
}) })
} }
// 新增商品类别 // 新增商品类别
export function addMaterialTypeApi(data) { export function addMaterialTypeApi(data) {
return request({ return request({
url: '/smart-canteen/supermarket_material_type', url: '/smart-canteen/cook_material_type/add',
method: 'post', method: 'post',
headers: { headers: {
"merchant-id":"378915229716713472", "merchant-id":"378915229716713472",
@ -25,7 +25,7 @@ export function addMaterialTypeApi(data) {
//修改商品类别 //修改商品类别
export function updateMaterialTypeApi(data) { export function updateMaterialTypeApi(data) {
return request({ return request({
url: '/smart-canteen/supermarket_material_type/edit', url: '/smart-canteen/cook_material_type/edit',
method: 'post', method: 'post',
headers: { headers: {
"merchant-id":"378915229716713472", "merchant-id":"378915229716713472",
@ -36,7 +36,7 @@ export function updateMaterialTypeApi(data) {
//删除商品类别 //删除商品类别
export function removeMaterialTypeApi(data) { export function removeMaterialTypeApi(data) {
return request({ return request({
url: '/smart-canteen/supermarket_material_type/del/'+data.materialTypeId, url: '/smart-canteen/cook_material_type/del/'+data.id,
method: 'post', method: 'post',
headers: { headers: {
"merchant-id":"378915229716713472", "merchant-id":"378915229716713472",
@ -48,7 +48,7 @@ export function removeMaterialTypeApi(data) {
// 查询商品列表 // 查询商品列表
export function getMaterialListApi(data) { export function getMaterialListApi(data) {
return request({ return request({
url: '/smart-canteen/supermarket_material/list', url: '/smart-canteen/cook_material/list',
method: 'get', method: 'get',
headers: { headers: {
"merchant-id":"378915229716713472", "merchant-id":"378915229716713472",
@ -60,7 +60,7 @@ export function getMaterialListApi(data) {
// 新增商品 // 新增商品
export function addMaterialApi(data) { export function addMaterialApi(data) {
return request({ return request({
url: '/smart-canteen/supermarket_material', url: '/smart-canteen/cook_material/add',
method: 'post', method: 'post',
headers: { headers: {
"merchant-id":"378915229716713472", "merchant-id":"378915229716713472",
@ -72,7 +72,7 @@ export function addMaterialApi(data) {
// 编辑商品 // 编辑商品
export function updateMaterialApi(data) { export function updateMaterialApi(data) {
return request({ return request({
url: '/smart-canteen/supermarket_material/edit', url: '/smart-canteen/cook_material/edit',
method: 'post', method: 'post',
headers: { headers: {
"merchant-id":"378915229716713472", "merchant-id":"378915229716713472",
@ -84,7 +84,7 @@ export function updateMaterialApi(data) {
// 删除商品 // 删除商品
export function removeMaterialApi(data) { export function removeMaterialApi(data) {
return request({ return request({
url: '/smart-canteen/supermarket_material/del/'+data.materialId, url: '/smart-canteen/cook_material/del/'+data.materialId,
method: 'post', method: 'post',
headers: { headers: {
"merchant-id":"378915229716713472", "merchant-id":"378915229716713472",

View File

@ -352,7 +352,8 @@ export default {
// //
getTypeTreeData() { getTypeTreeData() {
let param = { let param = {
// areaId:this.form.areaId areaId:this.form.areaId,
goodsType:1
} }
systemMaterialTreeApi(param).then((response) => { systemMaterialTreeApi(param).then((response) => {
this.treeTypeOptions = response.data; this.treeTypeOptions = response.data;

View File

@ -430,7 +430,10 @@ export default {
}, },
/** 查询新增页面-上级类型下拉树结构 */ /** 查询新增页面-上级类型下拉树结构 */
getTreeData() { getTreeData() {
systemMaterialTreeApi({categoryType:1}).then((response) => { let param = {
goodsType:1
}
systemMaterialTreeApi(param).then((response) => {
this.treeOptions = response.data; this.treeOptions = response.data;
this.addLevel(this.treeOptions) this.addLevel(this.treeOptions)
console.log("this.treeOptions",this.treeOptions) console.log("this.treeOptions",this.treeOptions)
@ -549,6 +552,7 @@ export default {
"areaId": this.queryParams.areaId, "areaId": this.queryParams.areaId,
"materialName": this.queryParams.materialName, "materialName": this.queryParams.materialName,
"materialCode": this.queryParams.materialCode, "materialCode": this.queryParams.materialCode,
"goodsType": 1,
"materialTypeIds": this.$refs.typeTree.getCheckedKeys(), "materialTypeIds": this.$refs.typeTree.getCheckedKeys(),
} }
getMaterialListApi(params).then((response) => { getMaterialListApi(params).then((response) => {

View File

@ -39,7 +39,7 @@
:props="{ :props="{
emitPath: false,// falseid emitPath: false,// falseid
checkStrictly: false,// checkStrictly: false,//
value:'materialTypeId',label:'materialTypeName' value:'id',label:'categoryName'
}" clearable > }" clearable >
</el-cascader> </el-cascader>
</el-form-item> </el-form-item>
@ -264,40 +264,10 @@ export default {
}, },
// //
getTypeTreeData() { getTypeTreeData() {
shopMaterialTreeApi().then((response) => { shopMaterialTreeApi({areaId:this.form.areaId,goodsType:2}).then((response) => {
this.treeTypeOptions = this.handleTree(response.rows,'materialTypeId'); this.treeTypeOptions = response.data;
}); });
}, },
handleTree(data, idKey, parentIdKey = 'parentId', childrenKey = 'children') {
// MapidKey
const nodeMap = new Map();
//
const rootNodes = [];
// nodeMap
data.forEach(node => {
// nodeMapchildren
if(node.parentId==0){
nodeMap.set(node[idKey], { ...node, [childrenKey]: [] });
}else{
nodeMap.set(node[idKey], { ...node });
}
// parentIdnullnodeMap
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() { getDrpUnitList() {
let param = { let param = {

View File

@ -27,7 +27,7 @@
:expand-on-click-node="false" :expand-on-click-node="false"
:filter-node-method="filterNode" :filter-node-method="filterNode"
ref="typeTree" ref="typeTree"
node-key="materialTypeId" node-key="id"
highlight-current highlight-current
@node-click="handleNodeClick" @node-click="handleNodeClick"
@check-change="handleCheckChange" @check-change="handleCheckChange"
@ -312,7 +312,7 @@ export default {
isMousemoveId: null, isMousemoveId: null,
defaultProps: { defaultProps: {
children: "children", children: "children",
label: "materialTypeName", label: "categoryName",
}, },
keyWord:"",//- keyWord:"",//-
isEditType:false,// isEditType:false,//
@ -383,8 +383,11 @@ export default {
}, },
/** 查询新增页面-上级类型下拉树结构 */ /** 查询新增页面-上级类型下拉树结构 */
getTreeData() { getTreeData() {
shopMaterialTreeApi().then((response) => { let param = {
this.treeOptions = this.handleTree(response.rows,'materialTypeId'); goodsType:2
}
shopMaterialTreeApi(param).then((response) => {
this.treeOptions = response.data;
this.addLevel(this.treeOptions) this.addLevel(this.treeOptions)
console.log("this.treeOptions",this.treeOptions) console.log("this.treeOptions",this.treeOptions)
if(this.treeOptions && this.treeOptions.length > 0){ if(this.treeOptions && this.treeOptions.length > 0){
@ -442,7 +445,8 @@ export default {
this.isEditType=false; this.isEditType=false;
this.form={} this.form={}
this.resetForm("form"); this.resetForm("form");
this.$set(this.form,"parentId",data.materialTypeId) this.$set(this.form,"parentId",data.id)
this.$set(this.form,"goodsType",data.categoryType)
this.open = true; this.open = true;
this.title = "新增"; this.title = "新增";
}, },
@ -454,33 +458,19 @@ export default {
this.form = { this.form = {
...data ...data
}; };
console.log(this.form) this.$set(this.form,"materialTypeId",data.id)
this.$set(this.form,"materialTypeName",data.categoryName)
this.$set(this.form,"goodsType",data.categoryType)
this.open = true; this.open = true;
this.title = "修改"; this.title = "修改";
}, },
//
getParentCategoryName(parentId) {
const findNode = (nodes) => {
for (let node of nodes) {
if (node.materialTypeId === parentId) {
return node.materialTypeName;
}
if (node.children) {
const result = findNode(node.children);
if (result) return result;
}
}
return "";
};
return findNode(this.treeOptions);
},
/* 树节点删除 */ /* 树节点删除 */
removeTreeNode(data) { removeTreeNode(data) {
console.log(data, "删除时的数据源--"); console.log(data, "删除时的数据源--");
this.$modal this.$modal
.confirm("是否确认删除数据项?") .confirm("是否确认删除数据项?")
.then(function () { .then(function () {
return removeMaterialTypeApi({"materialTypeId":data.materialTypeId}); return removeMaterialTypeApi({"id":data.id});
}) })
.then(() => { .then(() => {
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
@ -540,6 +530,7 @@ export default {
"materialName": this.queryParams.materialName, "materialName": this.queryParams.materialName,
"barCode": this.queryParams.barCode, "barCode": this.queryParams.barCode,
"materialCode": this.queryParams.materialCode, "materialCode": this.queryParams.materialCode,
"goodsType": 2,
"materialTypeIds": this.$refs.typeTree.getCheckedKeys(), "materialTypeIds": this.$refs.typeTree.getCheckedKeys(),
} }
getMaterialListApi(params).then((response) => { getMaterialListApi(params).then((response) => {

View File

@ -92,22 +92,79 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
<div style="width: 100%;height: 450px;padding: 10px;border-radius: 10px;margin-bottom: 10px;display: flex;"> <div style="width: 100%;height: 450px;padding: 10px;border-radius: 10px;margin-bottom: 10px;background: #FFF;">
<div style="width: 100%;display: flex;justify-content: space-between;align-items: center;margin-bottom: 10px;">
<div>
货品信息
</div>
<div style="display: flex;align-items: center;">
<el-button type="primary" plain @click="addMaterial">添加货品</el-button>
<el-button type="danger" plain @click="">删除</el-button>
</div>
</div>
<div style="width: 100%;height: 400px;overflow-y: auto;">
<el-table :data="contractMaterialList" ref="multipleTable" :row-key="(row)=>{return row.materialId}" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" :reserve-selection="true" />
<el-table-column label="序号" align="center" width="80" type="index" />
<el-table-column label="图片" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="货品编码" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="货品名称" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="货品类别" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="计量单位" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="货品规格" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="单价(元)" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="数量" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="总金额(元)" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="备注" align="center" prop="" :show-overflow-tooltip="true" />
</el-table>
</div>
</div> </div>
<div style="width: 100%;height: 80px;padding: 10px;background: #FFF;border-radius: 10px;display: flex;align-items: center;justify-content: center;"> <div style="width: 100%;height: 80px;padding: 10px;background: #FFF;border-radius: 10px;display: flex;align-items: center;justify-content: center;">
<el-button type="primary" @click="confirmSubmit" :loading="loading"> </el-button> <el-button type="primary" @click="confirmSubmit" :loading="loadingBtn"> </el-button>
<el-button @click="jumpList"> </el-button> <el-button @click="jumpList"> </el-button>
</div> </div>
<!-- 选择菜品 --> <!-- 选择菜品 -->
<el-dialog title="选择货品" :visible.sync="openDishes" width="90%" append-to-body > <el-dialog title="选择货品" :visible.sync="openDialog" width="65%" append-to-body >
<div style="width: 100%;height:640px;display: flex;align-items: center;color: #000;"> <div style="width: 100%;height:620px;">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
<el-form-item label="货品编码" prop="searchValue">
<el-input v-model="queryParams.searchValue" placeholder="请输入货品编码" maxlength="20" clearable style="width: 240px"/>
</el-form-item>
<el-form-item label="货品名称" prop="searchValue">
<el-input v-model="queryParams.searchValue" placeholder="请输入货品名称" maxlength="20" clearable style="width: 240px"/>
</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>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="tableListData" ref="multipleTable1" height="520" :row-key="(row)=>{return row.materialId}" @selection-change="handleSelectionChange2">
<el-table-column type="selection" width="50" align="center" :reserve-selection="true" />
<el-table-column label="序号" align="center" width="80" type="index">
<template slot-scope="scope">
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
</template>
</el-table-column>
<el-table-column label="图片" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="货品编码" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="货品名称" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="货品类别" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="计量单位" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="货品规格" align="center" prop="" :show-overflow-tooltip="true" />
<el-table-column label="单价(元)" align="center" prop="" :show-overflow-tooltip="true" />
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div> </div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="openDishes=false"> </el-button> <el-button type="primary" @click=""> </el-button>
<el-button @click="openDishes=false"> </el-button> <el-button @click="openDialog=false"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
@ -122,6 +179,7 @@ export default {
data() { data() {
return { return {
loading:false, loading:false,
loadingBtn:false,
baseInfo: { baseInfo: {
contractName:undefined, contractName:undefined,
contractType:undefined, contractType:undefined,
@ -152,25 +210,23 @@ export default {
canteenOptions:[], canteenOptions:[],
supplierOptions:[], supplierOptions:[],
stallOptions:[], stallOptions:[],
dateRange:[], dateRange:[],
// dateRangeRadio:"",
// dateRangeList:[],
// dateRangeIndex:0,
pickerOptions: { pickerOptions: {
disabledDate(v) { disabledDate(v) {
return v.getTime() < (new Date().getTime() - 86400000);// - 86400000 return v.getTime() < (new Date().getTime() - 86400000);// - 86400000
} }
}, },
contractDateList:[], contractMaterialList:[],
weekDateList:[], openDialog:false,
detailList:[], //
openDishes:false, queryParams: {
// pageNum: 1,
queryDish:{ pageSize: 10,
salesMode:null, },
typeId:null, //
dishesName:'' total: 0,
}, //
tableListData: [],
}; };
}, },
@ -212,12 +268,39 @@ export default {
// getSupplierByAreaApi(param).then((response) => { // getSupplierByAreaApi(param).then((response) => {
// this.supplierOptions=response.rows||[] // this.supplierOptions=response.rows||[]
// }); // });
}, },
// //
changeDateRange(e){ changeDateRange(e){
//this.formatDate(e[0]) //this.formatDate(e[0])
},
addMaterial(){
this.openDialog=true
setTimeout(()=>{
this.$refs.multipleTable1.clearSelection()
},300)
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 查询列表 */
getList() {
this.loading = true;
let param = {
"pageNum": this.queryParams.pageNum,
"pageSize": this.queryParams.pageSize,
}
getPageCanteenApi(param).then(response => {
this.tableListData = response.records;
this.total = Number(response.total);
this.loading = false;
});
}, },
// //
confirmSubmit(){ confirmSubmit(){
@ -251,18 +334,28 @@ export default {
// if(this.noDishes){ // if(this.noDishes){
// this.$modal.msgError(""); // this.$modal.msgError("");
// }else{ // }else{
// this.loading=true // this.loadingBtn=true
// addMenucontractApi(param).then((response) => { // addMenucontractApi(param).then((response) => {
// this.loading=false // this.loadingBtn=false
// this.jumpList() // this.jumpList()
// }).catch(() => { // }).catch(() => {
// this.loading=false // this.loadingBtn=false
// }); // });
// } // }
} }
}); });
}, },
//
handleSelectionChange(selection) {
// this.batchIds1 = selection.map(item => item.tradeId)
// this.single = selection.length !== 1
// this.multiple = !selection.length
},
handleSelectionChange2(selection) {
// this.batchIds1 = selection.map(item => item.tradeId)
// this.single = selection.length !== 1
// this.multiple = !selection.length
},
// //
formatDate(date) { formatDate(date) {
// YYYY-MM-DD // YYYY-MM-DD

View File

@ -218,8 +218,8 @@ export default {
getList() { getList() {
this.loading = true; this.loading = true;
let param = { let param = {
"current": this.queryParams.pageNum, "pageNum": this.queryParams.pageNum,
"size": this.queryParams.pageSize, "pageSize": this.queryParams.pageSize,
} }
getPageCanteenApi(param).then(response => { getPageCanteenApi(param).then(response => {
this.tableListData = response.records; this.tableListData = response.records;