|
|
|
@ -15,7 +15,8 @@
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
<el-form :model="form" :rules="rules" ref="form" label-width="120px">
|
|
|
|
|
</el-form>
|
|
|
|
|
<el-table v-loading="loading" :data="detailList" style="width: 100%;"
|
|
|
|
|
:row-class-name="tableRowClassName"
|
|
|
|
|
border
|
|
|
|
@ -392,7 +393,6 @@ export default {
|
|
|
|
|
{
|
|
|
|
|
this.selectProductVisible = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
saveChange(row) {
|
|
|
|
@ -400,12 +400,14 @@ export default {
|
|
|
|
|
if (row.batchNo == '') {
|
|
|
|
|
row.batchNo = null;
|
|
|
|
|
}
|
|
|
|
|
if (row.produceDate == '') {
|
|
|
|
|
row.produceDate = null;
|
|
|
|
|
}
|
|
|
|
|
if (row.expireDate == '') {
|
|
|
|
|
row.expireDate = null;
|
|
|
|
|
}
|
|
|
|
|
// 对produceDate进行校验和设置
|
|
|
|
|
if (row.productDate !== '' && row.productDate !== null)
|
|
|
|
|
if (!this.validateAndSetDate(row, 'productDate')) return;
|
|
|
|
|
|
|
|
|
|
// 对expireDate进行校验和设置
|
|
|
|
|
if (row.productDate !== '' && row.expireDate !== null)
|
|
|
|
|
if (!this.validateAndSetDate(row, 'expireDate')) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateBizProduct(row)
|
|
|
|
|
.then((response) => {
|
|
|
|
@ -426,6 +428,23 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
validateAndSetDate(row, fieldName) {
|
|
|
|
|
if (!row || !Object.prototype.hasOwnProperty.call(row, fieldName)) {
|
|
|
|
|
this.$message.error('日期字段缺失');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (row[fieldName] === '') {
|
|
|
|
|
row[fieldName] = null;
|
|
|
|
|
} else {
|
|
|
|
|
let msg = this.checkTimeFormat(row[fieldName]);
|
|
|
|
|
if (msg !== "") {
|
|
|
|
|
this.$message.error(msg);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
copyDetail(row) {
|
|
|
|
|
let data = {
|
|
|
|
|
relId: row.bindRlFk,
|
|
|
|
@ -521,6 +540,43 @@ export default {
|
|
|
|
|
this.refreshPanel();
|
|
|
|
|
}
|
|
|
|
|
,
|
|
|
|
|
|
|
|
|
|
checkTimeFormat(dateStr) {
|
|
|
|
|
let errorMessage = '';
|
|
|
|
|
|
|
|
|
|
// 异常处理和边界条件覆盖
|
|
|
|
|
if (typeof dateStr !== 'string' || dateStr === null || dateStr === undefined) {
|
|
|
|
|
errorMessage = '输入参数必须是非空字符串';
|
|
|
|
|
return errorMessage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const regex = /^\d{6}$/;
|
|
|
|
|
if (!regex.test(dateStr)) {
|
|
|
|
|
errorMessage = '时间格式不正确,应为 yyMMdd';
|
|
|
|
|
} else {
|
|
|
|
|
// 增强日期有效性检查
|
|
|
|
|
const year = parseInt(dateStr.substring(0, 2), 10);
|
|
|
|
|
const month = parseInt(dateStr.substring(2, 4), 10);
|
|
|
|
|
const day = parseInt(dateStr.substring(4, 6), 10);
|
|
|
|
|
|
|
|
|
|
// 检查年、月、日的有效性
|
|
|
|
|
if (year < 0 || year > 99 ||
|
|
|
|
|
month < 1 || month > 12 ||
|
|
|
|
|
day < 1 || day > 31) {
|
|
|
|
|
errorMessage = '时间格式有效,但日期不存在';
|
|
|
|
|
} else {
|
|
|
|
|
// 修正年份的两位数到四位数
|
|
|
|
|
const fullYear = year < 50 ? 2000 + year : 1900 + year;
|
|
|
|
|
const dateObj = new Date(fullYear, month - 1, day);
|
|
|
|
|
|
|
|
|
|
// 检查是否为有效日期
|
|
|
|
|
if (dateObj.getFullYear() !== fullYear || dateObj.getMonth() + 1 !== month || dateObj.getDate() !== day) {
|
|
|
|
|
errorMessage = '时间格式有效,但日期不存在';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return errorMessage;
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
,
|
|
|
|
|
filters: {}
|
|
|
|
|