From ec0d91353b767f089fa72f3cd1eb62568852710b Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 22 八月 2024 10:39:30 +0800
Subject: [PATCH] 工单管理增加取消下发功能

---
 src/views/tigerprojects/system/lowcode/entityts/BIZ_MES_WO.ts |  147 +++++++++++++++++++++++++++++++------------------
 1 files changed, 93 insertions(+), 54 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/entityts/BIZ_MES_WO.ts b/src/views/tigerprojects/system/lowcode/entityts/BIZ_MES_WO.ts
index 4917931..319c207 100644
--- a/src/views/tigerprojects/system/lowcode/entityts/BIZ_MES_WO.ts
+++ b/src/views/tigerprojects/system/lowcode/entityts/BIZ_MES_WO.ts
@@ -4,16 +4,13 @@
  * @version:
  * @Date: 2024-06-19 20:34:27
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-07-20 22:18:28
+ * @LastEditTime: 2024-08-13 15:49:49
  */
 
 import { Ref, h, ref, render, unref } from 'vue';
-import { GetRoutePTree, RouteToCust, RouteToProd } from '/@/api/tigerapi/mes/router';
 import { GetEnum, SaveEntity, convertToTree, getEntity } from '/@/api/tigerapi/system';
 import { useLocale } from '/@/locales/useLocale';
-import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
 import { useI18n } from '/@/hooks/web/useI18n';
-import { NavItem } from '/@/api/tigerapi/model/basModel';
 import { useMessage } from '/@/hooks/web/useMessage';
 import { useModal } from '/@/components/Modal';
 import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table';
@@ -23,23 +20,15 @@
 import { CustModalParams, FunctionType } from '/@/api/tigerapi/model/systemModel';
 import { SaveMesBatchWo } from '/@/api/tigerapi/mes/wo';
 import { useForm } from '/@/components/Form/index';
