From a8ebfcbec49fb628fa2fa1a66bc1950125bc0786 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 18 五月 2026 14:51:14 +0800
Subject: [PATCH] 优化设备保养表单:新增保养人选择器,确保保养人必填,加载保养人列表

---
 src/pages/sales/salesAccount/index.vue |  119 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 105 insertions(+), 14 deletions(-)

diff --git a/src/pages/sales/salesAccount/index.vue b/src/pages/sales/salesAccount/index.vue
index d6a8646..2e1b083 100644
--- a/src/pages/sales/salesAccount/index.vue
+++ b/src/pages/sales/salesAccount/index.vue
@@ -27,7 +27,7 @@
       <view v-for="(item, index) in ledgerList"
             :key="index">
         <view class="ledger-item"
-              @click="handleInfo('edit', item)">
+              @click="openOut(item)">
           <view class="item-header">
             <view class="item-left">
               <view class="document-icon">
@@ -46,10 +46,6 @@
             <view class="detail-row">
               <text class="detail-label">瀹㈡埛鍚嶇О</text>
               <text class="detail-value">{{ item.customerName }}</text>
-            </view>
-            <view class="detail-row">
-              <text class="detail-label">瀹㈡埛鍚堝悓鍙�</text>
-              <text class="detail-value">{{ item.customerContractNo }}</text>
             </view>
             <view class="detail-row">
               <text class="detail-label">涓氬姟鍛�</text>
@@ -71,6 +67,13 @@
               <text class="detail-label">绛捐鏃ユ湡</text>
               <text class="detail-value">{{ item.executionDate }}</text>
             </view>
+            <view class="detail-row">
+              <text class="detail-label">鍙戣揣鐘舵��</text>
+              <u-tag size="mini"
+                     :type="getLedgerShippingTagType(item)">{{
+                getLedgerShippingLabel(item)
+              }}</u-tag>
+            </view>
             <up-divider></up-divider>
             <view class="detail-info">
               <view class="detail-row">
@@ -83,12 +86,36 @@
               </view>
             </view>
             <up-divider></up-divider>
-            <u-button class="detail-button"
-                      size="small"
-                      type="primary"
-                      @click="openOut(item)">
-              鍙戣揣鐘舵��
-            </u-button>
+            <view class="detail-buttons">
+              <u-button class="detail-button"
+                        size="small"
+                        type="primary"
+                        plain
+                        :disabled="!canLedgerShip(item)"
+                        @click.stop="handleShip(item)">
+                鍙戣揣
+              </u-button>
+              <!-- <u-button class="detail-button"
+                        size="small"
+                        type="primary"
+                        @click.stop="handleInfo('edit', item)">
+                缂栬緫
+              </u-button>
+              <u-button class="detail-button"
+                        size="small"
+                        type="primary"
+                        plain
+                        @click.stop="openOut(item)">
+                鍙戣揣鐘舵��
+              </u-button> -->
+              <!-- <u-button class="detail-button"
+                        size="small"
+                        type="error"
+                        plain
+                        @click.stop="handleDelete(item)">
+                鍒犻櫎
+              </u-button> -->
+            </view>
           </view>
         </view>
       </view>
@@ -98,19 +125,26 @@
       <text>鏆傛棤閿�鍞彴璐︽暟鎹�</text>
     </view>
     <!-- 娴姩鎿嶄綔鎸夐挳 -->
-    <view class="fab-button"
+    <!-- <view class="fab-button"
           @click="handleInfo('add')">
       <up-icon name="plus"
                size="24"
                color="#ffffff"></up-icon>
-    </view>
+    </view> -->
   </view>
 </template>
 
 <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 {
+    hasShippedProducts,
+    getLedgerShippingLabel,
+    getLedgerShippingTagType,
+    canLedgerShip,
+    executeSalesLedgerShip,
+  } from "@/utils/salesLedgerShip";
   import useUserStore from "@/store/modules/user";
   import PageHeader from "@/components/PageHeader.vue";
   const userStore = useUserStore();
@@ -129,6 +163,8 @@
 
   // 閿�鍞彴璐︽暟鎹�
   const ledgerList = ref([]);
+
+  const handleShip = item => executeSalesLedgerShip(item);
 
   // 杩斿洖涓婁竴椤�
   const goBack = () => {
@@ -157,11 +193,61 @@
       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",
+            });
+          }
+        }
+      },
+    });
+  };
   // 澶勭悊鍙拌处淇℃伅鎿嶄綔锛堟煡鐪�/缂栬緫/鏂板锛�
   const handleInfo = (type, row) => {
     try {
       // 璁剧疆鎿嶄綔绫诲瀷
       uni.setStorageSync("operationType", type);
+      uni.removeStorageSync("editData");
 
       // 濡傛灉鏄煡鐪嬫垨缂栬緫鎿嶄綔
       if (type !== "add") {
@@ -213,4 +299,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