Просмотр исходного кода

feat(维护管理): 新增班组类型支持并优化执行人选择逻辑

liujt 6 месяцев назад
Родитель
Сommit
ecf6b8bf40

+ 12 - 0
src/api/maintenance/patrol_maintenance.js

@@ -144,3 +144,15 @@ export async function getSpareParts(params) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 列表
+export async function getteampage(data) {
+    const res = await request.get(`/main/team/page`, {
+        params: data
+    });
+    console.log(res.data.code == 0)
+    if (res.data.code == 0) {
+        return res.data.data;
+    }
+    return Promise.reject(new Error(res.data.message));
+}

+ 178 - 13
src/views/maintenance/components/programRulesDialog.vue

@@ -37,17 +37,63 @@
           </el-form-item>
         </el-col>
 
-        <el-col :span="8" v-if="addForm.autoOrder && !dialogTitle.includes('量具送检')">
+        <el-col :span="8" v-if="!dialogTitle.includes('量具送检')">
+          <el-form-item label="类型" prop="executeUserType">
+            <el-select v-model="addForm.executeUserType" :disabled="isBindPlan" size="small" @change="typeChange" style="width: 100%">
+              <el-option :value="1" label="班组"></el-option>
+              <el-option :value="0" label="个人"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8" v-if="dispatchStatus && addForm.executeUserType == 1 && !dialogTitle.includes('量具送检')">
+          <el-form-item label="班组" prop="teamId">
+            <el-select
+              v-model="addForm.teamId"
+              :disabled="isBindPlan"
+              size="small"
+              @change="teamChange"
+              style="width: 100%"
+            >
+              <el-option
+                :value="i.id"
+                :label="i.name"
+                v-for="i in teamAllList"
+                :key="i.id"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8" v-if="dispatchStatus && addForm.executeUserType == 0 && !dialogTitle.includes('量具送检')">
           <el-form-item label="部门" prop="groupId">
             <deptSelect v-model="addForm.groupId" @changeGroup="searchDeptNodeClick" :disabled="isBindPlan" />
           </el-form-item>
         </el-col>
-        <el-col :span="8" v-if="addForm.autoOrder && !dialogTitle.includes('量具送检')">
-          <el-form-item label="负责人" prop="executorId">
+        <el-col :span="8" v-if="dispatchStatus && addForm.executeUserType == 0 && !dialogTitle.includes('量具送检')">
+          <!-- <el-form-item label="负责人" prop="executorId">
             <el-select v-model="addForm.executorId" size="small" style="width: 100%" :disabled="isBindPlan" multiple
               filterable>
               <el-option v-for="item in executorList" :key="item.id" :value="item.id" :label="item.name"></el-option>
             </el-select>
+          </el-form-item> -->
+          <el-form-item label="负责人" prop="executeIdList">
+            <el-select
+              v-model="addForm.executeIdList"
+              :disabled="isBindPlan"
+              size="small"
+              style="width: 100%"
+              multiple
+              filterable
+              @change="executeIdListChange"
+            >
+              <el-option
+                v-for="item in executorList"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+              ></el-option>
+            </el-select>
           </el-form-item>
         </el-col>
         <el-col :span="8" v-if="!dialogTitle.includes('量具送检')">
@@ -260,7 +306,7 @@ import {
   getAssetList,
   getInfoById
 } from '@/api/ruleManagement/plan';
-import { saveOrUpdate } from '@/api/maintenance/patrol_maintenance';
+import { saveOrUpdate, getteampage } from '@/api/maintenance/patrol_maintenance';
 import { getUserPage } from '@/api/system/organization';
 import { getTreeByType } from '@/api/classifyManage';
 import MaterialAdd from './MaterialAdd.vue';
