|
@@ -156,6 +156,7 @@
|
|
|
>
|
|
>
|
|
|
<ele-pro-table
|
|
<ele-pro-table
|
|
|
ref="table"
|
|
ref="table"
|
|
|
|
|
+ :key="'productTable' + formData.bizType"
|
|
|
:columns="columns"
|
|
:columns="columns"
|
|
|
:datasource="productList"
|
|
:datasource="productList"
|
|
|
:needPage="false"
|
|
:needPage="false"
|
|
@@ -212,6 +213,12 @@
|
|
|
<template v-slot:headerBatchNo="{ column }">
|
|
<template v-slot:headerBatchNo="{ column }">
|
|
|
<span class="is-required">{{ column.label }}</span>
|
|
<span class="is-required">{{ column.label }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+ <template v-slot:headerDetailProductionDate="{ column }">
|
|
|
|
|
+ <span class="required-star">{{ column.label }}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template v-slot:headerDetailExpireDate="{ column }">
|
|
|
|
|
+ <span class="required-star">{{ column.label }}</span>
|
|
|
|
|
+ </template>
|
|
|
<template v-slot:batchNo="{ row, $index }">
|
|
<template v-slot:batchNo="{ row, $index }">
|
|
|
<template v-if="row.isSave">
|
|
<template v-if="row.isSave">
|
|
|
{{ row.batchNo }}
|
|
{{ row.batchNo }}
|
|
@@ -433,16 +440,21 @@
|
|
|
<template v-if="row.isSave">
|
|
<template v-if="row.isSave">
|
|
|
{{ row.detailProductionDate }}
|
|
{{ row.detailProductionDate }}
|
|
|
</template>
|
|
</template>
|
|
|
- <el-date-picker
|
|
|
|
|
|
|
+ <el-form-item
|
|
|
v-else
|
|
v-else
|
|
|
- :disabled="row.isPack"
|
|
|
|
|
- size="small"
|
|
|
|
|
- v-model="row.detailProductionDate"
|
|
|
|
|
- type="datetime"
|
|
|
|
|
- value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
- placeholder="选择日期"
|
|
|
|
|
|
|
+ :prop="`productList.${$index}.detailProductionDate`"
|
|
|
|
|
+ :required="isProductionInbound"
|
|
|
>
|
|
>
|
|
|
- </el-date-picker>
|
|
|
|
|
|
|
+ <el-date-picker
|
|
|
|
|
+ :disabled="row.isPack"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ v-model="row.detailProductionDate"
|
|
|
|
|
+ type="datetime"
|
|
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
+ placeholder="选择日期"
|
|
|
|
|
+ >
|
|
|
|
|
+ </el-date-picker>
|
|
|
|
|
+ </el-form-item>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-slot:detailPurchaseDate="{ row, $index }">
|
|
<template v-slot:detailPurchaseDate="{ row, $index }">
|
|
|
<template v-if="row.isSave">
|
|
<template v-if="row.isSave">
|
|
@@ -463,16 +475,21 @@
|
|
|
<template v-if="row.isSave">
|
|
<template v-if="row.isSave">
|
|
|
{{ row.detailExpireDate }}
|
|
{{ row.detailExpireDate }}
|
|
|
</template>
|
|
</template>
|
|
|
- <el-date-picker
|
|
|
|
|
|
|
+ <el-form-item
|
|
|
v-else
|
|
v-else
|
|
|
- :disabled="row.isPack"
|
|
|
|
|
- size="small"
|
|
|
|
|
- v-model="row.detailExpireDate"
|
|
|
|
|
- type="datetime"
|
|
|
|
|
- value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
- placeholder="选择日期"
|
|
|
|
|
|
|
+ :prop="`productList.${$index}.detailExpireDate`"
|
|
|
|
|
+ :required="isProductionInbound"
|
|
|
>
|
|
>
|
|
|
- </el-date-picker>
|
|
|
|
|
|
|
+ <el-date-picker
|
|
|
|
|
+ :disabled="row.isPack"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ v-model="row.detailExpireDate"
|
|
|
|
|
+ type="datetime"
|
|
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
|
|
+ placeholder="选择日期"
|
|
|
|
|
+ >
|
|
|
|
|
+ </el-date-picker>
|
|
|
|
|
+ </el-form-item>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-slot:action="{ row, $index }">
|
|
<template v-slot:action="{ row, $index }">
|
|
|
<el-button
|
|
<el-button
|
|
@@ -1095,6 +1112,10 @@
|
|
|
clientEnvironmentId() {
|
|
clientEnvironmentId() {
|
|
|
return this.$store.state.user.info.clientEnvironmentId;
|
|
return this.$store.state.user.info.clientEnvironmentId;
|
|
|
},
|
|
},
|
|
|
|
|
+ // 生产入库(入库类型=1):产品信息行「生产日期」「失效日期」必填
|
|
|
|
|
+ isProductionInbound() {
|
|
|
|
|
+ return String(this.formData.bizType) === '1';
|
|
|
|
|
+ },
|
|
|
columns() {
|
|
columns() {
|
|
|
// 当columnsVersion变化时会重新计算
|
|
// 当columnsVersion变化时会重新计算
|
|
|
const version = this.columnsVersion;
|
|
const version = this.columnsVersion;
|
|
@@ -1345,7 +1366,11 @@
|
|
|
slot: 'detailProductionDate',
|
|
slot: 'detailProductionDate',
|
|
|
showOverflowTooltip: true,
|
|
showOverflowTooltip: true,
|
|
|
width: 220,
|
|
width: 220,
|
|
|
- align: 'center'
|
|
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ // 生产入库时该列必填,表头补红星(其它入库类型不注册表头插槽)
|
|
|
|
|
+ ...(this.isProductionInbound
|
|
|
|
|
+ ? { headerSlot: 'headerDetailProductionDate' }
|
|
|
|
|
+ : {})
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
label: '采购日期',
|
|
label: '采购日期',
|
|
@@ -1361,7 +1386,11 @@
|
|
|
slot: 'detailExpireDate',
|
|
slot: 'detailExpireDate',
|
|
|
showOverflowTooltip: true,
|
|
showOverflowTooltip: true,
|
|
|
width: 220,
|
|
width: 220,
|
|
|
- align: 'center'
|
|
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ // 生产入库时该列必填,表头补红星(其它入库类型不注册表头插槽)
|
|
|
|
|
+ ...(this.isProductionInbound
|
|
|
|
|
+ ? { headerSlot: 'headerDetailExpireDate' }
|
|
|
|
|
+ : {})
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
columnKey: 'action',
|
|
columnKey: 'action',
|
|
@@ -1381,6 +1410,13 @@
|
|
|
if (String(newValue) !== '2') {
|
|
if (String(newValue) !== '2') {
|
|
|
this.clearInboundRequestId();
|
|
this.clearInboundRequestId();
|
|
|
}
|
|
}
|
|
|
|
|
+ // 切换入库类型后清掉上一类型留下的必填标红(只有生产入库校验日期)
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ const productForm = this.$refs.productListRef;
|
|
|
|
|
+ if (productForm && typeof productForm.clearValidate === 'function') {
|
|
|
|
|
+ productForm.clearValidate();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
packingList: {
|
|
packingList: {
|
|
|
handler(newVal) {
|
|
handler(newVal) {
|
|
@@ -2442,6 +2478,18 @@
|
|
|
this.$message.warning('请先保存所有产品信息');
|
|
this.$message.warning('请先保存所有产品信息');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ // 生产入库:入库前生产日期/失效日期必须已填写(含已保存的行)
|
|
|
|
|
+ if (this.isProductionInbound) {
|
|
|
|
|
+ const dateGroups = this.buildRequiredGroups(
|
|
|
|
|
+ null,
|
|
|
|
|
+ true,
|
|
|
|
|
+ this.dateFileds()
|
|
|
|
|
+ );
|
|
|
|
|
+ if (dateGroups.length) {
|
|
|
|
|
+ this.showRequiredMessage(dateGroups);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
// 处理包装数据
|
|
// 处理包装数据
|
|
|
this.packingList = this.packingList.map((packingItem) => {
|
|
this.packingList = this.packingList.map((packingItem) => {
|
|
|
if (packingItem.modelKey) {
|
|
if (packingItem.modelKey) {
|
|
@@ -2898,6 +2946,127 @@
|
|
|
this.productList = this.productList.concat(productList);
|
|
this.productList = this.productList.concat(productList);
|
|
|
console.log('this.productList--------', this.productList);
|
|
console.log('this.productList--------', this.productList);
|
|
|
},
|
|
},
|
|
|
|
|
+ // 产品信息行的必填字段(生产入库额外要求生产日期/失效日期)
|
|
|
|
|
+ requiredFileds() {
|
|
|
|
|
+ const fileds = [
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'batchNo',
|
|
|
|
|
+ label: '批次号'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'quantity',
|
|
|
|
|
+ label: '数量'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'unit',
|
|
|
|
|
+ label: '单位'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'warehouseId',
|
|
|
|
|
+ label: '仓库'
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+ if (this.isProductionInbound) {
|
|
|
|
|
+ fileds.push(...this.dateFileds());
|
|
|
|
|
+ }
|
|
|
|
|
+ return fileds;
|
|
|
|
|
+ },
|
|
|
|
|
+ // 生产入库才校验的两个日期字段
|
|
|
|
|
+ dateFileds() {
|
|
|
|
|
+ return [
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'detailProductionDate',
|
|
|
|
|
+ label: '生产日期'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'detailExpireDate',
|
|
|
|
|
+ label: '失效日期'
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+ },
|
|
|
|
|
+ // 与 el-form required 同口径:undefined/null/空串算未填,0 算已填
|
|
|
|
|
+ isBlank(value) {
|
|
|
|
|
+ return value === undefined || value === null || value === '';
|
|
|
|
|
+ },
|
|
|
|
|
+ // 必填缺项按「行」聚合:一行一条、缺的字段用「、」并列,
|
|
|
|
|
+ // 逐字段摊平在几十行明细里看不出到底哪几行缺什么
|
|
|
|
|
+ buildRequiredGroups(indexes, includeSaved, fileds) {
|
|
|
|
|
+ const rowIndexes =
|
|
|
|
|
+ indexes || this.productList.map((item, index) => index);
|
|
|
|
|
+ const fieldList = fileds || this.requiredFileds();
|
|
|
|
|
+ const groups = [];
|
|
|
|
|
+ rowIndexes.forEach((index) => {
|
|
|
|
|
+ const row = this.productList[index];
|
|
|
|
|
+ if (!row || (!includeSaved && row.isSave)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const labels = fieldList
|
|
|
|
|
+ .filter((item) => this.isBlank(row[item.prop]))
|
|
|
|
|
+ .map((item) => item.label);
|
|
|
|
|
+ if (labels.length) {
|
|
|
|
|
+ groups.push({
|
|
|
|
|
+ index,
|
|
|
|
|
+ labels,
|
|
|
|
|
+ name: row.categoryName || row.categoryCode || '未选择物品'
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return groups;
|
|
|
|
|
+ },
|
|
|
|
|
+ escapeHtml(text) {
|
|
|
|
|
+ const map = {
|
|
|
|
|
+ '&': '&',
|
|
|
|
|
+ '<': '<',
|
|
|
|
|
+ '>': '>',
|
|
|
|
|
+ '"': '"',
|
|
|
|
|
+ "'": '''
|
|
|
|
|
+ };
|
|
|
|
|
+ return String(text).replace(/[&<>"']/g, (char) => map[char]);
|
|
|
|
|
+ },
|
|
|
|
|
+ // 必填缺项提示:先给总行数/总项数,再一行一条;超过 3 行只列前 3 行,
|
|
|
|
|
+ // 只有一处缺失时退回最短的一句
|
|
|
|
|
+ showRequiredMessage(groups) {
|
|
|
|
|
+ if (!groups.length) {
|
|
|
|
|
+ this.$message.error('请填入必填项!');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (groups.length === 1 && groups[0].labels.length === 1) {
|
|
|
|
|
+ const single = groups[0];
|
|
|
|
|
+ this.$message.warning(
|
|
|
|
|
+ `第${single.index + 1}行 物品「${single.name}」的「${
|
|
|
|
|
+ single.labels[0]
|
|
|
|
|
+ }」未填写`
|
|
|
|
|
+ );
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const total = groups.reduce(
|
|
|
|
|
+ (sum, group) => sum + group.labels.length,
|
|
|
|
|
+ 0
|
|
|
|
|
+ );
|
|
|
|
|
+ const maxRows = 3;
|
|
|
|
|
+ const lines = groups.slice(0, maxRows).map(
|
|
|
|
|
+ (group) =>
|
|
|
|
|
+ // 物品名来自业务数据,拼进 HTML 提示前必须转义
|
|
|
|
|
+ `第${group.index + 1}行 物品「${this.escapeHtml(
|
|
|
|
|
+ group.name
|
|
|
|
|
+ )}」:${group.labels.join('、')}`
|
|
|
|
|
+ );
|
|
|
|
|
+ if (groups.length > maxRows) {
|
|
|
|
|
+ lines.push(
|
|
|
|
|
+ `另有 ${groups.length - maxRows} 行未填写完整(共 ${
|
|
|
|
|
+ groups.length
|
|
|
|
|
+ } 行 / ${total} 项)`
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ this.$message.warning({
|
|
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
|
|
+ showClose: true,
|
|
|
|
|
+ duration: 6000,
|
|
|
|
|
+ message: `产品信息共 ${
|
|
|
|
|
+ groups.length
|
|
|
|
|
+ } 行 ${total} 项必填未填写:<br/>${lines.join('<br/>')}`
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
// 物品保存验证表单(批量)
|
|
// 物品保存验证表单(批量)
|
|
|
validateForm() {
|
|
validateForm() {
|
|
|
return new Promise(async (resolve, reject) => {
|
|
return new Promise(async (resolve, reject) => {
|
|
@@ -2908,6 +3077,12 @@
|
|
|
`productList.${index}.unit`,
|
|
`productList.${index}.unit`,
|
|
|
`productList.${index}.warehouseId`
|
|
`productList.${index}.warehouseId`
|
|
|
];
|
|
];
|
|
|
|
|
+ if (this.isProductionInbound) {
|
|
|
|
|
+ fileds.push(
|
|
|
|
|
+ `productList.${index}.detailProductionDate`,
|
|
|
|
|
+ `productList.${index}.detailExpireDate`
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
console.log(fileds);
|
|
console.log(fileds);
|
|
|
if (row.isSave) {
|
|
if (row.isSave) {
|
|
|
return Promise.resolve(true);
|
|
return Promise.resolve(true);
|
|
@@ -2935,8 +3110,13 @@
|
|
|
})
|
|
})
|
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
|
console.log('保存失败!');
|
|
console.log('保存失败!');
|
|
|
- this.$message.error('请填入必填项!');
|
|
|
|
|
- reject(err);
|
|
|
|
|
|
|
+ // 必填缺项按行聚合提示(行号 + 物品 + 缺的字段)
|
|
|
|
|
+ this.showRequiredMessage(this.buildRequiredGroups());
|
|
|
|
|
+ // 已给出必填提示时不再叠加批量保存的兜底文案
|
|
|
|
|
+ reject({
|
|
|
|
|
+ ...(err && typeof err === 'object' ? err : {}),
|
|
|
|
|
+ requiredTips: true
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
@@ -2950,6 +3130,12 @@
|
|
|
`productList.${index}.unit`,
|
|
`productList.${index}.unit`,
|
|
|
`productList.${index}.warehouseId`
|
|
`productList.${index}.warehouseId`
|
|
|
];
|
|
];
|
|
|
|
|
+ if (this.isProductionInbound) {
|
|
|
|
|
+ fileds.push(
|
|
|
|
|
+ `productList.${index}.detailProductionDate`,
|
|
|
|
|
+ `productList.${index}.detailExpireDate`
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
Promise.all(
|
|
Promise.all(
|
|
|
fileds.map(
|
|
fileds.map(
|
|
|
(item) =>
|
|
(item) =>
|
|
@@ -2968,7 +3154,8 @@
|
|
|
resolve();
|
|
resolve();
|
|
|
})
|
|
})
|
|
|
.catch(() => {
|
|
.catch(() => {
|
|
|
- this.$message.error('请填入必填项!');
|
|
|
|
|
|
|
+ // 必填缺项按行聚合提示(行号 + 物品 + 缺的字段)
|
|
|
|
|
+ this.showRequiredMessage(this.buildRequiredGroups([index]));
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
@@ -3025,7 +3212,10 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- this.$message.error('批量保存失败,请检查必填项');
|
|
|
|
|
|
|
+ // 必填缺项已由 validateForm 逐行提示,不再叠加兜底文案
|
|
|
|
|
+ if (!error || !error.requiredTips) {
|
|
|
|
|
+ this.$message.error('批量保存失败,请检查必填项');
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -3065,6 +3255,11 @@
|
|
|
try {
|
|
try {
|
|
|
await this.validateFormIndividually(index);
|
|
await this.validateFormIndividually(index);
|
|
|
|
|
|
|
|
|
|
+ // 必填缺项时不保存该行(提示已由校验方法弹出)
|
|
|
|
|
+ if (this.buildRequiredGroups([index]).length) {
|
|
|
|
|
+ return resolve();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (row.packingSpecificationLabel?.length < 1) {
|
|
if (row.packingSpecificationLabel?.length < 1) {
|
|
|
this.$message.error('请到主数据维护包装组信息!');
|
|
this.$message.error('请到主数据维护包装组信息!');
|
|
|
return;
|
|
return;
|
|
@@ -3866,6 +4061,13 @@
|
|
|
color: red;
|
|
color: red;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 生产入库必填列表头红星
|
|
|
|
|
+ .required-star::before {
|
|
|
|
|
+ content: '*';
|
|
|
|
|
+ color: #f56c6c;
|
|
|
|
|
+ margin-right: 4px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
.wareHouse_style {
|
|
.wareHouse_style {
|
|
|
text-overflow: ellipsis;
|
|
text-overflow: ellipsis;
|
|
|
overflow: hidden;
|
|
overflow: hidden;
|