From cc5dd2f9edbe437356067fe125f1ed0cf5fd2b3a Mon Sep 17 00:00:00 2001
From: Cloud Zhang <941187371@qq.com>
Date: 星期三, 22 五月 2024 15:25:11 +0800
Subject: [PATCH] 优化

---
 src/views/tigerprojects/mes/eng/route/index.vue |  845 +++++++++++++++++++++++++------------------------------
 1 files changed, 388 insertions(+), 457 deletions(-)

diff --git a/src/views/tigerprojects/mes/eng/route/index.vue b/src/views/tigerprojects/mes/eng/route/index.vue
index 624facf..f0c3508 100644
--- a/src/views/tigerprojects/mes/eng/route/index.vue
+++ b/src/views/tigerprojects/mes/eng/route/index.vue
@@ -3,11 +3,12 @@
     <Layout class="h-full">
       <LayoutContent :style="{ overflow: 'initial' }">
         <FlowChart
-          :data="demoData"
+          :data="routeData"
           @save-data="handleSave"
           @add-lf="handleAddlf"
           @select-node="handleSelect"
           @click-blank="clickBlank"
+          @init="init"
         />
       </LayoutContent>
       <LayoutSider
@@ -37,10 +38,10 @@
 <script lang="ts" setup>
   import { FlowChart } from '/@/components/FlowChart';
   import { PageWrapper } from '/@/components/Page';
-  import { SaveRouteData } from '/@/api/tigerapi/mes/router';
+  import { SaveRouteData, getRouteData } from '/@/api/tigerapi/mes/router';
   import { useModal } from '/@/components/Modal';
   import RouteModal from './RouteModal.vue';
-  import { ref, unref, Ref, provide, reactive } from 'vue';
+  import { onMounted, ref, unref, Ref, provide, reactive, nextTick } from 'vue';
   import { Layout, LayoutContent, LayoutSider } from 'ant-design-vue';
   import {
     RouteData,
@@ -52,18 +53,21 @@
     MES_ROUTE,
   } from '/@/api/tigerapi/model/router';
   import { useUserStore } from '/@/store/modules/user';
-  import { buildUUID } from '/@/utils/uuid';
   import RouteDrawer from './RouteDrawer.vue';
   import { useDrawer } from '/@/components/Drawer';
   import PropsPanel from './components/PropsPanel.vue';
   import { IRouteConfig } from './typings/v-form-component';
   import { useMessage } from '/@/hooks/web/useMessage';
   import { useI18n } from '/@/hooks/web/useI18n';
-  import { isNullOrEmpty } from '/@/utils/is';
+  import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
+  import { useRoute } from 'vue-router';
+  import { useTabs } from '/@/hooks/web/useTabs';
 
   const [registerDrawer, { openDrawer }] = useDrawer();
   const [registerModal, { openModal }] = useModal();
   const { t } = useI18n();
+  const route = useRoute();
+  const { setTitle } = useTabs();
   const { notification, createErrorModal } = useMessage();
   const routeConfig = reactive({
     // 琛ㄥ崟閰嶇疆
@@ -74,306 +78,226 @@
     labelCol: {},
     wrapperCol: {},
     currentItem: {} as MES_ROUTE_NODE,
+    currentAct: {} as MES_ROUTE_NODE_ACT,
+    routeData: {} as RouteData,
     activeKey: 1,
   } as IRouteConfig);
   const currRoute = ref({} as MES_ROUTE);
