From 4e39a9af1b2fe4a0cdd12f16175d3e601063cb58 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期四, 10 七月 2025 11:41:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 src/views/basicData/product/index.vue |   88 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 70 insertions(+), 18 deletions(-)

diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index 6d31b8d..3aa263e 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -40,7 +40,13 @@
         >
           <template #default="{ node, data }">
             <div class="custom-tree-node">
-              <span>{{ node.label }}</span>
+              <span class="tree-node-content">
+                <el-icon class="orange-icon">
+                  <component :is="data.children && data.children.length > 0
+                  ? node.expanded ? 'FolderOpened' : 'Folder' : 'Tickets'" />
+                </el-icon>
+                {{ data.label }}
+              </span>
               <div>
                 <el-button
                   type="primary"
@@ -49,7 +55,7 @@
                 >
                   缂栬緫
                 </el-button>
-                <el-button type="primary" link @click="openProDia('add', data)">
+                <el-button type="primary" link @click="openProDia('add', data)" :disabled="node.level >= 3">
                   娣诲姞浜у搧
                 </el-button>
                 <el-button
@@ -91,10 +97,9 @@
         @selection-change="handleSelectionChange"
         :tableLoading="tableLoading"
         @pagination="pagination"
-        :total="total"
       ></PIMTable>
     </div>
-    <el-dialog v-model="productDia" title="浜у搧" width="400px">
+    <el-dialog v-model="productDia" title="浜у搧" width="400px" @keydown.enter.prevent>
       <el-form
         :model="form"
         label-width="140px"
@@ -109,6 +114,7 @@
                 v-model="form.productName"
                 placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�"
                 clearable
+                @keydown.enter.prevent
               />
             </el-form-item>
           </el-col>
@@ -126,6 +132,7 @@
       title="瑙勬牸鍨嬪彿"
       width="400px"
       @close="closeModelDia"
+      @keydown.enter.prevent
     >
       <el-form
         :model="modelForm"
@@ -141,6 +148,7 @@
                 v-model="modelForm.model"
                 placeholder="璇疯緭鍏ヨ鏍煎瀷鍙�"
                 clearable
+                @keydown.enter.prevent
               />
             </el-form-item>
           </el-col>
@@ -152,6 +160,7 @@
                 v-model="modelForm.unit"
                 placeholder="璇疯緭鍏ュ崟浣�"
                 clearable
+                @keydown.enter.prevent
               />
             </el-form-item>
           </el-col>
@@ -221,11 +230,11 @@
 const tableData = ref([]);
 const tableLoading = ref(false);
 const isShowButton = ref(false);
-const total = ref(0);
 const selectedRows = ref([]);
 const page = reactive({
   current: 1,
   size: 10,
+  total: 0,
 });
 const data = reactive({
   form: {
@@ -310,16 +319,53 @@
   proxy.$refs.formRef.resetFields();
   productDia.value = false;
 };
+// 灏佽涓�涓畨鍏ㄧ殑纭妗嗭紝褰诲簳闃绘Enter閿Е鍙�
+const safeConfirm = (message, title) => {
+  // 鏍囪鏄惁鏄紶鏍囩偣鍑伙紙鐐瑰嚮鎸夐挳浼氳Е鍙慺ocus浜嬩欢锛�
+  let isMouseClick = false;
+
+  return new Promise((resolve, reject) => {
+    const box = ElMessageBox.confirm(message, title, {
+      confirmButtonText: "纭",
+      cancelButtonText: "鍙栨秷",
+      type: "warning",
+      beforeClose: (action, instance, done) => {
+        if (action === "confirm") {
+          // 鍙湁榧犳爣鐐瑰嚮鏃舵墠鍏佽纭
+          if (isMouseClick) {
+            done();
+            resolve();
+          } else {
+            // Enter閿Е鍙戞椂闃绘
+            done(false);
+          }
+        } else {
+          // 鍙栨秷鎿嶄綔鐩存帴鍏佽
+          done();
+          reject();
+        }
+      }
+    });
+
+    // 鐩戝惉纭鎸夐挳鐨刦ocus浜嬩欢锛堥紶鏍囩偣鍑讳細瑙﹀彂锛孍nter閿笉浼氾級
+    setTimeout(() => {
+      const confirmBtn = document.querySelector('.el-message-box__btns .el-button--primary');
+      if (confirmBtn) {
+        confirmBtn.addEventListener('focus', () => {
+          isMouseClick = true;
+        });
+      }
+    }, 0); // 寤惰繜鑾峰彇锛岀‘淇滵OM宸叉覆鏌�
+  });
+};
+// 鍒犻櫎浜у搧
 // 鍒犻櫎浜у搧
 const remove = (node, data) => {
-  let ids = [];
-  ids.push(data.id);
-  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
-    confirmButtonText: "纭",
-    cancelButtonText: "鍙栨秷",
-    type: "warning",
-  })
+  let ids = [data.id];
+  // 浣跨敤灏佽鐨剆afeConfirm
+  safeConfirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず")
     .then(() => {
+      // 纭鍒犻櫎閫昏緫
       tableLoading.value = true;
       delProduct(ids)
         .then((res) => {
@@ -382,7 +428,7 @@
   }).then((res) => {
     console.log("res", res);
     tableData.value = res.records;
-    total.value = res.total;
+    page.total = res.total;
     tableLoading.value = false;
   });
 };
@@ -395,11 +441,7 @@
     proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
     return;
   }
-  ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", {
-    confirmButtonText: "纭",
-    cancelButtonText: "鍙栨秷",
-    type: "warning",
-  })
+  safeConfirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず")
     .then(() => {
       tableLoading.value = true;
       delProductModel(ids)
@@ -477,4 +519,14 @@
   font-size: 14px;
   padding-right: 8px;
 }
+.tree-node-content {
+  display: flex;
+  align-items: center; /* 鍨傜洿灞呬腑 */
+  height: 100%;
+}
+.orange-icon {
+  color: orange;
+  font-size: 18px;
+  margin-right: 8px; /* 鍥炬爣涓庢枃瀛椾箣闂村姞鐐归棿璺� */
+}
 </style>

--
Gitblit v1.9.3