From 2dc24084675a49f6c55da5ee0069b2de0503c449 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 05 二月 2026 16:33:35 +0800
Subject: [PATCH] 进销存升级app: 1.开票登记、开票台账、回款流水还有客户合同号字段(需要去掉) 2.采购台账、销售台账页面都需要加上删除按钮

---
 src/pages/sales/salesAccount/index.vue |   85 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/src/pages/sales/salesAccount/index.vue b/src/pages/sales/salesAccount/index.vue
index 8e3fdf6..250447d 100644
--- a/src/pages/sales/salesAccount/index.vue
+++ b/src/pages/sales/salesAccount/index.vue
@@ -79,12 +79,21 @@
               </view>
             </view>
             <up-divider></up-divider>
-            <u-button class="detail-button"
+            <view class="detail-buttons">
+              <u-button class="detail-button"
                       size="small"
                       type="primary"
                       @click="openOut(item)">
               鍙戣揣鐘舵��
             </u-button>
+            <u-button class="detail-button"
+                      size="small"
+                      type="error"
+                      plain
+                      @click.stop="handleDelete(item)">
+              鍒犻櫎
+            </u-button>
+            </view>
           </view>
         </view>
       </view>
@@ -106,7 +115,11 @@
 <script setup>
   import { ref } from "vue";
   import { onShow } from "@dcloudio/uni-app";
-  import { ledgerListPage } from "@/api/salesManagement/salesLedger";
+  import {
+    ledgerListPage,
+    delLedger,
+    productList,
+  } from "@/api/salesManagement/salesLedger";
   import useUserStore from "@/store/modules/user";
   import PageHeader from "@/components/PageHeader.vue";
   const userStore = useUserStore();
@@ -125,6 +138,20 @@
 
   // 閿�鍞彴璐︽暟鎹�
   const ledgerList = ref([]);
+
+  // 鍒ゆ柇鏄惁瀛樺湪宸插彂璐�/鍙戣揣瀹屾垚鐨勪骇鍝�
+  const hasShippedProducts = products => {
+    if (!products || products.length === 0) return false;
+    return products.some(p => {
+      const statusStr = (p.shippingStatus ?? "").toString();
+      // 鍖呭惈鈥滃彂璐р�濇垨鏈夊彂璐ф棩鏈�/杞︾墝鍙疯涓哄凡鍙戣揣
+      return (
+        statusStr.includes("鍙戣揣") ||
+        !!p.shippingDate ||
+        !!p.shippingCarNumber
+      );
+    });
+  };
 
   // 杩斿洖涓婁竴椤�
   const goBack = () => {
@@ -151,6 +178,55 @@
     uni.setStorageSync("outData", JSON.stringify(item));
     uni.navigateTo({
       url: "/pages/sales/salesAccount/out",
+    });
+  };
+
+  // 鍒犻櫎鍗曟潯閿�鍞彴璐�
+  const handleDelete = async row => {
+    if (!row || !row.id) return;
+
+    // 鑾峰彇浜у搧鍒楄〃锛岀敤浜庡垽鏂槸鍚﹀凡鍙戣揣
+    let products = row.children && row.children.length > 0 ? row.children : null;
+    if (!products) {
+      try {
+        const res = await productList({ salesLedgerId: row.id, type: 1 });
+        products = res.data || res.records || [];
+      } catch (e) {
+        products = [];
+      }
+    }
+
+    if (hasShippedProducts(products)) {
+      uni.showToast({
+        title: "宸插彂璐�/鍙戣揣瀹屾垚鐨勯攢鍞鍗曚笉鑳藉垹闄�",
+        icon: "none",
+      });
+      return;
+    }
+
+    uni.showModal({
+      title: "鍒犻櫎纭",
+      content: "閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�",
+      success: async res => {
+        if (res.confirm) {
+          try {
+            showLoadingToast("澶勭悊涓�...");
+            await delLedger([row.id]);
+            closeToast();
+            uni.showToast({
+              title: "鍒犻櫎鎴愬姛",
+              icon: "success",
+            });
+            getList();
+          } catch (e) {
+            closeToast();
+            uni.showToast({
+              title: "鍒犻櫎澶辫触锛岃閲嶈瘯",
+              icon: "none",
+            });
+          }
+        }
+      },
     });
   };
   // 澶勭悊鍙拌处淇℃伅鎿嶄綔锛堟煡鐪�/缂栬緫/鏂板锛�
@@ -209,4 +285,9 @@
 
 <style scoped lang="scss">
   @import "@/styles/sales-common.scss";
+  .detail-buttons {
+    display: flex;
+    gap: 10px;
+    justify-content: space-between;
+  }
 </style>

--
Gitblit v1.9.3