From 08ff521545cfe49199986b15d71425b254d9a4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=87=E5=B3=B0?= Date: Tue, 14 Apr 2026 17:44:07 +0800 Subject: [PATCH] up --- .workbuddy/expert-history.json | 2 +- .../src/components/PurchaseOrderForm.vue | 30 ++++++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.workbuddy/expert-history.json b/.workbuddy/expert-history.json index c1e38f3..6ed51ad 100644 --- a/.workbuddy/expert-history.json +++ b/.workbuddy/expert-history.json @@ -13,5 +13,5 @@ } ] }, - "lastUpdated": 1776158712744 + "lastUpdated": 1776159168693 } \ No newline at end of file diff --git a/frontend/ops_vue_js/src/components/PurchaseOrderForm.vue b/frontend/ops_vue_js/src/components/PurchaseOrderForm.vue index 9b8a1eb..4bf9dfd 100644 --- a/frontend/ops_vue_js/src/components/PurchaseOrderForm.vue +++ b/frontend/ops_vue_js/src/components/PurchaseOrderForm.vue @@ -106,24 +106,18 @@ watch( }, ); -// ==================== 外部初始化接口 ==================== -/** - * 由父组件调用,用于回填已有费用数据(来自 API) - * @param {Array} list 费用数组,单位:分 - */ -function initCostEntries(list) { - if (!list || list.length === 0) return; - costEntries.splice(0, costEntries.length); - list.forEach((c) => { - costEntries.push({ - type: c.type ?? c.CostType ?? 1, - int: c.int ?? c.Quantity ?? 1, - cost: parseFloat(((c.cost ?? c.Price) / 100).toFixed(2)), - costt: parseFloat(((c.costt ?? c.Price * (c.int ?? c.Quantity)) / 100).toFixed(2)), - currencytype: c.currencytype ?? c.CurrencyType ?? 1, +// 回填费用(父组件填充 form._costs 后直接消费) +watch( + () => props.modelValue._costs, + (list) => { + if (!list || list.length === 0) return; + // 先清空默认空白行,再填入 API 返回的数据 + costEntries.splice(0, costEntries.length); + list.forEach((c) => { + costEntries.push({ ...c }); }); - }); -} + }, +); // ==================== 图片上传 ==================== const photosRef = ref(null); @@ -135,7 +129,7 @@ function getPhotoHashes() { return photosRef.value?.return_files().map((f) => f.hash) ?? []; } -defineExpose({ getPhotoHashes, costEntries, initCostEntries }); +defineExpose({ getPhotoHashes, costEntries }); // ==================== 表单字段双向绑定 ==================== function update(field, value) {