From 10a8da68d9db10313c67e0f193c160e9740d95cd Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 21 四月 2026 17:09:42 +0800
Subject: [PATCH] 湟水峡 1.发货改为在产品上发货

---
 src/views/salesManagement/salesLedger/index.vue |  381 +++++++++++++++++++++++++----------------------------
 1 files changed, 180 insertions(+), 201 deletions(-)

diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 382a1cd..582fdf1 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -46,11 +46,63 @@
               <el-table-column label="浜у搧澶х被" prop="productCategory" />
               <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" />
               <el-table-column label="鍗曚綅" prop="unit" />
+							<el-table-column label="浜у搧鐘舵��"
+															 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-else type="danger">涓嶈冻</el-tag>
+                </template>
+              </el-table-column>
+							<el-table-column label="鍙戣揣鐘舵��" width="140" align="center">
+								<template #default="scope">
+									<el-tag :type="getShippingStatusType(scope.row)" size="small">
+										{{ getShippingStatusText(scope.row) }}
+									</el-tag>
+								</template>
+							</el-table-column>
+							<el-table-column label="蹇�掑叕鍙�" prop="expressCompany" show-overflow-tooltip />
+							<el-table-column label="蹇�掑崟鍙�" prop="expressNumber" show-overflow-tooltip />
+              <el-table-column label="鍙戣揣杞︾墝" minWidth="100px" align="center">
+                <template #default="scope">
+                  <div>
+                    <el-tag type="success" v-if="scope.row.shippingCarNumber">{{ scope.row.shippingCarNumber }}</el-tag>
+                    <el-tag v-else type="info">-</el-tag>
+                  </div>
+                </template>
+              </el-table-column>
+							<el-table-column label="鍙戣揣鏃ユ湡"
+															 minWidth="100px"
+															 align="center">
+                <template #default="scope">
+                  <div>
+                    <div v-if="scope.row.shippingDate">{{ scope.row.shippingDate }}</div>
+										<el-tag v-else
+														type="info">-</el-tag>
+                  </div>
+                </template>
+              </el-table-column>
               <el-table-column label="鏁伴噺" prop="quantity" />
               <el-table-column label="绋庣巼(%)" prop="taxRate" />
-              <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" />
-              <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" />
-              <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" />
+              <el-table-column label="鍚◣鍗曚环(鍏�)" prop="taxInclusiveUnitPrice" :formatter="sensitiveAmountFormatter" />
+              <el-table-column label="鍚◣鎬讳环(鍏�)" prop="taxInclusiveTotalPrice" :formatter="sensitiveAmountFormatter" />
+              <el-table-column label="涓嶅惈绋庢�讳环(鍏�)" prop="taxExclusiveTotalPrice" :formatter="sensitiveAmountFormatter" />
+            <!--鎿嶄綔-->
+              <el-table-column Width="60px" label="鎿嶄綔" align="center">
+                <template #default="scope">
+                  <el-button
+                    link
+                    type="primary"
+                    :disabled="!canShip(scope.row)"
+                    @click="openDeliveryForm(scope.row)">
+                    鍙戣揣
+                  </el-button>
+                </template>
+              </el-table-column>
             </el-table>
           </template>
         </el-table-column>
@@ -71,27 +123,10 @@
         <el-table-column label="褰曞叆浜�" prop="entryPersonName" width="100" show-overflow-tooltip />
         <el-table-column label="褰曞叆鏃ユ湡" prop="entryDate" width="120" show-overflow-tooltip />
         <el-table-column label="绛捐鏃ユ湡" prop="executionDate" width="120" show-overflow-tooltip />
-        <el-table-column label="鍙戣揣鐘舵��" prop="shippingStatus" width="140" align="center" show-overflow-tooltip />
-        <el-table-column label="鍙戣揣鏃ユ湡" prop="shippingDate" width="140" align="center" show-overflow-tooltip />
         <el-table-column fixed="right" label="鎿嶄綔" min-width="140" align="center">
           <template #default="scope">
