From 7a0790d8224db45a039bf33d0ef4e24ae879a243 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期二, 30 六月 2026 10:38:05 +0800
Subject: [PATCH] 采购退货重构,添加新增、删除功能;供应商管理新增修改删除功能

---
 src/pages/procurementManagement/procurementLedger/index.vue |   98 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 95 insertions(+), 3 deletions(-)

diff --git a/src/pages/procurementManagement/procurementLedger/index.vue b/src/pages/procurementManagement/procurementLedger/index.vue
index ebcf07a..028fb1c 100644
--- a/src/pages/procurementManagement/procurementLedger/index.vue
+++ b/src/pages/procurementManagement/procurementLedger/index.vue
@@ -46,8 +46,12 @@
           <up-divider></up-divider>
           <view class="item-details">
             <view class="detail-row">
-              <text class="detail-label">閿�鍞悎鍚屽彿</text>
-              <text class="detail-value">{{ item.salesContractNo }}</text>
+              <text class="detail-label">鍏ュ簱鐘舵��</text>
+              <view class="detail-value">
+                <u-tag :type="getStockInStatusType(item.stockInStatus)">
+                  {{ item.stockInStatus || '--' }}
+                </u-tag>
+              </view>
             </view>
             <view class="detail-row">
               <text class="detail-label">渚涘簲鍟嗗悕绉�</text>
@@ -76,6 +80,17 @@
                 <text class="detail-value">{{ item.entryDate }}</text>
               </view>
             </view>
+            <!-- 浠呴潪鈥滃鎵归�氳繃鈥濈殑鍙拌处灞曠ず鍒犻櫎鎸夐挳 -->
+            <view class="detail-row"
+                  v-if="item.approvalStatus !== 3 && item.stockInStatus !== '瀹屽叏鍏ュ簱'"
+                  style="justify-content: flex-end; margin-top: 8px;">
+              <up-button type="error"
+                         size="small"
+                         plain
+                         @click.stop="handleDelete(item)">
+                鍒犻櫎
+              </up-button>
+            </view>
           </view>
         </view>
       </view>
@@ -99,7 +114,10 @@
   import { onShow } from "@dcloudio/uni-app";
   import useUserStore from "@/store/modules/user";
   import PageHeader from "@/components/PageHeader.vue";
-  import { purchaseListPage } from "@/api/procurementManagement/procurementLedger";
+  import {
+    purchaseListPage,
+    delPurchase,
+  } from "@/api/procurementManagement/procurementLedger";
   const userStore = useUserStore();
   const approvalStatusText = {
     1: "寰呭鏍�",
@@ -116,6 +134,14 @@
       4: "error", // 瀹℃壒澶辫触 - 绾㈣壊
     };
     return typeMap[status] || "";
+  };
+  const getStockInStatusType = status => {
+    const typeMap = {
+      寰呭叆搴�: "info",
+      鍏ュ簱涓�: "warning",
+      瀹屽叏鍏ュ簱: "success",
+    };
+    return typeMap[status] || "info";
   };
   // 鎼滅储鍏抽敭璇�
   const purchaseContractNumber = ref("");
@@ -165,6 +191,7 @@
     try {
       // 璁剧疆鎿嶄綔绫诲瀷
       uni.setStorageSync("operationType", type);
+      uni.removeStorageSync("editData");
 
       // 濡傛灉鏄煡鐪嬫垨缂栬緫鎿嶄綔
       if (type !== "add") {
@@ -180,6 +207,13 @@
         // 妫�鏌ユ潈闄愶細鍙湁褰曞叆浜烘墠鑳界紪杈�
         if (row.recorderName != userStore.nickName) {
           // 闈炲綍鍏ヤ汉璺宠浆鍒板彧璇昏鎯呴〉闈�
+          uni.setStorageSync("editData", JSON.stringify(row));
+          uni.navigateTo({
+            url: "/pages/procurementManagement/procurementLedger/view",
+          });
+          return;
+        }
+        if (row.stockInStatus === "瀹屽叏鍏ュ簱") {
           uni.setStorageSync("editData", JSON.stringify(row));
           uni.navigateTo({
             url: "/pages/procurementManagement/procurementLedger/view",
@@ -208,6 +242,64 @@
     }
   };
 
+  // 鍒犻櫎鍗曟潯閲囪喘鍙拌处
+  const handleDelete = row => {
+    if (!row || !row.id) {
+      uni.showToast({
+        title: "鏁版嵁鏈夎锛屾棤娉曞垹闄�",
+        icon: "none",
+      });
+      return;
+    }
+
+    uni.showModal({
+      title: "鎻愮ず",
+      content: "閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�",
+      confirmText: "纭",
+      cancelText: "鍙栨秷",
+      success: res => {
+        if (res.confirm) {
+          delPurchase([row.id])
+            .then(result => {
+              // 鎴愬姛锛歝ode === 200
+              if (result && result.code === 200) {
+                uni.showToast({
+                  title: "鍒犻櫎鎴愬姛",
+                  icon: "success",
+                });
+                getList();
+                return;
+              }
+              // 涓氬姟澶辫触锛氫紭鍏堝睍绀哄悗绔繑鍥炵殑 msg锛堝 CG2026... 涓嶅厑璁稿垹闄わ級
+              uni.showToast({
+                title: (result && result.msg) || "鍒犻櫎澶辫触",
+                icon: "none",
+              });
+            })
+            .catch(error => {
+              // 瀵逛簬 request 灏佽杩斿洖鐨� '500' 鎴栧叾浠� code锛岄敊璇彁绀哄凡缁忓湪 request 閲� toast 杩囦簡锛岃繖閲屼笉鍐嶉噸澶嶈鐩�
+              if (error === "500" || typeof error === "number") {
+                return;
+              }
+              // 鍙湁鍦ㄧ湡姝e紓甯告椂锛屾墠鍦ㄨ繖閲屽厹搴曟彁绀�
+              const msg =
+                (error && error.msg) ||
+                (error &&
+                  error.response &&
+                  error.response.data &&
+                  error.response.data.msg) ||
+                (error && error.message) ||
+                "鍒犻櫎澶辫触";
+              uni.showToast({
+                title: msg,
+                icon: "none",
+              });
+            });
+        }
+      },
+    });
+  };
+
   onShow(() => {
     // 椤甸潰鏄剧ず鏃跺埛鏂板垪琛�
     getList();

--
Gitblit v1.9.3