From 5f0513d0955146124c2a8dc37202caf6001f36d2 Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期五, 29 五月 2026 15:19:30 +0800
Subject: [PATCH] feat: 添加一键发货,自动审批通过出库,取消车牌必填项,发货完成后产品状态自己变为不足->变为已发货

---
 src/views/salesManagement/salesLedger/index.vue |  608 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 502 insertions(+), 106 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 16fde49..b017f5f 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -6,7 +6,7 @@
           <el-input v-model="searchForm.customerName" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
             @change="handleQuery" />
         </el-form-item>
-        <el-form-item label="閿�鍞悎鍚屽彿锛�">
+        <el-form-item label="閿�鍞崟鍙凤細">
           <el-input v-model="searchForm.salesContractNo" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
             @change="handleQuery" />
         </el-form-item>
@@ -51,11 +51,11 @@
 															 width="100px"
 															 align="center">
                 <template #default="scope">
-
-									<el-tag v-if="scope.row.approveStatus === 1 && (!scope.row.shippingDate || !scope.row.shippingCarNumber)"
-													type="success">鍏呰冻</el-tag>
-									<el-tag v-else-if="scope.row.approveStatus === 0 && (scope.row.shippingDate || scope.row.shippingCarNumber)"
-													type="success">宸插嚭搴�</el-tag>
+									<!-- 宸插彂璐ф樉绀哄凡鍑哄簱 -->
+									<el-tag v-if="scope.row.shippingDate" type="success">宸插嚭搴�</el-tag>
+									<!-- 鏈彂璐т笖搴撳瓨鍏呰冻 -->
+									<el-tag v-else-if="scope.row.approveStatus === 1" type="success">鍏呰冻</el-tag>
+									<!-- 鏈彂璐т笖搴撳瓨涓嶈冻 -->
 									<el-tag v-else type="danger">涓嶈冻</el-tag>
                 </template>
               </el-table-column>
@@ -93,10 +93,10 @@
               <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" />
               <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" />
             <!--鎿嶄綔-->
-              <el-table-column Width="60px" label="鎿嶄綔" align="center">
+              <el-table-column width="100px" label="鎿嶄綔" align="center">
                 <template #default="scope">
-                  <el-button 
-                    link 
+                  <el-button
+                    link
                     type="primary"
                     :disabled="!canShip(scope.row)"
                     @click="openDeliveryForm(scope.row)">
@@ -108,7 +108,7 @@
           </template>
         </el-table-column>
         <el-table-column align="center" label="搴忓彿" type="index" width="60" />
-        <el-table-column label="閿�鍞悎鍚屽彿" prop="salesContractNo" width="180" show-overflow-tooltip />
+        <el-table-column label="閿�鍞崟鍙�" prop="salesContractNo" width="180" show-overflow-tooltip />
         <el-table-column label="瀹㈡埛鍚嶇О" prop="customerName" width="300" show-overflow-tooltip />
         <el-table-column label="涓氬姟鍛�" prop="salesman" width="100" show-overflow-tooltip />
         <el-table-column label="椤圭洰鍚嶇О" prop="projectName" width="180" show-overflow-tooltip />
@@ -143,7 +143,7 @@
 				</el-row>
         <el-row :gutter="30">
           <el-col :span="12">
-            <el-form-item label="閿�鍞悎鍚屽彿锛�" prop="salesContractNo">
+            <el-form-item label="閿�鍞崟鍙凤細" prop="salesContractNo">
               <el-input v-model="form.salesContractNo" placeholder="鑷姩鐢熸垚" clearable disabled />
             </el-form-item>
           </el-col>
@@ -234,7 +234,7 @@
 					<el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" />
 					<el-table-column fixed="right" label="鎿嶄綔" min-width="60" align="center" v-if="operationType !== 'view'">
 						<template #default="scope">
-							<el-button link type="primary" size="small" 
+							<el-button link type="primary" size="small"
 								:disabled="isProductShipped(scope.row)"
 								@click="openProductForm('edit', scope.row,scope.$index)">缂栬緫</el-button>
 						</template>
@@ -292,7 +292,7 @@
 				<el-button type="primary" @click="fetchQuotationList">鎼滅储</el-button>
 				<el-button @click="resetQuotationSearch">閲嶇疆</el-button>
 			</div>
-			
+
 			<el-table
 				:data="quotationList"
 				border
@@ -317,7 +317,7 @@
 					</template>
 				</el-table-column>
 			</el-table>
-			
+
 			<pagination
 				v-show="quotationPage.total > 0"
 				:total="quotationPage.total"
@@ -326,7 +326,7 @@
 				:limit="quotationPage.size"
 				@pagination="quotationPaginationChange"
 			/>
-			
+
 			<template #footer>
 				<el-button @click="quotationDialogVisible = false">鍏抽棴</el-button>
 			</template>
@@ -482,7 +482,7 @@
 							<div class="header">
 								<div class="document-title">闆跺敭鍙戣揣鍗�</div>
 							</div>
-							
+
 							<div class="info-section">
 								<div class="info-row">
 									<div>
@@ -503,7 +503,7 @@
 									<span class="value">{{ item.salesContractNo }}</span>
 								</div>
 							</div>
-							
+
 							<div class="table-section">
 								<table class="product-table">
 									<thead>
@@ -541,7 +541,7 @@
 									</tfoot>
 								</table>
 							</div>
