Browse Source

feat: 更新任务ID展示逻辑,使用文本格式替代下拉选择

xieyong 1 day ago
parent
commit
a71784d5b0
1 changed files with 47 additions and 20 deletions
  1. 47 20
      src/views/bpm/handleTask/components/entrust/create.vue

+ 47 - 20
src/views/bpm/handleTask/components/entrust/create.vue

@@ -180,24 +180,8 @@
           <el-input v-model="row.describes" disabled> </el-input>
         </template>
 
-        <template v-slot:taskId="{ row, $index }">
-          <el-select
-            clearable
-            filterable
-            style="width: 100%"
-            v-model="row.taskId"
-            placeholder="请选择"
-            @change="taskListChange(row, $index)"
-            disabled
-          >
-            <el-option
-              v-for="item in row.taskList"
-              :label="item.name"
-              :value="item.id"
-              :key="item.id"
-            >
-            </el-option>
-          </el-select>
+        <template v-slot:taskIds="{ row }">
+          <span class="task-ids-cell">{{ formatTaskIds(row) }}</span>
         </template>
 
         <template v-slot:planDeliveryTime="{ row }">
@@ -508,8 +492,8 @@
             }
           },
           {
-            prop: 'taskId',
-            slot: 'taskId',
+            prop: 'taskIds',
+            slot: 'taskIds',
             label: '工序',
             align: 'center',
             minWidth: 150,
@@ -631,6 +615,10 @@
           taskList: []
         };
 
+        // 后端 taskIds 是逗号分隔的字符串,多选 el-select 需要数组才能正常显示
+        newData.taskIds = !!newData?.taskIdList.length ? newData.taskIdList : this.parseTaskIdsToArray(newData.taskIds);
+
+        console.log(newData.taskIds,'taskIds');
         this.orderList.push(newData);
         this.getOrderTaskList();
         // this.form.procedureList = this.form.procedureList.map(
@@ -639,6 +627,37 @@
         this.form.type = this.form.type + '';
       },
 
+      // 后端 taskIds 是逗号分隔字符串,转成数组供 el-select multiple 使用
+      parseTaskIdsToArray(value) {
+        if (Array.isArray(value)) return value;
+        if (typeof value === 'string' && value.trim()) {
+          return value.split(',').filter(Boolean);
+        }
+        return [];
+      },
+
+      // 把 taskIds 数组渲染成"name1、name2"形式的文本;空值显示"—"
+      formatTaskIds(row) {
+        const ids = Array.isArray(row.taskIds) ? row.taskIds : [];
+        if (!ids.length) return '—';
+        const lookup = (id) => {
+          // 优先用当前行的 taskList 查 name;若该行没有,再兜底从全表 orderList 查
+          const local = (row.taskList || []).find((o) => o.id === id);
+          if (local) return local.name;
+          const global = (this.orderList || []).find(
+            (o) => Array.isArray(o.taskList) && o.taskList.find((t) => t.id === id)
+          );
+          if (global) {
+            const hit = global.taskList.find((t) => t.id === id);
+            return hit ? hit.name : null;
+          }
+          return null;
+        };
+        return ids
+          .map((id) => lookup(id) || id)
+          .join('、');
+      },
+
       deepCopy(obj, hash = new WeakMap()) {
         if (obj === null) return null;
         if (obj instanceof Date) return new Date(obj);
@@ -742,4 +761,12 @@
   .create-form .el-form-item {
     margin-bottom: 15px !important;
   }
+
+  // taskIds 列:纯文本展示,避免多个 tag 顶到 cell 上方
+  .task-ids-cell {
+    display: inline-block;
+    width: 100%;
+    word-break: break-all;
+    line-height: 1.5;
+  }
 </style>