From 38b2a8369513ebcc34c6dd01a176593b825fe71e Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期日, 09 六月 2024 17:06:08 +0800
Subject: [PATCH] 工单管理更新

---
 src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue |  130 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 114 insertions(+), 16 deletions(-)

diff --git a/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue b/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue
index 56fe9bd..672314f 100644
--- a/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue
+++ b/src/views/tigerprojects/mes/prod/biz_mes_wo/index.vue
@@ -71,7 +71,7 @@
     >
       <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� -->
       <template #[item.name] v-for="item in dtlSlots" :key="item.name">
-        <BasicForm @register="useFormData[item.name][0]">
+        <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]">
           <!-- 鐢ㄦ彃妲借嚜瀹氫箟寮瑰嚭閫夋嫨妗� -->
           <template #[name]="{ field }" v-for="name in item.slots" :key="name">
             <a-button
@@ -86,13 +86,16 @@
             />
           </template>
         </BasicForm>
+        <!-- 鑷畾涔夊唴瀹� -->
+        <div style="height: 200px" id="lfContainer" v-if="isCustEl[item.name]"></div>
       </template>
     </CustModal>
     <RouteViewModal @register="registerRv" @success="RvItemSuccess" />
   </div>
 </template>
 <script lang="ts" setup>
-  import { reactive, unref, h, onMounted, ref, nextTick } from 'vue';
+  import { reactive, unref, h, onMounted, ref, nextTick, Ref } from 'vue';
+  import { Steps, Step, Layout, LayoutContent } from 'ant-design-vue';
   import { BasicTable, useTable, TableAction } from '/@/components/Table';
   import { BasicForm, FormSchema, FormActionType, useForm } from '/@/components/Form/index';
   import WoDrawer from './WoDrawer.vue';
@@ -109,8 +112,20 @@
   import { useModal } from '/@/components/Modal';
   import { getListByPage } from '/@/api/tigerapi/system';
   import { GetSelectSuccess, OpenSelectItem, getFormSchema } from '/@/views/components/data';
+  import LogicFlow from '@logicflow/core';
+  import { getRouteData } from '/@/api/tigerapi/mes/router';
+  import actionRect from '/@/components/FlowChart/src/actionRect';
+  import TestNode from '/@/components/FlowChart/src/TestNode';
+  import CollectNode from '/@/components/FlowChart/src/CollectNode';
+  import AssemblyNode from '/@/components/FlowChart/src/AssemblyNode';
+  import PackingNode from '/@/components/FlowChart/src/PackingNode';
+  import RepairNode from '/@/components/FlowChart/src/RepairNode';
+  import customEdge from '/@/components/FlowChart/src/customEdge';
+  import { Snapshot, BpmnElement, Menu, DndPanel, SelectionSelect } from '@logicflow/extension';
 
   const { t } = useI18n();
+  const ASteps = Steps;
+  const AStep = Step;
   const cType = ref('');
   const title = ref('宸ュ崟瀵煎叆');
   const mtitle = ref('宸ュ崟鍒楄〃');
@@ -123,6 +138,7 @@
     loading: false,
     tip: '鍔犺浇涓�...',
   });
+  const lfInstance = ref(null) as Ref<LogicFlow | null>;
   const [registerRv, { openModal: openRvModal }] = useModal();
   const [registerWo, { openModal: openWoModal }] = useModal();
   const [registerItemAdd, { openModal: openItemModal }] = useModal();
@@ -148,10 +164,20 @@
     bordered: true,
     showIndexColumn: false,
   });
+  const routeData = ref({
+    nodes: [],
+    edges: [],
+  });
   const formSchema = ref([] as FormSchema[]);
   const woSchema = ref([] as FormSchema[]);
   const prodSchema = ref([] as FormSchema[]);
-  const xxSchema = ref([] as FormSchema[]);
+  const rotSchema = ref([] as FormSchema[]);
+  const isCustEl = ref({
+    forminfo: false,
+    woinfo: false,
+    prodinfo: false,
+    rotinfo: true,
+  });
   //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶
   const useModalData = ref({
     add: useModal(),
@@ -185,17 +211,17 @@
       },
       showActionButtonGroup: false,
     }),
-    xxinfo: useForm({
-      labelWidth: 120,
-      schemas: xxSchema,
-      actionColOptions: {
-        span: 24,
-      },
-      showActionButtonGroup: false,
-    }),
+    // rotinfo: useForm({
+    //   labelWidth: 120,
+    //   schemas: rotSchema,
+    //   actionColOptions: {
+    //     span: 24,
+    //   },
+    //   showActionButtonGroup: false,
+    // }),
   });
 