-							
+
 							<div class="footer-section">
 								<div class="footer-row">
 									<div class="footer-item">
@@ -595,6 +595,79 @@
 						</el-form-item>
 					</el-col>
 				</el-row>
+				<el-row :gutter="30">
+					<el-col :span="24">
+						<el-form-item label="鍙戣揣鏃ユ湡锛�" prop="shippingDate">
+							<el-date-picker
+								style="width: 100%"
+								v-model="deliveryForm.shippingDate"
+								value-format="YYYY-MM-DD"
+								format="YYYY-MM-DD"
+								type="date"
+								placeholder="璇烽�夋嫨鍙戣揣鏃ユ湡"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="30">
+					<el-col :span="24" v-if="deliveryForm.type === '璐ц溅'">
+						<el-form-item label="鍙戣揣杞︾墝鍙凤細" prop="shippingCarNumber">
+							<el-input
+								v-model="deliveryForm.shippingCarNumber"
+								placeholder="璇疯緭鍏ュ彂璐ц溅鐗屽彿"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+					<el-col :span="24" v-else>
+						<el-form-item label="蹇�掑叕鍙革細" prop="expressCompany">
+							<el-input
+								v-model="deliveryForm.expressCompany"
+								placeholder="璇疯緭鍏ュ揩閫掑叕鍙�"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="30" v-if="deliveryForm.type === '蹇��'">
+					<el-col :span="24">
+						<el-form-item label="蹇�掑崟鍙凤細" prop="expressNumber">
+							<el-input
+								v-model="deliveryForm.expressNumber"
+								placeholder="璇疯緭鍏ュ揩閫掑崟鍙�"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="30">
+					<el-col :span="24">
+						<el-form-item label="鍙戣揣鍥剧墖锛�">
+							<el-upload
+								v-model:file-list="deliveryFileList"
+								:action="upload.url"
+								multiple
+								ref="deliveryFileUpload"
+								auto-upload
+								:headers="upload.headers"
+								:data="{ type: 9 }"
+								:on-success="handleDeliveryUploadSuccess"
+								:on-remove="handleDeliveryRemove"
+								list-type="picture-card"
+								:limit="9"
+								accept="image/png,image/jpeg,image/jpg"
+							>
+								<el-icon class="avatar-uploader-icon"><Plus /></el-icon>
+								<template #tip>
+									<div class="el-upload__tip">
+										鏀寔 jpg銆乯peg銆乸ng 鏍煎紡锛屾渶澶氫笂浼� 9 寮狅紝鍗曞紶澶у皬涓嶈秴杩� 10MB
+									</div>
+								</template>
+							</el-upload>
+						</el-form-item>
+					</el-col>
+				</el-row>
 
         <!-- 瀹℃壒浜洪�夋嫨锛堜豢鍗忓悓瀹℃壒閲岀殑瀹℃壒浜鸿妭鐐归�夋嫨锛� -->
         <el-row>
@@ -642,8 +715,93 @@
 			</el-form>
 			<template #footer>
 				<div class="dialog-footer">
-					<el-button type="primary" @click="submitDelivery">纭鍙戣揣</el-button>
+					<el-button type="success" @click="submitOneClickDelivery">涓�閿彂璐�</el-button>
+					<el-button type="primary" @click="submitDelivery">鎻愪氦瀹℃壒</el-button>
 					<el-button @click="closeDeliveryDia">鍙栨秷</el-button>
+				</div>
+			</template>
+		</el-dialog>
+
+		<!-- 鎵归噺涓�閿彂璐у脊妗� -->
+		<el-dialog
+			v-model="batchDeliveryFormVisible"
+			title="鎵归噺涓�閿彂璐�"
+			width="40%"
+			@close="closeBatchDeliveryDia"
+		>
+			<el-form :model="batchDeliveryForm" label-width="120px" label-position="top" :rules="batchDeliveryRules" ref="batchDeliveryFormRef">
+				<el-row :gutter="30">
+					<el-col :span="24">
+						<el-form-item label="鍙戣揣绫诲瀷锛�" prop="type">
+							<el-select
+								v-model="batchDeliveryForm.type"
+								placeholder="璇烽�夋嫨鍙戣揣绫诲瀷"
+								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="24">
+						<el-form-item label="鍙戣揣鏃ユ湡锛�" prop="shippingDate">
+							<el-date-picker
+								style="width: 100%"
+								v-model="batchDeliveryForm.shippingDate"
+								value-format="YYYY-MM-DD"
+								format="YYYY-MM-DD"
+								type="date"
+								placeholder="璇烽�夋嫨鍙戣揣鏃ユ湡"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="30">
+					<el-col :span="24" v-if="batchDeliveryForm.type === '璐ц溅'">
+						<el-form-item label="鍙戣揣杞︾墝鍙凤細">
+							<el-input
+								v-model="batchDeliveryForm.shippingCarNumber"
+								placeholder="璇疯緭鍏ュ彂璐ц溅鐗屽彿"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+					<el-col :span="24" v-else>
+						<el-form-item label="蹇�掑叕鍙革細">
+							<el-input
+								v-model="batchDeliveryForm.expressCompany"
+								placeholder="璇疯緭鍏ュ揩閫掑叕鍙�"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-row :gutter="30" v-if="batchDeliveryForm.type === '蹇��'">
+					<el-col :span="24">
+						<el-form-item label="蹇�掑崟鍙凤細">
+							<el-input
+								v-model="batchDeliveryForm.expressNumber"
+								placeholder="璇疯緭鍏ュ揩閫掑崟鍙�"
+								clearable
+							/>
+						</el-form-item>
+					</el-col>
+				</el-row>
+				<el-alert
+					title="鎻愮ず锛氬皢瀵硅閿�鍞彴璐︿笅鎵�鏈夋湭鍙戣揣鐨勪骇鍝佽繘琛屼竴閿彂璐э紝鑷姩瀹℃壒閫氳繃骞跺嚭搴�"
+					type="warning"
+					:closable="false"
+					show-icon
+					style="margin-top: 10px;"
+				/>
+			</el-form>
+			<template #footer>
+				<div class="dialog-footer">
+					<el-button type="success" @click="submitBatchDelivery">纭鎵归噺鍙戣揣</el-button>
+					<el-button @click="closeBatchDeliveryDia">鍙栨秷</el-button>
 				</div>
 			</template>
 		</el-dialog>