@@ -298,7 +344,7 @@ export default {
       brandNum: '',
       specification: '',
       measuringUnit: '',
-
+      type: 0,
       bomList: []
     };
     return {
@@ -329,7 +375,21 @@ export default {
         executorPhone: '',
         status: 1, // 状态
         remark: '', // 备注
-        urgent: '1'
+        urgent: '1',
+        executeIdList: [],
+        executeUsers: [
+          // {
+          //   groupId: 0,
+          //   groupName: '',
+          //   teamId: 0,
+          //   teamName: '',
+          //   userId: 0,
+          //   userName: ''
+          // }
+        ],
+        teamId: '',
+        type: 0,
+        executeUserType: 0,
       },
       ruleNameList: [], // 规则列表
       uerList: [], // 审核人列表
@@ -368,9 +428,15 @@ export default {
         executorId: [
           { required: true, message: '请选择巡点检人员', trigger: 'change' }
         ],
+        executeIdList: [
+          { required: true, message: '请选择人员', trigger: 'change' }
+        ],
         urgent: [
           { required: true, message: '请选择紧急程度', trigger: 'change' }
-        ]
+        ],
+        teamId: [
+          { required: true, message: '请选择班组', trigger: 'change' }
+        ],
       },
 
       columns: [
@@ -461,13 +527,18 @@ export default {
       tabsValue: null,
 
       hasCategoryId: false,
-      getByIdData: {}
+      getByIdData: {},
+      teamAllList: [],
+      model: ''
     };
   },
   computed: {
     // 是否开启响应式布局
     styleResponsive() {
       return this.$store.state.theme.styleResponsive;
+    },
+    dispatchStatus() {
+      return ((this.addForm.autoOrder && (this.model == 'add' || this.model == 'edit')) || (((!this.addForm.autoOrder && this.addForm.planStatus == 0) || (this.addForm.autoOrder &&this.addForm.planStatus == 4)) && this.model == 'dispatch'))
     }
   },
   watch: {
@@ -477,6 +548,8 @@ export default {
         this.getUserList();
         // 获取规则名称
         this._getRuleNameList();
+        // 获取所有班组
+        this.getAllTeamList();
       }
     }
   },
@@ -485,9 +558,11 @@ export default {
       this.visible = false;
     },
     // 初始化
