From 579db1b26e426693ba90dc08557e65b5d8b1e4e2 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期日, 14 七月 2024 01:13:24 +0800
Subject: [PATCH] 上传文件更新

---
 src/views/components/bizMesWo.ts |  275 ++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 234 insertions(+), 41 deletions(-)

diff --git a/src/views/components/bizMesWo.ts b/src/views/components/bizMesWo.ts
index 222e258..f2f4919 100644
--- a/src/views/components/bizMesWo.ts
+++ b/src/views/components/bizMesWo.ts
@@ -1,3 +1,12 @@
+/*
+ * @Description: 宸ュ崟鑷畾涔夋柟娉晅s
+ * @Author: Ben Lin
+ * @version: 
+ * @Date: 2024-06-05 16:10:24
+ * @LastEditors: Ben Lin
+ * @LastEditTime: 2024-07-03 21:56:56
+ */
+/* 宸ュ崟鐩稿叧鑷畾涔夋柟娉� */
 import { FunctionType } from '/@/api/tigerapi/model/systemModel';
 import { GetEnum, SaveEntity, getEntity } from '/@/api/tigerapi/system';
 import { FormSchema } from '/@/components/Table';
@@ -5,38 +14,212 @@
 import { useI18n } from '/@/hooks/web/useI18n';
 import { uploadApi } from '/@/api/sys/upload';
 import { useLocale } from '/@/locales/useLocale';
-import { unref } from 'vue';
+import { ref, unref } from 'vue';
+import { BIZ_MES_WO_BATCH } from '/@/api/tigerapi/model/mesModel';
+import { buildUUID } from '/@/utils/uuid';
+import LogicFlow from '@logicflow/core';
+import { BpmnElement } from '@logicflow/extension';
+import { getRouteData } from '/@/api/tigerapi/mes/router';
+import customEdge from '/@/components/FlowChart/src/customEdge';
+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 { multiply } from 'lodash-es';
 
 const { t } = useI18n();
 const { getLocale } = useLocale();
 
