This commit is contained in:
2026-04-14 17:44:07 +08:00
parent 0310fd9aa3
commit 08ff521545
2 changed files with 13 additions and 19 deletions
+1 -1
View File
@@ -13,5 +13,5 @@
} }
] ]
}, },
"lastUpdated": 1776158712744 "lastUpdated": 1776159168693
} }
@@ -106,24 +106,18 @@ watch(
}, },
); );
// ==================== 外部初始化接口 ==================== // 回填费用(父组件填充 form._costs 后直接消费)
/** watch(
* 由父组件调用,用于回填已有费用数据(来自 API) () => props.modelValue._costs,
* @param {Array} list 费用数组,单位:分 (list) => {
*/
function initCostEntries(list) {
if (!list || list.length === 0) return; if (!list || list.length === 0) return;
// 先清空默认空白行,再填入 API 返回的数据
costEntries.splice(0, costEntries.length); costEntries.splice(0, costEntries.length);
list.forEach((c) => { list.forEach((c) => {
costEntries.push({ costEntries.push({ ...c });
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,
}); });
}); },
} );
// ==================== 图片上传 ==================== // ==================== 图片上传 ====================
const photosRef = ref(null); const photosRef = ref(null);
@@ -135,7 +129,7 @@ function getPhotoHashes() {
return photosRef.value?.return_files().map((f) => f.hash) ?? []; return photosRef.value?.return_files().map((f) => f.hash) ?? [];
} }
defineExpose({ getPhotoHashes, costEntries, initCostEntries }); defineExpose({ getPhotoHashes, costEntries });
// ==================== 表单字段双向绑定 ==================== // ==================== 表单字段双向绑定 ====================
function update(field, value) { function update(field, value) {