-            <el-button
-              link
-              type="primary"
-              size="small"
-              @click="openForm('edit', scope.row)"
-              :disabled="scope.row.approvalStatus === 3 && scope.row.entryPerson !== userStore.id"
-            >缂栬緫</el-button>
-            <el-button link type="primary" size="small" @click="downLoadFile(scope.row)">闄勪欢</el-button>
-            <el-button
-              link
-              type="primary"
-              size="small"
-              @click="openDeliveryForm(scope.row)"
-              :disabled="scope.row.shippingStatus === '宸插彂璐�'"
-            >
-              鍙戣揣
-            </el-button>
+            <el-button link type="primary" @click="openForm('edit', scope.row)" :disabled="!scope.row.isEdit || scope.row.hasProductionRecord">缂栬緫</el-button>
+            <el-button link type="primary" @click="downLoadFile(scope.row)">闄勪欢</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -496,7 +531,6 @@
 								v-model="deliveryForm.type"
 								placeholder="璇烽�夋嫨鍙戣揣绫诲瀷"
 								style="width: 100%"
-								@change="handleShippingTypeChange"
 							>
 								<el-option label="璐ц溅" value="璐ц溅" />
 								<el-option label="蹇��" value="蹇��" />
@@ -504,81 +538,6 @@
 						</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 }"
-									:before-upload="handleDeliveryBeforeUpload"
-									:on-error="handleDeliveryUploadError"
-									: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-form>
 			<template #footer>
 				<div class="dialog-footer">
@@ -694,7 +653,6 @@
 });
 const total = ref(0);
 const fileList = ref([]);
-const deliveryFileList = ref([]);
 
 // 瀹℃壒浜鸿妭鐐癸紙浠块噰璐彴璐﹀鎵逛汉锛�
 const approverNodes = ref([{ id: 1, userId: null }]);
@@ -810,25 +768,11 @@
 const currentDeliveryRow = ref(null);
 const deliveryFormData = reactive({
   deliveryForm: {
-    type: "璐ц溅", // 璐ц溅, 蹇��
-    shippingDate: "",
-    shippingCarNumber: "",
-    expressCompany: "",
-    expressNumber: "", // 蹇�掑崟鍙�
-    shippingImages: "", // 鍙戣揣鍥剧墖锛屽涓敤閫楀彿鍒嗛殧
+    type: "", // 璐ц溅, 蹇��
   },
   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" }
     ],
   },
 });
@@ -1220,47 +1164,6 @@
     delLedgerFile(ids).then((res) => {
       proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
     });
-  }
-}
-// 鍙戣揣鍥剧墖涓婁紶鍓嶆牎妫�
-function handleDeliveryBeforeUpload(file) {
-  // 鏍℃鏂囦欢绫诲瀷
-  const isImage = file.type === 'image/png' || file.type === 'image/jpeg' || file.type === 'image/jpg';
-  if (!isImage) {
-    proxy.$modal.msgError("鍙兘涓婁紶 jpg銆乯peg銆乸ng 鏍煎紡鐨勫浘鐗�!");
-    return false;
-  }
-  // 鏍℃鏂囦欢澶у皬
-  const isLt10M = file.size / 1024 / 1024 < 10;
-  if (!isLt10M) {
-    proxy.$modal.msgError("涓婁紶鍥剧墖澶у皬涓嶈兘瓒呰繃 10MB!");
-    return false;
-  }
-  proxy.$modal.loading("姝e湪涓婁紶鍥剧墖锛岃绋嶅��...");
-  return true;
-}
-// 鍙戣揣鍥剧墖涓婁紶澶辫触
-function handleDeliveryUploadError(err) {
-  proxy.$modal.msgError("涓婁紶鍥剧墖澶辫触");
-  proxy.$modal.closeLoading();
-}
-// 鍙戣揣鍥剧墖涓婁紶鎴愬姛鍥炶皟
-function handleDeliveryUploadSuccess(res, file, uploadFiles) {
-  proxy.$modal.closeLoading();
-  if (res.code === 200) {
-    file.tempId = res.data.tempId;
-    proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
-  } else {
-    proxy.$modal.msgError(res.msg);
-    proxy.$refs.deliveryFileUpload.handleRemove(file);
-  }
-}
-// 绉婚櫎鍙戣揣鍥剧墖
-function handleDeliveryRemove(file) {
-  // 浠庢枃浠跺垪琛ㄤ腑绉婚櫎
-  const index = deliveryFileList.value.findIndex(item => item.uid === file.uid);
-  if (index > -1) {
-    deliveryFileList.value.splice(index, 1);
   }
 }
 // 鎻愪氦琛ㄥ崟
