From c2ae2396f2f869bb1f083aa9921bcd1f85ba307d Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期四, 26 三月 2026 09:56:54 +0800
Subject: [PATCH] 销售台账修改

---
 src/views/salesManagement/salesLedger/index.vue |  644 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 607 insertions(+), 37 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index c6122ed..8b6e024 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -337,88 +337,353 @@
 		<FormDialog
 			v-model="productFormVisible"
 			:title="productOperationType === 'add' ? '鏂板浜у搧' : '缂栬緫浜у搧'"
-			:width="'40%'"
+			:width="'60%'"
 			:operation-type="productOperationType"
 			@close="closeProductDia"
 			@confirm="submitProduct"
 			@cancel="closeProductDia">
 			<el-form :model="productForm" label-width="140px" label-position="top" :rules="productRules" ref="productFormRef">
+				<!-- 姣忚涓変釜锛氫骇鍝佸ぇ绫�/瑙勬牸鍨嬪彿/鍗曚綅 -->
 				<el-row :gutter="30">
-					<el-col :span="24">
+					<el-col :span="8">
 						<el-form-item label="浜у搧澶х被锛�" prop="productCategory">
-							<!-- <el-select v-model="productForm.productCategory" placeholder="璇烽�夋嫨" clearable>
-								<el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName"/>
-							</el-select> -->
-							<el-tree-select v-model="productForm.productCategory" placeholder="璇烽�夋嫨" clearable check-strictly
-															@change="getModels" :data="productOptions" :render-after-expand="false" style="width: 100%" />
+							<el-tree-select
+								v-model="productForm.productCategory"
+								placeholder="璇烽�夋嫨"
+								clearable
+								check-strictly
+								@change="getModels"
+								:data="productOptions"
+								:render-after-expand="false"
+								style="width: 100%"
+							/>
 						</el-form-item>
 					</el-col>
-				</el-row>
-				<el-row :gutter="30">
-					<el-col :span="24">
+					<el-col :span="8">
 						<el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
-							<el-select v-model="productForm.productModelId" placeholder="璇烽�夋嫨" clearable @change="getProductModel" filterable>
+							<el-select
+								v-model="productForm.productModelId"
+								placeholder="璇烽�夋嫨"
+								clearable
+								@change="getProductModel"
+								filterable
+								style="width: 100%"
+							>
 								<el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id" />
 							</el-select>
 						</el-form-item>
 					</el-col>
-				</el-row>
-				<el-row :gutter="30">
-					<el-col :span="12">
+					<el-col :span="8">
 						<el-form-item label="鍗曚綅锛�" prop="unit">
 							<el-input v-model="productForm.unit" placeholder="璇疯緭鍏�" clearable />
 						</el-form-item>
 					</el-col>
-					<el-col :span="12">
+				</el-row>
+
+				<!-- 姣忚涓変釜锛氱◣鐜�/鍚◣鍗曚环/鏁伴噺 -->
+				<el-row :gutter="30">
+					<el-col :span="8">
 						<el-form-item label="绋庣巼(%)锛�" prop="taxRate">
-							<el-select v-model="productForm.taxRate" placeholder="璇烽�夋嫨" clearable @change="calculateFromTaxRate">
+							<el-select v-model="productForm.taxRate" placeholder="璇烽�夋嫨" clearable @change="calculateFromTaxRate" style="width: 100%">
 								<el-option label="1" value="1" />
 								<el-option label="6" value="6" />
 								<el-option label="13" value="13" />
 							</el-select>
 						</el-form-item>
 					</el-col>
-				</el-row>
-				<el-row :gutter="30">
-					<el-col :span="12">
+					<el-col :span="8">
 						<el-form-item label="鍚◣鍗曚环(鍏�)锛�" prop="taxInclusiveUnitPrice">
-							<el-input-number :step="0.01" :min="0" v-model="productForm.taxInclusiveUnitPrice" style="width: 100%"
-															 :precision="2"
-															 placeholder="璇疯緭鍏�" clearable @change="calculateFromUnitPrice" />
+							<el-input-number
+								:step="0.01"
+								:min="0"
+								v-model="productForm.taxInclusiveUnitPrice"
+								style="width: 100%"
+								:precision="2"
+								placeholder="璇疯緭鍏�"
+								clearable
+								@change="calculateFromUnitPrice"
+							/>
 						</el-form-item>
 					</el-col>