-  // const schemas: FormSchema[] = [
-  //   {
-  //     field: 'func_type',
-  //     label: '灞炴�ч〉',
-  //     component: 'RadioButtonGroup',
-  //     defaultValue: '0',
-  //     componentProps: {
-  //       options: [
-  //         { label: '宸ヨ壓娴佺▼', value: '0' },
-  //         { label: '宸ュ簭', value: '1' },
-  //       ],
-  //     },
-  //     colProps: { lg: 24, md: 24 },
-  //   },
-  //   {
-  //     field: 'OPER_CODE',
-  //     component: 'ApiSelect',
-  //     label: '閫夋嫨宸ュ簭',
-  //     componentProps: {
-  //       api: getOperAllList,
-  //       // params: {
-  //       //   id: 1,
-  //       // },
-  //       resultField: 'items',
-  //       labelField: 'OPER_NAME',
-  //       valueField: 'OPER_CODE',
-  //       // not request untill to select
-  //       immediate: false,
-  //       onChange: (e) => {
-  //         console.log('selected:', e);
-  //       },
-  //       // atfer request callback
-  //       onOptionsChange: (options) => {
-  //         console.log('get options', options.length, options);
-  //       },
-  //     },
-  //     ifShow: ({ values }) => isOper(values.func_type),
-  //   },
-  //   {
-  //     field: 'field2',
-  //     component: 'Input',
-  //     label: '宸ュ簭绫诲瀷',
-  //     // componentProps:{},
-  //     // can func
-  //     componentProps: ({ schema, formModel }) => {
-  //       console.log('form:', schema);
-  //       console.log('formModel:', formModel);
-  //       return {
-  //         placeholder: '娴嬭瘯',
-  //         onChange: (e: any) => {
-  //           console.log(e);
-  //         },
-  //       };
-  //     },
-  //     renderComponentContent: () => {
-  //       return {
-  //         prefix: () => '宸ュ簭',
-  //         suffix: () => '绫诲瀷',
-  //       };
-  //     },
-  //     ifShow: ({ values }) => isOper(values.func_type),
-  //   },
-  //   {
-  //     field: 'field3',
-  //     component: 'Select',
-  //     label: '宸ュ簭琛屼负',
-  //     componentProps: {
-  //       options: [
-  //         {
-  //           label: '瀛樺偍杩囩▼',
-  //           value: '1',
-  //           key: '1',
-  //         },
-  //         {
-  //           label: '鏉$爜瑙勫垯',
-  //           value: '2',
-  //           key: '2',
-  //         },
-  //         {
-  //           label: '琛屼负涓�',
-  //           value: '3',
-  //           key: '3',
-  //         },
-  //         {
-  //           label: '琛屼负浜�',
-  //           value: '4',
-  //           key: '4',
-  //         },
-  //         {
-  //           label: '琛屼负涓�',
-  //           value: '5',
-  //           key: '5',
-  //         },
-  //       ],
-  //     },
-  //     ifShow: ({ values }) => isOper(values.func_type),
-  //   },
-  //   {
-  //     field: 'field4',
-  //     component: 'Switch',
-  //     label: '鏄惁璁$畻鐩撮�氱巼',
-  //     colProps: {
-  //       span: 16,
-  //     },
-  //     labelWidth: 200,
-  //     ifShow: ({ values }) => isOper(values.func_type),
-  //   },
-  //   {
-  //     field: 'field5',
-  //     component: 'Switch',
-  //     label: '鏄惁鍙烦绔�',
-  //     colProps: {
-  //       span: 16,
-  //     },
-  //     labelWidth: 200,
-  //     ifShow: ({ values }) => isOper(values.func_type),
-  //   },
-  //   {
-  //     field: 'ROT_CODE',
-  //     label: '宸ヨ壓璺嚎缂栫爜',
-  //     required: true,
-  //     component: 'Input',
-  //     colProps: { span: 16 },
-  //     ifShow: ({ values }) => isRute(values.func_type),
-  //   },
-  //   {
-  //     field: 'ROT_NAME',
-  //     label: '宸ヨ壓璺嚎鍚嶇О',
-  //     required: true,
-  //     component: 'Input',
-  //     colProps: { span: 16 },
-  //     ifShow: ({ values }) => isRute(values.func_type),
-  //   },
-  //   {
-  //     field: 'ROT_TYPE',
-  //     label: '宸ヨ壓璺嚎绫诲瀷',
-  //     required: true,
-  //     component: 'Input',
-  //     colProps: { span: 16 },
-  //     ifShow: ({ values }) => isRute(values.func_type),
-  //   },
-  //   {
-  //     field: 'ROT_VER',
-  //     label: '宸ヨ壓璺嚎鐗堟湰',
-  //     required: true,
-  //     component: 'Input',
-  //     colProps: { span: 16 },
-  //     ifShow: ({ values }) => isRute(values.func_type),
-  //   },
-  //   {
-  //     field: 'IS_ACTIVE',
-  //     label: '鏄惁鍚敤',
-  //     required: true,
-  //     component: 'Select',
-  //     colProps: { span: 16 },
-  //     componentProps: {
-  //       options: [
-  //         {
-  //           label: '鏄�',
-  //           value: 'Y',
-  //           key: 'Y',
-  //         },
-  //         {
-  //           label: '鍚�',
-  //           value: 'N',
-  //           key: 'N',
-  //         },
-  //       ],
-  //     },
-  //     ifShow: ({ values }) => isRute(values.func_type),
-  //   },
-  // ];
-  const demoData = ref({});
+  const routeData = ref({
+    nodes: [],
+    edges: [],
+  });
   provide<Ref<IRouteConfig>>('routeConfig', routeConfig);
   provide<Ref<MES_ROUTE>>('mesRoute', currRoute);
   const selectnode = ref({} as node);
+  const currRotId = ref(route.params?.id);
 
