Преглед изворни кода

refactor: 优化执行人和班组选择逻辑

yusheng пре 1 месец
родитељ
комит
29246ac4b9
2 измењених фајлова са 49 додато и 78 уклоњено
  1. 8 14
      src/views/recordComponents/plan.vue
  2. 41 64
      src/views/recordComponents/workOrderReport.vue

+ 8 - 14
src/views/recordComponents/plan.vue

@@ -173,16 +173,13 @@
             showOverflowTooltip: true,
             minWidth: 110,
             formatter: (row) => {
-              if (row.type == 0) {
-                return [
-                  ...new Set(
-                    (row.executeUsers || [])
-                      .map((i) => i.groupName)
-                      .filter((i) => i)
-                  )
-                ].join(',');
-              }
-              return '';
+              return [
+                ...new Set(
+                  (row.executeUsers || [])
+                    .map((i) => i.groupName)
+                    .filter((i) => i)
+                )
+              ].join(',');
             }
           },
           {
@@ -192,10 +189,7 @@
             showOverflowTooltip: true,
             minWidth: 110,
             formatter: (row) => {
-              if (row.type == 0) {
-                return row.executeUsers.map((i) => i.userName).join(',');
-              }
-              return '';
+              return row.executeUsers.map((i) => i.userName).join(',');
             }
           },
 

+ 41 - 64
src/views/recordComponents/workOrderReport.vue

@@ -90,6 +90,7 @@
               multiple
               filterable
               @change="executeIdListChange"
+              key="executeUsersIds"
             >
               <el-option
                 v-for="item in executorList"
@@ -101,29 +102,23 @@
           </el-form-item>
         </el-col>
         <el-col :span="8" v-if="addForm.type">
-          <el-form-item label="执行人" required prop="teamId">
-            <el-select
-              v-model="addForm.teamId"
-              placeholder="请选择班组"
-              filterable
-              style="width: 120px"
+          <el-form-item label="班组" required prop="teamId">
+            <el-input
+              v-model="addForm.teamName"
+              placeholder=" "
               disabled
-              @change="checkTeamList(addForm.teamId)"
-            >
-              <el-option
-                v-for="item in allTeamList"
-                :label="item.name"
-                :value="item.id"
-                :key="item.id"
-              >
-              </el-option>
-            </el-select>
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" v-if="addForm.type">
+          <el-form-item label="执行人" required prop="executeUsersIds">
             <el-select
               v-model="addForm.executeUsersIds"
               placeholder="请选择执行人"
               filterable
               multiple
               @change="changeId"
+              style="width: 100%"
             >
               <div class="checkboxWrapper">
                 <el-checkbox v-model="checked" @change="checkChange">
@@ -140,8 +135,8 @@
             </el-select>
           </el-form-item>
         </el-col>
-        <el-col :span="8">
-          <el-form-item label="场站" prop="postName">
+        <el-col :span="8" v-if="addForm.type">
+          <el-form-item label="场站" prop="productLineId">
             <el-select
               v-model="addForm.productLineId"
               placeholder="请选择场站"
@@ -180,31 +175,21 @@
             />
           </el-form-item>
         </el-col>
+        <el-col :span="8" v-if="pageName == 'qualityTestRecords'">
+          <el-form-item label="联合站检查人" required prop="contactName">
+            <el-input
+              clearable
+              v-model="addForm.contactName"
+              @click.native="handParent"
+              placeholder="请选择"
+              readonly
+            />
+          </el-form-item>
+        </el-col>
       </el-row>
 
       <header-title title="记录数据" :style="`margin-top: 20px`"></header-title>
 
-      <!-- <template v-if="addForm.recordTemplateStyle == '4'">
-        <el-tabs v-model="statisticsType" type="card">
-          <el-tab-pane
-            v-for="i in statisticsTypeList"
-            :label="i.label"
-            :name="i.value"
-            :key="i.value"
-          >
-          </el-tab-pane>
-        </el-tabs>
-        <statistics
-          ref="statisticsRef"
-          :details.sync="addForm.detailList"
-          :statisticsType="statisticsType"
-          :produceTaskId="addForm.produceTaskId"
-          :workOrderId="addForm.workOrderId"
-          :routingId="addForm.produceRoutingId"
-          :ruleId="addForm.ruleId"
-        ></statistics>
-      </template> -->
-
       <ele-pro-table
         v-loading="loading"
         ref="table"
@@ -493,20 +478,12 @@
           // ]
         },
         loading: false,
-        currentRow: null,
         butLoading: false,
         checked: false,
         teamUserList: [],
         teamList: [],
         teamAllList: [],
-        workshopAreaList: [],
-        // 1-成品统计,2-物料统计,3-工序统计"
-        statisticsType: '1',
-        statisticsTypeList: [
-          { label: '成品统计', value: '1' },
-          { label: '物料统计', value: '2' },
-          { label: '工序统计', value: '3' }
-        ],
+
         executorList: [],
         allTeamList: [],
         productLineList: []
@@ -662,21 +639,10 @@
           //     : '';
 
           if (this.addForm.executeUsers.length > 0 && !this.addForm.type) {
-            let groupIds = this.addForm.executeUsers
-              .map((i) => i.groupId)
-              .filter(
-                (item, index, arr) => arr.indexOf(item) === index && item
-              );
-
-            if (groupIds.includes('1')) {
-              this.addForm.groupId = '1';
-            } else {
-              this.addForm.groupId =
-                this.addForm.executeUsers[0]?.groupId + '' || '1';
-            }
-
+            this.addForm.groupId = this.addForm.executeUsers[0]?.groupId + '';
+            this.addForm.groupName = this.addForm.executeUsers[0]?.groupName;
             if (this.addForm.groupId) {
-              this.searchDeptNodeClick(this.addForm.groupId);
+              this.searchDeptNodeClick(this.addForm.groupId, 'init');
             }
           }
 
@@ -755,6 +721,8 @@
             }
 
             const body = JSON.parse(JSON.stringify(this.addForm));
+            console.log(body)
+            // return
 
             this.butLoading = true;
 
@@ -856,6 +824,7 @@
         } else {
           this.addForm.executeUsersIds = [];
         }
+        this.changeId()
       },
 
       // 批量检查
@@ -889,7 +858,7 @@
         } catch (error) {}
       },
       //选择部门(搜索)
-      async searchDeptNodeClick(groupId, data) {
+      async searchDeptNodeClick(groupId, type) {
         if (groupId) {
           // 根据部门获取人员
           const params = { groupId: groupId };
@@ -897,6 +866,14 @@
         } else {
           this.addForm.groupId = null;
         }
+        if (type != 'init') {
+          this.addForm.detailList.forEach((detail) => {
+            detail.checkUsersIds = [];
+            detail.checkUsers = [];
+          });
+          this.addForm.executeUsers = [];
+          this.addForm.executeUsersIds = [];
+        }
       },
       // 负责人变更 同步执行人列表
       executeIdListChange() {
@@ -913,7 +890,7 @@
           })
           .filter((i) => i);
         // 同步详情执行人
-        this.addForm.details.forEach((detail) => {
+        this.addForm.detailList.forEach((detail) => {
           detail.checkUsersIds = this.addForm.executeUsersIds;
           detail.checkUsers = this.addForm.executeUsers;
         });