From 54bd2e89b8689e9aa8ab6edcda003da46065cb19 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期日, 04 八月 2024 18:44:55 +0800
Subject: [PATCH] 工单工艺路线编辑

---
 src/views/tigerprojects/mes/eng/route/index.vue |   72 ++++++++++++++++++++++++++++++++----
 1 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/src/views/tigerprojects/mes/eng/route/index.vue b/src/views/tigerprojects/mes/eng/route/index.vue
index f9221a4..c7e85c1 100644
--- a/src/views/tigerprojects/mes/eng/route/index.vue
+++ b/src/views/tigerprojects/mes/eng/route/index.vue
@@ -47,7 +47,12 @@
 <script lang="ts" setup>
   import { FlowChart } from '/@/components/FlowChart';
   import { PageWrapper } from '/@/components/Page';
-  import { SaveRouteData, getRouteData } from '/@/api/tigerapi/mes/router';
+  import {
+    SaveRouteData,
+    SaveWoRouteData,
+    getRouteData,
+    getWoRouteData,
+  } from '/@/api/tigerapi/mes/router';
   import { useModal } from '/@/components/Modal';
   import RouteModal from './RouteModal.vue';
   import { onMounted, ref, unref, Ref, provide, reactive, nextTick, watch } from 'vue';
@@ -94,6 +99,7 @@
     currentAct: {} as MES_ROUTE_NODE_ACT,
     routeData: {} as RouteData,
     activeKey: 1,
+    isWorkOrder: false,
   });
   const currRoute = ref({} as MES_ROUTE);
   const routeData = ref({
@@ -109,14 +115,17 @@
   const entityName = ref<any>('MES_POSITION');
   const props = defineProps({
     rotId: { type: String, default: '' },
+    rotType: { type: String, default: 'Route' },
   });
   const IsOperation = ref(false);
   const title = ref('');
   const posttitle = ref('');
+  let _num = 1;
+  let _numEdge = 1;
   watch(
     () => props.rotId,
     (v) => {
-      if (v !== currRotId.value) {
+      if (!isNullOrEmpty(v) && v !== currRotId.value) {
         currRotId.value = v;
         if (!isNullOrUnDef(unref(currlf))) {
           unref(currlf).render({});
@@ -143,7 +152,11 @@
   async function init(lf) {
     currlf.value = unref(lf);
     //閫氳繃宸ヨ壓璺嚎ID鑾峰彇鍥惧舰鏁版嵁锛屽苟娓叉煋
-    var _data = await getRouteData(currRotId.value);
+    routeConfig.isWorkOrder = props.rotType == 'Wo';
+    var _data =
+      props.rotType == 'Route'
+        ? await getRouteData(currRotId.value)
+        : await getWoRouteData(currRotId.value);
     console.log('缁勪欢宸叉寕杞�', _data);
     //宸ヨ壓璺嚎鍏ㄤ俊鎭紝鍖呮嫭Node銆丒dge鍜孉ct
     routeConfig.routeData = _data.Data;
@@ -172,6 +185,11 @@
     }
   }
 
+  /**
+   * @description: 鑾峰彇宸ヨ壓璺嚎鍥炬暟鎹�
+   * @param {*} lf
+   * @return {*}
+   */
   const GetRotData = (lf) => {
     var currRotData: RouteData = {
       route: {
@@ -190,6 +208,9 @@
         AUTH_ORG: useUserStore().getUserInfo.orgCode,
         AUTH_PROD: '',
         AUTH_WH: '',
+        WORK_ORDER: currRoute.value.WORK_ORDER,
+        PROD_CODE: currRoute.value.PROD_CODE,
+        CUST_CODE: currRoute.value.CUST_CODE,
       },
       nodes: [],
       edges: [],
@@ -197,7 +218,6 @@
     };
     var _nodes = unref(lf).getGraphData().nodes as node[];
     var _edges = unref(lf).getGraphData().edges as edge[];
-    var _num = 1;
     const diffnodes = routeConfig.routeData.nodes.filter((itemA) =>
       _nodes.some((itemB) => itemB.id === itemA.ID),
     );
@@ -243,6 +263,9 @@
               // DO_IF_FAIL: a.DO_IF_FAIL,
               node: {} as node,
               IS_ACTIVE: a.IS_ACTIVE,
+              WORK_ORDER: a.WORK_ORDER,
+              PROD_CODE: a.PROD_CODE,
+              CUST_CODE: a.CUST_CODE,
             };
             var pnode = [n];
             while (pnode[0].properties.operType == 'Action') {
@@ -278,6 +301,7 @@
               GPH_TEXT: n.text.value,
               IS_ACTIVE: nd.IS_ACTIVE,
               IS_CALC_FPY: nd.IS_CALC_FPY,
+              ALLOW_DFT_IN: nd.ALLOW_DFT_IN,
               CAN_SKIP: nd.CAN_SKIP,
               REMARK: nd.REMARK,
               AUTH_ORG: useUserStore().getUserInfo.orgCode,
@@ -292,6 +316,9 @@
               OPTION_4: '',
               OPTION_5: '',
               node: {} as node,
+              WORK_ORDER: nd.WORK_ORDER,
+              PROD_CODE: nd.PROD_CODE,
+              CUST_CODE: nd.CUST_CODE,
             };
             nd.GPH_TYPE = n.type;
             nd.GPH_PROP = JSON.stringify(n.properties);
@@ -340,9 +367,13 @@
         OPTION_4: '',
         OPTION_5: '',
         edge: {} as edge,
+        WORK_ORDER: routeConfig.routeData.route.WORK_ORDER,
+        PROD_CODE: routeConfig.routeData.route.PROD_CODE,
+        CUST_CODE: routeConfig.routeData.route.CUST_CODE,
       };
       routeConfig.routeData.edges.push(edge);
       currRotData.edges.push(edge);
+      _numEdge++;
     });
     return currRotData;
   };
@@ -352,7 +383,10 @@
    */
   async function handleSave(lf) {
     console.log('handleSave', unref(lf).getGraphData().nodes[0]);
-    if (isNullOrEmpty(currRoute.value.ROT_CODE)) {
+    if (
+      isNullOrEmpty(currRoute.value.ROT_CODE) ||
+      (props.rotType == 'Wo' && isNullOrEmpty(currRoute.value.WORK_ORDER))
+    ) {
       createErrorModal({
         title: t('鏈�夋嫨'),
         content: t('鏈�夋嫨宸ヨ壓璺嚎鎴栬�呮柊澧炲伐鑹鸿矾绾�'),
@@ -377,7 +411,10 @@
           getContainer: () => document.body,
         });
       } else {
-        var action = await SaveRouteData(GetRotData(lf));
+        var action =
+          props.rotType == 'Wo'
+            ? await SaveWoRouteData(GetRotData(lf))
+            : await SaveRouteData(GetRotData(lf));
         if (action.IsSuccessed) {
           await refreshPage();
         }
@@ -426,7 +463,7 @@
         UPDATE_TIME: currRoute.value.UPDATE_TIME,
         UPDATE_USER: useUserStore().getUserInfo.userId as string,
         GHOST_ROW: false,
-        NODE_NAME: `${selectnode.value.text.value}_0`,
+        NODE_NAME: `${selectnode.value.text.value}_${_num}`,
         ROT_ID: currRoute.value.ID,
         SEGMENT: '',
         OPER_CODE: selectnode.value.type,
@@ -443,6 +480,7 @@
         AUTH_PROD: '',
         AUTH_WH: '',
         IS_FIRST_NODE: '',
+        ALLOW_DFT_IN: '',
         IS_INPUT: '',
         IS_OUTPUT: '',
         OPTION_1: '',
@@ -451,8 +489,12 @@
         OPTION_4: '',
         OPTION_5: '',
         node: {} as node,
+        WORK_ORDER: currRoute.value.WORK_ORDER,
+        PROD_CODE: currRoute.value.PROD_CODE,
+        CUST_CODE: currRoute.value.CUST_CODE,
       };
       routeConfig.routeData.nodes.push(_node);
+      _num++;
     }
     //鏄涓�
     if (
@@ -475,7 +517,7 @@
           AUTH_ORG: useUserStore().getUserInfo.orgCode,
           AUTH_PROD: '',
           AUTH_WH: '',
-          ACT_NAME: `${selectnode.value.text.value}_0`,
+          ACT_NAME: `${selectnode.value.text.value}_${_numEdge}`,
           ACT_CODE: '',
           ROT_ID: currRoute.value.ID,
           NODE_ID: '',
@@ -499,8 +541,12 @@
           OPTION_5: '',
           REMARK: '',
           node: {} as node,
+          WORK_ORDER: currRoute.value.WORK_ORDER,
+          PROD_CODE: currRoute.value.PROD_CODE,
+          CUST_CODE: currRoute.value.CUST_CODE,
         };
         routeConfig.routeData.acts.push(_act);
+        _numEdge++;
       }
       routeConfig.currentAct = {
         ID: selectnode.value.id,
@@ -536,6 +582,9 @@
         OPTION_5: '',
         REMARK: '',
         node: {} as node,
+        WORK_ORDER: currRoute.value.WORK_ORDER,
+        PROD_CODE: currRoute.value.PROD_CODE,
+        CUST_CODE: currRoute.value.CUST_CODE,
       };
       const actModel = lf.getNodeModelById(selectnode.value.id);
       actModel.updateText(routeConfig.currentAct?.ACT_NAME);
@@ -565,13 +614,20 @@
         IS_CALC_FPY: _node.IS_CALC_FPY,
         CAN_SKIP: _node.CAN_SKIP,
         IS_INPUT: _node.IS_INPUT,
+        ALLOW_DFT_IN: _node.ALLOW_DFT_IN,
         IS_OUTPUT: _node.IS_OUTPUT,
         REMARK: _node.REMARK,
+        WORK_ORDER: currRoute.value.WORK_ORDER,
+        PROD_CODE: currRoute.value.PROD_CODE,
+        CUST_CODE: currRoute.value.CUST_CODE,
+        node: {} as node,
       };
       const nodeModel = lf.getNodeModelById(selectnode.value.id);
       nodeModel.updateText(_node.NODE_NAME);
       routeConfig.isCalcFpy = _node.IS_CALC_FPY == 'Y';
       routeConfig.canSkip = _node.CAN_SKIP == 'Y';
+      routeConfig.isActive = _node.IS_ACTIVE == 'Y';
+      routeConfig.allowDftIn = _node.ALLOW_DFT_IN == 'Y';
       routeConfig.isInput = _node.IS_INPUT == 'Y';
       routeConfig.isOutput = _node.IS_OUTPUT == 'Y';
       setTimeout(() => {

--
Gitblit v1.9.3