@@ -653,8 +811,9 @@
 <script setup>
 import { getToken } from "@/utils/auth";
 import pagination from "@/components/PIMTable/Pagination.vue";
-import {onMounted, ref, getCurrentInstance} from "vue";
-import { addShippingInfo } from "@/api/salesManagement/deliveryLedger.js";
+import {onMounted, ref, getCurrentInstance, h} from "vue";
+import { ElButton } from "element-plus";
+import { addShippingInfo, oneClickShipping, batchOneClickShipping } from "@/api/salesManagement/deliveryLedger.js";
 import { ElMessageBox, ElMessage } from "element-plus";
 import { UploadFilled, Download } from "@element-plus/icons-vue";
 import useUserStore from "@/store/modules/user";
@@ -798,17 +957,61 @@
 // 鍙戣揣鐩稿叧
 const deliveryFormVisible = ref(false);
 const currentDeliveryRow = ref(null);
+
+// 鎵归噺涓�閿彂璐х浉鍏�
+const batchDeliveryFormVisible = ref(false);
+const currentBatchDeliveryRow = ref(null);
+const batchDeliveryFormData = reactive({
+  batchDeliveryForm: {
+    type: "璐ц溅",
+    shippingDate: "",
+    shippingCarNumber: "",
+    expressCompany: "",
+    expressNumber: "",
+  },
+  batchDeliveryRules: {
+    type: [
+      { required: true, message: "璇烽�夋嫨鍙戣揣绫诲瀷", trigger: "change" }
+    ],
+    shippingDate: [{ required: true, message: "璇烽�夋嫨鍙戣揣鏃ユ湡", trigger: "change" }],
+  },
+});
+const { batchDeliveryForm, batchDeliveryRules } = toRefs(batchDeliveryFormData);
+const deliveryFileList = ref([]);
 const deliveryFormData = reactive({
   deliveryForm: {
     type: "璐ц溅", // 璐ц溅, 蹇��
+    shippingDate: "",
+    shippingCarNumber: "",
+    expressCompany: "",
+    expressNumber: "",
   },
   deliveryRules: {
     type: [
       { required: true, message: "璇烽�夋嫨鍙戣揣绫诲瀷", trigger: "change" }
-    ]
+    ],
+    shippingDate: [{ required: true, message: "璇烽�夋嫨鍙戣揣鏃ユ湡", trigger: "change" }],
+    shippingCarNumber: [
+      { validator: (_, value, callback) => validateShippingCarNumber(value, callback), trigger: "blur" }
+    ],
+    expressCompany: [
+      { validator: (_, value, callback) => validateExpressCompany(value, callback), trigger: "blur" }
+    ],
   },
 });
 const { deliveryForm, deliveryRules } = toRefs(deliveryFormData);
+
+// 鍙戣揣绫诲瀷鏍¢獙锛氳揣杞︽椂杞︾墝闈炲繀濉紝蹇�掓椂瑕佹眰蹇�掑叕鍙�
+const validateShippingCarNumber = (value, callback) => {
+  // 鍙栨秷杞︾墝蹇呭~闄愬埗
+  callback();
+};
+const validateExpressCompany = (value, callback) => {
+  if (deliveryForm.value.type === "蹇��") {
+    if (!value) return callback(new Error("璇疯緭鍏ュ揩閫掑叕鍙�"));
+  }
+  callback();
+};
 
 // 鍙戣揣瀹℃壒浜鸿妭鐐癸紙浠垮崗鍚屽鎵� infoFormDia.vue锛�
 const approverNodes = ref([{ id: 1, userId: null }]);
@@ -968,7 +1171,7 @@
 		if (children && children.length > 0) {
 			newItem.children = convertIdToValue(children);
 		}
-		
+
 		return newItem;
 	});
 }
@@ -999,6 +1202,8 @@
 const expandChange = (row, expandedRows) => {
 	if (expandedRows.length > 0) {
 		expandedRowKeys.value = [];
+		// 璁剧疆褰撳墠灞曞紑琛岋紝鐢ㄤ簬涓�閿彂璐�
+		currentExpandedRow.value = row;
 		try {
 			productList({ salesLedgerId: row.id, type: 1 }).then((res) => {
 				const index = tableData.value.findIndex((item) => item.id === row.id);
@@ -1012,6 +1217,7 @@
 		}
 	} else {
 		expandedRowKeys.value = [];
+		currentExpandedRow.value = null;
 	}
 };
 
@@ -1039,13 +1245,58 @@
 		"taxExclusiveTotalPrice",
 	]);
 };