-					<el-col :span="12">
+					<el-col :span="8">
 						<el-form-item label="鏁伴噺锛�" prop="quantity">
-							<el-input-number  :step="0.1" :min="0" v-model="productForm.quantity" placeholder="璇疯緭鍏�" clearable
-																:precision="2"
-																@change="calculateFromQuantity" style="width: 100%" />
+							<el-input-number
+								:step="0.1"
+								:min="0"
+								v-model="productForm.quantity"
+								placeholder="璇疯緭鍏�"
+								clearable
+								:precision="2"
+								@change="() => { calculateFromQuantity(); recalcAreaTotals(); }"
+								style="width: 100%"
+							/>
 						</el-form-item>
 					</el-col>
 				</el-row>
+
+				<!-- 姣忚涓変釜锛氬惈绋庢�讳环/涓嶅惈绋庢�讳环/鍙戠エ绫诲瀷 -->
 				<el-row :gutter="30">
-					<el-col :span="12">
+					<el-col :span="8">
 						<el-form-item label="鍚◣鎬讳环(鍏�)锛�" prop="taxInclusiveTotalPrice">
 							<el-input v-model="productForm.taxInclusiveTotalPrice" placeholder="璇疯緭鍏�" clearable @change="calculateFromTotalPrice" />
 						</el-form-item>
 					</el-col>
-					<el-col :span="12">
+					<el-col :span="8">
 						<el-form-item label="涓嶅惈绋庢�讳环(鍏�)锛�" prop="taxExclusiveTotalPrice">
 							<el-input v-model="productForm.taxExclusiveTotalPrice" placeholder="璇疯緭鍏�" clearable @change="calculateFromExclusiveTotalPrice" />
 						</el-form-item>
 					</el-col>
-				</el-row>
-				<el-row :gutter="30">
-					<el-col :span="12">
+					<el-col :span="8">
 						<el-form-item label="鍙戠エ绫诲瀷锛�" prop="invoiceType">
-							<el-select v-model="productForm.invoiceType" placeholder="璇烽�夋嫨" clearable>
+							<el-select v-model="productForm.invoiceType" placeholder="璇烽�夋嫨" clearable style="width: 100%">
 								<el-option label="澧炴櫘绁�" value="澧炴櫘绁�" />
 								<el-option label="澧炰笓绁�" value="澧炰笓绁�" />
 							</el-select>
 						</el-form-item>
 					</el-col>
 				</el-row>