-export const getFns: Record<string, FunctionType> = {
+/**
+ * @description: 鑷畾涔夋柟娉�
+ * @return {*}
+ */
+export const getWoFns: Record<string, FunctionType> = {
   handleSubmit: async (e, ...args) => {
-    try {
-      const values = await args[0][0].validate();
-      args[0][1]({ confirmLoading: true });
-      values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
-      //   const apiAction = SaveEntity(values, e, 'MES_LINE');
-      //   apiAction.then((action) => {
-      //     if (action.IsSuccessed) {
-      //       args[0][2]();
-      //       args[0][3]('success');
-      //     }
-      //   });
-      args[0][2]();
-      args[0][3]('success');
-    } finally {
-      args[0][1]({ confirmLoading: false });
-    }
+    const values = await args[0][0].validate();
+    return new Promise((resolve, reject) => {
+      try {
+        args[0][1]({ confirmLoading: true });
+        values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
+        //   const apiAction = SaveEntity(values, e, 'MES_LINE');
+        //   apiAction.then((action) => {
+        //     if (action.IsSuccessed) {
+        //       args[0][2]();
+        //       args[0][3]('success');
+        //     }
+        //   });
+        args[0][2]();
+        args[0][3]('success');
+        resolve(true);
+      } catch {
+        reject(false);
+      } finally {
+        args[0][1]({ confirmLoading: false });
+      }
+    });
   },
   rvSubmit: (e, ...args) => {
-    try {
-      args[0][0]({ confirmLoading: true });
-      args[0][1]();
-      args[0][2]('success');
-    } finally {
-      args[0][0]({ confirmLoading: false });
-    }
+    return new Promise((resolve, reject) => {
+      try {
+        args[0][0]({ confirmLoading: true });
+        args[0][1]();
+        args[0][2]('success');
+        resolve(true);
+      } catch {
+        reject(false);
+      } finally {
+        args[0][0]({ confirmLoading: false });
+      }
+    });
+  },
+  
+  /**
+   * @description: 宸ュ崟閰嶇疆淇濆瓨鏂规硶
+   * @param {*} e
+   * @param {array} args
+   * @return {*}
+   */  
+  SaveCofig: (e, ...args) => {
+    return new Promise((resolve, reject) => {
+      try {
+        const form = e['prodinfo'];
+        const wo = e['mValues'];
+        wo.ROUTE_STATUS = 1;
+        SaveEntity(wo, true, 'BIZ_MES_WO').then((action) => {
+          if (action.IsSuccessed) {
+            resolve(true);
+          } else {
+            reject(false);
+          }
+        });
+      } catch {
+        reject(false);
+      }
+    });
+  },
+  /**
+   * @description: 宸ュ崟涓嬪彂淇濆瓨鏂规硶
+   * @param {*} e
+   * @param {array} args
+   * @return {*}
+   */  
+  SaveWoBatch: (e, ...args) => {
+    return new Promise((resolve, reject) => {
+      try {
+        const form = e['forminfo'];
+        const wo = e['mValues'];
+        wo.ROUTE_CODE = form.ROUTE_CODE;
+        wo.STATUS = 2;
+        const woBatch: BIZ_MES_WO_BATCH = {
+          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,
+          AUTH_ORG: '',
+          AUTH_PROD: useUserStore().getUserInfo.prodCode as string,
+          AUTH_WH: '',
+          ORDER_NO: wo.ORDER_NO,
+          STATUS: wo.STATUS,
+          ITEM_CODE: wo.ITEM_CODE,
+          CUST_CODE: wo.CUST_CODE,
+          FACTORY: wo.FACTORY,
+          WS_CODE: wo.WS_CODE,
+          ACT_LINE: form.PLAN_LINE,
+          STD_WORKER_QTY: wo.STD_WORKER_QTY,
+          ACT_WORKER_QTY: wo.ACT_WORKER_QTY,
+          RELEASE_TIME: new Date(),
+          RELEASE_USER: useUserStore().getUserInfo.userId as string,
+          PLAN_QTY: wo.PLAN_QTY,
+          INPUT_QTY: wo.INPUT_QTY,
+          OUTPUT_QTY: wo.OUTPUT_QTY,
+          SCRAP_QTY: wo.SCRAP_QTY,
+          STOCK_IN_QTY: wo.STOCK_IN_QTY,
+          UPH: wo.UPH,
+          UPPH: wo.UPPH,
+          REMARK: wo.REMARK,
+          ACT_START_TIME: wo.ACT_START_TIME,
+          ACT_END_TIME: wo.ACT_END_TIME,
+        };
+        SaveEntity(woBatch, false, 'BIZ_MES_WO_BATCH').then((action) => {
+          if (action.IsSuccessed) {
+            SaveEntity(wo, true, 'BIZ_MES_WO').then((action) => {
+              if (action.IsSuccessed) {
+                resolve(true);
+              } else {
+                reject(false);
+              }
+            });
+          } else {
+            reject(false);
+          }
+        });
+      } catch {
+        reject(false);
+      }
+    });
+  },
+  initRoute: async (e, ...args) => {
+    const _data = await getRouteData(args[0][0].ROUTE_CODE);
+    args[0][1] = ref({
+      nodes: [],
+      edges: [],
+    });
+    return new Promise((resolve, reject) => {
+      try {
+        LogicFlow.use(BpmnElement);
+        const lf = 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';
+          },
+        });
+        lf.register(customEdge);
+        lf.register(actionRect);
+        lf.register(TestNode);
+        lf.register(CollectNode);
+        lf.register(AssemblyNode);
+        lf.register(PackingNode);
+        lf.register(RepairNode);
+        lf.render({});
+        //閫氳繃宸ヨ壓璺嚎ID鑾峰彇鍥惧舰鏁版嵁锛屽苟娓叉煋
+        console.log('缁勪欢宸叉寕杞�', _data);
+        //宸ヨ壓璺嚎鍏ㄤ俊鎭紝鍖呮嫭Node銆丒dge鍜孉ct
+        // routeConfig.routeData = _data.Data;
+        if (_data.Data != null) {
+          //宸ヨ壓璺嚎涓讳俊鎭�
+          const currRoute = _data.Data.route;
+          _data.Data.nodes.forEach((n) => {
+            n.node.properties = JSON.parse(n.node.properties);
+            args[0][1].value.nodes.push(n.node);
+          });
+          console.log('111', args[0][1]);
+          _data.Data.edges.forEach((e) => {
+            e.edge.properties = JSON.parse(e.edge.properties);
+            args[0][1].value.edges.push(e.edge);
+          });
+          _data.Data.acts.forEach((act) => {
+            act.node.properties = JSON.parse(act.node.properties);
+            args[0][1].value.nodes.push(act.node);
+          });
+          console.log('init', unref(lf).getGraphData(), JSON.parse(JSON.stringify(args[0][1])));
+          lf.render(args[0][1].value);
+          // lf.graphModel.resize(500, 400);
+          lf.graphModel.fitView();
+          lf.graphModel.translateCenter();
+        }
+        resolve(true);
+      } catch {
+        reject(false);
+      }
+    });
   },
 };
 
