Procházet zdrojové kódy

修改布点的bug

695593266@qq.com před 2 měsíci
rodič
revize
cc477c14a2

+ 25 - 19
src/views/produceOrder/components/details/dotLineDetail.vue

@@ -14,7 +14,6 @@
         >
           <span
             class="route-node"
-            :class="{ 'route-node--done': isDotLineTaskDone(item) }"
           >
             {{ getDotLineTaskName(item, index) }}
           </span>
@@ -103,7 +102,9 @@
     data() {
       return {
         dotLineTaskList: [],
-        hasDotLineDetail: false
+        hasDotLineDetail: false,
+        lastLoadTriggerKey: '',
+        currentLoadRequestId: 0
       };
     },
 
@@ -114,10 +115,15 @@
     },
 
     watch: {
-      'workOrderInfo.productionPlanId': {
+      workOrderInfo: {
         immediate: true,
         handler() {
-          this.loadDotLineData();
+          this.triggerLoadDotLineData();
+        }
+      },
+      'workOrderInfo.productionPlanId': {
+        handler() {
+          this.triggerLoadDotLineData();
         }
       }
     },
@@ -145,25 +151,29 @@
         );
       },
 
-      isDotLineTaskDone(item) {
-        const status = Number(item.status ?? item.flag ?? item.taskStatus);
-        return (
-          [3, 4, 5, 6, 9].includes(status) ||
-          !!item.executionEndTime ||
-          !!item.completeTime ||
-          Number(item.finished) === 1
-        );
+      triggerLoadDotLineData() {
+        const workOrderId = this.workOrderInfo?.id ?? '';
+        const productionPlanId = this.workOrderInfo?.productionPlanId ?? '';
+        const triggerKey = `${workOrderId}-${productionPlanId}`;
+        if (triggerKey === this.lastLoadTriggerKey) {
+          return;
+        }
+        this.lastLoadTriggerKey = triggerKey;
+        this.loadDotLineData();
       },
 
       async loadDotLineData() {
-        if (!this.workOrderInfo.productionPlanId) {
+        const productionPlanId = this.workOrderInfo?.productionPlanId;
+        if (!productionPlanId) {
           this.resetDotLineState();
           return;
         }
+        const requestId = ++this.currentLoadRequestId;
         try {
           const planData = await getPlanDotLine({
-            planId: this.workOrderInfo.productionPlanId
+            planId: productionPlanId
           });
+          if (requestId !== this.currentLoadRequestId) return;
           const details = planData?.detailList;
           if (!Array.isArray(details) || details.length === 0) {
             this.resetDotLineState();
@@ -270,7 +280,7 @@
     border-radius: 4px;
     padding: 2px 10px;
     color: #fff;
-    background: #909399;
+    background: #67c23a;
     font-size: clamp(10px, 2.6vw, 12px);
     font-weight: 600;
     line-height: 1.2;
@@ -280,10 +290,6 @@
     text-align: center;
   }
 
-  .route-node--done {
-    background: #56bf1d;
-  }
-
   .route-arrow {
     flex: 1 1 0;
     display: flex;

+ 3 - 2
src/views/produceOrder/components/releaseDialog/planDotLineReleaseDialog.vue

@@ -636,6 +636,7 @@
             });
           }
           // 如果没有首工序的数据 就不能选择工序任务派单
+          console.log(res, 'resresresres');
           if (!res || res.length === 0) {
             this.processList = [];
             // this.form.taskAss = 1;
@@ -647,7 +648,7 @@
           let list = [];
           res.forEach((item, index) => {
             let obj = {
-              id: item.taskId, //工序 id
+              id: item.sourceTaskId, //工序 id
               name: item.taskName, //工序 名称
               executionTeamName: item.executionTeamName || '', // 工序执行班组
               assignType: 1, // 默认的指派数据
@@ -677,7 +678,7 @@
             list.push(obj);
           });
           this.processList = list;
-          this.processId = list[0].id;
+          this.processId = res[0].sourceTaskId;
           // this.handleClick({ name: res[0].sourceTaskId });
           this.initializeQuery();
         } catch (err) {

+ 181 - 22
src/views/produceOrder/workReport.vue

@@ -299,6 +299,7 @@
   import addPlease from '@/views/produce/components/outsourcing/addPlease.vue';
   import qualityInspection from '@/views/produce/components/qualityInspection/index.vue';
   import { checkProductionResult } from '@/api/producetaskrulerecord/index.js';
+  import { getPlanDotLine } from '@/api/produceOrder/index.js';
 
   export default {
     components: {
@@ -392,7 +393,8 @@
         workPlanType: '',
         isPleaseEntrust: false,
         workInfoList: {},
-        drawerKey: 0
+        drawerKey: 0,
+        planDotLineEnabled: false
       };
     },
 
@@ -413,6 +415,7 @@
 
       this.getTaskList();
       this.getFactoryworkstationPageList();
+      this.getPlanDotLineConfig();
 
       this.operationType = null;
       this.workListIds = [];
@@ -422,6 +425,144 @@
         this.name = '';
         this.seekInput();
       },
+
+      async getPlanDotLineConfig() {
+        try {
+          const res = await parameterGetByCode({
+            code: 'plan_dot_line'
+          });
+          this.planDotLineEnabled = !!res && res.value == '1';
+        } catch (error) {
+          this.planDotLineEnabled = false;
+          console.error('getPlanDotLineConfig error', error);
+        }
+      },
+      async syncPlanDotLineRouteList() {
+        if (!this.planDotLineEnabled) {
+          return;
+        }
+        const productionPlanId = this.workOrderInfo?.productionPlanId;
+        if (!productionPlanId) {
+          return;
+        }
+        if (!Array.isArray(this.routeList) || this.routeList.length === 0) {
+          return;
+        }
+        try {
+          const res = await getPlanDotLine({
+            planId: productionPlanId
+          });
+          const detailList = Array.isArray(res?.detailList)
+            ? res.detailList
+            : [];
+          if (!detailList.length) {
+            return;
+          }
+
+          console.log(detailList, 'detailList');
+          const detailMap = detailList.reduce((map, item) => {
+            const taskId = item?.taskId;
+            if (taskId !== undefined && taskId !== null && taskId !== '') {
+              map.set(String(taskId), item);
+            }
+            return map;
+          }, new Map());
+          this.routeList = this.routeList.map((item) => {
+            const taskId = item?.taskId;
+            if (taskId === undefined || taskId === null || taskId === '') {
+              return item;
+            }
+            const detail = detailMap.get(String(taskId));
+
+            if (!detail) {
+              return item;
+            }
+            return {
+              ...item,
+              executionTeamName: detail.executionTeamName ?? '',
+              executionTeamId: detail.executionTeamId ?? ''
+            };
+          });
+          console.log(this.routeList, 'thisnewewewewrouteList');
+        } catch (error) {
+          console.error('syncPlanDotLineRouteList error', error);
+        }
+      },
+      getUserTeamIds() {
+        const teamId = this.$store?.state?.user?.info?.teamId;
+        if (Array.isArray(teamId)) {
+          return teamId
+            .map((item) => String(item).trim())
+            .filter((item) => item);
+        }
+        if (typeof teamId !== 'string' || !teamId) {
+          return [];
+        }
+        return teamId
+          .split(',')
+          .map((item) => item.trim())
+          .filter((item) => item);
+      },
+      getCurrentRouteItem() {
+        if (
+          this.curTaskObj?.taskId !== undefined &&
+          this.curTaskObj?.taskId !== null
+        ) {
+          return this.curTaskObj;
+        }
+        if (!Array.isArray(this.routeList) || this.routeList.length === 0) {
+          return null;
+        }
+        const currentTaskId =
+          this.taskId ??
+          this.workOrderInfo?.taskId ??
+          this.routeList[this.desIndex]?.taskId;
+        if (
+          currentTaskId === undefined ||
+          currentTaskId === null ||
+          currentTaskId === ''
+        ) {
+          return this.routeList[this.desIndex] || null;
+        }
+        return (
+          this.routeList.find(
+            (item) => String(item?.taskId) === String(currentTaskId)
+          ) ||
+          this.routeList[this.desIndex] ||
+          null
+        );
+      },
+      checkCurrentTaskTeamPermission(actionName) {
+        const deny = (message) => {
+          this.operationType = null;
+          this.$message.warning(message);
+          return false;
+        };
+        const currentTask = this.getCurrentRouteItem();
+        if (!currentTask) {
+          return deny(`未获取到当前工序,不能${actionName}`);
+        }
+        const executionTeamId = currentTask.executionTeamId;
+        if (
+          executionTeamId === undefined ||
+          executionTeamId === null ||
+          executionTeamId === ''
+        ) {
+          return deny(`当前工序未配置执行班组,不能${actionName}`);
+        }
+        const teamIds = this.getUserTeamIds();
+        if (!teamIds.length) {
+          return deny(`当前用户未配置班组,不能${actionName}`);
+        }
+        const executionTeamIdStr = String(executionTeamId).trim();
+        if (!executionTeamIdStr) {
+          return deny(`当前工序未配置执行班组,不能${actionName}`);
+        }
+        if (!teamIds.includes(executionTeamIdStr)) {
+          return deny(`当前用户班组无权限${actionName}`);
+        }
+        return true;
+      },
       // 前端筛选
       seekInput() {
         // console.log(activeName);
@@ -582,6 +723,7 @@
         this.workOrderInfo = row;
         this.routeObj.id = this.workOrderInfo.id;
         this.operationType = '';
+        await this.getPlanDotLineConfig();
         // this.getTaskFn();
         this.drawer = true;
         // this.getOrderData();
@@ -621,31 +763,42 @@
       },
 
       async getTaskFn() {
-        await getTaskInstanceList(this.workOrderInfo.id).then((res) => {
-          this.routeList = res;
+        const res = await getTaskInstanceList(this.workOrderInfo.id);
+        this.routeList = Array.isArray(res) ? res : [];
 
-          console.log(this.routeList, 'routeList');
-          console.log(this.workOrderInfo, 'this.workOrderInfo');
+        console.log(this.routeList, 'routeList');
+        console.log(this.workOrderInfo, 'this.workOrderInfo');
 
-          // 使用findIndex方法查找
-          const index = this.routeList.findIndex(
-            (item) => item.taskId == this.workOrderInfo.taskId
-          );
+        if (!this.routeList.length) {
+          this.desIndex = 0;
+          this.activeIndex = 0;
+          this.newId = '';
+          this.workData = this.workOrderInfo;
+          return;
+        }
 
-          this.desIndex = index;
-          console.log(this.routeList, '888888');
-          this.newId = this.routeList[this.desIndex].taskId || '';
+        await this.syncPlanDotLineRouteList();
 
-          if (this.workOrderInfo.taskId != -2) {
-            this.curTaskObj = JSON.parse(JSON.stringify(this.routeObj));
-          } else {
-            this.curTaskObj = JSON.parse(JSON.stringify(this.routeList[0]));
-            this.desIndex = 0;
-          }
-          this.activeIndex = index;
-          this.workData = this.workOrderInfo;
-          this.handIdx(this.activeIndex, this.routeList[index]);
-        });
+        const index = this.routeList.findIndex(
+          (item) => item.taskId == this.workOrderInfo.taskId
+        );
+        const currentIndex = index > -1 ? index : 0;
+
+        this.desIndex = currentIndex;
+        console.log(this.routeList, '888888');
+        this.newId = this.routeList[currentIndex]?.taskId || '';
+
+        if (this.workOrderInfo.taskId != -2) {
+          this.curTaskObj = JSON.parse(JSON.stringify(this.routeObj));
+        } else {
+          this.curTaskObj = JSON.parse(JSON.stringify(this.routeList[0] || {}));
+          this.desIndex = 0;
+        }
+        this.activeIndex = currentIndex;
+        this.workData = this.workOrderInfo;
+        if (this.routeList[currentIndex]) {
+          this.handIdx(this.activeIndex, this.routeList[currentIndex]);
+        }
       },
 
       async getCodeData(req) {
@@ -715,6 +868,12 @@
             this.$message.warning('请选择工单列表');
             return false;
           }
+          if ((t === 'feed' || t === 'job') && this.planDotLineEnabled) {
+            const actionName = t === 'feed' ? '投料' : '报工';
+            if (!this.checkCurrentTaskTeamPermission(actionName)) {
+              return false;
+            }
+          }
         }
 
         // console.log('按钮被点击了.....', t);