+
+				<!-- 姣忚涓変釜锛氬/楂�/瀹為檯鍗曠墖闈㈢Н -->
+				<el-row :gutter="30">
+					<el-col :span="8">
+						<el-form-item label="瀹�(mm)锛�" prop="width">
+							<el-input-number
+								v-model="productForm.width"
+								:min="0"
+								:step="1"
+								:precision="2"
+								style="width: 100%"
+								placeholder="璇疯緭鍏ュ(mm)"
+								clearable
+								@change="recalcAreaFromWidthHeight"
+							/>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="楂�(mm)锛�" prop="height">
+							<el-input-number
+								v-model="productForm.height"
+								:min="0"
+								:step="1"
+								:precision="2"
+								style="width: 100%"
+								placeholder="璇疯緭鍏ラ珮(mm)"
+								clearable
+								@change="recalcAreaFromWidthHeight"
+							/>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="鍛ㄩ暱(cm)锛�" prop="perimeter">
+							<el-input-number
+								v-model="productForm.perimeter"
+								:min="0"
+								:step="0.01"
+								:precision="2"
+								style="width: 100%"
+								placeholder="璇疯緭鍏�"
+								clearable
+								:disabled="true"
+							/>
+						</el-form-item>
+					</el-col>
+				</el-row>
+
+				<!-- 姣忚涓変釜锛氬疄闄呭崟鐗囬潰绉�/瀹為檯鎬婚潰绉�/缁撶畻鍗曠墖闈㈢Н -->
+				<el-row :gutter="30">
+					<el-col :span="8">
+						<el-form-item label="瀹為檯鍗曠墖闈㈢Н(銕�)锛�" prop="actualPieceArea">
+							<el-input-number
+								v-model="productForm.actualPieceArea"
+								:min="0"
+								:step="0.00001"
+								:precision="5"
+								style="width: 100%"
+								placeholder="璇疯緭鍏�"
+								clearable
+								@change="recalcAreaTotals"
+							/>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="瀹為檯鎬婚潰绉�(銕�)锛�" prop="actualTotalArea">
+							<el-input-number
+								v-model="productForm.actualTotalArea"
+								:min="0"
+								:step="0.00001"
+								:precision="5"
+								style="width: 100%"
+								placeholder="璇疯緭鍏�"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="缁撶畻鍗曠墖闈㈢Н(銕�)锛�" prop="settlePieceArea">
+							<el-input-number
+								v-model="productForm.settlePieceArea"
+								:min="0"
+								:step="0.00001"
+								:precision="5"
+								style="width: 100%"
+								placeholder="璇疯緭鍏�"
+								clearable
+								@change="recalcAreaTotals"
+							/>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="缁撶畻鎬婚潰绉�(銕�)锛�" prop="settleTotalArea">
+							<el-input-number
+								v-model="productForm.settleTotalArea"
+								:min="0"
+								:step="0.00001"
+								:precision="5"
+								style="width: 100%"
+								placeholder="璇疯緭鍏�"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="缁撶畻鎬婚潰绉�(銕�)锛�" prop="settleTotalArea">
+							<el-input-number
+								v-model="productForm.settleTotalArea"
+								:min="0"
+								:step="0.00001"
+								:precision="5"
+								style="width: 100%"
+								placeholder="璇疯緭鍏�"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+					<el-col :span="8">
+						<el-form-item label="閲嶇锛�" prop="heavyBox">
+							<el-input v-model="productForm.heavyBox" placeholder="璇疯緭鍏�" clearable @change="calculateFromExclusiveTotalPrice" />
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<!-- 鍏朵粬閲戦锛堝崰婊′竴琛岋細绛夊悓浜� 3 鍒楃綉鏍肩殑鏁磋锛� -->
+				<el-row :gutter="30">
+					<el-col :span="12">
+						<el-form-item label="鍔犲伐瑕佹眰锛�" prop="processRequirement">
+							<el-input v-model="productForm.processRequirement" placeholder="璇疯緭鍏ュ姞宸ヨ姹�" clearable />
+						</el-form-item>
+					</el-col>
+					<el-col :span="12">
+						<el-form-item label="澶囨敞锛�" prop="remark">
+							<el-input v-model="productForm.remark" placeholder="璇疯緭鍏ュ娉�" clearable />
+						</el-form-item>
+					</el-col>
+				</el-row>
+
+				<el-row :gutter="30">
+					<el-col :span="24">
+						<el-form-item>
+							<template #label>
+								<div style="display:flex; align-items:center; gap: 12px; width: 100%;">
+									<div style="font-weight: 600; color: #303133;">鍏朵粬閲戦锛�</div>
+									<div style="color:#909399; font-size: 13px; flex: 1;">
+										宸查�夋嫨 {{ productForm?.salesProductProcessList?.length || 0 }} 椤�
+									</div>
+									<el-button
+										v-if="operationType !== 'view'"
+										type="primary"
+										plain
+										size="small"
+										@click="startAddOtherAmount"
+									>
+										鏂板
+									</el-button>
+								</div>
+							</template>
+
+							<div style="display:flex; flex-direction:column; gap: 12px;">
+								<div v-if="Array.isArray(productForm?.salesProductProcessList) && productForm.salesProductProcessList.length > 0"
+									style="display:flex; flex-wrap:wrap; gap: 12px; align-items:flex-start;"
+								>
+									<div
+										v-for="(item, index) in productForm.salesProductProcessList"
+										:key="String(item.id) + '_' + index"
+										style="display:flex; gap: 10px; align-items:center; padding: 10px 12px; border: 1px solid #ebeef5; border-radius: 8px; box-sizing:border-box; min-width: 0;"
+										:style="getOtherAmountCardFlexStyle()"
+									>
+										<div style="flex: 1; min-width: 0;">
+											<el-tag type="info" style="width: 100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;">
+												{{ item.processName }}
+											</el-tag>
+										</div>
+										<div style="flex: 1;">
+											<el-input-number
+												v-model="item.quantity"
+												:min="0"
+												:step="0.1"
+												:precision="2"
+												style="width: 100%;"
+												placeholder="璇疯緭鍏ユ暟閲�"
+												:disabled="operationType === 'view'"
+											/>
+										</div>
+										<el-button
+											v-if="operationType !== 'view'"
+											type="danger"
+											link
+											size="small"
+											@click="removeOtherAmountAt(index)"
+										>
+											鍒犻櫎
+										</el-button>
+									</div>
+								</div>
+
+								<div v-else style="color:#909399; font-size: 13px;">
+									鏆傛棤鍏朵粬閲戦
+								</div>
+							</div>
+						</el-form-item>
+					</el-col>
+				</el-row>
 			</el-form>
 		</FormDialog>
+		<!-- 鍏朵粬閲戦锛氭柊澧炲脊妗� -->
+		<el-dialog
+			v-model="otherAmountAddDialogVisible"
+			title="鏂板鍏朵粬閲戦"
+			width="520px"
+			:close-on-click-modal="false"
+		>
+			<div style="padding: 4px 0 10px;">
+				<div style="font-size: 14px; color: #606266; margin-bottom: 10px;">
+					璇烽�夋嫨瑕佹柊澧炵殑鍏朵粬閲戦椤圭洰
+				</div>
+				<el-select
+					v-model="otherAmountAddId"
+					filterable
+					clearable
+					placeholder="璇烽�夋嫨鍏朵粬閲戦椤圭洰"
+					style="width: 100%;"
+					:disabled="operationType === 'view'"
+				>
+					<el-option
+						v-for="item in otherAmountSelectOptions"
+						:key="item.id"
+						:label="item.processName"
+						:value="item.id"
+					/>
+				</el-select>
+			</div>
+			<template #footer>
+				<el-button @click="cancelAddOtherAmount">鍙栨秷</el-button>
+				<el-button
+					type="primary"
+					@click="confirmAddOtherAmount"
+					:disabled="operationType === 'view' || otherAmountAddId === null || otherAmountAddId === undefined || otherAmountAddId === ''"
+				>
+					纭娣诲姞
+				</el-button>
+			</template>
+		</el-dialog>
 		<!-- 瀵煎叆寮圭獥 -->
 		<FormDialog
 			v-model="importUpload.open"
@@ -714,15 +979,15 @@
 							:rules="otherAmountRules"
 							ref="otherAmountFormRef"
 						>
-							<el-form-item label="缂栫爜code">
+							<el-form-item label="缂栫爜">
 								<el-input v-model="otherAmountForm.code" placeholder="璇疯緭鍏ョ紪鐮侊紙鍙�夛級" clearable />
 							</el-form-item>
 
-							<el-form-item label="椤圭洰processName" prop="processName">
+							<el-form-item label="椤圭洰" prop="processName">
 								<el-input v-model="otherAmountForm.processName" placeholder="璇疯緭鍏ラ」鐩悕绉�" clearable />
 							</el-form-item>
 
-							<el-form-item label="鏁伴噺quantity" prop="quantity">
+							<el-form-item label="鏁伴噺" prop="quantity">
 								<el-input-number
 									v-model="otherAmountForm.quantity"
 									:min="0"
@@ -734,7 +999,7 @@
 								/>
 							</el-form-item>
 
-							<el-form-item label="鍗曚环unitPrice(鍏�)" prop="unitPrice">
+							<el-form-item label="鍗曚环(鍏�)" prop="unitPrice">
 								<el-input-number
 									v-model="otherAmountForm.unitPrice"
 									:min="0"
@@ -746,7 +1011,7 @@
 								/>
 							</el-form-item>
 
-							<el-form-item label="閲戦amount(鍏�)">
+							<el-form-item label="閲戦(鍏�)">
 								<el-input v-model="otherAmountForm.amount" disabled />
 							</el-form-item>
 
@@ -861,6 +1126,18 @@
 		taxInclusiveTotalPrice: "",
 		taxExclusiveTotalPrice: "",
 		invoiceType: "",
