原料商品表合并接口修改
This commit is contained in:
parent
9233f2cb36
commit
2ead883af0
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
:props="{
|
||||
emitPath: false,// 若设置 false,则只返回该节点的值,只返回最后选择的id
|
||||
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') {
|
||||
// 用于存储节点数据的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 = {
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue