原料商品表合并接口修改

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({
url: '/smart-canteen/cook_material_type/getTree',
method: 'post',
headers: {
"merchant-id":"378915229716713472",
},
data: data
})
}

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@
:props="{
emitPath: false,// falseid
checkStrictly: false,//
value:'materialTypeId',label:'materialTypeName'
value:'id',label:'categoryName'
}" clearable >
</el-cascader>
</el-form-item>
@ -264,40 +264,10 @@ export default {
},
//
getTypeTreeData() {
shopMaterialTreeApi().then((response) => {
this.treeTypeOptions = this.handleTree(response.rows,'materialTypeId');
shopMaterialTreeApi({areaId:this.form.areaId,goodsType:2}).then((response) => {
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() {
let param = {

View File

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

View File

@ -92,22 +92,79 @@
</el-form-item>
</el-form>
</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 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>
</div>
<!-- 选择菜品 -->
<el-dialog title="选择货品" :visible.sync="openDishes" width="90%" append-to-body >
<div style="width: 100%;height:640px;display: flex;align-items: center;color: #000;">
<el-dialog title="选择货品" :visible.sync="openDialog" width="65%" append-to-body >
<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 slot="footer" class="dialog-footer">
<el-button type="primary" @click="openDishes=false"> </el-button>
<el-button @click="openDishes=false"> </el-button>
<el-button type="primary" @click=""> </el-button>
<el-button @click="openDialog=false"> </el-button>
</div>
</el-dialog>
</div>
@ -122,6 +179,7 @@ export default {
data() {
return {
loading:false,
loadingBtn:false,
baseInfo: {
contractName:undefined,
contractType:undefined,
@ -152,25 +210,23 @@ export default {
canteenOptions:[],
supplierOptions:[],
stallOptions:[],
dateRange:[],
// dateRangeRadio:"",
// dateRangeList:[],
// dateRangeIndex:0,
dateRange:[],
pickerOptions: {
disabledDate(v) {
return v.getTime() < (new Date().getTime() - 86400000);// - 86400000
}
},
contractDateList:[],
weekDateList:[],
detailList:[],
openDishes:false,
//
queryDish:{
salesMode:null,
typeId:null,
dishesName:''
},
contractMaterialList:[],
openDialog:false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
},
//
total: 0,
//
tableListData: [],
};
},
@ -212,12 +268,39 @@ export default {
// getSupplierByAreaApi(param).then((response) => {
// this.supplierOptions=response.rows||[]
// });
},
},
//
changeDateRange(e){
//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(){
@ -251,18 +334,28 @@ export default {
// if(this.noDishes){
// this.$modal.msgError("");
// }else{
// this.loading=true
// this.loadingBtn=true
// addMenucontractApi(param).then((response) => {
// this.loading=false
// this.loadingBtn=false
// this.jumpList()
// }).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) {
// YYYY-MM-DD

View File

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