+		// 鏂板锛氬昂瀵�/闈㈢Н/鍔犲伐涓庡叾浠栭噾棰�
+		width: 0, // 瀹�(mm)
+		height: 0, // 楂�(mm)
+		perimeter: 0, // 鍛ㄩ暱(cm) = (瀹�+楂�)*2锛屽楂樹负 mm
+		// 闈㈢Н瀛楁锛堛帯锛�
+		actualPieceArea: 0, // 瀹為檯鍗曠墖闈㈢Н(銕�)
+		actualTotalArea: 0, // 瀹為檯鎬婚潰绉�(銕�)
+		settlePieceArea: 0, // 缁撶畻鍗曠墖闈㈢Н(銕�)
+		settleTotalArea: 0, // 缁撶畻鎬婚潰绉�(銕�)
+		processRequirement: "", // 鍔犲伐瑕佹眰
+		remark: "", // 澶囨敞
+		salesProductProcessList: [], // 鍏朵粬閲戦锛歔{id, processName, quantity}]
 	},
 	productRules: {
 		productCategory: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
@@ -1088,6 +1365,169 @@
 		.catch(() => {
 			proxy.$modal.msg("宸插彇娑�");
 		});
+};
+
+// 浜у搧寮规锛氬叾浠栭噾棰濆閫変笅鎷夛紙鍩轰簬鈥滃叾浠栭噾棰濈淮鎶も�濇煡璇㈡帴鍙o級
+const otherAmountSelectOptions = ref([]); // [{id, processName}]
+const otherAmountSelectOptionsLoading = ref(false);
+
+const fetchOtherAmountSelectOptions = async (force = false) => {
+	if (!force && otherAmountSelectOptions.value.length > 0) return;
+	otherAmountSelectOptionsLoading.value = true;
+	try {
+		const params = {
+			current: 1,
+			// 涓嬫媺妗嗗敖閲忎竴娆℃�ф媺鍏紝閬垮厤澶氭鍒嗛〉褰卞搷閫夋嫨浣撻獙
+			size: 1000,
+		};
+		const res = await salesLedgerProductProcessList(params);
+		const records = res?.records ?? res?.data?.records ?? [];
+
+		otherAmountSelectOptions.value = records.map((item) => ({
+			id: item.id,
+			processName: item.processName ?? "",
+		}));
+	} finally {
+		otherAmountSelectOptionsLoading.value = false;
+	}
+};
+
+const normalizeOtherAmountsFromRow = (row) => {
+	if (!row) return [];
+	const raw =
+		row.other_amounts ??
+		row.otherAmounts ??
+		row.otherAmountProjects ??
+		row.otherAmountList ??
+		row.salesProductProcessList ??
+		[];
+
+	if (!Array.isArray(raw)) return [];
+	if (raw.length === 0) return [];
+
+	// 鎯呭喌1锛氬悗绔洿鎺ヨ繑鍥� [{id, processName}...]
+	if (typeof raw[0] === "object") {
+		return raw
+			.map((it) => {
+				const id = it?.id ?? it?.processId ?? it?.otherAmountId ?? null;
+				const quantity =
+					Number(
+						it?.quantity ??
+							it?.processQuantity ??
+							it?.otherQuantity ??
+							it?.process_quantity ??
+							it?.other_amount_quantity
+					) || 0;
+				return {
+					id,
+					processName: it?.processName ?? "",
+					quantity,
+				};
+			})
+			.filter((it) => it.id !== null && it.id !== undefined && it.id !== "");
+	}
+
+	// 鎯呭喌2锛氬悗绔彧杩斿洖 ids: [1,2,3]
+	return raw
+		.map((id) => ({
+			id,
+			processName: "",
+			quantity: 0,
+		}))
+		.filter((it) => it.id !== null && it.id !== undefined && it.id !== "");
+};
+
+const mergeOtherAmountOptionsBySelection = (selected) => {
+	const list = Array.isArray(selected) ? selected : [];
+	for (const s of list) {
+		const exists = otherAmountSelectOptions.value.some((o) => String(o.id) === String(s.id));
+		if (!exists) {
+			otherAmountSelectOptions.value.push({
+				id: s.id,
+				processName: s.processName ?? "",
+			});
+		}
+	}
+};
+
+const fillOtherAmountProcessName = (selected) => {
+	const list = Array.isArray(selected) ? selected : [];
+	return list.map((s) => {
+		const opt = otherAmountSelectOptions.value.find((o) => String(o.id) === String(s.id));
+		return {
+			id: s.id,
+			processName: opt?.processName ?? s.processName ?? "",
+			quantity: Number(s.quantity ?? 0) || 0,
+		};
+	});
+};
+
+// 鈥滃叾浠栭噾棰濃�濆崱鐗囧竷灞�锛氬彧鏈変竴鏉℃椂鍗犳弧鏁磋锛�>=2鏃朵袱鍒楁帓甯�
+const getOtherAmountCardFlexStyle = () => {
+	const list = productForm.value?.salesProductProcessList;
+	const len = Array.isArray(list) ? list.length : 0;
+	if (len === 1) {
+		return { flex: "0 0 100%", maxWidth: "100%", width: "100%" };
+	}
+	return {
+		flex: "0 0 calc(50% - 6px)",
+		maxWidth: "calc(50% - 6px)",
+		width: "calc(50% - 6px)",
+	};
+};
+
+// 鍏朵粬閲戦锛氱偣鍑烩�滄柊澧炩�濆悗鍦ㄥ脊绐楅噷閫夋嫨涓�涓」鐩�
+const otherAmountAddDialogVisible = ref(false);
+const otherAmountAddId = ref(null);
+
+const startAddOtherAmount = () => {
+	if (operationType.value === "view") return;
+	otherAmountAddDialogVisible.value = true;
+	otherAmountAddId.value = null;
+	// 閫氬父 openProductForm 宸茬粡鎷夎繃 options锛岃繖閲屽厹搴�
+	if (otherAmountSelectOptions.value.length === 0) {
+		fetchOtherAmountSelectOptions(true);
+	}
+};
+
+const cancelAddOtherAmount = () => {
+	otherAmountAddDialogVisible.value = false;
+	otherAmountAddId.value = null;
+};
+
+const handleOtherAmountSelected = (id) => {
+	const selectedId = id ?? otherAmountAddId.value;
+	if (selectedId === null || selectedId === undefined || selectedId === "") return;
+	const opt = otherAmountSelectOptions.value.find((o) => String(o.id) === String(selectedId));
+	if (!opt) return;
+
+	const exists = (productForm.value?.salesProductProcessList ?? []).some(
+		(it) => String(it?.id) === String(opt.id)
+	);
+	if (exists) {
+		proxy.$modal.msgWarning("璇ュ叾浠栭噾棰濋」鐩凡娣诲姞");
+		return;
+	}
+
+	productForm.value.salesProductProcessList.push({
+		id: opt.id,
+		processName: opt.processName,
+		quantity: 0,
+	});
+
+	// 閫夋嫨瀹屾垚鍚庡叧闂脊绐楋紝涓嬩竴娆″彲鍐嶆鐐瑰嚮鈥滄柊澧炩�濈户缁坊鍔�
+	otherAmountAddDialogVisible.value = false;
+	otherAmountAddId.value = null;
+};
+
+const confirmAddOtherAmount = () => {
+	handleOtherAmountSelected(otherAmountAddId.value);
+};
+
+const removeOtherAmountAt = (index) => {
+	if (operationType.value === "view") return;
+	if (!Array.isArray(productForm.value?.salesProductProcessList)) return;
+	productForm.value.salesProductProcessList.splice(index, 1);
 };
 
 // 鍙戣揣瀹℃壒浜鸿妭鐐癸紙浠垮崗鍚屽鎵� infoFormDia.vue锛�
