| | |
| | | min-width="150" |
| | | show-overflow-tooltip /> |
| | | <el-table-column label="车牌号" |
| | | prop="truckPlateNo" |
| | | min-width="110" |
| | | show-overflow-tooltip /> |
| | | show-overflow-tooltip> |
| | | <!-- 出库单没登记车辆时到货记录车辆为空,不能渲染成空白格 --> |
| | | <template #default="scope"> |
| | | {{ scope.row.truckPlateNo || "--" }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="到货数量(吨)" |
| | | prop="arrivalQuantity" |
| | | min-width="110" |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <!-- 车辆不强制:出库单没登记车辆(代储/客存出库)时留空即可 --> |
| | | <el-form-item label="车辆" |
| | | prop="vehicleId" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: '请选择车辆', |
| | | trigger: 'change', |
| | | } |
| | | ]"> |
| | | prop="vehicleId"> |
| | | <el-select v-model="form.vehicleId" |
| | | placeholder="请先选择出库单" |
| | | :placeholder="vehiclePlaceholder" |
| | | clearable |
| | | filterable |
| | | :disabled="!form.stockOutRecordId" |
| | | :disabled="!form.stockOutRecordId || !vehicleOptions.length" |
| | | style="width: 100%" |
| | | @change="handleVehicleChange"> |
| | | <el-option v-for="item in vehicleOptions" |
| | |
| | | prop="arrivalQuantity" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: '请输入到货数量', |
| | | validator: validateArrivalQuantity, |
| | | trigger: 'blur', |
| | | } |
| | | ]"> |
| | |
| | | return [...map.values()]; |
| | | }); |
| | | |
| | | // 没登记车辆的出库单(代储/客存不强制选车)拿不出车辆候选,不该当成一个空选项 |
| | | const vehicleOptions = computed(() => |
| | | bindableRows.value.filter( |
| | | item => item.stockOutRecordId === form.value.stockOutRecordId |
| | | item => |
| | | item.stockOutRecordId === form.value.stockOutRecordId && |
| | | item.vehicleId !== null && |
| | | item.vehicleId !== undefined |
| | | ) |
| | | ); |
| | | |
| | | const vehiclePlaceholder = computed(() => { |
| | | if (!form.value.stockOutRecordId) return "请先选择出库单"; |
| | | return vehicleOptions.value.length |
| | | ? "请选择车辆" |
| | | : "该出库单未登记车辆,可留空"; |
| | | }); |
| | | |
| | | const selectedOutbound = computed(() => |
| | | outboundOptions.value.find( |
| | |
| | | |
| | | // 编辑时本条已占的量要从「已到货」里加回来,否则数量改不大于原值 |
| | | const originalArrivalQuantity = ref(0); |
| | | |
| | | // 0 在 required 眼里算「已填」,拦不住,这里按后端口径要求 > 0 |
| | | const validateArrivalQuantity = (rule, value, callback) => { |
| | | if (value === null || value === undefined || value === "") { |
| | | callback(new Error("请输入到货数量")); |
| | | return; |
| | | } |
| | | if (!(Number(value) > 0)) { |
| | | callback(new Error("到货数量必须大于0")); |
| | | return; |
| | | } |
| | | callback(); |
| | | }; |
| | | |
| | | // 到货上限 = 该台账在这张出库单上分摊到的数量 |
| | | const arrivalMax = computed(() => { |
| | |
| | | form.value.id = row.id ?? null; |
| | | form.value.stockOutRecordId = row.stockOutRecordId; |
| | | // 车辆/车牌以出库单登记为准,但列表行里带回的是当时的值,直接回显 |
| | | form.value.vehicleId = row.vehicleId; |
| | | form.value.vehicleId = row.vehicleId ?? undefined; |
| | | form.value.truckPlateNo = row.truckPlateNo || ""; |
| | | form.value.arrivalQuantity = row.arrivalQuantity ?? null; |
| | | form.value.arrivalDate = row.arrivalDate || ""; |
| | |
| | | // 车辆随出库单联动:换了出库单,原来选的车辆可能不在候选里 |
| | | form.value.vehicleId = undefined; |
| | | form.value.truckPlateNo = ""; |
| | | // 一张出库单只登记一个车辆,能定就直接带出来(代储/客存没登记车辆则留空) |
| | | const only = vehicleOptions.value[0]; |
| | | if (vehicleOptions.value.length === 1) { |
| | | form.value.vehicleId = only.vehicleId; |
| | | form.value.truckPlateNo = only.truckPlateNo || ""; |
| | | } |
| | | }; |
| | | |
| | | const handleVehicleChange = id => { |
| | |
| | | const payload = { |
| | | stockOutRecordId: form.value.stockOutRecordId, |
| | | salesLedgerId: props.ledgerId, |
| | | vehicleId: form.value.vehicleId, |
| | | truckPlateNo: form.value.truckPlateNo, |
| | | arrivalQuantity: form.value.arrivalQuantity, |
| | | arrivalDate: form.value.arrivalDate, |
| | | // 只存永久链接,2 小时失效的签名 URL 过期后附件会打不开 |
| | | attachments: form.value.attachmentList.map(getPhotoUrl).filter(Boolean), |
| | | remark: form.value.remark, |
| | | }; |
| | | // 车辆/车牌以出库单为准,只有选了车才传,空值不参与后端的比对 |
| | | if (form.value.vehicleId !== undefined && form.value.vehicleId !== null) { |
| | | payload.vehicleId = form.value.vehicleId; |
| | | payload.truckPlateNo = form.value.truckPlateNo; |
| | | } |
| | | const submit = form.value.id |
| | | ? updateSalesLedgerArrival({ ...payload, id: form.value.id }) |
| | | : addSalesLedgerArrival(payload); |