-// 瀛愯〃鍚堣鏂规硶
+
+// 褰撳墠灞曞紑琛岀殑閿�鍞彴璐︽暟鎹紙鐢ㄤ簬涓�閿彂璐э級
+const currentExpandedRow = ref(null);
+// 褰撳墠灞曞紑琛屾槸鍚︽湁鏈彂璐т骇鍝�
+const hasUnshippedProducts = ref(false);
+
+// 瀛愯〃鍚堣鏂规硶 - 鏈�鍚庝竴鍒楁樉绀轰竴閿彂璐ф寜閽�
 const summarizeChildrenTable = (param) => {
-	return proxy.summarizeTable(param, [
-		"taxInclusiveUnitPrice",
-		"taxInclusiveTotalPrice",
-		"taxExclusiveTotalPrice",
-	]);
+	const { columns, data } = param;
+	const sums = [];
+
+	// 妫�鏌ユ槸鍚︽湁鏈彂璐х殑浜у搧
+	const unshipped = data.filter(item => {
+		const status = item.shippingStatus;
+		return !item.shippingDate && (!status || status === '寰呭彂璐�' || status === '瀹℃牳鎷掔粷');
+	});
+	hasUnshippedProducts.value = unshipped.length > 0;
+
+	columns.forEach((column, index) => {
+		if (index === 0) {
+			sums[index] = "鍚堣";
+			return;
+		}
+
+		const prop = column.property;
+		const summaryProps = ["taxInclusiveUnitPrice", "taxInclusiveTotalPrice", "taxExclusiveTotalPrice"];
+
+		if (summaryProps.includes(prop)) {
+			const values = data.map((item) => Number(item[prop]));
+			if (!values.every(isNaN)) {
+				const sum = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0);
+				sums[index] = parseFloat(sum).toFixed(2);
+			} else {
+				sums[index] = "";
+			}
+		} else if (index === columns.length - 1 && currentExpandedRow.value && hasUnshippedProducts.value) {
+			// 鏈�鍚庝竴鍒楋紙鎿嶄綔鍒楋級娓叉煋涓�閿彂璐ф寜閽紝浠呭綋鏈夋湭鍙戣揣浜у搧鏃舵樉绀�
+			sums[index] = h(
+				ElButton,
+				{
+					type: 'success',
+					size: 'small',
+					onClick: () => openBatchDeliveryForm(currentExpandedRow.value)
+				},
+				{ default: () => '涓�閿彂璐�' }
+			);
+		} else {
+			sums[index] = "";
+		}
+	});
+
+	return sums;
 };
 // 鎵撳紑寮规
 const openForm = async (type, row) => {
@@ -1137,10 +1388,10 @@
 const applyQuotation = (row) => {
 	if (!row) return;
 	selectedQuotation.value = row;
-	
+
 	// 涓氬姟鍛�
 	form.value.salesman = (row.salesperson || "").trim();
-	
+
 	// 瀹㈡埛鍚嶇О -> customerId
 	const qCustomerName = String(row.customer || "").trim();
 	const customer = (customerOption.value || []).find((c) => {
@@ -1153,7 +1404,7 @@
 		// 濡傛灉鎵句笉鍒帮紝淇濈暀鍘熷�硷紙鍏佽鐢ㄦ埛鎵嬪姩閫夋嫨/涓嶆墦鏂凡鏈夎緭鍏ワ級
 		form.value.customerId = form.value.customerId || "";
 	}
-	
+
 	// 浜у搧淇℃伅鏄犲皠锛氭姤浠� products -> 鍙拌处 productData
 	const products = Array.isArray(row.products) ? row.products : [];
 	productData.value = products.map((p) => {
@@ -1175,7 +1426,7 @@
 			invoiceType: "澧炴櫘绁�",
 		};
 	});
-	
+
 	quotationDialogVisible.value = false;
 };
 function changs(val) {
@@ -1237,6 +1488,7 @@
 			addOrUpdateSalesLedger(form.value).then((res) => {
 				proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
 				closeDia();
+				expandedRowKeys.value = [];
 				getList();
 			});
 		}
@@ -1256,7 +1508,7 @@
 		proxy.$modal.msgWarning("宸插彂璐ф垨瀹℃牳閫氳繃鐨勪骇鍝佷笉鑳界紪杈�");
 		return;
 	}
-	
+
 	productOperationType.value = type;
 	productForm.value = {};
 	proxy.resetForm("productFormRef");
@@ -1323,14 +1575,14 @@
 		proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
 		return;
 	}
-	
+
 	// 妫�鏌ユ槸鍚︽湁宸插彂璐ф垨瀹℃牳閫氳繃鐨勪骇鍝�
 	const shippedProducts = productSelectedRows.value.filter(row => isProductShipped(row));
 	if (shippedProducts.length > 0) {
 		proxy.$modal.msgWarning("宸插彂璐ф垨瀹℃牳閫氳繃鐨勪骇鍝佷笉鑳藉垹闄�");
 		return;
 	}