-import { uploadApi } from '/@/api/sys/upload';
-import { initRoute } from '../data';
+import { SP_MES_PROD2WO } from '/@/api/tigerapi/mes/router';
+import { cloneDeep } from 'lodash-es';
 
 const { t } = useI18n();
 const { createErrorModal } = useMessage();
 const { getLocale } = useLocale();
 function _default() {
-  /* 瀹氫箟鍙橀噺 */
-  const isNormal = (type: number) => type === 0;
-  const isScan = (type: number) => type === 1;
-  const isAssy = (type: number) => type === 2;
-  const isTest = (type: number) => type === 3;
-  const isAudit = (type: number) => type === 4;
-  const isPrint = (type: number) => type === 5;
-  const isPackage = (type: number) => type === 6;
   const ActionColumn: BasicColumn = {
-    width: 220,
+    width: 180,
     title: '鎿嶄綔',
     dataIndex: 'action',
     slots: { customRender: 'action' },
@@ -54,7 +43,7 @@
      * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓�
      * @return {*}
      */
-    CreateAction: (fnName: string) => {
+    CreateAction: (type: string) => {
       return {
         action: 'drawer', //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�)
       };
@@ -203,7 +192,8 @@
     GetSelectSuccess: (d, u) => {
       return {
         ROUTE_CODE: d.values['val'],
-        ID: d.values['id'],
+        // ID: d.values['id'],
+        ROT_ID: d.values['id'],
       };
     },
     /**
@@ -249,13 +239,14 @@
             ],
             tableName: 'MES_ROUTE',
             rowKey: 'ROT_CODE',
-            returnFieldName: 'ROUTE_CODE', //杩斿洖鍊艰璧嬪�肩殑瀛楁鍚嶇О
+            returnFieldName: ['ROUTE_CODE', 'ROT_ID'], //杩斿洖鍊艰璧嬪�肩殑瀛楁鍚嶇О
             searchInfo: { TABLE_NAME: 'MES_ROUTE' },
           });
           break;
         case 'set':
-        case 'setRot':
           openRvModal(true, { rotId: selectVals.value['ROUTE_CODE'], slotName: slotName });
+          break;
+        case 'setRot':
           break;
       }
     },
@@ -279,10 +270,17 @@
         try {
           const form = param.values['prodinfo'];
           const wo = param.values['mValues'];
-          wo.ROUTE_STATUS = 1;
-          SaveEntity(wo, true, 'BIZ_MES_WO').then((action) => {
+          const _wo = cloneDeep(wo);
+          _wo.ROUTE_STATUS = 1;
+          _wo.ROUTE_CODE = form.ROUTE_CODE;
+          SaveEntity(_wo, true, 'BIZ_MES_WO').then((action) => {
             if (action.IsSuccessed) {
-              resolve(action);
+              SP_MES_PROD2WO({ rotId: form.ROT_ID, wo: wo.ORDER_NO }).then((res) => {
+                if (!res.IsSuccessed) {
+                  SaveEntity(wo, true, 'BIZ_MES_WO');
+                }
+                resolve(res);
+              });
             } else {
               reject(action);
             }
@@ -313,7 +311,7 @@
               UPDATE_TIME: new Date(),
               UPDATE_USER: useUserStore().getUserInfo.userId as string,
               GHOST_ROW: false,
-              AUTH_ORG: '',
+              AUTH_ORG: useUserStore().getUserInfo.orgCode,
               AUTH_PROD: useUserStore().getUserInfo.prodCode as string,
               AUTH_WH: '',
               ORDER_NO: wo.ORDER_NO,
@@ -322,7 +320,7 @@
               CUST_CODE: wo.CUST_CODE,
               FACTORY: wo.FACTORY,
               WS_CODE: wo.WS_CODE,
-              ACT_LINE: form.PLAN_LINE,
+              ACT_LINE: form.ACT_LINE,
               STD_WORKER_QTY: wo.STD_WORKER_QTY,
               ACT_WORKER_QTY: wo.ACT_WORKER_QTY,
               RELEASE_TIME: new Date(),
@@ -371,6 +369,7 @@
       keyFieldValues: { ORDER_NO: params['record']['ORDER_NO'] },
       colSlots: params['colSlots'].value,
       SessionName: 'BIZ_MES_WO_BATCH_update',
+      ifSave: false,
     };
     // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage
     sessionStorage.removeItem(`${id.SessionName}_params`);
@@ -385,26 +384,54 @@
    * @return {*}
    */
   function handleConfig(args, params: Recordable) {
-    const openCustModal = args[7];
-    // rotSchema.value = getFormSchema('rotinfo');
-    params['routeData'].value = {
-      nodes: [],
-      edges: [],
+    // const openCustModal = args[7];
+    // // rotSchema.value = getFormSchema('rotinfo');
+    // params['routeData'].value = {
+    //   nodes: [],
+    //   edges: [],
+    // };
+    // initRoute(params['currlf'], params['record'].ROUTE_CODE, params['routeData'], params['currlf']);
+    // getEntity({
+    //   sqlcmd: `ROT_CODE = '${params['record'].ROUTE_CODE}'`,
+    //   entityName: 'MES_ROUTE',
+    //   order: '',
+    // }).then((rot) => {
+    //   params['selectVals'].value['ROUTE_CODE'] = params['record'].ROUTE_CODE;
+    //   params['selectVals'].value['ROT_ID'] =
+    //     !isNullOrEmpty(rot.Data) && !isNullOrEmpty(rot.Data.Items) ? rot.Data.Items[0].ID : '';
+    //   openCustModal(true, {
+    //     isUpdate: true,
+    //     ctype: 'BIZ_MES_WO_Config',
+    //     title: '宸ヨ壓閰嶇疆',
+    //     width: '1200px',
+    //     formEl: params['useFormData'].value, //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы
+    //     formElName: ['woinfo', 'prodinfo', 'rotinfo'], //琛ㄥ崟鎻掓Ы鍚嶇О锛屾敮鎸佸涓〃鍗�
+    //     RowKey: '',
+    //     fnName: 'SaveCofig', //淇濆瓨鏂规硶鍚�
+    //     others: params['routeData'].value,
+    //     values: { ...params['record'], ...params['selectVals'].value }, //琛ㄥ崟璁板綍
+    //   });
+    // });
+    const go = args[5];
+    const id = {
+      ID: params['record'].ID,
+      Name: 'WoRouteBinding',
+      CODE: params['record'].ORDER_NO,
+      Title: `宸ュ崟[${params['record'].ORDER_NO}]宸ヨ壓缁戝畾`,
+      colSlots: params['colSlots'].value, /* 琛ㄦ牸鍐呯殑鏌ヨ琛ㄥ崟瀛楁鐨勬彃妲藉垪琛紝涓�鑸敤浜庡脊鍑洪�夋嫨妗嗘寜閽� */
+      crudColSlots: {BAS_PKG_DTL:['BAS_LABEL_TEMP1add'], ItemCode: ['BAS_CODE_RULE1add']} /* 澧炲垹鏀硅〃鍗曞瓧娈电殑鎻掓Ы鍒楄〃锛屼竴鑸敤浜庡脊鍑洪�夋嫨妗嗘寜閽� */,
+      OtherTableName: ['BAS_PKG_DTL', 'ItemCode'], /* 鑷畾涔夋樉绀哄垪琛ㄧ殑琛ㄥ悕锛岃窡涓婇潰澧炲垹鏀圭殑琛ㄥ悕涓�鑷达紝鏈夊涓氨鏀惧垪琛ㄤ腑 */
+      dense: true,
+      pageTitle: `宸ュ崟宸ヨ壓缁戝畾`,
+      pageContent: `杩欓噷鏄鐞嗗伐鍗曠殑宸ヨ壓缁戝畾锛屼竴涓伐鍗曞彲浠ョ粦瀹氬涓伐鑹鸿矾绾縛,
+      SessionName: 'WoRouteBinding_update',
+      ifSave: false,
+      rotType: 'Wo'
     };
-    initRoute(params['currlf'], params['record'].ROUTE_CODE, params['routeData'], params['currlf']);
-    params['selectVals'].value['ROUTE_CODE'] = params['record'].ROUTE_CODE;
-    openCustModal(true, {
-      isUpdate: true,
-      ctype: 'BIZ_MES_WO_Config',
-      title: '宸ヨ壓閰嶇疆',
-      width: '1200px',
-      formEl: params['useFormData'].value, //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы
-      formElName: ['woinfo', 'prodinfo', 'rotinfo'], //琛ㄥ崟鎻掓Ы鍚嶇О锛屾敮鎸佸涓〃鍗�
-      RowKey: '',
-      fnName: 'SaveCofig', //淇濆瓨鏂规硶鍚�
-      others: params['routeData'].value,
-      values: params['record'], //琛ㄥ崟璁板綍
-    });
+    // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage
+    sessionStorage.removeItem(`${id.SessionName}_params`);
+    sessionStorage.setItem(`${id.SessionName}_params`, encodeURI(JSON.stringify(id)));
+    go(`/WoRouteBinding/CP/${encodeURI(JSON.stringify({ sName: id.SessionName, Name: id.Name }))}`);
   }
 
   /**
@@ -437,6 +464,9 @@
       colProps: {
         span: 24,
       },
+      dynamicDisabled: ({ values }) => {
+        return true;
+      },
     },
     {
       field: 'RELEASE_QTY',
@@ -448,8 +478,8 @@
       },
     },
     {
-      label: '璁″垝浜х嚎',
-      field: 'PLAN_LINE',
+      label: '瀹為檯浜х嚎',
+      field: 'ACT_LINE',
       component: 'ApiSelect',
       required: true,
       colProps: {
@@ -594,18 +624,27 @@
       },
     },
     {
-      field: 'fieldsc',
-      component: 'Upload',
-      label: '鎵撳嵃妯℃澘',
+      label: '宸ヨ壓璺嚎',
+      field: 'ROT_ID',
+      component: 'Input',
+      show: false,
       colProps: {
-        span: 10,
-      },
-      rules: [{ required: true, message: '璇烽�夋嫨涓婁紶鏂囦欢' }],
-      componentProps: {
-        api: uploadApi,
-        multiple: false,
+        span: 12,
       },
     },
+    // {
+    //   field: 'fieldsc',
+    //   component: 'Upload',
+    //   label: '鎵撳嵃妯℃澘',
+    //   colProps: {
+    //     span: 10,
+    //   },
+    //   rules: [{ required: true, message: '璇烽�夋嫨涓婁紶鏂囦欢' }],
+    //   componentProps: {
+    //     api: uploadApi,
+    //     multiple: false,
+    //   },
+    // },
   ];
 
   return [methods, ActionColumn];

--
Gitblit v1.9.3