From 8a3bfdab689684fe5ee19b2f69842e450fc7c60a Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 30 一月 2026 14:02:39 +0800
Subject: [PATCH] fix: 完成生产数据分析页面

---
 src/views/salesManagement/deliveryLedger/index.vue |  282 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 239 insertions(+), 43 deletions(-)

diff --git a/src/views/salesManagement/deliveryLedger/index.vue b/src/views/salesManagement/deliveryLedger/index.vue
index 7b94a29..de52c68 100644
--- a/src/views/salesManagement/deliveryLedger/index.vue
+++ b/src/views/salesManagement/deliveryLedger/index.vue
@@ -32,15 +32,39 @@
         <el-table-column align="center" type="selection" width="55" />
         <el-table-column align="center" label="搴忓彿" type="index" width="60" />
         <el-table-column label="閿�鍞鍗�" prop="salesContractNo" show-overflow-tooltip />
+        <el-table-column label="鍙戣揣璁㈠崟鍙�" prop="shippingNo" show-overflow-tooltip />
         <el-table-column label="瀹㈡埛鍚嶇О" prop="customerName" show-overflow-tooltip />
         <el-table-column label="鍙戣揣鏃堕棿" prop="shippingDate" show-overflow-tooltip />
         <el-table-column label="鍙戣揣杞︾墝鍙�" prop="shippingCarNumber" show-overflow-tooltip />
         <el-table-column label="蹇�掑叕鍙�" prop="expressCompany" show-overflow-tooltip />
         <el-table-column label="蹇�掑崟鍙�" prop="expressNumber" show-overflow-tooltip />
-        <el-table-column fixed="right" label="鎿嶄綔" width="150" align="center">
+        <el-table-column label="瀹℃牳鐘舵��" prop="status" align="center" width="120">
           <template #default="scope">
-            <el-button link type="primary" size="small" @click="openForm('edit', scope.row)">缂栬緫</el-button>
-            <el-button link type="danger" size="small" @click="handleDeleteSingle(scope.row)">鍒犻櫎</el-button>
+            <el-tag :type="getApprovalStatusType(scope.row.status)">
+              {{ getApprovalStatusText(scope.row.status) }}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column fixed="right" label="鎿嶄綔" width="200" align="center">
+          <template #default="scope">
+            <el-button 
+              link 
+              type="primary" 
+              size="small" 
+              :disabled="!isApproved(scope.row.status)"
+              @click="openForm('edit', scope.row)">琛ュ厖鍙戣揣淇℃伅</el-button>
+            <el-button
+              link
+              type="primary"
+              size="small"
+              @click="openDetail(scope.row)"
+            >璇︽儏</el-button>
+            <el-button 
+              link 
+              type="danger" 
+              size="small" 
+              :disabled="isApproving(scope.row.status)"
+              @click="handleDeleteSingle(scope.row)">鍒犻櫎</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -148,6 +172,41 @@
         </div>
       </template>
     </el-dialog>
+
+    <!-- 璇︽儏寮规 -->
+    <el-dialog v-model="detailDialogVisible" title="鍙戣揣鍙拌处璇︽儏" width="55%" @close="closeDetail">
+      <div v-if="detailRow" class="detail-wrapper">
+        <el-descriptions :column="2" border>
+          <el-descriptions-item label="閿�鍞鍗�">{{ detailRow.salesContractNo || '--' }}</el-descriptions-item>
+          <el-descriptions-item label="鍙戣揣璁㈠崟鍙�">{{ detailRow.shippingNo || '--' }}</el-descriptions-item>
+          <el-descriptions-item label="瀹㈡埛鍚嶇О">{{ detailRow.customerName || '--' }}</el-descriptions-item>
+          <el-descriptions-item label="鍙戣揣绫诲瀷">{{ detailRow.type || '--' }}</el-descriptions-item>
+          <el-descriptions-item label="鍙戣揣鏃ユ湡">{{ detailRow.shippingDate || '--' }}</el-descriptions-item>
+          <el-descriptions-item label="瀹℃牳鐘舵��">{{ getApprovalStatusText(detailRow.status) }}</el-descriptions-item>
+          <el-descriptions-item label="鍙戣揣杞︾墝鍙�">{{ detailRow.shippingCarNumber || '--' }}</el-descriptions-item>
+          <el-descriptions-item label="蹇�掑叕鍙�">{{ detailRow.expressCompany || '--' }}</el-descriptions-item>
+          <el-descriptions-item label="蹇�掑崟鍙�" :span="2">{{ detailRow.expressNumber || '--' }}</el-descriptions-item>
+        </el-descriptions>
+
+        <div class="detail-images" v-if="detailImages.length">
+          <div class="detail-images-title">鍙戣揣鍥剧墖</div>
+          <el-image
+            v-for="img in detailImages"
+            :key="img.url"
+            :src="img.url"
+            :preview-src-list="detailImages.map(i => i.url)"
+            fit="cover"
+            class="detail-image"
+          />
+        </div>
+        <div v-else class="detail-images-empty">鏆傛棤鍙戣揣鍥剧墖</div>
+      </div>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="closeDetail">鍏抽棴</el-button>
+        </div>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -159,9 +218,9 @@
 import { getToken } from "@/utils/auth";
 import { getCurrentDate } from "@/utils/index.js";
 import {
-  deliveryLedgerListPage,
-  addOrUpdateDeliveryLedger,
-  delDeliveryLedger,
+	deliveryLedgerListPage,
+	addOrUpdateDeliveryLedger,
+	delDeliveryLedger, deductStock,
 } from "@/api/salesManagement/deliveryLedger.js";
 import { delLedgerFile } from "@/api/salesManagement/salesLedger.js";
  