-	
+
 	if (operationType.value === "add") {
 		productSelectedRows.value.forEach((selectedRow) => {
 			const index = productData.value.findIndex(
@@ -1476,25 +1728,25 @@
 		proxy.$modal.msgWarning("璇烽�夋嫨瑕佹墦鍗扮殑鏁版嵁");
 		return;
 	}
-	
+
 	// 鏄剧ず鍔犺浇鐘舵��
 	proxy.$modal.loading("姝e湪鑾峰彇浜у搧鏁版嵁锛岃绋嶅��...");
-	
+
 	try {
 		// 涓烘瘡涓�変腑鐨勯攢鍞彴璐﹁褰曟煡璇㈠搴旂殑浜у搧鏁版嵁
 		const printDataWithProducts = [];
-		
+
 		for (const row of selectedRows.value) {
 			try {
 				// 璋冪敤productList鎺ュ彛鏌ヨ浜у搧鏁版嵁
 				const productRes = await productList({ salesLedgerId: row.id, type: 1 });
-				
+
 				// 灏嗕骇鍝佹暟鎹暣鍚堝埌閿�鍞彴璐﹁褰曚腑
 				const rowWithProducts = {
 					...row,
 					products: productRes.data || []
 				};
-				
+
 				printDataWithProducts.push(rowWithProducts);
 			} catch (error) {
 				console.error(`鑾峰彇閿�鍞彴璐� ${row.id} 鐨勪骇鍝佹暟鎹け璐�:`, error);
@@ -1505,11 +1757,11 @@
 				});
 			}
 		}
-		
+
 		printData.value = printDataWithProducts;
 		console.log('鎵撳嵃鏁版嵁锛堝寘鍚骇鍝侊級:', printData.value);
 		printPreviewVisible.value = true;
-		
+
 	} catch (error) {
 		console.error('鑾峰彇浜у搧鏁版嵁澶辫触:', error);
 		proxy.$modal.msgError("鑾峰彇浜у搧鏁版嵁澶辫触锛岃閲嶈瘯");
@@ -1521,10 +1773,10 @@
 const executePrint = () => {
 	console.log('寮�濮嬫墽琛屾墦鍗帮紝鏁版嵁鏉℃暟:', printData.value.length);
 	console.log('鎵撳嵃鏁版嵁:', printData.value);
-	
+
 	// 鍒涘缓涓�涓柊鐨勬墦鍗扮獥鍙�
 	const printWindow = window.open('', '_blank', 'width=800,height=600');
-	
+
 	// 鏋勫缓鎵撳嵃鍐呭
 	let printContent = `
     <!DOCTYPE html>
@@ -1660,7 +1912,7 @@
     </head>
     <body>
   `;
-	
+
 	// 涓烘瘡鏉℃暟鎹敓鎴愭墦鍗伴〉闈�
 	printData.value.forEach((item, index) => {
 		printContent += `
@@ -1669,7 +1921,7 @@
           <div class="header">
             <div class="document-title">闆跺敭鍙戣揣鍗�</div>
           </div>
-          
+
           <div class="info-section">
             <div class="info-row">
               <div>
@@ -1757,16 +2009,16 @@
       </div>
     `;
 	});
-	
+
 	printContent += `
     </body>
     </html>
   `;
-	
+
 	// 鍐欏叆鍐呭鍒版柊绐楀彛
 	printWindow.document.write(printContent);
 	printWindow.document.close();
-	
+
 	// 绛夊緟鍐呭鍔犺浇瀹屾垚鍚庢墦鍗�
 	printWindow.onload = () => {
 		setTimeout(() => {
@@ -1857,19 +2109,19 @@
 // 鏍规嵁鍚◣鎬讳环璁$畻鍚◣鍗曚环鍜屾暟閲�
 const calculateFromTotalPrice = () => {
 	if (isCalculating.value) return;
-	
+
 	const totalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
 	const quantity = parseFloat(productForm.value.quantity);
-	
+
 	if (!totalPrice || !quantity || quantity <= 0) {
 		return;
 	}
-	
+
 	isCalculating.value = true;
-	
+
 	// 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
 	productForm.value.taxInclusiveUnitPrice = (totalPrice / quantity).toFixed(2);
-	
+
 	// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
 	if (productForm.value.taxRate) {
 		productForm.value.taxExclusiveTotalPrice =
@@ -1878,7 +2130,7 @@
 				productForm.value.taxRate
 			);
 	}
-	
+
 	isCalculating.value = false;
 };
 
@@ -1889,25 +2141,25 @@
 		return;
 	}
 	if (isCalculating.value) return;
-	
+
 	const exclusiveTotalPrice = parseFloat(productForm.value.taxExclusiveTotalPrice);
 	const quantity = parseFloat(productForm.value.quantity);
 	const taxRate = parseFloat(productForm.value.taxRate);
-	
+
 	if (!exclusiveTotalPrice || !quantity || quantity <= 0 || !taxRate) {
 		return;
 	}
-	
+
 	isCalculating.value = true;
-	
+
 	// 鍏堣绠楀惈绋庢�讳环 = 涓嶅惈绋庢�讳环 / (1 - 绋庣巼/100)
 	const taxRateDecimal = taxRate / 100;
 	const inclusiveTotalPrice = exclusiveTotalPrice / (1 - taxRateDecimal);
 	productForm.value.taxInclusiveTotalPrice = inclusiveTotalPrice.toFixed(2);
-	
+
 	// 璁$畻鍚◣鍗曚环 = 鍚◣鎬讳环 / 鏁伴噺
 	productForm.value.taxInclusiveUnitPrice = (inclusiveTotalPrice / quantity).toFixed(2);
-	
+
 	isCalculating.value = false;
 };
 
@@ -1918,19 +2170,19 @@
 		return;
 	}
 	if (isCalculating.value) return;
-	
+
 	const quantity = parseFloat(productForm.value.quantity);
 	const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
-	
+
 	if (!quantity || quantity <= 0 || !unitPrice) {
 		return;
 	}
-	
+
 	isCalculating.value = true;
-	
+
 	// 璁$畻鍚◣鎬讳环
 	productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
-	
+
 	// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
 	if (productForm.value.taxRate) {
 		productForm.value.taxExclusiveTotalPrice =
@@ -1939,7 +2191,7 @@
 				productForm.value.taxRate
 			);
 	}
-	
+
 	isCalculating.value = false;
 };
 