-    async init(row, tips) {
+    async init(type, row, tips) {
       console.log(row);
       console.log(tips);
+      console.log(type);
+      this.model = type;
       this.visible = true;
       if (row) {
         this.getInfo(row.id, tips);
@@ -508,7 +583,21 @@ export default {
           executorPhone: '',
           status: 1, // 状态
           remark: '', // 备注
-          urgent: '1'
+          urgent: '1',
+          type: 0,
+          teamId: '',
+          executeIdList: [], // 负责人id
+          executeUserType: 0, // 执行人类型 0:部门 1:班组 0:个人
+          executeUsers: [
+          // {
+          //   groupId: 0,
+          //   groupName: '',
+          //   teamId: 0,
+          //   teamName: '',
+          //   userId: 0,
+          //   userName: ''
+          // }
+        ],
         };
         this.ruleIdList = [];
         this.isBindPlan = false;
@@ -542,10 +631,50 @@ export default {
       // };
       // this.addForm.planType = planRuleTypeObj[this.formLabel];
     },
+    // 负责人变更 同步执行人列表
+    executeIdListChange() {
+      this.addForm.executeUsers = this.addForm.executeIdList.map((userId) => {
+        const user = this.executorList.find((u) => u.id === userId);
+        return {
+          userId: user.id,
+          userName: user.name,
+
+          groupId: user.groupId,
+          groupName: user.groupName
+        };
+      });
+      console.log('this.addForm.executeUsers', this.addForm.executeUsers);
+    },
+    async getAllTeamList() {
+      const { list } = await getteampage({
+        pageNum: 1,
+        size: -1
+      });
+      console.log('teamAllList 班组', list);
+      this.teamAllList = list;
+    },
+    teamChange(v) {
+      console.log('teamChange', v);
+      this.$set(this.addForm, 'teamId', v);
+      // 当前班组
+      const currentTeam = this.teamAllList.find(
+        (item) => item.id === this.addForm.teamId
+      );
+      if (currentTeam) {
+        // 同步执行人
+        this.addForm.executeUsers = [
+          {
+            teamId: currentTeam.id,
+            teamName: currentTeam.name
+          }
+        ];
+      }
+    },
     autoOrderChange(val) {
       if (val == 0) {
         this.addForm.executorId = [];
         this.addForm.groupId = '';
+        this.addForm.executeIdList = '';
       }
     },
     ruleChange(item) {
@@ -557,7 +686,7 @@ export default {
       console.log(this.ruleIdList);
       if (this.ruleIdList && this.ruleIdList.length > 0) {
         this.$refs.addFormRef.validate(async (valid) => {
-          console.log(valid);
+          // console.log(valid);
           if (valid) {
             const planDeviceList = this.ruleIdList.map((ruleItem) => {
               return ruleItem.equipmentList.map((item) => {
@@ -586,6 +715,7 @@ export default {
             let sendMsg = this.ruleIdList.map((item, index) => {
               return {
                 ...this.addForm,
+                autoOrder: this.model == 'dispatch' ? 1 : this.addForm.autoOrder,
                 ruleId: item.ruleId,
                 categoryId: item.categoryId,
                 planDeviceList: planDeviceList[index],
@@ -697,6 +827,34 @@ export default {
           }
         ];
         console.log(this.ruleIdList);
+
+        // 处理回显数据
+        if (this.addForm.executeUserType === 0) {
+          // 个人
+          this.addForm.executeIdList = this.addForm.executeUsers.map(
+            (item) => item.userId
+          );
+
+          let groupIds = this.addForm.executeUsers
+            .map((i) => i.groupId)
+            .filter((i) => i);
+          groupIds = Array.from(new Set(groupIds));
+
+          if (groupIds.includes('1')) {
+            // 包含全部部门,置空
+            this.addForm.groupId = '1';
+          } else {
+            this.addForm.groupId = this.addForm.executeUsers[0]?.groupId || '1';
+          }
+
+          groupIds.map((item) => {
+            this.searchDeptNodeClick(item);
+          });
+        } else {
+          // 班组
+          this.addForm.teamId = this.addForm.executeUsers?.[0]?.teamId || '';
+        }
+
         this.tabsValue = this.ruleIdList[0].ruleId;
 
         // this._getMatterRulesDetails(res.ruleId);
@@ -704,11 +862,12 @@ export default {
         this.$set(this.addForm, 'urgent', JSON.stringify(res.data.urgent));
         this.$set(this.addForm, 'executorId', res.data.executorId.split(',').filter((i) => i));
         this.$set(this.addForm, 'imageUrl', {});
-        console.log(this.rootData);
+        // console.log(this.rootData);
         if(res.data.groupId){
-        this.getUserList({ groupId: res.data.groupId });
+          this.getUserList({ groupId: res.data.groupId });
 
         }
+        console.log('addForm~~~~', this.addForm);
         // const rep = await getTreeByType(0);
         // console.log('sasas', res);
         // const ids = this.findTopLevelAncestorId(
@@ -729,6 +888,12 @@ export default {
         console.log(error);
       }
     },
+    typeChange() {
+      this.addForm.groupId = '';
+      this.addForm.executeIdList = [];
+      this.addForm.teamId = '';
+      this.addForm.executorId = [];
+    },
     // 获取设备分类数据
     async categoryEquipment(id) {
       const params = { categoryLevelId: id, pageNum: 1, size: -1 };

+ 3 - 3
src/views/maintenance/delivery/plan/index.vue

@@ -17,7 +17,7 @@
             type="primary"
             icon="el-icon-plus"
             class="ele-btn-icon"
-            @click="openAdd('新增量具送检计划配置')"
+            @click="openAdd('add', '新增量具送检计划配置')"
           >
             新建抽检计划
           </el-button>
@@ -290,13 +290,13 @@
       // openAdd(dialogTitle, row) {
       //   this.$refs.addPatrolPlanDialogRef.open(dialogTitle, row);
       // },
-      openAdd(dialogTitle, row) {
+      openAdd(type, dialogTitle, row) {
         // this.$refs.addPatrolPlanDialogRef.open(dialogTitle, row);
         this.isBindPlan = false;
         this.addProgramRulesDialog = true;
         this.dialogTitle = dialogTitle;
         this.$nextTick(() => {
-          this.$refs.programRulesDialog.init(row, '量具送检');
+          this.$refs.programRulesDialog.init(type,row, '量具送检');
         });
       },
       // openDispatch(row) {

+ 5 - 5
src/views/maintenance/equipment/plan/index.vue

@@ -17,7 +17,7 @@
             type="primary"
             icon="el-icon-plus"
             class="ele-btn-icon"
-            @click="openAdd('新增保养计划配置')"
+            @click="openAdd('add', '新增保养计划配置')"
           >
             新建临时计划
           </el-button>
@@ -50,7 +50,7 @@
             type="primary"
             :underline="false"
             icon="el-icon-edit"
-            @click="openAdd('编辑保养计划配置', row)"
+            @click="openAdd('edit', '编辑保养计划配置', row)"
           >
             编辑
           </el-link>
@@ -60,7 +60,7 @@
             "
             type="primary"
             :underline="false"
-            @click="openAdd('派单', row)"
+            @click="openAdd('dispatch', '派单', row)"
           >
             派单
           </el-link>
@@ -264,13 +264,13 @@
       // openAdd(dialogTitle, row) {
       //   this.$refs.addPatrolPlanDialogRef.open(dialogTitle, row);
       // },
-      openAdd(dialogTitle, row) {
+      openAdd(type,dialogTitle, row) {
         // this.$refs.addPatrolPlanDialogRef.open(dialogTitle, row);
         this.isBindPlan = false;
         this.addProgramRulesDialog = true;
         this.dialogTitle = dialogTitle;
         this.$nextTick(() => {
-          this.$refs.programRulesDialog.init(row, '保养');
+          this.$refs.programRulesDialog.init(type, row, '保养');
         });
       },
       // openDispatch(row) {

+ 27 - 2
src/views/maintenance/equipment/workOrder/index.vue

@@ -154,13 +154,38 @@
             label: '保养部门',
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 120
+            minWidth: 120,
+            formatter: (row) => {
+              if (row.type == 0) {
+                return row.executeUsers.map((i) => i.groupName).join(',');
+              }
+              return '';
+            }
           },
           {
             prop: 'executeUserName',
             label: '保养人员',
             align: 'center',
-            showOverflowTooltip: true
+            showOverflowTooltip: true,
+            formatter: (row) => {
+              if (row.type == 0) {
+                return row.executeUsers.map((i) => i.userName).join(',');
+              }
+              return '';
+            }
+          },
+          {
+            prop: 'executeUsers',
+            label: '班组',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (row) => {
+              if (row.type == 1) {
+                return row.executeUsers.map((i) => i.teamName).join(',');
+              }
+              return '';
+            }
           },
           {
             prop: 'ruleName',

+ 5 - 5
src/views/maintenance/patrol/plan/index.vue

@@ -17,7 +17,7 @@
             type="primary"
             icon="el-icon-plus"
             class="ele-btn-icon"
-            @click="openAdd('新增巡点检计划配置')"
+            @click="openAdd('add', '新增巡点检计划配置')"
           >
             新建临时计划
           </el-button>
@@ -46,7 +46,7 @@
             v-if="row.planStatus == 4 || row.planStatus == 0
             "
             icon="el-icon-edit"
-            @click="openAdd('编辑巡点检计划配置', row)"
+            @click="openAdd('edit', '编辑巡点检计划配置', row)"
           >
             编辑
           </el-link>
@@ -56,7 +56,7 @@
             type="primary"
             :underline="false"
             icon="el-icon-edit"
-            @click="openAdd('派单', row)"
+            @click="openAdd('dispatch', '派单', row)"
           >
             派单
           </el-link>
@@ -254,13 +254,13 @@
         });
       },
 
-      openAdd(dialogTitle, row) {
+      openAdd(type, dialogTitle, row) {
         // this.$refs.addPatrolPlanDialogRef.open(dialogTitle, row);
         this.isBindPlan = false;
         this.addProgramRulesDialog = true;
         this.dialogTitle = dialogTitle;
         this.$nextTick(() => {
-          this.$refs.programRulesDialog.init(row, '巡点检');
+          this.$refs.programRulesDialog.init(type, row, '巡点检');
         });
       },
       goDetail({ id }) {

+ 27 - 2
src/views/maintenance/patrol/workOrder/index.vue

@@ -126,13 +126,38 @@
             label: '巡点检部门',
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 120
+            minWidth: 120,
+            formatter: (row) => {
+              if (row.type == 0) {
+                return row.executeUsers.map((i) => i.groupName).join(',');
+              }
+              return '';
+            }
           },
           {
             prop: 'executeUserName',
             label: '巡点检人员',
             align: 'center',
-            showOverflowTooltip: true
+            showOverflowTooltip: true,
+            formatter: (row) => {
+              if (row.type == 0) {
+                return row.executeUsers.map((i) => i.userName).join(',');
+              }
+              return '';
+            }
+          },
+          {
+            prop: 'executeUsers',
+            label: '班组',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (row) => {
+              if (row.type == 1) {
+                return row.executeUsers.map((i) => i.teamName).join(',');
+              }
+              return '';
+            }
           },
           {
             prop: 'ruleName',