-  // const demoData1 = ref({
-  //   nodes: [
-  //     {
-  //       id: '5d82e943-477f-4313-aaff-a736d8caba74',
-  //       type: 'rect',
-  //       x: 340,
-  //       y: 120,
-  //       properties: {},
-  //       text: {
-  //         x: 340,
-  //         y: 120,
-  //         value: '娴嬭瘯宸ュ簭',
-  //       },
-  //     },
-  //     {
-  //       id: '6e0c6714-69a7-4160-8bda-61f4e6d285dd',
-  //       type: 'rect',
-  //       x: 560,
-  //       y: 120,
-  //       properties: {},
-  //       text: {
-  //         x: 560,
-  //         y: 120,
-  //         value: '涓婃枡宸ュ簭',
-  //       },
-  //     },
-  //     {
-  //       id: '80b2ee17-5a0e-4586-ba28-6ba59fcc0f59',
-  //       type: 'rect',
-  //       x: 340,
-  //       y: 280,
-  //       properties: {
-  //         isReturn: true,
-  //       },
-  //       text: {
-  //         x: 340,
-  //         y: 280,
-  //         value: '缁翠慨宸ュ簭',
-  //       },
-  //     },
-  //   ],
-  //   edges: [
-  //     {
-  //       id: 'Flow_0p4u47c',
-  //       type: 'bpmn:sequenceFlow',
-  //       sourceNodeId: '5d82e943-477f-4313-aaff-a736d8caba74',
-  //       targetNodeId: '6e0c6714-69a7-4160-8bda-61f4e6d285dd',
-  //       startPoint: {
-  //         x: 390,
-  //         y: 120,
-  //       },
-  //       endPoint: {
-  //         x: 510,
-  //         y: 120,
-  //       },
-  //       properties: {},
-  //       pointsList: [
-  //         {
-  //           x: 390,
-  //           y: 120,
-  //         },
-  //         {
-  //           x: 510,
-  //           y: 120,
-  //         },
-  //       ],
-  //     },
-  //     {
-  //       id: 'Flow_09tu4cm',
-  //       type: 'bpmn:sequenceFlow',
-  //       sourceNodeId: '5d82e943-477f-4313-aaff-a736d8caba74',
-  //       targetNodeId: '80b2ee17-5a0e-4586-ba28-6ba59fcc0f59',
-  //       startPoint: {
-  //         x: 340,
-  //         y: 160,
-  //       },
-  //       endPoint: {
-  //         x: 340,
-  //         y: 240,
-  //       },
-  //       properties: {},
-  //       pointsList: [
-  //         {
-  //           x: 340,
-  //           y: 160,
-  //         },
-  //         {
-  //           x: 340,
-  //           y: 240,
-  //         },
-  //       ],
-  //     },
-  //     {
-  //       id: '22226ec4-9960-497d-93cb-6226a3f29b3d',
-  //       type: 'custom-edge',
-  //       sourceNodeId: '80b2ee17-5a0e-4586-ba28-6ba59fcc0f59',
-  //       targetNodeId: '5d82e943-477f-4313-aaff-a736d8caba74',
-  //       startPoint: {
-  //         x: 351,
-  //         y: 240,
-  //       },
-  //       endPoint: {
-  //         x: 351,
-  //         y: 160,
-  //       },
-  //       properties: {},
-  //       pointsList: [
-  //         {
-  //           x: 351,
-  //           y: 240,
-  //         },
-  //         {
-  //           x: 351,
-  //           y: 160,
-  //         },
-  //       ],
-  //     },
-  //   ],
-  // });
+  console.log(currRotId.value);
+  async function init(lf) {
+    //閫氳繃宸ヨ壓璺嚎ID鑾峰彇鍥惧舰鏁版嵁锛屽苟娓叉煋
+    var _data = await getRouteData(currRotId.value);
+    console.log('缁勪欢宸叉寕杞�', _data);
+    //宸ヨ壓璺嚎鍏ㄤ俊鎭紝鍖呮嫭Node銆丒dge鍜孉ct
+    routeConfig.routeData = _data.Data;
+    if (_data.Data != null) {
+      //宸ヨ壓璺嚎涓讳俊鎭�
+      currRoute.value = _data.Data.route;
+      if (!isNullOrEmpty(currRotId.value)) {
+        setTitle('璁捐锛氬伐鑹鸿矾绾�-' + currRoute.value.ROT_CODE);
+      }
+      _data.Data.nodes.forEach((n) => {
+        n.node.properties = JSON.parse(n.node.properties);
+        routeData.value.nodes.push(n.node);
+      });
+      console.log('111', routeData.value);
+      _data.Data.edges.forEach((e) => {
+        e.edge.properties = JSON.parse(e.edge.properties);
+        routeData.value.edges.push(e.edge);
+      });
+      _data.Data.acts.forEach((act) => {
+        act.node.properties = JSON.parse(act.node.properties);
+        routeData.value.nodes.push(act.node);
+      });
+      console.log('init', unref(lf).getGraphData(), JSON.parse(JSON.stringify(routeData.value)));
+      unref(lf).render(routeData.value);
+    }
+  }
 