@@ -1950,19 +2202,19 @@
 		return;
 	}
 	if (isCalculating.value) return;
-	
+
 	const quantity = parseFloat(productForm.value.quantity);
 	const unitPrice = parseFloat(productForm.value.taxInclusiveUnitPrice);
-	
+
 	if (!quantity || quantity <= 0 || !unitPrice) {
 		return;
 	}
-	
+
 	isCalculating.value = true;
-	
+
 	// 璁$畻鍚◣鎬讳环
 	productForm.value.taxInclusiveTotalPrice = (unitPrice * quantity).toFixed(2);
-	
+
 	// 濡傛灉鏈夌◣鐜囷紝璁$畻涓嶅惈绋庢�讳环
 	if (productForm.value.taxRate) {
 		productForm.value.taxExclusiveTotalPrice =
@@ -1971,7 +2223,7 @@
 				productForm.value.taxRate
 			);
 	}
-	
+
 	isCalculating.value = false;
 };
 
@@ -1982,23 +2234,23 @@
 		return;
 	}
 	if (isCalculating.value) return;
-	
+
 	const inclusiveTotalPrice = parseFloat(productForm.value.taxInclusiveTotalPrice);
 	const taxRate = parseFloat(productForm.value.taxRate);
-	
+
 	if (!inclusiveTotalPrice || !taxRate) {
 		return;
 	}
-	
+
 	isCalculating.value = true;
-	
+
 	// 璁$畻涓嶅惈绋庢�讳环
 	productForm.value.taxExclusiveTotalPrice =
 		proxy.calculateTaxExclusiveTotalPrice(
 			inclusiveTotalPrice,
 			taxRate
 		);