@@ -1828,19 +1731,7 @@
 	return total.toFixed(2);
 };
 
-// 鍙戣揣绫诲瀷鏍¢獙锛氳揣杞︽椂瑕佹眰杞︾墝锛屽揩閫掓椂瑕佹眰蹇�掑叕鍙�
-const validateShippingCarNumber = (value, callback) => {
-  if (deliveryForm.value.type === "璐ц溅") {
-    if (!value) return callback(new Error("璇疯緭鍏ュ彂璐ц溅鐗屽彿"));
-  }
-  callback();
-};
-const validateExpressCompany = (value, callback) => {
-  if (deliveryForm.value.type === "蹇��") {
-    if (!value) return callback(new Error("璇疯緭鍏ュ揩閫掑叕鍙�"));
-  }
-  callback();
-};
+
 
 const mathNum = () => {
 	console.log("productForm.value", productForm.value);
@@ -2017,6 +1908,92 @@
   isCalculating.value = false;
 };
 /**
+ * 鑾峰彇鍙戣揣鐘舵�佹枃鏈�
+ * @param row 琛屾暟鎹�
+ */
+const getShippingStatusText = (row) => {
+	// 濡傛灉宸插彂璐э紙鏈夊彂璐ф棩鏈熸垨杞︾墝鍙凤級锛屾樉绀�"宸插彂璐�"
+	if (row.shippingDate || row.shippingCarNumber) {
+		return '宸插彂璐�';
+	}
+	
+	// 鑾峰彇鍙戣揣鐘舵�佸瓧娈�
+	const status = row.shippingStatus;
+	
+	// 濡傛灉鐘舵�佷负绌烘垨鏈畾涔夛紝榛樿涓�"寰呭彂璐�"
+	if (status === null || status === undefined || status === '') {
+		return '寰呭彂璐�';
+	}
+	
+	// 鐘舵�佹槸瀛楃涓�
+	const statusStr = String(status).trim();
+	const statusTextMap = {
+		'寰呭彂璐�': '寰呭彂璐�',
+		'寰呭鏍�': '寰呭鏍�',
+		'瀹℃牳涓�': '瀹℃牳涓�',
+		'瀹℃牳鎷掔粷': '瀹℃牳鎷掔粷',
+		'瀹℃牳閫氳繃': '瀹℃牳閫氳繃',
+		'宸插彂璐�': '宸插彂璐�'
+	};
+	return statusTextMap[statusStr] || '寰呭彂璐�';
+};
+
+/**
+ * 鑾峰彇鍙戣揣鐘舵�佹爣绛剧被鍨嬶紙棰滆壊锛�
+ * @param row 琛屾暟鎹�
+ */
+const getShippingStatusType = (row) => {
+	// 濡傛灉宸插彂璐э紙鏈夊彂璐ф棩鏈熸垨杞︾墝鍙凤級锛屾樉绀虹豢鑹�
+	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 = {
+		'寰呭彂璐�': 'info',
+		'寰呭鏍�': 'info',
+		'瀹℃牳涓�': 'warning',
+		'瀹℃牳鎷掔粷': 'danger',
+		'瀹℃牳閫氳繃': 'success',
+		'宸插彂璐�': 'success'
+	};
+	return typeTextMap[statusStr] || 'info';
+};
+
+/**
+ * 鍒ゆ柇鏄惁鍙互鍙戣揣
+ * 鍙湁鍦ㄤ骇鍝佺姸鎬佹槸鍏呰冻锛屽彂璐х姸鎬佹槸寰呭彂璐у拰瀹℃牳鎷掔粷鐨勬椂鍊欐墠鍙互鍙戣揣
+ * @param row 琛屾暟鎹�
+ */
+const canShip = (row) => {
+	// 浜у搧鐘舵�佸繀椤绘槸鍏呰冻锛坅pproveStatus === 1锛�
+	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 === '瀹℃牳鎷掔粷';
+};
+
+/**
  * 涓嬭浇鏂囦欢
  *
  * @param row 涓嬭浇鏂囦欢鐨勭浉鍏充俊鎭璞�
@@ -2030,16 +2007,16 @@
 
 // 鎵撳紑鍙戣揣寮规
 const openDeliveryForm = (row) => {
+	// 妫�鏌ユ槸鍚﹀彲浠ュ彂璐�
+	if (!canShip(row)) {
+		proxy.$modal.msgWarning("鍙湁鍦ㄤ骇鍝佺姸鎬佹槸鍏呰冻锛屽彂璐х姸鎬佹槸寰呭彂璐ф垨瀹℃牳鎷掔粷鐨勬椂鍊欐墠鍙互鍙戣揣");
+		return;
+	}
+	
 	currentDeliveryRow.value = row;
   deliveryForm.value = {
-    type: "璐ц溅",
-    shippingDate: getCurrentDate(),
-    shippingCarNumber: "",
-    expressCompany: "",
-    expressNumber: "", // 鍒濆鍖栧揩閫掑崟鍙蜂负绌�
-    shippingImages: "", // 鍒濆鍖栧浘鐗囦负绌�
+    type: "",
   };
-  deliveryFileList.value = []; // 鍒濆鍖栨枃浠跺垪琛ㄤ负绌�
 	deliveryFormVisible.value = true;
 };
 
@@ -2047,27 +2024,37 @@
 const submitDelivery = () => {
   proxy.$refs["deliveryFormRef"].validate((valid) => {
     if (valid) {
-      let tempFileIds = [];
-      if (deliveryFileList.value !== null && deliveryFileList.value.length > 0) {
-        tempFileIds = deliveryFileList.value.map((item) => item.tempId);
-      }
+      // 淇濆瓨褰撳墠灞曞紑鐨勮ID锛屼互渚垮彂璐у悗閲嶆柊鍔犺浇瀛愯〃鏍兼暟鎹�
+      const currentExpandedKeys = [...expandedRowKeys.value];
+      const salesLedgerId = currentDeliveryRow.value.salesLedgerId;
       addShippingInfo({
-        salesLedgerId: currentDeliveryRow.value.id,
+        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();
+          // 鍒锋柊涓昏〃鏁版嵁
+          getList().then(() => {
+            // 濡傛灉涔嬪墠鏈夊睍寮�鐨勮锛岄噸鏂板姞杞借繖浜涜鐨勫瓙琛ㄦ牸鏁版嵁
+            if (currentExpandedKeys.length > 0) {
+              // 浣跨敤 Promise.all 骞惰鍔犺浇鎵�鏈夊睍寮�琛岀殑瀛愯〃鏍兼暟鎹�
+              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;
+              });
+            }
+          });
         })
-        .catch(() => {
-          proxy.$modal.msgError("鍙戣揣澶辫触锛岃閲嶈瘯");
-        });
     }
   });
 };
@@ -2075,21 +2062,13 @@
 // 鍏抽棴鍙戣揣寮规
 const closeDeliveryDia = () => {
   proxy.resetForm("deliveryFormRef");
-  deliveryFileList.value = []; // 娓呯┖鏂囦欢鍒楄〃
-  deliveryForm.value.shippingImages = ""; // 娓呯┖鍥剧墖
-  deliveryForm.value.expressNumber = ""; // 娓呯┖蹇�掑崟鍙�
   deliveryFormVisible.value = false;
   currentDeliveryRow.value = null;
 };
-
-// 鍙戣揣绫诲瀷鍒囨崲鏃舵竻绌哄搴斿瓧娈�
-const handleShippingTypeChange = (val) => {
-  if (val === "璐ц溅") {
-    deliveryForm.value.expressCompany = "";
-    deliveryForm.value.expressNumber = "";
-  } else {
-    deliveryForm.value.shippingCarNumber = "";
-  }
+const currentFactoryName = ref("");
+const getCurrentFactoryName = async () => {
+	let res = await userStore.getInfo();
+	currentFactoryName.value = res.user.currentFactoryName;
 };
 
 onMounted(() => {

--
Gitblit v1.9.3