货品供应商页面重做

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
export function supplierBindMaterialListApi(data) {
export function materialBindSupplierPageApi(data) {
return request({
url: '/smart-canteen/ims_supplier_bind_material/list',
method: 'get',
@ -98,6 +98,29 @@ export function supplierBindMaterialListApi(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) {

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="fetchNum" :show-overflow-tooltip="true">
<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>
</el-table-column>
</el-table>

View File

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