@@ -1453,6 +1893,16 @@
 			taxInclusiveTotalPrice: taxInclusiveTotalPrice,
 			taxExclusiveTotalPrice: taxExclusiveTotalPrice,
 			invoiceType: "澧炴櫘绁�",
+			// 鏂板锛氶粯璁ゅ�硷紙閬垮厤鍚庣画鎻愪氦鏃跺瓧娈电己澶憋級
+			width: 0,
+			height: 0,
+			actualPieceArea: 0,
+			actualTotalArea: 0,
+			settlePieceArea: 0,
+			settleTotalArea: 0,
+			processRequirement: "",
+			remark: "",
+			salesProductProcessList: [],
 		};
 	});
 	
@@ -1540,8 +1990,29 @@
 	productOperationType.value = type;
 	productForm.value = {};
 	proxy.resetForm("productFormRef");
+	// 纭繚澶氶�夐」榛樿鏄暟缁勶紝閬垮厤 el-select multiple 鎶ラ敊
+		productForm.value.salesProductProcessList = [];
+	otherAmountAddDialogVisible.value = false;
+	otherAmountAddId.value = null;
 	if (type === "edit") {
 		productForm.value = { ...row };
+
+		// 瀛楁鍛藉悕鍏煎锛氫紭鍏堥┘宄帮紙濡� actualPieceArea锛夛紝鍏煎鍚庣鍙兘杩斿洖涓嬪垝绾匡紙濡� actual_piece_area锛�
+		productForm.value.actualPieceArea = row?.actualPieceArea ?? row?.actual_piece_area ?? 0;
+		productForm.value.actualTotalArea = row?.actualTotalArea ?? row?.actual_total_area ?? 0;
+		productForm.value.settlePieceArea = row?.settlePieceArea ?? row?.settle_piece_area ?? 0;
+		productForm.value.settleTotalArea = row?.settleTotalArea ?? row?.settle_total_area ?? 0;
+
+		// 鍔犲伐瑕佹眰/澶囨敞鍏煎锛氬悗绔彲鑳戒娇鐢ㄥ叾瀹冨懡鍚�
+		productForm.value.processRequirement =
+			row?.processRequirement ?? row?.process_requirement ?? "";
+		productForm.value.remark = row?.remark ?? row?.remarks ?? "";
+
+		// 鍛ㄩ暱鍥炴樉锛堝鍚庣杩斿洖锛涙渶缁堜粛浠ュ叕寮忚绠椾负鍑嗭級
+		productForm.value.perimeter =
+			row?.perimeter ?? row?.heavyBoxPerimeter ?? row?.heavyboxPerimeter ?? 0;
+
+		productForm.value.salesProductProcessList = normalizeOtherAmountsFromRow(row);
 		productIndex.value = index;
 		// 缂栬緫鏃舵牴鎹骇鍝佸ぇ绫诲悕绉板弽鏌� tree 鑺傜偣 id锛屽苟鍔犺浇瑙勬牸鍨嬪彿鍒楄〃
 		try {
@@ -1564,8 +2035,19 @@
 			// 鍔犺浇澶辫触鏃朵繚鎸佸彲缂栬緫锛屼笉涓柇寮圭獥
 			console.error("鍔犺浇浜у搧瑙勬牸鍨嬪彿澶辫触", e);
 		}
+
+		// 鏍规嵁褰撳墠瀹介珮閲嶆柊璁$畻鍛ㄩ暱涓庨潰绉�
+		recalcPerimeterFromWidthHeight();
+		recalcAreaFromWidthHeight();
+
+		// 鍥炴樉鈥滃叾浠栭噾棰濃�濆閫夛細鍏堟媺鍙栦笅鎷夐�夐」锛屽啀琛ラ綈 processName
+		await fetchOtherAmountSelectOptions(true);
+		mergeOtherAmountOptionsBySelection(productForm.value.salesProductProcessList);
+		productForm.value.salesProductProcessList = fillOtherAmountProcessName(productForm.value.salesProductProcessList);
 	} else {
 		getProductOptions()
+		// 鏂板鏃朵笅鎷夐�夐」鍔犺浇涓�娆″嵆鍙�
+		fetchOtherAmountSelectOptions(true);
 	}
 	productFormVisible.value = true;
 };
