货品供应商页面重做

This commit is contained in:
zzyuan 2025-08-12 16:06:43 +08:00
parent 029c4ab38d
commit f8bf51983e
3 changed files with 226 additions and 116 deletions

View File

@ -88,7 +88,7 @@ export function supplyStatisticsPageApi(data) {
// 货品供应商关联list // 货品供应商关联list
export function supplierBindMaterialListApi(data) { export function materialBindSupplierPageApi(data) {
return request({ return request({
url: '/smart-canteen/ims_supplier_bind_material/list', url: '/smart-canteen/ims_supplier_bind_material/list',
method: 'get', method: 'get',
@ -98,6 +98,29 @@ export function supplierBindMaterialListApi(data) {
params:data params:data
}) })
} }
// 货品类别供应商关联list
export function materialTypeBindSupplierPageApi(data) {
return request({
url: '/smart-canteen/ims_supplier_bind_material/list_type',
method: 'get',
headers: {
//"merchant-id":"378915229716713472",
},
params:data
})
}
// 货品供应商-关联
export function supplierBindMaterialApi(data) {
return request({
url: '/smart-canteen/ims_supplier_bind_material/bind_material_category',
method: 'post',
headers: {
//"merchant-id":"378915229716713472",
},
data: data
})
}
// 货品供应商-新增 // 货品供应商-新增
export function addSupplierBindMaterialApi(data) { export function addSupplierBindMaterialApi(data) {

View File

@ -75,7 +75,8 @@
<el-table-column label="库存数量" align="center" prop="materialNum" :show-overflow-tooltip="true"/> <el-table-column label="库存数量" align="center" prop="materialNum" :show-overflow-tooltip="true"/>
<el-table-column label="出库数量" align="center" prop="fetchNum" :show-overflow-tooltip="true"> <el-table-column label="出库数量" align="center" prop="fetchNum" :show-overflow-tooltip="true">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.fetchNum" placeholder="请输入" maxlength="8" clearable @change="patternValue(scope.row)"/> <el-input v-if="!baseInfo.fetchMaterialId" v-model="scope.row.fetchNum" placeholder="请输入" maxlength="8" clearable @change="patternValue(scope.row)"/>
<span v-else>{{ scope.row.fetchNum }}</span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>

View File

@ -41,9 +41,9 @@
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="tableListData" height="550" :row-key="(row)=>{return row.id}" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="tableListData" height="550" :row-key="(row)=>{return row.materialId}" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" :reserve-selection="true" /> <el-table-column type="selection" width="50" align="center" :reserve-selection="true" />
<el-table-column label="序号" align="center" width="80" type="index" fixed="left"> <el-table-column label="序号" align="center" width="80" type="index">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span> <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
</template> </template>
@ -63,8 +63,9 @@
</el-table-column> --> </el-table-column> -->
<el-table-column label="首选供应商" align="center" prop="supplierId" :show-overflow-tooltip="true" width="180"> <el-table-column label="首选供应商" align="center" prop="supplierId" :show-overflow-tooltip="true" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.supplierId" placeholder="请选择供应商" style="width: 100%;" @change="changSupplier(scope.row)"> <el-select v-model="scope.row.supplierId" placeholder="请选择供应商" style="width: 100%;" @change="changSupplier(scope.row)" @clear="clearSupplier(scope.row)" clearable>
<el-option v-for="item in supplierOptions" <el-option v-for="item in supplierOptions"
:disabled="checkDisabled(item,scope.row)"
:key="item.supplierId" :key="item.supplierId"
:label="item.supplierName" :label="item.supplierName"
:value="item.supplierId" :value="item.supplierId"
@ -74,8 +75,9 @@
</el-table-column> </el-table-column>
<el-table-column label="备选供应商" align="center" prop="supplierIdList" :show-overflow-tooltip="true" width="240"> <el-table-column label="备选供应商" align="center" prop="supplierIdList" :show-overflow-tooltip="true" width="240">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.supplierIdList" multiple collapse-tags :multiple-limit="3" placeholder="请选择供应商" style="width: 100%;" @change="changSupplierList(scope.row)"> <el-select v-model="scope.row.supplierIdList" multiple collapse-tags :multiple-limit="3" placeholder="请选择供应商" style="width: 100%;" @change="changSupplierList(scope.row)" @clear="changSupplierList(scope.row)" clearable>
<el-option v-for="item in supplierOptions" <el-option v-for="item in supplierOptions"
:disabled="checkDisabled2(item,scope.row)"
:key="item.supplierId" :key="item.supplierId"
:label="item.supplierName" :label="item.supplierName"
:value="item.supplierId" :value="item.supplierId"
@ -100,7 +102,7 @@
@pagination="getList" @pagination="getList"
/> />
</el-tab-pane> </el-tab-pane>
<!-- <el-tab-pane label="货品类别" name="category"> <el-tab-pane label="货品类别" name="category">
<el-form :model="queryParams2" ref="queryForm2" size="small" :inline="true" v-show="showSearch" label-width="90px"> <el-form :model="queryParams2" ref="queryForm2" size="small" :inline="true" v-show="showSearch" label-width="90px">
<el-form-item label="货品类别" prop="materialTypeIds"> <el-form-item label="货品类别" prop="materialTypeIds">
<el-cascader <el-cascader
@ -122,31 +124,46 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList2"></right-toolbar> <el-col :span="1.5">
<el-button
type="primary"
plain
size="mini"
@click="handleBatch"
>批量关联供应商</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="tableListData2" height="800"> <el-table v-loading="loading" :data="tableListData2" height="800" :row-key="(row)=>{return row.materialTypeId}" @selection-change="handleSelectionChange">
<el-table-column label="序号" align="center" width="80" type="index" fixed="left"> <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"> <template slot-scope="scope">
<span>{{(queryParams2.pageNum - 1) * queryParams2.pageSize + scope.$index + 1}}</span> <span>{{(queryParams2.pageNum - 1) * queryParams2.pageSize + scope.$index + 1}}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="货品类别" align="center" prop="categoryName" :show-overflow-tooltip="true"/> <el-table-column label="货品类别" align="center" prop="materialTypeName" :show-overflow-tooltip="true"/>
<el-table-column label="首选供应商" align="center" prop="supplierName" :show-overflow-tooltip="true"> <el-table-column label="首选供应商" align="center" prop="supplierId" :show-overflow-tooltip="true">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.supplierId" placeholder="首选供应商" style="width: 100%;"> <el-select v-model="scope.row.supplierId" placeholder="请选择供应商" style="width: 100%;" @change="changSupplier(scope.row)" @clear="clearSupplier(scope.row)" clearable>
<el-option label="是" :value="1"></el-option> <el-option v-for="item in supplierOptions"
<el-option label="否" :value="2"></el-option> :disabled="checkDisabled(item,scope.row)"
:key="item.supplierId"
:label="item.supplierName"
:value="item.supplierId"
></el-option>
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备选供应商" align="center" prop="telephone" :show-overflow-tooltip="true"> <el-table-column label="备选供应商" align="center" prop="supplierIdList" :show-overflow-tooltip="true">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-select v-model="scope.row.supplierIdList" multiple collapse-tags :multiple-limit="3" placeholder="请选择供应商" style="width: 100%;" @change="changSupplierList(scope.row)" @clear="changSupplierList(scope.row)" clearable>
size="mini" <el-option v-for="item in supplierOptions"
type="text" :disabled="checkDisabled2(item,scope.row)"
icon="el-icon-edit" :key="item.supplierId"
@click="handleUpdate(scope.row)" :label="item.supplierName"
>选择</el-button> :value="item.supplierId"
></el-option>
</el-select>
</template> </template>
</el-table-column> </el-table-column>
@ -158,7 +175,7 @@
:limit.sync="queryParams2.pageSize" :limit.sync="queryParams2.pageSize"
@pagination="getList2" @pagination="getList2"
/> />
</el-tab-pane> --> </el-tab-pane>
</el-tabs> </el-tabs>
@ -194,8 +211,9 @@
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="首选供应商" prop="supplierId"> <el-form-item label="首选供应商" prop="supplierId">
<el-select v-model="batchForm.supplierId" placeholder="请选择首选供应商" style="width: 100%;"> <el-select v-model="batchForm.supplierId" placeholder="请选择首选供应商" style="width: 100%;" @change="dialogChangeSupplier">
<el-option v-for="item in supplierOptions" <el-option v-for="item in supplierOptions"
:disabled="checkDisabled(item,batchForm)"
:key="item.supplierId" :key="item.supplierId"
:label="item.supplierName" :label="item.supplierName"
:value="item.supplierId" :value="item.supplierId"
@ -205,8 +223,9 @@
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="备选供应商" prop="supplierIdList"> <el-form-item label="备选供应商" prop="supplierIdList">
<el-select v-model="batchForm.supplierIdList" multiple :multiple-limit="3" collapse-tags placeholder="请选择备选供应商" style="width: 100%;"> <el-select v-model="batchForm.supplierIdList" multiple :multiple-limit="3" collapse-tags placeholder="请选择备选供应商" style="width: 100%;" @change="dialogChangeSupplierList">
<el-option v-for="item in supplierOptions" <el-option v-for="item in supplierOptions"
:disabled="checkDisabled2(item,batchForm)"
:key="item.supplierId" :key="item.supplierId"
:label="item.supplierName" :label="item.supplierName"
:value="item.supplierId" :value="item.supplierId"
@ -214,14 +233,14 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <!-- <el-col :span="24">
<el-form-item label="是否供应" prop="ifSupply"> <el-form-item label="是否供应" prop="ifSupply">
<el-select v-model="batchForm.ifSupply" placeholder="是否供应" style="width: 100%;"> <el-select v-model="batchForm.ifSupply" placeholder="是否供应" style="width: 100%;">
<el-option label="是" :value="1"></el-option> <el-option label="是" :value="1"></el-option>
<el-option label="否" :value="2"></el-option> <el-option label="否" :value="2"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col> -->
</el-row> </el-row>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
@ -237,7 +256,7 @@
<script> <script>
import { systemMaterialTreeApi } from "@/api/dish/material"; import { systemMaterialTreeApi } from "@/api/dish/material";
import { supplierBindMaterialListApi,supplierPageApi,addSupplierBindMaterialApi, editSupplierBindMaterialApi } from "@/api/foodManage/supplierManage"; import { materialBindSupplierPageApi,materialTypeBindSupplierPageApi,supplierPageApi,supplierBindMaterialApi,addSupplierBindMaterialApi, editSupplierBindMaterialApi } from "@/api/foodManage/supplierManage";
export default { export default {
name: "", name: "",
@ -358,6 +377,12 @@ export default {
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.queryParams={
pageNum: 1,
pageSize: 10,
supplierName: undefined,
materialTypeIds:[]
}
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
}, },
@ -370,7 +395,7 @@ export default {
"supplierName": this.queryParams.supplierName, "supplierName": this.queryParams.supplierName,
"materialTypeIds": this.queryParams.materialTypeIds, "materialTypeIds": this.queryParams.materialTypeIds,
} }
supplierBindMaterialListApi(param).then(response => { materialBindSupplierPageApi(param).then(response => {
this.tableListData = response.rows; this.tableListData = response.rows;
this.tableListData.forEach(item=>{ this.tableListData.forEach(item=>{
let arr=[] let arr=[]
@ -385,74 +410,116 @@ export default {
this.loading = false; this.loading = false;
}); });
}, },
//-
changSupplier(row){ changSupplier(row){
console.log(row) console.log(row)
if(row.ifSupply){ let param = {
let param = [ "materialId":null,
{ "materialIds":null,
"id":row.id, "categoryId":null,
"canteenId": row.canteenId, "categoryIds":null,
"supplierId": row.supplierId, "canteenId": row.canteenId,
"materialId": row.materialId, "supplierId": row.supplierId,
"alternativeSuppliers": row.alternativeSuppliers, "alternativeSuppliers": row.alternativeSuppliers,
"ifSupply": row.ifSupply "ifSupply": row.ifSupply
}
]
editSupplierBindMaterialApi(param).then(response => {
this.$modal.msgSuccess("修改成功");
});
}else{
let param = [
{
"id":row.id,
"canteenId": row.canteenId,
"supplierId": row.supplierId,
"materialId": row.materialId,
"alternativeSuppliers": row.alternativeSuppliers,
"ifSupply": row.ifSupply
}
]
addSupplierBindMaterialApi(param).then(response => {
this.getList();
});
} }
if(!row.materialId){//
param.categoryId = row.materialTypeId
}else{//
param.materialId = row.materialId
}
supplierBindMaterialApi(param).then(response => {
this.$modal.msgSuccess("修改成功");
this.getList()
});
}, },
//-
clearSupplier(row){
let param = {
"materialId":null,
"materialIds":null,
"categoryId":null,
"categoryIds":null,
"supplierId": null,
"canteenId": row.canteenId,
"alternativeSuppliers": row.alternativeSuppliers,
"ifSupply": row.ifSupply
}
if(!row.materialId){//
param.categoryId = row.materialTypeId
}else{//
param.materialId = row.materialId
}
supplierBindMaterialApi(param).then(response => {
this.$modal.msgSuccess("修改成功");
this.getList()
});
},
//-
changSupplierList(row){ changSupplierList(row){
console.log(row) console.log(row)
let param = [ let param = {
{ "materialId":null,
"id":row.id, "materialIds":null,
"canteenId": row.canteenId, "categoryId":null,
"supplierId": row.supplierId, "categoryIds":null,
"materialId": row.materialId, "canteenId": row.canteenId,
"alternativeSuppliers": [], "supplierId": row.supplierId,
"ifSupply": row.ifSupply "materialId": row.materialId,
} "alternativeSuppliers": [],
] "ifSupply": row.ifSupply
}
if(!row.materialId){//
param.categoryId = row.materialTypeId
}else{//
param.materialId = row.materialId
}
if(row.supplierIdList&&row.supplierIdList.length>0){ if(row.supplierIdList&&row.supplierIdList.length>0){
row.supplierIdList.forEach(item => { row.supplierIdList.forEach(item => {
param[0].alternativeSuppliers.push({"supplierId":item}) param.alternativeSuppliers.push({"supplierId":item})
}) })
}else{ }else{
param[0].alternativeSuppliers=[] param.alternativeSuppliers=null
}
if(row.ifSupply){
editSupplierBindMaterialApi(param).then(response => {
// this.$modal.msgSuccess("");
// this.getList();
});
}else{
addSupplierBindMaterialApi(param).then(response => {
// this.$modal.msgSuccess("");
this.getList();
});
} }
supplierBindMaterialApi(param).then(response => {
this.$modal.msgSuccess("修改成功");
this.getList();
});
}, },
//
checkDisabled(item,row){
//
let flag = false;
if(row.alternativeSuppliers&&row.alternativeSuppliers.length>0){
let index = row.alternativeSuppliers.findIndex(v=>v.supplierId==item.supplierId)
if(index==-1){
flag=false
}else{
flag=true
}
}
return flag;
},
//
checkDisabled2(item,row){
//
let flag = false;
if(row.supplierId&&row.supplierId!=""){
if(item.supplierId==row.supplierId){
flag=true
}else{
flag=false
}
}
return flag;
},
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.batchRows = selection this.batchRows = selection
}, },
//
handleBatch(){ handleBatch(){
if(this.batchRows.length==0){ if(this.batchRows.length==0){
this.$modal.msgError("请先选择货品!"); this.$modal.msgError("请先选择货品!");
@ -462,6 +529,7 @@ export default {
this.openBatch=true this.openBatch=true
} }
}, },
//
confirmBatchEdit(){ confirmBatchEdit(){
this.$refs["batchForm"].validate(valid => { this.$refs["batchForm"].validate(valid => {
if (valid) { if (valid) {
@ -469,31 +537,47 @@ export default {
this.batchForm.supplierIdList.forEach(item => { this.batchForm.supplierIdList.forEach(item => {
arr.push({"supplierId":item}) arr.push({"supplierId":item})
}) })
let param =[] let param = {
"materialId":null,
"materialIds":[],
"categoryId":null,
"categoryIds":[],
"canteenId": null,
"supplierId": this.batchForm.supplierId,
"alternativeSuppliers": arr,
"ifSupply": "1"
}
this.batchRows.forEach(item=>{ this.batchRows.forEach(item=>{
let obj = { if(!item.materialId){
"id":item.id, param.categoryIds.push(item.materialTypeId)
"canteenId": item.canteenId, param.materialIds=null
"supplierId": this.batchForm.supplierId, }else{
"materialId": item.materialId, param.materialIds.push(item.materialId)
"alternativeSuppliers": arr, param.categoryIds=null
"ifSupply": this.batchForm.ifSupply
} }
param.push(obj)
}) })
console.log(param) console.log(param)
editSupplierBindMaterialApi(param).then(response => { supplierBindMaterialApi(param).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.openBatch=false this.openBatch=false;
this.getList(); this.getList();
this.getList2();
}); });
} }
}) })
}, },
//select
dialogChangeSupplier(e){
console.log(e)
this.$set(this.batchForm,"supplierId",e)
this.$set(this.batchForm,"supplierIdList",[])
},
//select
dialogChangeSupplierList(e){
console.log(e)
this.$set(this.batchForm,"supplierIdList",e)
},
//----------- //-----------
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -503,9 +587,10 @@ export default {
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery2() { resetQuery2() {
this.queryParams2 = { this.queryParams2={
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
materialTypeIds:[]
} }
this.resetForm("queryForm2"); this.resetForm("queryForm2");
this.handleQuery2(); this.handleQuery2();
@ -518,23 +603,24 @@ export default {
"pageSize": this.queryParams2.pageSize, "pageSize": this.queryParams2.pageSize,
"materialTypeIds": this.queryParams2.materialTypeIds, "materialTypeIds": this.queryParams2.materialTypeIds,
} }
// supplierBindMaterialListApi(param).then(response => { materialTypeBindSupplierPageApi(param).then(response => {
// this.tableListData2 = response.rows; this.tableListData2 = response.rows;
// this.total2 = Number(response.total); this.tableListData2.forEach(item=>{
let arr=[]
if(item.alternativeSuppliers&&item.alternativeSuppliers.length>0){
item.alternativeSuppliers.forEach(sub=>{
arr.push(sub.supplierId)
})
}
this.$set(item,"supplierIdList",arr)
})
this.total2 = Number(response.total);
this.loading = false; this.loading = false;
// }); });
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();