+  const GetRotData = (lf) => {
+    var currRotData: RouteData = {
+      route: {
+        ID: currRoute.value.ID,
+        CREATE_TIME: new Date(),
+        CREATE_USER: useUserStore().getUserInfo.userId as string,
+        UPDATE_TIME: new Date(),
+        UPDATE_USER: useUserStore().getUserInfo.userId as string,
+        GHOST_ROW: false,
+        ROT_CODE: currRoute.value.ROT_CODE,
+        ROT_NAME: currRoute.value.ROT_NAME,
+        ROT_TYPE: currRoute.value.ROT_TYPE,
+        ROT_VER: currRoute.value.ROT_VER,
+        IS_ACTIVE: currRoute.value.IS_ACTIVE,
+        REMARK: currRoute.value.REMARK,
+        AUTH_ORG: '',
+        AUTH_PROD: '',
+        AUTH_WH: '',
+      },
+      nodes: [],
+      edges: [],
+      acts: [],
+    };
+    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),
+    );
+    const diffacts = routeConfig.routeData.acts.filter((itemA) =>
+      _nodes.some((itemB) => itemB.id === itemA.ID),
+    );
+    _nodes.forEach((n) => {
+      if (n.properties.operType && n.properties.operType == 'Action') {
+        var _diffacts = diffacts.length > 0 ? diffacts : routeConfig.routeData.acts;
+        _diffacts.forEach((a) => {
+          if (a.ID == n.id) {
+            var act: MES_ROUTE_NODE_ACT = {
+              ID: n.id,
+              CREATE_TIME: routeConfig.routeData.route.CREATE_TIME,
+              CREATE_USER: useUserStore().getUserInfo.userId as string,
+              UPDATE_TIME: routeConfig.routeData.route.UPDATE_TIME,
+              UPDATE_USER: useUserStore().getUserInfo.userId as string,
+              GHOST_ROW: false,
+              ROT_ID: routeConfig.routeData.route.ID,
+              GPH_TYPE: n.type,
+              GPH_X: n.x,
+              GPH_Y: n.y,
+              GPH_PROP: JSON.stringify(n.properties),
+              GPH_TEXT: n.text.value,
+              REMARK: a.REMARK,
+              AUTH_ORG: '',
+              AUTH_PROD: '',
+              AUTH_WH: '',
+              OPTION_1: '',
+              OPTION_2: '',
+              OPTION_3: '',
+              OPTION_4: '',
+              OPTION_5: '',
+              ACT_NAME: `${routeConfig.routeData.route.ROT_CODE}_${n.text.value}_${_num}`,
+              NODE_ID: a.NODE_ID,
+              ACT_TYPE: a.ACT_TYPE,
+              DO_TYPE: a.DO_TYPE,
+              DO_METHOD: a.DO_METHOD,
+              DO_IF_PASS: a.DO_IF_PASS,
+              DO_IF_FAIL: a.DO_IF_FAIL,
+              node: {} as node,
+              IS_ACTIVE: a.IS_ACTIVE,
+            };
+            var pnode = [n];
+            while (pnode[0].properties.operType == 'Action') {
+              pnode = unref(lf).getNodeIncomingNode(pnode[0].id);
+              if (pnode[0].properties.operType != 'Action') {
+                act.NODE_ID = pnode[0].id;
+                break;
+              }
+            }
+            currRotData.acts.push(act);
+          }
+        });
+        routeConfig.routeData.acts = _diffacts;
+      } else {
+        var _diffnodes = diffnodes.length > 0 ? diffnodes : routeConfig.routeData.nodes;
+        _diffnodes.forEach((nd) => {
+          if (nd.ID == n.id) {
+            var node: MES_ROUTE_NODE = {
+              ID: n.id,
+              CREATE_TIME: currRotData.route.CREATE_TIME,
+              CREATE_USER: useUserStore().getUserInfo.userId as string,
+              UPDATE_TIME: currRotData.route.UPDATE_TIME,
+              UPDATE_USER: useUserStore().getUserInfo.userId as string,
+              GHOST_ROW: false,
+              NODE_NAME: `${currRotData.route.ROT_CODE}_${n.text.value}_${_num}`,
+              ROT_ID: currRotData.route.ID,
+              SEGMENT: nd.SEGMENT,
+              OPER_CODE: nd.OPER_CODE,
+              GPH_TYPE: n.type,
+              GPH_X: n.x,
+              GPH_Y: n.y,
+              GPH_PROP: JSON.stringify(n.properties),
+              GPH_TEXT: n.text.value,
+              IS_ACTIVE: nd.IS_ACTIVE,
+              IS_CALC_FPY: nd.IS_CALC_FPY,
+              CAN_SKIP: nd.CAN_SKIP,
+              REMARK: nd.REMARK,
+              AUTH_ORG: '',
+              AUTH_PROD: '',
+              AUTH_WH: '',
+              IS_FIRST_NODE: 'N',
+              IS_INPUT: nd.IS_INPUT,
+              IS_OUTPUT: nd.IS_OUTPUT,
+              OPTION_1: '',
+              OPTION_2: '',
+              OPTION_3: '',
+              OPTION_4: '',
+              OPTION_5: '',
+              node: {} as node,
+            };
+            nd.GPH_TYPE = n.type;
+            nd.GPH_PROP = JSON.stringify(n.properties);
+            nd.GPH_TEXT = n.text.value;
+            nd.GPH_X = n.x;
+            nd.GPH_Y = n.y;
+            if (unref(lf).getNodeIncomingNode(n.id).length == 0) {
+              node.IS_FIRST_NODE = 'Y';
+              nd.IS_FIRST_NODE = 'Y';
+            }
+            currRotData.nodes.push(node);
+          }
+        });
+        routeConfig.routeData.nodes = _diffnodes;
+      }
+      _num++;
+    });
+    routeConfig.routeData.edges = [];
+    _edges.forEach((e) => {
+      var edge: MES_ROUTE_EDGE = {
+        ID: e.id,
+        CREATE_TIME: routeConfig.routeData.route.CREATE_TIME,
+        CREATE_USER: useUserStore().getUserInfo.userId as string,
+        UPDATE_TIME: routeConfig.routeData.route.UPDATE_TIME,
+        UPDATE_USER: useUserStore().getUserInfo.userId as string,
+        GHOST_ROW: false,
+        EDGE_NAME: `${routeConfig.routeData.route.ROT_CODE}_${e.id}`,
+        ROT_ID: routeConfig.routeData.route.ID,
+        SRC_NODE: e.sourceNodeId,
+        TGT_NODE: e.targetNodeId,
+        GPH_TYPE: e.type,
+        GPH_SRC_X: e.startPoint.x,
+        GPH_SRC_Y: e.startPoint.y,
+        GPH_TGT_X: e.endPoint.x,
+        GPH_TGT_Y: e.endPoint.y,
+        GPH_PROP: JSON.stringify(e.properties),
+        GPH_POTS: JSON.stringify(e.pointsList),
+        REMARK: '',
+        AUTH_ORG: '',
+        AUTH_PROD: '',
+        AUTH_WH: '',
+        EDGE_TYPE: 0,
+        OPTION_1: '',
+        OPTION_2: '',
+        OPTION_3: '',
+        OPTION_4: '',
+        OPTION_5: '',
+        edge: {} as edge,
+      };
+      routeConfig.routeData.edges.push(edge);
+      currRotData.edges.push(edge);
+    });
+    return currRotData;
+  };
+
+  /*
+   *淇濆瓨宸ヨ壓璺嚎浜嬩欢
+   */
   async function handleSave(lf) {
     console.log('handleSave', unref(lf).getGraphData().nodes[0]);
     if (isNullOrEmpty(currRoute.value.ROT_CODE)) {
@@ -383,146 +307,38 @@
         getContainer: () => document.body,
       });
     } else {
-      var _routeData: RouteData = {
-        route: {
-          ID: buildUUID(),
-          CREATE_TIME: new Date(),
-          CREATE_USER: useUserStore().getUserInfo.userId as string,
-          UPDATE_TIME: new Date(),
-          UPDATE_USER: useUserStore().getUserInfo.userId as string,
-          GHOST_ROW: false,
-          ROT_CODE: currRoute.value.ROT_CODE,
-          ROT_NAME: currRoute.value.ROT_NAME,
-          ROT_TYPE: currRoute.value.ROT_TYPE,
-          ROT_VER: currRoute.value.ROT_VER,
-          IS_ACTIVE: currRoute.value.IS_ACTIVE,
-          REMARK: currRoute.value.REMARK,
-          AUTH_ORG: '',
-          AUTH_PROD: '',
-          AUTH_WH: '',
-        },
-        nodes: [],
-        edges: [],
-        acts: [],
-      };
-      var _nodes = unref(lf).getGraphData().nodes as node[];
-      var _edges = unref(lf).getGraphData().edges as edge[];
-      var _num = 1;
-      _nodes.forEach((n) => {
-        if (n.properties.operType && n.properties.operType == 'Action') {
-          var act: MES_ROUTE_NODE_ACT = {
-            ID: n.id,
-            CREATE_TIME: _routeData.route.CREATE_TIME,
-            CREATE_USER: useUserStore().getUserInfo.userId as string,
-            UPDATE_TIME: _routeData.route.UPDATE_TIME,
-            UPDATE_USER: useUserStore().getUserInfo.userId as string,
-            GHOST_ROW: false,
-            ROT_ID: _routeData.route.ID,
-            GPH_TYPE: n.type,
-            GPH_X: n.x,
-            GPH_Y: n.y,
-            GPH_PROP: JSON.stringify(n.properties),
-            GPH_TEXT: n.text.value,
-            REMARK: '',
-            AUTH_ORG: '',
-            AUTH_PROD: '',
-            AUTH_WH: '',
-            OPTION_1: '',
-            OPTION_2: '',
-            OPTION_3: '',
-            OPTION_4: '',
-            OPTION_5: '',
-            ACT_NAME: `${_routeData.route.ROT_CODE}_${n.text.value}_${_num}`,
-            NODE_ID: '',
-            ACT_TYPE: 0,
-            DO_TYPE: 0,
-            DO_METHOD: '',
-            DO_IF_PASS: '',
-            DO_IF_FAIL: '',
-            RULE_CODE: '',
-            ITEM_CODE: '',
-            PROD_CODE: '',
-            TEST_CODE: '',
-            SAPL_CODE: '',
-            LABEL_CODE: '',
-          };
-          _routeData.acts.push(act);
-        } else {
-          var node: MES_ROUTE_NODE = {
-            ID: n.id,
-            CREATE_TIME: _routeData.route.CREATE_TIME,
-            CREATE_USER: useUserStore().getUserInfo.userId as string,
-            UPDATE_TIME: _routeData.route.UPDATE_TIME,
-            UPDATE_USER: useUserStore().getUserInfo.userId as string,
-            GHOST_ROW: false,
-            NODE_NAME: `${_routeData.route.ROT_CODE}_${n.text.value}_${_num}`,
-            ROT_ID: _routeData.route.ID,
-            SEGMENT: '',
-            OPER_CODE: '',
-            GPH_TYPE: n.type,
-            GPH_X: n.x,
-            GPH_Y: n.y,
-            GPH_PROP: JSON.stringify(n.properties),
-            GPH_TEXT: n.text.value,
-            IS_ACTIVE: 'Y',
-            IS_CALC_FPY: 'N',
-            CAN_SKIP: 'N',
-            REMARK: '',
-            AUTH_ORG: '',
-            AUTH_PROD: '',
-            AUTH_WH: '',
-            IS_FIRST_NODE: 'N',
-            IS_INPUT: '',
-            IS_OUTPUT: '',
-            OPTION_1: '',
-            OPTION_2: '',
-            OPTION_3: '',
-            OPTION_4: '',
-            OPTION_5: '',
-          };
-          if (unref(lf).getNodeIncomingNode(n.id).length == 0) {
-            node.IS_FIRST_NODE = 'Y';
+      var hasError = false;
+      unref(lf)
+        .getGraphData()
+        .nodes.forEach((n) => {
+          if (
+            unref(lf).getNodeIncomingEdge(n.id).length == 0 &&
+            unref(lf).getNodeOutgoingEdge(n.id).length == 0
+          ) {
+            hasError = true;
           }
-          _routeData.nodes.push(node);
+        });
+      if (hasError) {
+        createErrorModal({
+          title: t('璀﹀憡'),
+          content: t('鏈夎妭鐐规湭杩炵嚎锛岃閲嶆柊璁捐宸ヨ壓璺嚎鍐嶄繚瀛樻暟鎹紒'),
+          getContainer: () => document.body,
+        });
+      } else {
+        var action = await SaveRouteData(GetRotData(lf));
+        if (action.IsSuccessed) {
+          notification['success']({
+            message: '鎿嶄綔鎴愬姛',
+            description: `淇濆瓨宸ヨ壓璺嚎锛�${currRoute.value.ROT_CODE} 鎴愬姛`,
+          });
         }
-        _num++;
-      });
-      _edges.forEach((e) => {
-        var edge: MES_ROUTE_EDGE = {
-          ID: e.id,
-          CREATE_TIME: _routeData.route.CREATE_TIME,
-          CREATE_USER: useUserStore().getUserInfo.userId as string,
-          UPDATE_TIME: _routeData.route.UPDATE_TIME,
-          UPDATE_USER: useUserStore().getUserInfo.userId as string,
-          GHOST_ROW: false,
-          EDGE_NAME: `${_routeData.route.ROT_CODE}_${e.id}`,
-          ROT_ID: _routeData.route.ID,
-          SRC_NODE: e.sourceNodeId,
-          TGT_NODE: e.targetNodeId,
-          GPH_TYPE: e.type,
-          GPH_SRC_X: e.startPoint.x,
-          GPH_SRC_Y: e.startPoint.y,
-          GPH_TGT_X: e.endPoint.x,
-          GPH_TGT_Y: e.endPoint.y,
-          GPH_PROP: JSON.stringify(e.properties),
-          GPH_POTS: JSON.stringify(e.pointsList),
-          REMARK: '',
-          AUTH_ORG: '',
-          AUTH_PROD: '',
-          AUTH_WH: '',
-          EDGE_TYPE: 0,
-          OPTION_1: '',
-          OPTION_2: '',
-          OPTION_3: '',
-          OPTION_4: '',
-          OPTION_5: '',
-        };
-        _routeData.edges.push(edge);
-      });
-      await SaveRouteData(_routeData);
+      }
     }
   }
 
+  /*
+   *鏂板宸ヨ壓璺嚎寮瑰嚭妯℃�佺獥鍙d簨浠�
+   */
   async function handleAddlf(lf) {
     // openDrawer(true, {
     //   isUpdate: false,
@@ -534,43 +350,158 @@
     });
   }
 