-	
+
 	isCalculating.value = false;
 };
 /**
@@ -2010,15 +2262,15 @@
 	if (row.shippingDate || row.shippingCarNumber) {
 		return '宸插彂璐�';
 	}
-	
+
 	// 鑾峰彇鍙戣揣鐘舵�佸瓧娈�
 	const status = row.shippingStatus;
-	
+
 	// 濡傛灉鐘舵�佷负绌烘垨鏈畾涔夛紝榛樿涓�"寰呭彂璐�"
 	if (status === null || status === undefined || status === '') {
 		return '寰呭彂璐�';
 	}
-	
+
 	// 鐘舵�佹槸瀛楃涓�
 	const statusStr = String(status).trim();
 	const statusTextMap = {
@@ -2041,15 +2293,15 @@
 	if (row.shippingDate || row.shippingCarNumber) {
 		return 'success';
 	}
-	
+
 	// 鑾峰彇鍙戣揣鐘舵�佸瓧娈�
 	const status = row.shippingStatus;
-	
+
 	// 濡傛灉鐘舵�佷负绌烘垨鏈畾涔夛紝榛樿涓虹伆鑹诧紙寰呭彂璐э級
 	if (status === null || status === undefined || status === '') {
 		return 'info';
 	}
-	
+
 	// 鐘舵�佹槸瀛楃涓�
 	const statusStr = String(status).trim();
 	const typeTextMap = {
@@ -2073,15 +2325,15 @@
 	if (row.approveStatus !== 1) {
 		return false;
 	}
-	
+
 	// 鑾峰彇鍙戣揣鐘舵��
 	const shippingStatus = row.shippingStatus;
-	
+
 	// 濡傛灉宸插彂璐э紙鏈夊彂璐ф棩鏈熸垨杞︾墝鍙凤級锛屼笉鑳藉啀娆″彂璐�
 	if (row.shippingDate || row.shippingCarNumber) {
 		return false;
 	}
-	
+
 	// 鍙戣揣鐘舵�佸繀椤绘槸"寰呭彂璐�"鎴�"瀹℃牳鎷掔粷"
 	const statusStr = shippingStatus ? String(shippingStatus).trim() : '';
 	return statusStr === '寰呭彂璐�' || statusStr === '瀹℃牳鎷掔粷';
@@ -2109,15 +2361,35 @@
 		proxy.$modal.msgWarning("鍙湁鍦ㄤ骇鍝佺姸鎬佹槸鍏呰冻锛屽彂璐х姸鎬佹槸寰呭彂璐ф垨瀹℃牳鎷掔粷鐨勬椂鍊欐墠鍙互鍙戣揣");
 		return;
 	}
-	
+
 	currentDeliveryRow.value = row;
   deliveryForm.value = {
     type: "璐ц溅",
+    shippingDate: getCurrentDate(),
+    shippingCarNumber: "",
+    expressCompany: "",
+    expressNumber: "",
   };
+  deliveryFileList.value = [];
   // 閲嶇疆瀹℃壒浜鸿妭鐐癸紙榛樿涓�涓┖鑺傜偣锛�
   approverNodes.value = [{ id: 1, userId: null }];
   nextApproverId = 2;
 	deliveryFormVisible.value = true;
+};
+
+// 鍙戣揣鍥剧墖涓婁紶鎴愬姛鍥炶皟
+const handleDeliveryUploadSuccess = (res, file, uploadFiles) => {
+	if (res.code === 200) {
+		file.tempId = res.data.tempId;
+		proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
+	} else {
+		proxy.$modal.msgError(res.msg);
+	}
+};
+
+// 绉婚櫎鍙戣揣鍥剧墖
+const handleDeliveryRemove = (file) => {
+	// 鏂囦欢绉婚櫎鏃惰嚜鍔ㄤ粠 fileList 涓垹闄わ紝鏃犻渶棰濆澶勭悊
 };
 
 // 鎻愪氦鍙戣揣琛ㄥ崟
@@ -2134,10 +2406,22 @@
       // 淇濆瓨褰撳墠灞曞紑鐨勮ID锛屼互渚垮彂璐у悗閲嶆柊鍔犺浇瀛愯〃鏍兼暟鎹�
       const currentExpandedKeys = [...expandedRowKeys.value];
       const salesLedgerId = currentDeliveryRow.value.salesLedgerId;
+
+      // 鑾峰彇涓婁紶鍥剧墖鐨勪复鏃禝D
+      let tempFileIds = [];
+      if (deliveryFileList.value !== null && deliveryFileList.value.length > 0) {
+        tempFileIds = deliveryFileList.value.map((item) => item.tempId);
+      }
+
       addShippingInfo({
         salesLedgerId: salesLedgerId,
         salesLedgerProductId: currentDeliveryRow.value.id,
         type: deliveryForm.value.type,
+        shippingDate: deliveryForm.value.shippingDate,
+        shippingCarNumber: deliveryForm.value.type === "璐ц溅" ? deliveryForm.value.shippingCarNumber : "",
+        expressCompany: deliveryForm.value.type === "蹇��" ? deliveryForm.value.expressCompany : "",
+        expressNumber: deliveryForm.value.type === "蹇��" ? deliveryForm.value.expressNumber : "",
+        tempFileIds: tempFileIds,
 				approveUserIds,
       })
         .then(() => {
@@ -2167,12 +2451,124 @@
   });
 };
 
+// 涓�閿彂璐� - 鑷姩瀹℃壒閫氳繃骞跺嚭搴�
+const submitOneClickDelivery = () => {
+  proxy.$refs["deliveryFormRef"].validate((valid) => {
+    if (valid) {
+      // 淇濆瓨褰撳墠灞曞紑鐨勮ID锛屼互渚垮彂璐у悗閲嶆柊鍔犺浇瀛愯〃鏍兼暟鎹�
+      const currentExpandedKeys = [...expandedRowKeys.value];
+      const salesLedgerId = currentDeliveryRow.value.salesLedgerId;
+
+      // 鑾峰彇涓婁紶鍥剧墖鐨勪复鏃禝D
+      let tempFileIds = [];
+      if (deliveryFileList.value !== null && deliveryFileList.value.length > 0) {
+        tempFileIds = deliveryFileList.value.map((item) => item.tempId);
+      }
+
+      oneClickShipping({
+        salesLedgerId: salesLedgerId,
+        salesLedgerProductId: currentDeliveryRow.value.id,
+        type: deliveryForm.value.type,
+        shippingDate: deliveryForm.value.shippingDate,
+        shippingCarNumber: deliveryForm.value.type === "璐ц溅" ? deliveryForm.value.shippingCarNumber : "",
+        expressCompany: deliveryForm.value.type === "蹇��" ? deliveryForm.value.expressCompany : "",
+        expressNumber: deliveryForm.value.type === "蹇��" ? deliveryForm.value.expressNumber : "",
+        tempFileIds: tempFileIds,
+      })
+        .then(() => {
+          proxy.$modal.msgSuccess("涓�閿彂璐ф垚鍔�");
+          closeDeliveryDia();
+          // 鍒锋柊涓昏〃鏁版嵁
+          getList().then(() => {
+            // 濡傛灉涔嬪墠鏈夊睍寮�鐨勮锛岄噸鏂板姞杞借繖浜涜鐨勫瓙琛ㄦ牸鏁版嵁
+            if (currentExpandedKeys.length > 0) {
+              const loadPromises = currentExpandedKeys.map(ledgerId => {
+                return productList({ salesLedgerId: ledgerId, type: 1 }).then((res) => {
+                  const index = tableData.value.findIndex((item) => item.id === ledgerId);
+                  if (index > -1) {
+                    tableData.value[index].children = res.data;
+                  }
+                });
+              });
+              Promise.all(loadPromises).then(() => {
+                expandedRowKeys.value = currentExpandedKeys;
+              });
+            }
+          });
+        })
+    }
+  });
+};
+
 // 鍏抽棴鍙戣揣寮规
 const closeDeliveryDia = () => {
   proxy.resetForm("deliveryFormRef");
+  deliveryFileList.value = [];
   deliveryFormVisible.value = false;
   currentDeliveryRow.value = null;
 };
+
+// 鎵撳紑鎵归噺涓�閿彂璐у脊妗�
+const openBatchDeliveryForm = (row) => {
+  currentBatchDeliveryRow.value = row;
+  batchDeliveryForm.value = {
+    type: "璐ц溅",
+    shippingDate: getCurrentDate(),
+    shippingCarNumber: "",
+    expressCompany: "",
+    expressNumber: "",
+  };
+  batchDeliveryFormVisible.value = true;
+};
+
+// 鍏抽棴鎵归噺鍙戣揣寮规
+const closeBatchDeliveryDia = () => {
+  proxy.resetForm("batchDeliveryFormRef");
+  batchDeliveryFormVisible.value = false;
+  currentBatchDeliveryRow.value = null;
+};
+
+// 鎻愪氦鎵归噺涓�閿彂璐�
+const submitBatchDelivery = () => {
+  proxy.$refs["batchDeliveryFormRef"].validate((valid) => {
+    if (valid) {
+      // 淇濆瓨褰撳墠灞曞紑鐨勮ID
+      const currentExpandedKeys = [...expandedRowKeys.value];
+      const salesLedgerId = currentBatchDeliveryRow.value.id;
+
+      batchOneClickShipping({
+        salesLedgerId: salesLedgerId,
+        type: batchDeliveryForm.value.type,
+        shippingDate: batchDeliveryForm.value.shippingDate,
+        shippingCarNumber: batchDeliveryForm.value.type === "璐ц溅" ? batchDeliveryForm.value.shippingCarNumber : "",
+        expressCompany: batchDeliveryForm.value.type === "蹇��" ? batchDeliveryForm.value.expressCompany : "",
+        expressNumber: batchDeliveryForm.value.type === "蹇��" ? batchDeliveryForm.value.expressNumber : "",
+      })
+        .then(() => {
+          proxy.$modal.msgSuccess("鎵归噺鍙戣揣鎴愬姛");
+          closeBatchDeliveryDia();
+          // 鍒锋柊涓昏〃鏁版嵁
+          getList().then(() => {
+            // 濡傛灉涔嬪墠鏈夊睍寮�鐨勮锛岄噸鏂板姞杞借繖浜涜鐨勫瓙琛ㄦ牸鏁版嵁
+            if (currentExpandedKeys.length > 0) {
+              const loadPromises = currentExpandedKeys.map(ledgerId => {
+                return productList({ salesLedgerId: ledgerId, type: 1 }).then((res) => {
+                  const index = tableData.value.findIndex((item) => item.id === ledgerId);
+                  if (index > -1) {
+                    tableData.value[index].children = res.data;
+                  }
+                });
+              });
+              Promise.all(loadPromises).then(() => {
+                expandedRowKeys.value = currentExpandedKeys;
+              });
+            }
+          });
+        })
+    }
+  });
+};
+
 const currentFactoryName = ref("");
 const getCurrentFactoryName = async () => {
 	let res = await userStore.getInfo();
@@ -2230,12 +2626,12 @@
 		padding: 15px;
 		border-bottom: 1px solid #e4e7ed;
 		text-align: center;
-		
+
 		.el-button {
 			margin: 0 10px;
 		}
 	}
-	
+
 	.print-preview-content {
 		padding: 20px;
 		background-color: #f5f5f5;
@@ -2267,13 +2663,13 @@
 .header {
 	text-align: center;
 	margin-bottom: 8px;
-	
+
 	.company-name {
 		font-size: 18px;
 		font-weight: bold;
 		margin-bottom: 4px;
 	}
-	
+
 	.document-title {
 		font-size: 16px;
 		font-weight: bold;
@@ -2285,16 +2681,16 @@
 	display: flex;
 	justify-content: space-between;
 	align-items: center;
-	
+
 	.info-row {
 		line-height: 20px;
-		
+
 		.label {
 			font-weight: bold;
 			width: 60px;
 			font-size: 14px;
 		}
-		
+
 		.value {
 			margin-right: 20px;
 			min-width: 80px;
@@ -2306,12 +2702,12 @@
 .table-section {
 	margin-bottom: 4px;
 	flex: 1;
-	
+
 	.product-table {
 		width: 100%;
 		border-collapse: collapse;
 		border: 1px solid #000;
-		
+
 		th, td {
 			border: 1px solid #000;
 			padding: 6px;
@@ -2319,16 +2715,16 @@
 			font-size: 14px;
 			line-height: 1.4;
 		}
-		
+
 		th {
 			font-weight: bold;
 		}
-		
+
 		.total-label {
 			text-align: right;
 			font-weight: bold;
 		}
-		
+
 		.total-value {
 			font-weight: bold;
 		}
@@ -2341,22 +2737,22 @@
 		margin-bottom: 3px;
 		line-height: 20px;
 		justify-content: space-between;
-		
+
 		.footer-item {
 			display: flex;
 			margin-right: 20px;
-			
+
 			.label {
 				font-weight: bold;
 				width: 80px;
 				font-size: 14px;
 			}
-			
+
 			.value {
 				min-width: 80px;
 				font-size: 14px;
 			}
-			
+
 			&.address-item {
 				.address-value {
 					min-width: 200px;
@@ -2370,7 +2766,7 @@
 	.app-container {
 		display: none;
 	}
-	
+
 	.print-page {
 		box-shadow: none;
 		margin: 0;

--
Gitblit v1.9.3