-  onMounted(() => {});
+  onMounted(async () => {});
 
   //鏂板
   function addWo() {
@@ -231,19 +257,30 @@
         preIcons: { addRot: 'search|svg', setRot: 'config|svg' },
         title: '浜у搧淇℃伅',
       },
-      { name: 'xxinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: 'XXX' },
+      { name: 'rotinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: '宸ヨ壓淇℃伅' },
     ];
     woSchema.value = getFormSchema('woinfo');
     prodSchema.value = getFormSchema('prodinfo');
-    xxSchema.value = getFormSchema('xxinfo');
+    // rotSchema.value = getFormSchema('rotinfo');
+    if (lfInstance.value != null) {
+      routeData.value = {
+        nodes: [],
+        edges: [],
+      };
+      const lf = unref(lfInstance)!;
+      lf.render({});
+    }
     openCustModal(true, {
       isUpdate: true,
       ctype: cType,
       title: '宸ヨ壓閰嶇疆',
       width: '1000px',
       formEl: useFormData.value, //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы
-      formElName: ['woinfo', 'prodinfo', 'xxinfo'],
+      formElName: ['woinfo', 'prodinfo', 'rotinfo'], //琛ㄥ崟鎻掓Ы鍚嶇О锛屾敮鎸佸涓〃鍗�
       RowKey: '',
+      fnName: { BIZ_MES_WO_Config: 'SaveCofig' }, //淇濆瓨鏂规硶鍚�
+      initFnName: {}, //鍒濆鍖栨柟娉曞悕
+      isCustEl: isCustEl.value,
       ...record,
     });
   }
@@ -265,8 +302,11 @@
       title: '宸ュ崟涓嬪彂', //鏍囬
       width: '900px', //寮瑰嚭妗嗗搴�
       formEl: useFormData.value,
-      formElName: ['forminfo'],
+      formElName: ['forminfo'], //琛ㄥ崟鎻掓Ы鍚嶇О
       RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //鎻掓Ы鐨勫脊鍑烘閫夋嫨鐨刢ode
+      fnName: { BIZ_MES_WO: 'SaveWoBatch' }, //淇濆瓨鏂规硶鍚�
+      initFnName: {}, //鍒濆鍖栨柟娉曞悕
+      isCustEl: isCustEl.value,
       ...record,
     });
   }
@@ -336,6 +376,13 @@
     let _val = {};
     _val[d.returnFieldName] = values[d.returnFieldName];
     useFormData.value[item][1].setFieldsValue(_val);
+    if (d.returnFieldName == 'ROUTE_CODE') {
+      routeData.value = {
+        nodes: [],
+        edges: [],
+      };
+      init(selectVals.value['ID']);
+    }
   }
 
   /* 寮瑰嚭閫夋嫨妗� */
@@ -350,4 +397,55 @@
     ); //[openRvModal], selectVals.value['ID']杩欐槸鑷畾涔夊弬鏁帮紝鎸夊疄闄呴渶姹�
   }
   function RvItemSuccess(d, u) {}
+
+  async function init(rotId) {
+    LogicFlow.use(BpmnElement);
+    lfInstance.value = new LogicFlow({
+      container: document.querySelector('#lfContainer'),
+      edgeGenerator: (sourceNode) => {
+        // console.log('a');
+        // 璧峰鑺傜偣绫诲瀷 rect 鏃朵娇鐢� 鑷畾涔夌殑杈� custom-edge
+        if (sourceNode.properties.isReturn) return 'custom-edge';
+        // if (sourceNode.type === 'rect') return 'custom-edge';
+        // return 'custom-edge';
+      },
+    });
+    const lf = unref(lfInstance)!;
+    // lf?.setDefaultEdgeType('line');
+    lf.register(customEdge);
+    lf.register(actionRect);
+    lf.register(TestNode);
+    lf.register(CollectNode);
+    lf.register(AssemblyNode);
+    lf.register(PackingNode);
+    lf.register(RepairNode);
+    lf.render({});
+    //閫氳繃宸ヨ壓璺嚎ID鑾峰彇鍥惧舰鏁版嵁锛屽苟娓叉煋
+    var _data = await getRouteData(rotId);
+    console.log('缁勪欢宸叉寕杞�', _data);
+    //宸ヨ壓璺嚎鍏ㄤ俊鎭紝鍖呮嫭Node銆丒dge鍜孉ct
+    // routeConfig.routeData = _data.Data;
+    if (_data.Data != null) {
+      //宸ヨ壓璺嚎涓讳俊鎭�
+      var currRoute = _data.Data.route;
+      _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)));
+      lf.render(routeData.value);
+      // lf.graphModel.resize(500, 400);
+      lf.graphModel.fitView();
+      lf.graphModel.translateCenter();
+    }
+  }
 </script>

--
Gitblit v1.9.3