优化
This commit is contained in:
@ -70,10 +70,11 @@
|
||||
>修改</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button plain type="warning" icon="Finished" @click="handleAudit()" v-hasPermi="['cailiaoshebei:materialbatchdemandplan:query']"
|
||||
>审核</el-button
|
||||
>
|
||||
<el-col :span="1.5" v-if="form.mrpBaseBo.status == 'draft'">
|
||||
<el-button plain type="primary" icon="Finished" @click="handleAudit()">审核</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5" v-if="form.mrpBaseBo.status != 'draft'">
|
||||
<el-button type="warning" icon="View" @click="handleAudit()">查看流程</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
@ -125,9 +126,9 @@
|
||||
<!-- 表格添加border属性,优化视觉体验 -->
|
||||
<el-table :data="form.planList" border>
|
||||
<!-- 版本号列 -->
|
||||
<el-table-column prop="versions" align="center" label="版本号 " width="200">
|
||||
<el-table-column prop="batchNumber" align="center" label="版本号 " width="200">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.versions" placeholder="请选择" @change="(val) => selectNameVersion(val, scope.row, scope.$index)">
|
||||
<el-select v-model="scope.row.batchNumber" placeholder="请选择" @change="(val) => selectNameVersion(val, scope.row, scope.$index)">
|
||||
<el-option v-for="item in versionList" :key="item.versions" :label="item.versions" :value="item.versions" />
|
||||
</el-select>
|
||||
</template>
|
||||
@ -136,7 +137,7 @@
|
||||
<el-table-column prop="name" align="center" label="物资名称" width="160">
|
||||
<template #default="scope">
|
||||
<el-select
|
||||
:disabled="!scope.row.versions"
|
||||
:disabled="!scope.row.batchNumber"
|
||||
v-model="scope.row.suppliespriceId"
|
||||
placeholder="请选择"
|
||||
@change="(val) => selectName(val, scope.row, scope.$index)"
|
||||
@ -197,7 +198,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 备注列 -->
|
||||
<el-table-column prop="remark" align="center" label="备注" >
|
||||
<el-table-column prop="remark" align="center" label="备注">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.remark" placeholder="请输入备注" disabled />
|
||||
</template>
|
||||
@ -257,8 +258,9 @@ interface PlanListItem {
|
||||
remark?: string | undefined;
|
||||
Remaining: number; // 剩余量(必存在)
|
||||
quantityError: string; // 数量错误提示
|
||||
versions?: string | undefined; // 版本号
|
||||
batchNumber?: string | undefined; // 版本号
|
||||
duplicateError: string; // 重复错误提示
|
||||
mrpBaseId?: number | undefined;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
@ -321,8 +323,9 @@ const initFormData: FormData = {
|
||||
remark: undefined,
|
||||
Remaining: 0, // 初始化剩余量
|
||||
quantityError: '', // 初始化数量错误提示
|
||||
versions: undefined, // 初始化版本号
|
||||
duplicateError: '' // 初始化重复错误提示
|
||||
batchNumber: undefined, // 初始化版本号
|
||||
duplicateError: '', // 初始化重复错误提示
|
||||
mrpBaseId: undefined
|
||||
}
|
||||
]
|
||||
};
|
||||
@ -435,14 +438,14 @@ const checkDuplicate = () => {
|
||||
for (let i = 0; i < planList.length; i++) {
|
||||
const current = planList[i];
|
||||
// 跳过版本号或物资名称为空的行
|
||||
if (!current.versions || !current.suppliespriceId) continue;
|
||||
if (!current.batchNumber || !current.suppliespriceId) continue;
|
||||
|
||||
for (let j = i + 1; j < planList.length; j++) {
|
||||
const compare = planList[j];
|
||||
if (!compare.versions || !compare.suppliespriceId) continue;
|
||||
if (!compare.batchNumber || !compare.suppliespriceId) continue;
|
||||
|
||||
// 版本号和物资ID都相同则判定为重复
|
||||
if (current.versions === compare.versions && current.suppliespriceId === compare.suppliespriceId) {
|
||||
if (current.batchNumber === compare.batchNumber && current.suppliespriceId === compare.suppliespriceId) {
|
||||
current.duplicateError = `与第${j + 1}行重复(同版本+同物资)`;
|
||||
compare.duplicateError = `与第${i + 1}行重复(同版本+同物资)`;
|
||||
hasDuplicate = true;
|
||||
@ -455,6 +458,8 @@ const checkDuplicate = () => {
|
||||
|
||||
/** 选择物资名称触发(新增索引参数,用于触发重复校验) */
|
||||
const selectName = (val: number, row: PlanListItem, index: number) => {
|
||||
console.log(row);
|
||||
|
||||
// 1. 获取剩余量并更新基础信息
|
||||
getMrpBaseRemaining(val, row).then(() => {
|
||||
const selected = nameList.value.find((item: any) => item.id === val);
|
||||
@ -524,8 +529,9 @@ const addRow = () => {
|
||||
remark: undefined,
|
||||
Remaining: 0,
|
||||
quantityError: '',
|
||||
versions: undefined,
|
||||
duplicateError: ''
|
||||
batchNumber: undefined,
|
||||
duplicateError: '',
|
||||
mrpBaseId: undefined
|
||||
};
|
||||
form.value.planList.push(newRow);
|
||||
};
|
||||
@ -569,13 +575,14 @@ const handleUpdata = () => {
|
||||
if (!queryParams.value.mainData.mrpBaseId) {
|
||||
return proxy?.$modal.msgError('请先选择批次');
|
||||
}
|
||||
|
||||
// 1. 获取对应版本的物资列表
|
||||
reset();
|
||||
loading.value = true;
|
||||
getCailiaoshebei(queryParams.value.mainData.mrpBaseId)
|
||||
.then((res: any) => {
|
||||
// 1. 更新基础信息
|
||||
form.value.mrpBaseBo = res.data.mrpBaseBo || initFormData.mrpBaseBo;
|
||||
|
||||
// 2. 更新表格数据(补充缺失字段)
|
||||
form.value.planList = (res.data.planList || []).map((item: any) => ({
|
||||
id: item.id,
|
||||
@ -589,8 +596,9 @@ const handleUpdata = () => {
|
||||
remark: item.remark,
|
||||
Remaining: item.Remaining || 0,
|
||||
quantityError: '',
|
||||
versions: item.versions,
|
||||
duplicateError: ''
|
||||
batchNumber: item.batchNumber,
|
||||
duplicateError: '',
|
||||
mrpBaseId: item.mrpBaseId
|
||||
}));
|
||||
// 3. 打开对话框
|
||||
dialog.visible = true;
|
||||
@ -682,7 +690,7 @@ function validateAndClean(arr: PlanListItem[]) {
|
||||
const item = cleanedArr[idx];
|
||||
|
||||
// 校验版本号
|
||||
if (!item.versions) {
|
||||
if (!item.batchNumber) {
|
||||
return { valid: false, message: `第${idx + 1}行:版本号不能为空`, data: cleanedArr };
|
||||
}
|
||||
|
||||
@ -764,7 +772,7 @@ const getVersion = () => {
|
||||
|
||||
/** 选择版本号触发(新增索引参数,用于触发重复校验) */
|
||||
const selectNameVersion = (val: string, row: PlanListItem, index: number) => {
|
||||
row.versions = val;
|
||||
row.batchNumber = val;
|
||||
row.suppliespriceId = undefined; // 切换版本号时清空物资选择
|
||||
row.name = undefined;
|
||||
row.specification = undefined;
|
||||
@ -775,6 +783,7 @@ const selectNameVersion = (val: string, row: PlanListItem, index: number) => {
|
||||
row.demandQuantity = undefined;
|
||||
row.quantityError = '';
|
||||
row.duplicateError = '';
|
||||
row.mrpBaseId = '';
|
||||
|
||||
// 1. 获取对应版本的物资列表
|
||||
getNameList(val);
|
||||
|
Reference in New Issue
Block a user