@@ -96,7 +279,7 @@
     label: '鐗╂枡缂栫爜',
     required: true,
     colProps: {
-      span: 8,
+      span: 12,
     },
     componentProps: {
       placeholder: '璇疯緭鍏ョ墿鏂欑紪鐮�',
@@ -111,15 +294,7 @@
     component: 'Input',
     label: '鐗╂枡绫诲瀷',
     colProps: {
-      span: 8,
-    },
-  },
-  {
-    field: 'field6',
-    component: 'DatePicker',
-    label: '瀛楁3',
-    colProps: {
-      span: 8,
+      span: 12,
     },
   },
   {
@@ -152,11 +327,16 @@
     },
   },
   {
-    field: 'field8',
-    component: 'Input',
-    label: '瀛楁5',
+    field: 'fieldsc',
+    component: 'Upload',
+    label: '鎵撳嵃妯℃澘',
     colProps: {
       span: 10,
+    },
+    rules: [{ required: true, message: '璇烽�夋嫨涓婁紶鏂囦欢' }],
+    componentProps: {
+      api: uploadApi,
+      multiple: false,
     },
   },
 ];
@@ -224,7 +404,7 @@
     },
     componentProps: {
       api: getEntity,
-      params: { entityName: 'MES_LINE', sqlcmd: ' 1=1 ' },
+      params: { entityName: 'MES_LINE', sqlcmd: ' 1=1 ', order: '' },
       resultField: 'Data.Items',
       labelField: 'LINE_NAME',
       valueField: 'LINE_CODE',
@@ -273,7 +453,12 @@
   },
 ];
 
-//宸ヨ壓璺嚎寮规杩斿洖
+/**
+ * @description: 宸ヨ壓璺嚎寮规杩斿洖
+ * @param {*} d
+ * @param {*} u
+ * @return {*}
+ */
 export function woGetSelectSuccess(d, u) {
   return {
     ROUTE_CODE: d.values['val'],
@@ -281,7 +466,14 @@
   };
 }
 
-/* 鑷畾涔夋ā鎬佹鎵撳紑鏂规硶 */
+/**
+ * @description: 鑷畾涔夋ā鎬佹鎵撳紑鏂规硶
+ * @param {Fn} openModal
+ * @param {string} slotName
+ * @param {Fn} others
+ * @param {array} args
+ * @return {*}
+ */
 export function woCustFn(openModal: Fn, slotName: string, others: Fn[], ...args) {
   switch (slotName) {
     case 'add':
@@ -317,6 +509,7 @@
         tableName: 'MES_ROUTE',
         rowKey: 'ROT_CODE',
         returnFieldName: 'ROUTE_CODE', //杩斿洖鍊艰璧嬪�肩殑瀛楁鍚嶇О
+        searchInfo: {TABLE_NAME: 'MES_ROUTE' }
       });
       break;
     case 'set':

--
Gitblit v1.9.3