feat(web-admin): submit stable load/delivery/product ids on plan save.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-09-05 18:31:59 +08:00
1 parent 2e5b05f477
commit c90ff7c419
3 files changed
+24 -5

No files matched your search

+1
View File
@@ -699,6 +699,7 @@ export interface PlanCreateFullPayload {
load?: PlanLoad
deliveries?: PlanDelivery[]
products: Array<{
id?: string
productId: string
productNo: string
productName: string
@@ -1419,6 +1419,7 @@
return formData.products.map((item) => {
prepareLineAliasAndBrandForSubmit(item)
return {
...(item.id ? { id: item.id } : {}),
productId: item.productId,
productNo: item.productNo,
productName: item.productName,
@@ -1779,13 +1780,24 @@
remark: data.remark || ''
})
applyStopsFromPlan(data)
loadForm.value.products = loadForm.value.products.map((row) => ({
...row,
planProductId: undefined
}))
// 复制为新计划:不回传源计划段/段产品 id,避免误 upsert
loadForm.value = {
...loadForm.value,
id: undefined,
products: loadForm.value.products.map((row) => ({
...row,
id: undefined,
planProductId: undefined
}))
}
deliveryForms.value = deliveryForms.value.map((row) => ({
...row,
products: row.products.map((product) => ({ ...product, planProductId: undefined }))
id: undefined,
products: row.products.map((product) => ({
...product,
id: undefined,
planProductId: undefined
}))
}))
loadedTransportStatus.value = 'pending'
loadedFollowStatus.value = ''
+6
View File
@@ -84,6 +84,7 @@ export function formatStopArchiveAmount(
}
export interface PlanLoadForm {
id?: string
customerId: string
customerName: string
address: string
@@ -99,6 +100,7 @@ export interface PlanLoadForm {
}
export interface PlanDeliveryForm {
id?: string
seq: number
customerId: string
customerName: string
@@ -440,6 +442,7 @@ export function mapLoadFromApi(
vehiclePlate
)
return {
id: load.id || undefined,
customerId: load.customerId || '',
customerName: load.customerName || '',
address: load.address || '',
@@ -472,6 +475,7 @@ export function mapDeliveriesFromApi(
vehiclePlate
)
return {
id: row.id || undefined,
seq: row.seq ?? index + 1,
customerId: row.customerId || '',
customerName: row.customerName || '',
@@ -721,6 +725,7 @@ export function buildStopProductPayload(row: PlanStopProductFormRow) {
export function buildLoadPayload(load: PlanLoadForm) {
return {
...(load.id ? { id: load.id } : {}),
customerId: load.customerId,
customerName: load.customerName,
address: load.address || undefined,
@@ -738,6 +743,7 @@ export function buildLoadPayload(load: PlanLoadForm) {
export function buildDeliveriesPayload(deliveries: PlanDeliveryForm[]) {
return deliveries.map((row, index) => ({
...(row.id ? { id: row.id } : {}),
seq: row.seq || index + 1,
customerId: row.customerId,
customerName: row.customerName,