Procházet zdrojové kódy

修复:配穴表格最后一个无法删除以及当用户在详情中取消勾选有内容还是传给后端了

张田田 před 1 týdnem
rodič
revize
0576e0e57e
1 změnil soubory, kde provedl 9 přidání a 4 odebrání
  1. 9 4
      src/views/business/components/AcupointTable.vue

+ 9 - 4
src/views/business/components/AcupointTable.vue

@@ -620,7 +620,7 @@ import {
 } from "@/api/technology.js";
 import popup from "@/components/Propup.vue";
 
-// 详情默认值 value → label 映射
+// 详情默认值
 const DETAIL_DEFAULT_MAP = {
   "1": "穴位",
   "2": "部位",
@@ -1034,7 +1034,7 @@ export default {
         return;
       }
 
-      // 检查项目是否已存在,不允许重复添加
+      //不允许重复添加
       const isDuplicate = this.prescriptions.some(
         (p) => p.itemId === this.addForm.itemId,
       );
@@ -1044,7 +1044,6 @@ export default {
       }
 
       this.addLoading = true;
-      // 调用详情接口获取项目完整信息
       let detailData = {};
       try {
         const res = await getNondrugItemDetail(this.addForm.itemId);
@@ -1388,7 +1387,11 @@ export default {
       if (this.isDeleteDisabled(scope.row, detailType)) return;
       const table = this.getDetailTable(detailType);
       const index = scope.row.id - 1;
-      if (index === 0 && table.length === 1) return;
+      if (table.length === 1) {
+        // 仅剩一行时清空内容(保留空行占位),否则点击删除无反应
+        this.$set(table, 0, createEmptyRow(1));
+        return;
+      }
       table.splice(index, 1);
       this.reIndexDetail(detailType);
     },
@@ -1565,6 +1568,8 @@ export default {
         };
 
         Object.keys(detailArrays).forEach((type) => {
+          // 未勾选的详情类型不提交
+          if (!d.innerDetailTypes.includes(type)) return;
           const table = d.detailTables[type] || [];
           table.forEach((row) => {
             if (row.acuid || row.name) {