-  function handleSelect(data) {
+  /*
+   *鐐瑰嚮鑺傜偣閫変腑浜嬩欢
+   */
+  function handleSelect(data, lf) {
+    lf.graphModel.clearSelectElements();
+    lf.graphModel.getNodeModelById(data.data.id).setSelected(true);
     selectnode.value = data.data;
-    routeConfig.currentItem = {
-      ID: selectnode.value.id,
-      CREATE_TIME: currRoute.value.CREATE_TIME,
-      CREATE_USER: useUserStore().getUserInfo.userId as string,
-      UPDATE_TIME: currRoute.value.UPDATE_TIME,
-      UPDATE_USER: useUserStore().getUserInfo.userId as string,
-      GHOST_ROW: false,
-      NODE_NAME: 'N001',
-      ROT_ID: currRoute.value.ID,
-      SEGMENT: '',
-      OPER_CODE: '',
-      GPH_TYPE: selectnode.value.type,
-      GPH_X: selectnode.value.x,
-      GPH_Y: selectnode.value.y,
-      GPH_PROP: '',
-      GPH_TEXT: selectnode.value.text.value,
-      IS_ACTIVE: 'Y',
-      IS_CALC_FPY: 'N',
-      CAN_SKIP: 'N',
-      REMARK: '',
-    };
-    console.log(routeConfig.currentItem);
-    routeConfig.activeKey = 2;
+    if (isNullOrUnDef(routeConfig.routeData)) {
+      //鍏堝垵濮嬪寲routeData
+      routeConfig.routeData = {};
+      routeConfig.routeData.route = currRoute.value;
+      routeConfig.routeData.nodes = [];
+      routeConfig.routeData.edges = [];
+      routeConfig.routeData.acts = [];
+      //鍐嶈繑鍥炲叿浣撴暟鎹�
+      routeConfig.routeData = GetRotData(lf);
+    }
+
+    var _node = routeConfig.routeData.nodes.filter((x) => x.ID == selectnode.value.id)[0];
+    if (isNullOrUnDef(_node)) {
+      _node = {
+        ID: selectnode.value.id,
+        CREATE_TIME: currRoute.value.CREATE_TIME,
+        CREATE_USER: useUserStore().getUserInfo.userId as string,
+        UPDATE_TIME: currRoute.value.UPDATE_TIME,
+        UPDATE_USER: useUserStore().getUserInfo.userId as string,
+        GHOST_ROW: false,
+        NODE_NAME: `${currRoute.value.ROT_CODE}_${selectnode.value.text.value}_0`,
+        ROT_ID: currRoute.value.ID,
+        SEGMENT: '',
+        OPER_CODE: selectnode.value.type,
+        GPH_TYPE: selectnode.value.type,
+        GPH_X: selectnode.value.x,
+        GPH_Y: selectnode.value.y,
+        GPH_PROP: '',
+        GPH_TEXT: selectnode.value.text.value,
+        IS_ACTIVE: 'Y',
+        IS_CALC_FPY: 'N',
+        CAN_SKIP: 'N',
+        REMARK: '',
+        AUTH_ORG: '',
+        AUTH_PROD: '',
+        AUTH_WH: '',
+        IS_FIRST_NODE: '',
+        IS_INPUT: '',
+        IS_OUTPUT: '',
+        OPTION_1: '',
+        OPTION_2: '',
+        OPTION_3: '',
+        OPTION_4: '',
+        OPTION_5: '',
+        node: {} as node,
+      };
+      routeConfig.routeData.nodes.push(_node);
+    }
+    //鏄涓�
+    if (selectnode.value.properties.operType && selectnode.value.properties.operType == 'Action') {
+      var _act = routeConfig.routeData.acts.filter((x) => x.ID == selectnode.value.id)[0];
+      routeConfig.activeKey = 3;
+      routeConfig.currentAct = {
+        ID: selectnode.value.id,
+        CREATE_TIME: currRoute.value.CREATE_TIME,
+        CREATE_USER: useUserStore().getUserInfo.userId as string,
+        UPDATE_TIME: currRoute.value.UPDATE_TIME,
+        UPDATE_USER: useUserStore().getUserInfo.userId as string,
+        GHOST_ROW: false,
+        AUTH_ORG: '',
+        AUTH_PROD: '',
+        AUTH_WH: '',
+        ACT_NAME: _act.ACT_NAME,
+        ROT_ID: currRoute.value.ID,
+        NODE_ID: _act.NODE_ID,
+        ACT_TYPE: _act.ACT_TYPE,
+        GPH_TYPE: selectnode.value.type,
+        GPH_X: selectnode.value.x,
+        GPH_Y: selectnode.value.y,
+        GPH_PROP: JSON.stringify(selectnode.value.properties),
+        GPH_TEXT: selectnode.value.text.value,
+        DO_TYPE: _act.DO_TYPE,
+        DO_METHOD: _act.DO_METHOD,
+        DO_IF_PASS: _act.DO_IF_PASS,
+        DO_IF_FAIL: _act.DO_IF_FAIL,
+        IS_ACTIVE: _act.IS_ACTIVE,
+        OPTION_1: '',
+        OPTION_2: '',
+        OPTION_3: '',
+        OPTION_4: '',
+        OPTION_5: '',
+        REMARK: '',
+        node: {} as node,
+      };
+    } else {
+      //鏄伐搴�
+      routeConfig.currentItem = {
+        ID: selectnode.value.id,
+        CREATE_TIME: currRoute.value.CREATE_TIME,
+        CREATE_USER: useUserStore().getUserInfo.userId as string,
+        UPDATE_TIME: currRoute.value.UPDATE_TIME,
+        UPDATE_USER: useUserStore().getUserInfo.userId as string,
+        GHOST_ROW: false,
+        NODE_NAME: _node.NODE_NAME ?? '',
+        ROT_ID: currRoute.value.ID,
+        SEGMENT: _node.SEGMENT,
+        OPER_CODE: _node.OPER_CODE,
+        GPH_TYPE: selectnode.value.type,
+        GPH_X: selectnode.value.x,
+        GPH_Y: selectnode.value.y,
+        GPH_PROP: '',
+        GPH_TEXT: selectnode.value.text.value,
+        IS_ACTIVE: _node.IS_ACTIVE,
+        IS_CALC_FPY: _node.IS_CALC_FPY,
+        CAN_SKIP: _node.CAN_SKIP,
+        IS_INPUT: _node.IS_INPUT,
+        IS_OUTPUT: _node.IS_OUTPUT,
+        REMARK: _node.REMARK,
+      };
+      routeConfig.isCalcFpy = _node.IS_CALC_FPY == 'Y';
+      routeConfig.canSkip = _node.CAN_SKIP == 'Y';
+      routeConfig.isInput = _node.IS_INPUT == 'Y';
+      routeConfig.isOutput = _node.IS_OUTPUT == 'Y';
+
+      console.log(routeConfig.currentItem);
+      routeConfig.activeKey = 2;
+    }
   }
 
   function handleSuccess(lfInstance) {
     unref(lfInstance).render({});
   }
 
+  /*
+   *鐐瑰嚮鐢诲竷浜嬩欢
+   */
   function clickBlank() {
     routeConfig.activeKey = 1;
   }
 
-  function modalSuccess(lfInstance, route) {
+  /*
+   *鏂板宸ヨ壓璺嚎鎴愬姛鍚庝簨浠�
+   */
+  async function modalSuccess(lfInstance, route) {
     unref(lfInstance).render({});
     currRoute.value = route;
+    currRotId.value = currRoute.value.ID;
+    setTitle('璁捐锛氬伐鑹鸿矾绾�-' + currRoute.value.ROT_CODE);
+    //鍏堝垵濮嬪寲routeData
+    routeConfig.routeData = {};
+    routeConfig.routeData.route = currRoute.value;
+    routeConfig.routeData.nodes = [];
+    routeConfig.routeData.edges = [];
+    routeConfig.routeData.acts = [];
+    //鍐嶈繑鍥炲叿浣撴暟鎹�
+    routeConfig.routeData = GetRotData(unref(lfInstance));
   }
 </script>

--
Gitblit v1.9.3