✨ 编辑打卡记录支持里程采集与结算后冻结

This commit is contained in:
2026-10-24 21:29:21 +08:00
parent fa78a68df6
commit e8f6311477
@@ -2271,6 +2271,13 @@
<span v-if="record.volume">体积 {{ record.volume }}方</span>
<span v-if="record.quantity">数量 {{ record.quantity }}</span>
</div>
<!-- 里程只挂在末位节点上(needMileage 由后端下发),显示的是运单里程 -->
<div
v-if="record.needMileage && Number(record.mileage) > 0"
class="waybill-manage-page__punch-record-line"
>
里程 {{ record.mileage }} 公里
</div>
<div
v-if="record.remark"
class="waybill-manage-page__punch-record-line"
@@ -2867,6 +2874,20 @@
/>
</el-form-item>
</el-col>
<!-- 里程只在末位打卡节点出现:后端按「末位 + 计费规则含里程」下发 needMileage,前端不自己推 -->
<el-col v-if="waybillPunchEditMileageVisible" :span="8">
<el-form-item label="里程">
<el-input
v-model="waybillPunchEditForm.mileage"
maxlength="10"
:disabled="waybillPunchEditMileageLocked"
placeholder="请输入"
@input="handleWaybillPunchMileageInput"
>
<template #append>公里</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注">
<el-input
@@ -4029,6 +4050,7 @@ export default {
weight: '',
volume: '',
quantity: '',
mileage: '',
remark: '',
photos: [],
},
@@ -4431,6 +4453,15 @@ export default {
waybillPunchEditPunchDisabled() {
return this.waybillPunchEditNode?.punch === false;
},
// 里程:后端下发 needMileage 才出现(末位打卡节点 + 计费规则含里程);在途打卡不采集里程
waybillPunchEditMileageVisible() {
const record = this.waybillPunchEditRecord || {};
return record.needMileage === true && record.type !== 'enroute';
},
// 已生成结算单的运单里程冻结:输入框置灰,改动由后端拒绝
waybillPunchEditMileageLocked() {
return this.waybillPunchEditRecord?.mileageLocked === true;
},
waybillPunchEditRules() {
return { punchTime: [{ required: true, message: '请选择打卡时间', trigger: 'change' }] };
},
@@ -5962,6 +5993,7 @@ export default {
weight: record.weight || '',
volume: record.volume || '',
quantity: record.quantity || '',
mileage: Number(record.mileage) > 0 ? String(record.mileage) : '',
remark: record.remark || '',
photos: (record.photos || [])
.filter(photo => photo?.url)
@@ -6037,10 +6069,22 @@ export default {
photos.splice(index, 1);
this.waybillPunchEditForm.photos = photos;
},
// 里程只收整数:非数字直接丢掉,长度与「维护里程」一致(≤10 位)
handleWaybillPunchMileageInput(value) {
this.waybillPunchEditForm.mileage = String(value || '')
.replace(/\D/g, '')
.slice(0, 10);
},
async submitWaybillPunchRecordEdit() {
await this.$refs.waybillPunchRecordEditFormRef.validate();
const record = this.waybillPunchEditRecord;
const form = this.waybillPunchEditForm;
// 管理端里程选填:留空表示不改动运单里程,所以只校验填了值的情况
const mileageText = String(form.mileage || '').trim();
if (this.waybillPunchEditMileageVisible && mileageText && !/^[1-9]\d{0,9}$/.test(mileageText)) {
this.$message.warning('里程必须为不超过10位的正整数');
return;
}
const submit =
typeof this.api?.savePunchRecord === 'function' ? this.api.savePunchRecord : savePunchRecord;
this.waybillPunchRecordEditDialog.submitting = true;
@@ -6059,6 +6103,8 @@ export default {
weight: form.weight,
volume: form.volume,
quantity: form.quantity,
// 不传代表不改;后端按 null 处理
mileage: mileageText ? Number(mileageText) : undefined,
remark: form.remark,
photos: form.photos.map(photo => ({ url: photo.url, type: photo.type })),
});