@@ -178,6 +237,31 @@
 const total = ref(0);
 const deliveryFileList = ref([]);
 const javaApi = proxy.javaApi;
+// 璇︽儏寮规
+const detailDialogVisible = ref(false);
+const detailRow = ref(null);
+const detailImages = ref([]);
+
+const normalizeFileUrl = (rawUrl = '') => {
+  let fileUrl = rawUrl || '';
+  // Windows 璺緞杞� URL
+  if (fileUrl && fileUrl.indexOf('\\') > -1) {
+    const uploadsIndex = fileUrl.toLowerCase().indexOf('uploads');
+    if (uploadsIndex > -1) {
+      const relativePath = fileUrl.substring(uploadsIndex).replace(/\\/g, '/');
+      fileUrl = '/' + relativePath;
+    } else {
+      const parts = fileUrl.split('\\');
+      const fileName = parts[parts.length - 1];
+      fileUrl = '/uploads/' + fileName;
+    }
+  }
+  if (fileUrl && !fileUrl.startsWith('http')) {
+    if (!fileUrl.startsWith('/')) fileUrl = '/' + fileUrl;
+    fileUrl = javaApi + fileUrl;
+  }
+  return fileUrl;
+};
 
 // 涓婁紶閰嶇疆
 const upload = reactive({
@@ -266,6 +350,12 @@
 
 // 鎵撳紑寮规
 const openForm = async (type, row) => {
+  // 琛ュ厖鍙戣揣淇℃伅锛氫粎鈥滃鏍搁�氳繃鈥濆厑璁哥紪杈�
+  if (type === 'edit' && row && !isApproved(row.status)) {
+    proxy.$modal.msgWarning("鍙湁瀹℃牳閫氳繃鐨勬暟鎹墠鍙互琛ュ厖鍙戣揣淇℃伅");
+    return;
+  }
+  
   operationType.value = type;
   const baseUrl = import.meta.env.VITE_APP_BASE_API;
   
@@ -283,38 +373,7 @@
     // 濡傛灉鏈夊浘鐗囷紝灏� commonFileList 杞崲涓烘枃浠跺垪琛ㄦ牸寮�
     if (row.commonFileList && Array.isArray(row.commonFileList) && row.commonFileList.length > 0) {
       deliveryFileList.value = row.commonFileList.map((file, index) => {
-        // 澶勭悊 URL锛氬皢 Windows 璺緞杞崲涓哄彲璁块棶鐨� URL
-        let fileUrl = file.url || '';
-        console.log('鍘熷 URL:', fileUrl);
-        
-        // 濡傛灉 URL 鏄� Windows 璺緞鏍煎紡锛堝寘鍚弽鏂滄潬锛夛紝闇�瑕佽浆鎹�
-        if (fileUrl && fileUrl.indexOf('\\') > -1) {
-          // 鏌ユ壘 uploads 鍏抽敭瀛楃殑浣嶇疆锛屼粠閭i噷寮�濮嬫彁鍙栫浉瀵硅矾寰�
-          const uploadsIndex = fileUrl.toLowerCase().indexOf('uploads');
-          if (uploadsIndex > -1) {
-            // 浠� uploads 寮�濮嬫彁鍙栬矾寰勶紝骞跺皢鍙嶆枩鏉犳浛鎹负姝f枩鏉�
-            const relativePath = fileUrl.substring(uploadsIndex).replace(/\\/g, '/');
-            fileUrl = '/' + relativePath;
-            console.log('杞崲鍚庣殑鐩稿璺緞:', fileUrl);
-          } else {
-            // 濡傛灉娌℃湁鎵惧埌 uploads锛屾彁鍙栨渶鍚庝竴涓洰褰曞拰鏂囦欢鍚�
-            const parts = fileUrl.split('\\');
-            const fileName = parts[parts.length - 1];
-            fileUrl = '/uploads/' + fileName;
-            console.log('鏈壘鍒� uploads锛屼娇鐢ㄦ枃浠跺悕:', fileUrl);
-          }
-        }
-        
-        // 纭繚鎵�鏈夐潪 http 寮�澶寸殑 URL 閮芥嫾鎺� baseUrl
-        if (fileUrl && !fileUrl.startsWith('http')) {
-          // 纭繚璺緞浠� / 寮�澶�
-          if (!fileUrl.startsWith('/')) {
-            fileUrl = '/' + fileUrl;
-          }
-          // 鎷兼帴 baseUrl
-          fileUrl = javaApi + fileUrl;
-          console.log('鏈�缁堟嫾鎺ョ殑 URL:', fileUrl);
-        }
+        const fileUrl = normalizeFileUrl(file.url || '');
         
         return {
           uid: file.id || Date.now() + index,
@@ -351,6 +410,21 @@
   dialogFormVisible.value = true;
 };
 
+// 鎵撳紑璇︽儏寮规
+const openDetail = (row) => {
+  detailRow.value = row || null;
+  const list = Array.isArray(row?.commonFileList) ? row.commonFileList : [];
+  detailImages.value = list
+    .map((f) => ({ url: normalizeFileUrl(f?.url || '') }))
+    .filter((i) => !!i.url);
+  detailDialogVisible.value = true;
+};
+const closeDetail = () => {
+  detailDialogVisible.value = false;
+  detailRow.value = null;
+  detailImages.value = [];
+};
+
 // 鎻愪氦琛ㄥ崟
 const submitForm = () => {
   proxy.$refs["formRef"].validate((valid) => {
@@ -368,7 +442,7 @@
         expressNumber: form.value.type === "蹇��" ? form.value.expressNumber : "",
         tempFileIds: tempFileIds,
       };
-      addOrUpdateDeliveryLedger(payload).then((res) => {
+			deductStock(payload).then((res) => {
         proxy.$modal.msgSuccess("鎿嶄綔鎴愬姛");
         closeDia();
         getList();
@@ -401,13 +475,19 @@
 
 // 鎵归噺鍒犻櫎
 const handleDelete = () => {
-  let ids = [];
-  if (selectedRows.value.length > 0) {
-    ids = selectedRows.value.map((item) => item.id);
-  } else {
+  if (selectedRows.value.length === 0) {
     proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
     return;
   }
+  
+  // 妫�鏌ラ�変腑鐨勮鏄惁鏈�"瀹℃牳涓�"鐘舵��
+  const approvingRows = selectedRows.value.filter(row => isApproving(row.status));
+  if (approvingRows.length > 0) {
+    proxy.$modal.msgWarning("瀹℃牳涓殑鏁版嵁涓嶈兘鍒犻櫎");
+    return;
+  }
+  
+  const ids = selectedRows.value.map((item) => item.id);
   ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎", {
     confirmButtonText: "纭",
     cancelButtonText: "鍙栨秷",
@@ -426,6 +506,12 @@
 
 // 鍗曚釜鍒犻櫎
 const handleDeleteSingle = (row) => {
+  // 妫�鏌ユ槸鍚︿负"瀹℃牳涓�"鐘舵��
+  if (isApproving(row.status)) {
+    proxy.$modal.msgWarning("瀹℃牳涓殑鏁版嵁涓嶈兘鍒犻櫎");
+    return;
+  }
+  
   ElMessageBox.confirm("姝ゆ搷浣滃皢鍒犻櫎璇ヨ褰曪紝鏄惁纭锛�", "鍒犻櫎", {
     confirmButtonText: "纭",
     cancelButtonText: "鍙栨秷",
@@ -525,6 +611,94 @@
   }
 };
 
+// 鑾峰彇瀹℃牳鐘舵�佹枃鏈�
+const getApprovalStatusText = (status) => {
+  if (status === null || status === undefined || status === '') {
+    return '寰呭鏍�';
+  }
+  // 濡傛灉鏄暟瀛�
+  if (typeof status === 'number') {
+    const statusMap = {
+      0: '寰呭鏍�',
+      1: '瀹℃牳涓�',
+      2: '瀹℃牳鎷掔粷',
+      3: '瀹℃牳閫氳繃'
+    };
+    return statusMap[status] || '寰呭鏍�';
+  }
+  // 濡傛灉鏄瓧绗︿覆锛岀洿鎺ヨ繑鍥炴垨鏄犲皠
+  const statusStr = String(status).trim();
+  const statusTextMap = {
+    '寰呭鏍�': '寰呭鏍�',
+    '瀹℃牳涓�': '瀹℃牳涓�',
+    '瀹℃牳鎷掔粷': '瀹℃牳鎷掔粷',
+    '瀹℃牳閫氳繃': '瀹℃牳閫氳繃',
+    '0': '寰呭鏍�',
+    '1': '瀹℃牳涓�',
+    '2': '瀹℃牳鎷掔粷',
+    '3': '瀹℃牳閫氳繃'
+  };
+  return statusTextMap[statusStr] || statusStr || '寰呭鏍�';
+};
+
+// 鑾峰彇瀹℃牳鐘舵�佹爣绛剧被鍨嬶紙棰滆壊锛�
+const getApprovalStatusType = (status) => {
+  if (status === null || status === undefined || status === '') {
+    return 'info';
+  }
+  // 濡傛灉鏄暟瀛�
+  if (typeof status === 'number') {
+    const typeMap = {
+      0: 'info',      // 寰呭鏍� - 鐏拌壊
+      1: 'warning',   // 瀹℃牳涓� - 榛勮壊
+      2: 'danger',    // 瀹℃牳鎷掔粷 - 绾㈣壊
+      3: 'success'    // 瀹℃牳閫氳繃 - 缁胯壊
+    };
+    return typeMap[status] || 'info';
+  }
+  // 濡傛灉鏄瓧绗︿覆
+  const statusStr = String(status).trim();
+  const typeTextMap = {
+    '寰呭鏍�': 'info',
+    '瀹℃牳涓�': 'warning',
+    '瀹℃牳鎷掔粷': 'danger',
+    '瀹℃牳閫氳繃': 'success',
+    '0': 'info',
+    '1': 'warning',
+    '2': 'danger',
+    '3': 'success'
+  };
+  return typeTextMap[statusStr] || 'info';
+};
+
+// 妫�鏌ュ鏍哥姸鎬佹槸鍚︿负"瀹℃牳閫氳繃"
+const isApproved = (status) => {
+  if (status === null || status === undefined || status === '') {
+    return false;
+  }
+  // 濡傛灉鏄暟瀛楋紝3 琛ㄧず瀹℃牳閫氳繃
+  if (typeof status === 'number') {
+    return status === 3;
+  }
+  // 濡傛灉鏄瓧绗︿覆
+  const statusStr = String(status).trim();
+  return statusStr === '瀹℃牳閫氳繃' || statusStr === '3';
+};
+
+// 妫�鏌ュ鏍哥姸鎬佹槸鍚︿负"瀹℃牳涓�"
+const isApproving = (status) => {
+  if (status === null || status === undefined || status === '') {
+    return false;
+  }
+  // 濡傛灉鏄暟瀛楋紝1 琛ㄧず瀹℃牳涓�
+  if (typeof status === 'number') {
+    return status === 1;
+  }
+  // 濡傛灉鏄瓧绗︿覆
+  const statusStr = String(status).trim();
+  return statusStr === '瀹℃牳涓�' || statusStr === '1';
+};
+
 onMounted(() => {
   getList();
 });
@@ -547,5 +721,27 @@
     display: none;
   }
 }
+.detail-wrapper {
+  padding: 8px 0;
+}
+.detail-images {
+  margin-top: 16px;
+}
+.detail-images-title {
+  font-weight: 600;
+  margin-bottom: 10px;
+  color: #303133;
+}
+.detail-image {
+  width: 120px;
+  height: 120px;
+  margin-right: 10px;
+  margin-bottom: 10px;
+  border-radius: 6px;
+}
+.detail-images-empty {
+  margin-top: 16px;
+  color: #909399;
+}
 </style>
 

--
Gitblit v1.9.3