🐛 修复车务非必填-1展示,并完善总单调度与运单表单体验

调度页限制上一段到达后才可调度;司机候选项点击展开;车务多模块-1显示为空;同步配载/总单编辑与导入相关优化。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-27 21:26:55 +08:00
parent c268d2e64d
commit 98fbf123f5
29 changed files with 1150 additions and 250 deletions
+29 -9
View File
@@ -332,15 +332,34 @@ export default {
? values.vehicleNo.trim()
: values.vehicleNo.trim().toUpperCase();
}
// 非必填金额未填写时不要提交 -1 占位值
values.directEconomicLoss = this.normalizeOptionalAmount(values.directEconomicLoss);
values.insuranceClaimAmount = this.normalizeOptionalAmount(values.insuranceClaimAmount);
values.accidentLocation = this.normalizeOptionalText(values.accidentLocation);
values.accidentReasonDamage = this.normalizeOptionalText(values.accidentReasonDamage);
values.remark = this.normalizeOptionalText(values.remark);
values.attachments = this.stringifyAttachments(values.attachments);
return values;
},
normalizeOptionalAmount(value) {
if (value === undefined || value === null || value === '' || Number(value) === -1) {
return null;
}
return value;
},
normalizeOptionalText(value) {
if (value === undefined || value === null) return null;
const text = String(value).trim();
return !text || text === '-1' ? null : text;
},
validateRow(row) {
if (Number(row.directEconomicLoss) < 0) {
const directEconomicLoss = this.normalizeOptionalAmount(row.directEconomicLoss);
const insuranceClaimAmount = this.normalizeOptionalAmount(row.insuranceClaimAmount);
if (directEconomicLoss !== null && Number(directEconomicLoss) < 0) {
this.$message.warning('直接经济损失不能小于 0');
return false;
}
if (Number(row.insuranceClaimAmount) < 0) {
if (insuranceClaimAmount !== null && Number(insuranceClaimAmount) < 0) {
this.$message.warning('保险理赔金额不能小于 0');
return false;
}
@@ -353,13 +372,9 @@ export default {
return false;
}
if (
row.directEconomicLoss !== undefined &&
row.directEconomicLoss !== null &&
row.directEconomicLoss !== '' &&
row.insuranceClaimAmount !== undefined &&
row.insuranceClaimAmount !== null &&
row.insuranceClaimAmount !== '' &&
Number(row.insuranceClaimAmount) > Number(row.directEconomicLoss)
directEconomicLoss !== null &&
insuranceClaimAmount !== null &&
Number(insuranceClaimAmount) > Number(directEconomicLoss)
) {
this.$message.warning('保险理赔金额不能超过直接经济损失金额');
return false;
@@ -448,6 +463,11 @@ export default {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
detail.vehicleType = detail.vehicleType || '车辆';
detail.directEconomicLoss = this.normalizeOptionalAmount(detail.directEconomicLoss);
detail.insuranceClaimAmount = this.normalizeOptionalAmount(detail.insuranceClaimAmount);
detail.accidentLocation = this.normalizeOptionalText(detail.accidentLocation) || '';
detail.accidentReasonDamage = this.normalizeOptionalText(detail.accidentReasonDamage) || '';
detail.remark = this.normalizeOptionalText(detail.remark) || '';
this.form = detail;
this.updateVehicleTypeDisplays(detail.vehicleType);
this.vehicleOptions = [];
+28 -1
View File
@@ -367,11 +367,33 @@ export default {
} else {
values.shipInspectionType = undefined;
}
// 费用必填,-1 转 null 后由校验拦截;非必填文本清除 "-1"
values.fee = this.normalizeOptionalAmount(values.fee);
values.inspectionUnit = this.normalizeOptionalText(values.inspectionUnit);
values.assessmentUnit = this.normalizeOptionalText(values.assessmentUnit);
values.passengerTypeLevel = this.normalizeOptionalText(values.passengerTypeLevel);
values.remark = this.normalizeOptionalText(values.remark);
values.attachments = this.stringifyAttachments(values.attachments);
return values;
},
normalizeOptionalAmount(value) {
if (value === undefined || value === null || value === '' || Number(value) === -1) {
return null;
}
return value;
},
normalizeOptionalText(value) {
if (value === undefined || value === null) return null;
const text = String(value).trim();
return !text || text === '-1' ? null : text;
},
validateRow(row) {
if (Number(row.fee) < 0) {
const fee = this.normalizeOptionalAmount(row.fee);
if (fee === null) {
this.$message.warning('请输入费用');
return false;
}
if (Number(fee) < 0) {
this.$message.warning('费用不能小于 0');
return false;
}
@@ -465,6 +487,11 @@ export default {
getDetail(this.form.id).then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
detail.fee = this.normalizeOptionalAmount(detail.fee);
detail.inspectionUnit = this.normalizeOptionalText(detail.inspectionUnit) || '';
detail.assessmentUnit = this.normalizeOptionalText(detail.assessmentUnit) || '';
detail.passengerTypeLevel = this.normalizeOptionalText(detail.passengerTypeLevel) || '';
detail.remark = this.normalizeOptionalText(detail.remark) || '';
this.form = detail;
this.updateVehicleTypeDisplays(detail.vehicleType);
this.vehicleOptions = [];
+33 -8
View File
@@ -1549,6 +1549,10 @@ import SectionCard from '@/components/section-card/main.vue';
import PdfPreview from '@/components/pdf-preview/main.vue';
import ChangeRecordDetailDialog from '@/components/change-record-detail-dialog/main.vue';
const customerArchiveListRoute = '/vehicle/customer-archive';
const customerArchiveFormRoute = '/vehicle/customer-archive/form';
const customerArchiveListRefreshKey = 'customer-archive-list-refresh';
const createTimeRangeMap = {
createTimeRange: ['createTimeStart', 'createTimeEnd'],
};
@@ -1646,6 +1650,8 @@ export default {
readonly: false,
reviewMode: false,
listActivated: false,
// 表单页实例标记:创建时按路由落定,避免 keep-alive 缓存后随全局 $route 翻转
isFormPageInstance: false,
originalAccessType: '',
activeTab: 'scores',
archiveForm: this.emptyArchive(),
@@ -2033,6 +2039,7 @@ export default {
this.openArchive({ id }, true);
return;
}
this.isFormPageInstance = this.$route.path === customerArchiveFormRoute;
this.initDeptTree();
this.initRegionOptions();
this.initBusinessDictionaries();
@@ -2046,7 +2053,13 @@ export default {
}
},
activated() {
if (this.isArchivePage || this.isPublicViewPage) return;
if (this.isFormPageInstance || this.isPublicViewPage) return;
if (sessionStorage.getItem(customerArchiveListRefreshKey)) {
sessionStorage.removeItem(customerArchiveListRefreshKey);
this.onLoad(this.page, this.query);
this.listActivated = true;
return;
}
if (!this.listActivated) {
this.listActivated = true;
return;
@@ -2065,9 +2078,7 @@ export default {
};
},
isArchivePage() {
return (
this.$route.path === '/vehicle/customer-archive/form' || this.isPublicViewPage
);
return this.isFormPageInstance || this.isPublicViewPage;
},
isPublicViewPage() {
return (
@@ -2256,6 +2267,16 @@ export default {
},
},
watch: {
$route(to, from) {
if (this.isFormPageInstance || this.isPublicViewPage) return;
if (
to.path === customerArchiveListRoute &&
from?.path?.includes('/customer-archive/form')
) {
sessionStorage.removeItem(customerArchiveListRefreshKey);
this.onLoad(this.page, this.query);
}
},
'archiveForm.registeredDetailAddress'() {
this.$nextTick(() => this.checkOverflow('registeredDetailInput', 'registeredDetailOverflow'));
},
@@ -2264,6 +2285,9 @@ export default {
},
},
methods: {
markCustomerArchiveListNeedRefresh() {
sessionStorage.setItem(customerArchiveListRefreshKey, '1');
},
hasPermission(code) {
return this.isAdmin || this.validData(this.permission[code], false);
},
@@ -4016,27 +4040,28 @@ export default {
openArchivePage(row) {
const isEdit = Boolean(row?.id);
this.$router.push({
path: '/vehicle/customer-archive/form',
path: customerArchiveFormRoute,
query: isEdit ? { id: row.id, name: '编辑客商档案' } : { name: '新增客商档案' },
});
},
viewArchive(row) {
this.$router.push({
path: '/vehicle/customer-archive/form',
path: customerArchiveFormRoute,
query: { id: row.id, name: '查看客商档案', view: '1' },
});
},
openReview(row) {
this.$router.push({
path: '/vehicle/customer-archive/form',
path: customerArchiveFormRoute,
query: { id: row.id, name: '客商复评', review: '1' },
});
},
closeArchive() {
if (this.isPublicViewPage) return;
this.archiveBox = false;
this.markCustomerArchiveListNeedRefresh();
this.$router.$avueRouter?.closeTag?.();
this.$router.push('/vehicle/customer-archive');
this.$router.push(customerArchiveListRoute);
},
openArchive(row, readonly = false) {
this.readonly = readonly;
+42 -4
View File
@@ -381,8 +381,26 @@ export default {
if (values.policyNo) {
values.policyNo = values.policyNo.trim();
}
// 非必填项未填写时不要提交 -1 占位值
values.insuredAmount = this.normalizeOptionalAmount(values.insuredAmount);
values.premium = this.normalizeOptionalAmount(values.premium);
values.invoiceNo = this.normalizeOptionalText(values.invoiceNo);
values.invoiceDate = this.normalizeOptionalText(values.invoiceDate);
values.remark = this.normalizeOptionalText(values.remark);
values.policyFile = this.normalizeOptionalText(values.policyFile);
return values;
},
normalizeOptionalAmount(value) {
if (value === undefined || value === null || value === '' || Number(value) === -1) {
return null;
}
return value;
},
normalizeOptionalText(value) {
if (value === undefined || value === null) return null;
const text = String(value).trim();
return !text || text === '-1' ? null : text;
},
normalizeDecimalInput(prop, value) {
const sanitized = String(value ?? '').replace(/[^\d.]/g, '');
const [integerPart, ...decimalParts] = sanitized.split('.');
@@ -398,8 +416,18 @@ export default {
this.$message.warning('结束日期不能早于开始日期');
return false;
}
if (Number(row.insuredAmount) < 0 || Number(row.premium) < 0) {
this.$message.warning('保额、保费不能小于 0');
const insuredAmount = this.normalizeOptionalAmount(row.insuredAmount);
const premium = this.normalizeOptionalAmount(row.premium);
if (insuredAmount !== null && Number(insuredAmount) < 0) {
this.$message.warning('保额不能小于 0');
return false;
}
if (premium === null) {
this.$message.warning('请输入保费');
return false;
}
if (Number(premium) < 0) {
this.$message.warning('保费不能小于 0');
return false;
}
if (row.remark && row.remark.length > 200) {
@@ -479,15 +507,25 @@ export default {
this.vehicleOptions = [];
this.loadVehicleOptions('');
this.form.vehicleType = '车辆';
this.form.insuredAmount = '';
this.form.invoiceNo = '';
this.form.invoiceDate = '';
this.form.remark = '';
this.initOcrTemplateOptions('车辆', true);
}
if (['edit', 'view'].includes(type)) {
this.isDetailLoading = true;
getDetail(this.form.id)
.then(res => {
const detail = res.data.data || {};
this.form = {
...res.data.data,
vehicleType: res.data.data.vehicleType || '车辆',
...detail,
vehicleType: detail.vehicleType || '车辆',
insuredAmount: this.normalizeOptionalAmount(detail.insuredAmount),
premium: this.normalizeOptionalAmount(detail.premium),
invoiceNo: this.normalizeOptionalText(detail.invoiceNo) || '',
invoiceDate: this.normalizeOptionalText(detail.invoiceDate) || '',
remark: this.normalizeOptionalText(detail.remark) || '',
};
this.vehicleOptions = [];
this.loadVehicleOptions(this.form.vehicleNo || '');
+37 -11
View File
@@ -620,11 +620,11 @@ export default {
});
},
formatMileage(value, unit) {
if (value === undefined || value === null || value === '') return '';
if (value === undefined || value === null || value === '' || Number(value) === -1) return '';
return `${Math.max(Number(value), 0)} ${unit || '公里'}`;
},
isUnsetNextMaintenanceMileage(value) {
return Number(value) === -1;
return value === undefined || value === null || value === '' || Number(value) === -1;
},
formatNextMaintenanceMileage(value, unit) {
if (this.isUnsetNextMaintenanceMileage(value)) return '';
@@ -647,7 +647,7 @@ export default {
}
},
isEmpty(value) {
return value === undefined || value === null || value === '';
return value === undefined || value === null || value === '' || Number(value) === -1;
},
toNumber(value) {
return this.isEmpty(value) ? null : Number(value);
@@ -686,12 +686,34 @@ export default {
const values = { ...row };
values.vehicleType = values.vehicleType || '车辆';
values.mileageUnit = values.vehicleType === '船舶' ? '海里' : '公里';
// 非必填里程未填写时不要提交 -1 占位值
values.mileage = this.normalizeOptionalAmount(values.mileage);
values.nextMaintenanceMileage = this.normalizeOptionalAmount(values.nextMaintenanceMileage);
values.maintainer = this.normalizeOptionalText(values.maintainer);
values.maintenanceItem = this.normalizeOptionalText(values.maintenanceItem);
values.storeName = this.normalizeOptionalText(values.storeName);
values.contactPhone = this.normalizeOptionalText(values.contactPhone);
values.address = this.normalizeOptionalText(values.address);
values.remark = this.normalizeOptionalText(values.remark);
values.attachments = this.stringifyAttachments(values.attachments);
return values;
},
normalizeOptionalAmount(value) {
if (value === undefined || value === null || value === '' || Number(value) === -1) {
return null;
}
return value;
},
normalizeOptionalText(value) {
if (value === undefined || value === null) return null;
const text = String(value).trim();
return !text || text === '-1' ? null : text;
},
validateRow(row) {
const mileage = this.toNumber(row.mileage);
const nextMaintenanceMileage = this.toNumber(row.nextMaintenanceMileage);
const mileage = this.toNumber(this.normalizeOptionalAmount(row.mileage));
const nextMaintenanceMileage = this.toNumber(
this.normalizeOptionalAmount(row.nextMaintenanceMileage)
);
if (
mileage !== null &&
nextMaintenanceMileage !== null &&
@@ -782,12 +804,16 @@ export default {
detail.attachments = this.parseAttachments(detail.attachments);
detail.vehicleType = detail.vehicleType || '车辆';
detail.mileageUnit = detail.vehicleType === '船舶' ? '海里' : '公里';
if (type === 'edit') {
if (Number(detail.mileage) === -1) detail.mileage = '';
if (Number(detail.nextMaintenanceMileage) === -1) {
detail.nextMaintenanceMileage = '';
}
}
detail.mileage = this.normalizeOptionalAmount(detail.mileage);
detail.nextMaintenanceMileage = this.normalizeOptionalAmount(
detail.nextMaintenanceMileage
);
detail.maintainer = this.normalizeOptionalText(detail.maintainer) || '';
detail.maintenanceItem = this.normalizeOptionalText(detail.maintenanceItem) || '';
detail.storeName = this.normalizeOptionalText(detail.storeName) || '';
detail.contactPhone = this.normalizeOptionalText(detail.contactPhone) || '';
detail.address = this.normalizeOptionalText(detail.address) || '';
detail.remark = this.normalizeOptionalText(detail.remark) || '';
this.form = detail;
this.updateVehicleType(detail.vehicleType);
this.vehicleOptions = [];
+21 -1
View File
@@ -345,7 +345,7 @@ export default {
return JSON.stringify(value);
},
isEmpty(value) {
return value === undefined || value === null || value === '';
return value === undefined || value === null || value === '' || Number(value) === -1;
},
toNumber(value) {
return this.isEmpty(value) ? null : Number(value);
@@ -356,6 +356,15 @@ export default {
normalizeIntegerInput(prop, value) {
this.form[prop] = String(value ?? '').replace(/\D/g, '');
},
normalizeOptionalAmount(value) {
if (this.isEmpty(value)) return null;
return value;
},
normalizeOptionalText(value) {
if (value === undefined || value === null) return null;
const text = String(value).trim();
return !text || text === '-1' ? null : text;
},
normalizeRow(row) {
const values = { ...row };
values.vehicleType = '车辆';
@@ -363,6 +372,12 @@ export default {
if (values.vehicleNo) {
values.vehicleNo = values.vehicleNo.trim().toUpperCase();
}
// 非必填里程未填写时不要提交 -1 占位值
values.previousMonthMileage = this.normalizeOptionalAmount(values.previousMonthMileage);
values.currentMonthMileage = this.normalizeOptionalAmount(values.currentMonthMileage);
values.monthlyMileage = this.normalizeOptionalAmount(values.monthlyMileage);
values.totalMileage = this.normalizeOptionalAmount(values.totalMileage);
values.remark = this.normalizeOptionalText(values.remark);
const previousMonthMileage = this.toNumber(values.previousMonthMileage);
const currentMonthMileage = this.toNumber(values.currentMonthMileage);
if (
@@ -503,6 +518,11 @@ export default {
detail.attachments = this.parseAttachments(detail.attachments);
detail.vehicleType = '车辆';
detail.mileageUnit = '公里';
detail.previousMonthMileage = this.normalizeOptionalAmount(detail.previousMonthMileage);
detail.currentMonthMileage = this.normalizeOptionalAmount(detail.currentMonthMileage);
detail.monthlyMileage = this.normalizeOptionalAmount(detail.monthlyMileage);
detail.totalMileage = this.normalizeOptionalAmount(detail.totalMileage);
detail.remark = this.normalizeOptionalText(detail.remark) || '';
this.form = detail;
this.vehicleOptions = [];
this.loadVehicleOptions(this.form.vehicleNo || '');
+29 -1
View File
@@ -337,7 +337,7 @@ export default {
return JSON.stringify(value);
},
isEmpty(value) {
return value === undefined || value === null || value === '';
return value === undefined || value === null || value === '' || Number(value) === -1;
},
normalizeDecimalInput(prop, value) {
const sanitized = String(value ?? '').replace(/[^\d.]/g, '');
@@ -346,6 +346,15 @@ export default {
? `${integerPart || '0'}.${decimalParts.join('').slice(0, 2)}`
: integerPart;
},
normalizeOptionalAmount(value) {
if (this.isEmpty(value)) return null;
return value;
},
normalizeOptionalText(value) {
if (value === undefined || value === null) return null;
const text = String(value).trim();
return !text || text === '-1' ? null : text;
},
normalizeRow(row) {
const values = { ...row };
values.vehicleType = values.vehicleType || '车辆';
@@ -359,6 +368,16 @@ export default {
if (values.feeType === '充电') {
values.oilProduct = undefined;
}
// 非必填数值未填写时不要提交 -1;交易金额必填,-1 转 null 后由校验拦截
values.quantity = this.normalizeOptionalAmount(values.quantity);
values.unitPrice = this.normalizeOptionalAmount(values.unitPrice);
values.transactionAmount = this.normalizeOptionalAmount(values.transactionAmount);
values.balance = this.normalizeOptionalAmount(values.balance);
values.cardNo = this.normalizeOptionalText(values.cardNo);
values.cardHolder = this.normalizeOptionalText(values.cardHolder);
values.station = this.normalizeOptionalText(values.station);
values.oilProduct = this.normalizeOptionalText(values.oilProduct);
values.remark = this.normalizeOptionalText(values.remark);
values.attachments = this.stringifyAttachments(values.attachments);
return values;
},
@@ -472,6 +491,15 @@ export default {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
detail.vehicleType = detail.vehicleType || '车辆';
detail.quantity = this.normalizeOptionalAmount(detail.quantity);
detail.unitPrice = this.normalizeOptionalAmount(detail.unitPrice);
detail.transactionAmount = this.normalizeOptionalAmount(detail.transactionAmount);
detail.balance = this.normalizeOptionalAmount(detail.balance);
detail.cardNo = this.normalizeOptionalText(detail.cardNo) || '';
detail.cardHolder = this.normalizeOptionalText(detail.cardHolder) || '';
detail.station = this.normalizeOptionalText(detail.station) || '';
detail.oilProduct = this.normalizeOptionalText(detail.oilProduct) || '';
detail.remark = this.normalizeOptionalText(detail.remark) || '';
this.form = detail;
this.updateVehicleType(detail.vehicleType);
this.vehicleOptions = [];
+37 -8
View File
@@ -298,19 +298,41 @@ export default {
if (values.vehicleNo) {
values.vehicleNo = values.vehicleNo.trim().toUpperCase();
}
// 非必填数量未填写时不要提交 -1;费用必填,-1 转 null 后由校验拦截
values.tireQuantity = this.normalizeOptionalAmount(values.tireQuantity);
values.replacementCost = this.normalizeOptionalAmount(values.replacementCost);
values.handler = this.normalizeOptionalText(values.handler);
values.tireBrand = this.normalizeOptionalText(values.tireBrand);
values.replacementDescription = this.normalizeOptionalText(values.replacementDescription);
values.remark = this.normalizeOptionalText(values.remark);
values.attachments = this.stringifyAttachments(values.attachments);
return values;
},
normalizeOptionalAmount(value) {
if (value === undefined || value === null || value === '' || Number(value) === -1) {
return null;
}
return value;
},
normalizeOptionalText(value) {
if (value === undefined || value === null) return null;
const text = String(value).trim();
return !text || text === '-1' ? null : text;
},
validateRow(row) {
if (Number(row.replacementCost) < 0) {
const replacementCost = this.normalizeOptionalAmount(row.replacementCost);
const tireQuantity = this.normalizeOptionalAmount(row.tireQuantity);
if (replacementCost === null) {
this.$message.warning('请输入换胎费用');
return false;
}
if (Number(replacementCost) < 0) {
this.$message.warning('换胎费用不能小于 0');
return false;
}
if (
row.tireQuantity !== undefined &&
row.tireQuantity !== null &&
row.tireQuantity !== '' &&
(!Number.isInteger(Number(row.tireQuantity)) || Number(row.tireQuantity) <= 0)
tireQuantity !== null &&
(!Number.isInteger(Number(tireQuantity)) || Number(tireQuantity) <= 0)
) {
this.$message.warning('换胎数量必须为正整数');
return false;
@@ -391,9 +413,16 @@ export default {
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
this.form = detail;
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
detail.tireQuantity = this.normalizeOptionalAmount(detail.tireQuantity);
detail.replacementCost = this.normalizeOptionalAmount(detail.replacementCost);
detail.handler = this.normalizeOptionalText(detail.handler) || '';
detail.tireBrand = this.normalizeOptionalText(detail.tireBrand) || '';
detail.replacementDescription =
this.normalizeOptionalText(detail.replacementDescription) || '';
detail.remark = this.normalizeOptionalText(detail.remark) || '';
this.form = detail;
this.vehicleOptions = [];
this.loadVehicleOptions(this.form.vehicleNo || '');
});
+12 -5
View File
@@ -289,15 +289,20 @@ export default {
normalizeRow(row) {
const values = { ...row };
values.vehicleType = values.vehicleType || '车辆';
if (values.vehicleNo) {
values.vehicleNo =
values.vehicleType === '船舶'
? values.vehicleNo.trim()
: values.vehicleNo.trim().toUpperCase();
// 非必填文本未填写时不要提交 "-1" 占位值
values.vehicleNo = this.normalizeOptionalText(values.vehicleNo);
if (values.vehicleNo && values.vehicleType !== '船舶') {
values.vehicleNo = values.vehicleNo.toUpperCase();
}
values.remark = this.normalizeOptionalText(values.remark);
values.attachments = this.stringifyAttachments(values.attachments);
return values;
},
normalizeOptionalText(value) {
if (value === undefined || value === null) return null;
const text = String(value).trim();
return !text || text === '-1' ? null : text;
},
validateRow(row) {
if (row.changeContent && row.changeContent.length > 200) {
this.$message.warning('变更内容不能超过 200 字');
@@ -389,6 +394,8 @@ export default {
const detail = res.data.data;
detail.attachments = this.parseAttachments(detail.attachments);
detail.vehicleType = detail.vehicleType || '车辆';
detail.vehicleNo = this.normalizeOptionalText(detail.vehicleNo) || '';
detail.remark = this.normalizeOptionalText(detail.remark) || '';
this.form = detail;
this.updateVehicleType(detail.vehicleType);
this.vehicleOptions = [];
+27 -7
View File
@@ -448,9 +448,25 @@ export default {
} else {
values.violationItem = undefined;
}
// 非必填项未填写时不要提交 -1 占位值
values.fineAmount = this.normalizeOptionalAmount(values.fineAmount);
values.deductPoints = this.normalizeOptionalAmount(values.deductPoints);
values.penaltyUnit = this.normalizeOptionalText(values.penaltyUnit);
values.processResult = this.normalizeOptionalText(values.processResult);
values.attachments = this.stringifyAttachments(values.attachments);
return values;
},
normalizeOptionalAmount(value) {
if (value === undefined || value === null || value === '' || Number(value) === -1) {
return null;
}
return value;
},
normalizeOptionalText(value) {
if (value === undefined || value === null) return null;
const text = String(value).trim();
return !text || text === '-1' ? null : text;
},
validateRow(row) {
if (row.vehicleType === '船舶' && !row.violationItem) {
this.$message.warning('请输入事项');
@@ -467,17 +483,17 @@ export default {
this.$message.warning('日期不能超过当前时间');
return false;
}
if (Number(row.fineAmount) < 0) {
const fineAmount = this.normalizeOptionalAmount(row.fineAmount);
const deductPoints = this.normalizeOptionalAmount(row.deductPoints);
if (fineAmount !== null && Number(fineAmount) < 0) {
this.$message.warning('被罚金额不能小于 0');
return false;
}
if (
row.deductPoints !== undefined &&
row.deductPoints !== null &&
row.deductPoints !== '' &&
(!Number.isInteger(Number(row.deductPoints)) ||
Number(row.deductPoints) < 0 ||
Number(row.deductPoints) > 15)
deductPoints !== null &&
(!Number.isInteger(Number(deductPoints)) ||
Number(deductPoints) < 0 ||
Number(deductPoints) > 15)
) {
this.$message.warning('被扣分数范围为 0-15 分');
return false;
@@ -570,6 +586,10 @@ export default {
detail.attachments = this.parseAttachments(detail.attachments);
detail.vehicleType = detail.vehicleType || '车辆';
detail.processStatus = detail.processStatus || '未处理';
detail.fineAmount = this.normalizeOptionalAmount(detail.fineAmount);
detail.deductPoints = this.normalizeOptionalAmount(detail.deductPoints);
detail.penaltyUnit = this.normalizeOptionalText(detail.penaltyUnit) || '';
detail.processResult = this.normalizeOptionalText(detail.processResult) || '';
this.form = detail;
this.updateVehicleTypeDisplays(detail.vehicleType);
this.vehicleOptions = [];