@@ -1573,6 +2055,20 @@
 const submitProduct = () => {
 	proxy.$refs["productFormRef"].validate((valid) => {
 		if (valid) {
+			// 闈㈢Н/鎬昏瀛楁鍦ㄦ彁浜ゅ墠鍏滃簳璁$畻涓�娆�
+			recalcAreaTotals();
+			// 鍏朵粬閲戦鍙彁浜� {id, processName, quantity}锛堝悗绔瓧娈碉細salesProductProcessList锛�
+			productForm.value.salesProductProcessList = (Array.isArray(productForm.value.salesProductProcessList)
+				? productForm.value.salesProductProcessList
+				: []
+			)
+				.map((it) => ({
+					id: it?.id,
+					processName: it?.processName ?? "",
+					quantity: Number(it?.quantity ?? 0) || 0,
+				}))
+				.filter((it) => it.id !== null && it.id !== undefined && it.id !== "");
+
 			if (operationType.value === "edit") {
 				submitProductEdit();
 			} else {
@@ -1650,6 +2146,8 @@
 const closeProductDia = () => {
 	proxy.resetForm("productFormRef");
 	productFormVisible.value = false;
+	otherAmountAddDialogVisible.value = false;
+	otherAmountAddId.value = null;
 };
 // 瀵煎叆
 const handleImport = () => {
@@ -2134,6 +2632,67 @@
 	}
 };
 
+// 鏂板锛氬昂瀵�(瀹介珮)涓庨潰绉�(鍗曠墖/鎬昏)鑱斿姩
+const recalcAreaTotals = () => {
+	const qty = Number(productForm.value.quantity ?? 0) || 0;
+	const actualPiece = Number(productForm.value.actualPieceArea ?? 0) || 0;
+	const settlePiece = Number(productForm.value.settlePieceArea ?? 0) || 0;
+
+	productForm.value.actualTotalArea = Number((actualPiece * qty).toFixed(5));
+	productForm.value.settleTotalArea = Number((settlePiece * qty).toFixed(5));
+};
+
+// 鏂板锛氬懆闀�(cm)锛堥噸绠県eavyBox鍛ㄩ暱锛�
+// width/height 鍗曚綅涓� mm锛屽洜姝ゅ懆闀�(cm)闇�瑕侀櫎浠� 10
+const recalcPerimeterFromWidthHeight = () => {
+	const width = Number(productForm.value.width ?? 0) || 0;
+	const height = Number(productForm.value.height ?? 0) || 0;
+
+	if (width <= 0 || height <= 0) {
+		productForm.value.perimeter = 0;
+		return;
+	}
+
+	// 鍛ㄩ暱 = (瀹� + 楂�) * 2锛屽崟浣嶄粠 mm 杞负 cm锛�/10
+	productForm.value.perimeter = Number((((width + height) * 2) / 10).toFixed(2));
+};
+
+const recalcAreaFromWidthHeight = () => {
+	const width = Number(productForm.value.width ?? 0) || 0;
+	const height = Number(productForm.value.height ?? 0) || 0;
+
+	if (width <= 0 || height <= 0) {
+		// 瀹介珮涓虹┖/涓�0鏃讹紝鎶婂崟鐗囬潰绉笌鎬婚潰绉疆涓�0
+		productForm.value.actualPieceArea = 0;
+		productForm.value.actualTotalArea = 0;
+		productForm.value.perimeter = 0;
+
+		// 鍙湁鍦ㄧ粨绠楀崟鐗囬潰绉篃涓虹┖/涓�0鏃讹紝鎵嶅悓姝ョ疆0锛岄伩鍏嶈鐩栫敤鎴锋墜鍔ㄥ~鍐�
+		const settlePiece = Number(productForm.value.settlePieceArea ?? 0) || 0;
+		if (!settlePiece) {
+			productForm.value.settlePieceArea = 0;
+		}
+		productForm.value.settleTotalArea = Number(
+			((Number(productForm.value.settlePieceArea ?? 0) || 0) * (Number(productForm.value.quantity ?? 0) || 0)).toFixed(5)
+		);
+		return;
+	}
+
+	const computedPieceArea = (width * height) / 1e6; // mm*mm -> 銕�
+	const computed = Number(computedPieceArea.toFixed(5));
+
+	productForm.value.actualPieceArea = computed;
+
+	// settlePieceArea锛氳嫢鐢ㄦ埛鏈~鍐�/涓�0锛屽垯榛樿浣跨敤瀹介珮璁$畻鍊�
+	const settlePieceRaw = Number(productForm.value.settlePieceArea ?? 0) || 0;
+	if (!settlePieceRaw) {
+		productForm.value.settlePieceArea = computed;
+	}
+
+	recalcPerimeterFromWidthHeight();
+	recalcAreaTotals();
+};
+
 // 鏍规嵁鍚◣鎬讳环璁$畻鍚◣鍗曚环鍜屾暟閲�
 const calculateFromTotalPrice = () => {
 	if (isCalculating.value) return;
@@ -2488,6 +3047,17 @@
   background-color: #F4DEFA;
 }
 
+.other-amount-select {
+	/* 澶氶�夋爣绛惧尯鍩熷己鍒跺崟琛岋紝涓嶈杈撳叆妗嗛殢鏍囩鎹㈣鑰屾媺楂橀珮搴� */
+	:deep .el-select__tags {
+		display: flex;
+		flex-wrap: nowrap !important;
+		white-space: nowrap;
+		overflow: hidden;
+		max-height: 32px;
+	}
+}
+
 .table_list {
 	margin-top: unset;
 }

--
Gitblit v1.9.3