From 07895c65b99fa43f8e54f5054bd8351a71158143 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 17 十月 2024 21:17:28 +0800
Subject: [PATCH] 工艺路线绑定优化

---
 src/store/modules/prodRoute.ts                                      |   27 ++++++---
 src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts |   16 +++-
 src/views/components/GeneralModal.vue                               |   11 +--
 src/views/tigerprojects/system/lowcode/entityts/WoRouteBinding.ts   |   21 ++++---
 src/views/tigerprojects/system/lowcode/composition/Config.vue       |   46 +++++++++------
 src/api/tigerapi/system.ts                                          |    2 
 src/views/components/GeneralCrudModal.vue                           |    2 
 7 files changed, 73 insertions(+), 52 deletions(-)

diff --git a/src/api/tigerapi/system.ts b/src/api/tigerapi/system.ts
index d06f975..e6a9a45 100644
--- a/src/api/tigerapi/system.ts
+++ b/src/api/tigerapi/system.ts
@@ -316,7 +316,7 @@
  * @param {string} childId
  * @return {*}
  */
-export function findParent(tree: any[], nodeId: number): any | undefined {
+export function findParent(tree: any[], nodeId: string): any | undefined {
   for (const node of tree) {
       if (node.children) {
           for (const child of node.children) {
diff --git a/src/store/modules/prodRoute.ts b/src/store/modules/prodRoute.ts
index c60b36e..b3d2342 100644
--- a/src/store/modules/prodRoute.ts
+++ b/src/store/modules/prodRoute.ts
@@ -4,7 +4,7 @@
  * @version:
  * @Date: 2024-06-18 15:09:47
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-10-16 00:41:53
+ * @LastEditTime: 2024-10-17 14:43:28
  */
 import { defineStore } from 'pinia';
 import { store } from '@/store';
@@ -15,25 +15,27 @@
 
 interface ProdRouteState {
   curProdRotTree: MesRotTree[];
-  curPkgConfig: any;
+  curConfig: any;
   curSelectedNodes: any;
   ItemCode: string;
+  curDtl: any
 }
 
 export const useProdRouteStore = defineStore({
   id: 'app-prodrot',
   state: (): ProdRouteState => ({
     curProdRotTree: [],
-    curPkgConfig: {},
+    curConfig: {},
     curSelectedNodes: {},
-    ItemCode: ''
+    ItemCode: '',
+    curDtl: {}
   }),
   getters: {
     getCurProdRotTree(state): MesRotTree[] {
       return state.curProdRotTree;
     },
-    getCurPkgConfig(state): any {
-      return state.curPkgConfig;
+    getCurConfig(state): any {
+      return state.curConfig;
     },
     getCurSelectedNodes(state): any {
       return state.curSelectedNodes;
@@ -41,10 +43,13 @@
     getItemCodes(state): string {
       return state.ItemCode;
     },
+    getcurDtl(state): any {
+      return state.curDtl;
+    },
   },
   actions: {
     setCurPkgConfig(val: any) {
-      this.curPkgConfig = val;
+      this.curConfig = val;
     },
     setCurProdRotTree(info: MesRotTree[]) {
       this.curProdRotTree = info;
@@ -55,10 +60,14 @@
     setItemCode(val: string) {
       this.ItemCode = val;
     },
+    setcurDtl(val: any) {
+      this.curDtl = val;
+    },
     resetState() {
       this.curProdRotTree = [];
-      this.curPkgConfig = {};
+      this.curConfig = {};
       this.curSelectedNodes = {};
+      this.curDtl = {};
     },
     /**
      * @description: 璁剧疆榛樿宸ヨ壓璺嚎
@@ -99,7 +108,7 @@
      * @return {*}
      */    
     getParent(tid: string): MesRotTree{
-      return findParent(this.getCurProdRotTree,tid) as unknown as MesRotTree;
+      return findParent(this.getCurProdRotTree, tid) as unknown as MesRotTree;
     }
   },
 });
diff --git a/src/views/components/GeneralCrudModal.vue b/src/views/components/GeneralCrudModal.vue
index 9defb6e..cd60d7c 100644
--- a/src/views/components/GeneralCrudModal.vue
+++ b/src/views/components/GeneralCrudModal.vue
@@ -1,7 +1,7 @@
 <template>
   <BasicModal
     :width="width"
-    :height="650"
+    :height="750"
     v-bind="$attrs"
     @register="register"
     :title="title"
diff --git a/src/views/components/GeneralModal.vue b/src/views/components/GeneralModal.vue
index 8955d04..639e25d 100644
--- a/src/views/components/GeneralModal.vue
+++ b/src/views/components/GeneralModal.vue
@@ -1,7 +1,7 @@
 <template>
   <BasicModal
     width="800px"
-    :height="600"
+    :height="450"
     v-bind="$attrs"
     @register="register"
     :title="title"
@@ -53,6 +53,8 @@
     },
     useSearchForm: true,
     showTableSetting: false,
+    scroll: { y: 350 },
+    canResize: false,
     rowKey: rowKey,
     rowSelection: {
       selectedRowKeys: checkedKeys.value,
@@ -70,13 +72,6 @@
     },
     bordered: true,
     showIndexColumn: false,
-    // actionColumn: {
-    //   width: 80,
-    //   title: '鎿嶄綔',
-    //   dataIndex: 'action',
-    //   slots: { customRender: 'action' },
-    //   fixed: 'right' //undefined,
-    // },
   });
   const [register, { setModalProps, closeModal }] = useModalInner((data) => {
     setModalProps({ confirmLoading: false });
diff --git a/src/views/tigerprojects/system/lowcode/composition/Config.vue b/src/views/tigerprojects/system/lowcode/composition/Config.vue
index 77d33d0..17c33a1 100644
--- a/src/views/tigerprojects/system/lowcode/composition/Config.vue
+++ b/src/views/tigerprojects/system/lowcode/composition/Config.vue
@@ -4,7 +4,7 @@
  * @version: 
  * @Date: 2024-06-24 23:44:31
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-09-29 16:23:30
+ * @LastEditTime: 2024-10-17 20:28:47
 -->
 <template>
   <Card :title="GetTitle(configType)['configTitle']">
@@ -34,16 +34,18 @@
   <Card
     :title="GetTitle(configType, item)['tableTitle']"
     :bordered="false"
-    class="!mt-5"
     v-for="item in OtherTables"
     :key="item"
     v-show="showOtherTable[item]"
+    class="mt-1"
   >
+  <div :style="custTableStyle" >
     <BasicTable @register="useTables[item][0]" v-if="showOtherTable[item]">
       <template #action="{ record }">
         <TableAction :actions="createActions(record, item)" />
       </template>
     </BasicTable>
+  </div>
     <normalDrawer @register="useDrawers[item][0]" @success="(d, u) => EditSuccess(d, u, item)" />
     <GeneralCrudModal @register="useModalsCrud[item][0]"></GeneralCrudModal>
   </Card>
@@ -62,6 +64,8 @@
   import { useDrawer } from '/@/components/Drawer';
   import normalDrawer from '../normalDrawer.vue';
   import { useModal } from '/@/components/Modal';
+  import { useProdRouteStore } from '/@/store/modules/prodRoute';
+  import { storeToRefs } from 'pinia';
 
   const { t } = useI18n();
   const emit = defineEmits(['success', 'register']);
@@ -113,10 +117,11 @@
   ] = isNullOrUnDef(custImport.value['default'])
     ? EntityCustFunction.value
     : custImport.value['default']();
-
+  const useProdRoute = useProdRouteStore();
+  const { curDtl } = storeToRefs(useProdRoute);
   const useModalData = ref(GetUseModals());
-  const data = ref({});
-  const useTables = ref(GetUseTables(data, emit));
+  // const data = ref({});
+  const useTables = ref(GetUseTables(curDtl, emit));
   const useForms = ref(GetUseForm());
   const useDrawers = ref({});
   const useModalsCrud = ref({});
@@ -127,6 +132,9 @@
     showOtherTable.value[x] = false;
     useDrawers.value[x] = useDrawer();
     useModalsCrud.value[x] = useModal();
+  });
+  const custTableStyle = ref({
+    height: window.screen.width == 1366? '350px': '450px'
   });
 
   /* 娉ㄥ叆閫変腑鑺傜偣鏁版嵁 */
@@ -150,9 +158,9 @@
             const name = result['name'];
             if (showOtherTable.value[name]) {
               showOtherTable.value[name] = false;
-              data.value[name] = result[name];
-              data.value['Action'] = result['Action'];
-              useTables.value = GetUseTables(data, emit);
+              // data.value[name] = curDtl.value[name]; //result[name];
+              // data.value['Action'] = curDtl.value['Action']; //result['Action'];
+              useTables.value = GetUseTables(curDtl, emit);
               setTimeout(() => {
                 showOtherTable.value[name] = true;
               }, 10);
@@ -180,10 +188,10 @@
     const nodes = selectedNodes.value;
     nodeChange({ useForms, objParams, selectedNodes: nodes }).then((result) => {
       showOtherTable.value = result.isShow;
-      data.value[configType.value as string] = result[configType.value as string];
-      useTables.value = GetUseTables(data, emit);
-      if (showOtherTable.value[result['name']]) {
-        data.value[result['name']] = result[result['name']];
+      // data.value[configType.value as string] = curDtl.value[configType.value as string]; //result[configType.value as string];
+      useTables.value = GetUseTables(curDtl, emit);
+      if (showOtherTable.value[curDtl.value['name']]) {
+        // curDtl.value[result['name']] = curDtl.value[result['name']];
         // useTables.value[result['name']][1].setProps({
         //   dataSource: [],
         // });
@@ -263,7 +271,7 @@
       CustFunc({
         ctype: item,
         values: d,
-        data: data,
+        data: curDtl,
       }).then(() => {
         /* 鏄剧ず鍏朵粬琛ㄦ牸 */
         if (showOtherTable.value[item]) {
@@ -271,12 +279,12 @@
           setTimeout(() => {
             showOtherTable.value[item] = true;
           }, 10);
-          useTables.value = GetUseTables(data, emit);
+          useTables.value = GetUseTables(curDtl, emit);
           setTimeout(() => {
             useTables.value[item][1].reload();
             useForms.value[configType.value as string][1].resetFields();
             useForms.value[configType.value as string][1].setFieldsValue(
-              data.value[configType.value as string][0],
+              curDtl.value[configType.value as string][0],
             );
           }, 10);
         }
@@ -311,17 +319,17 @@
   function SelectInFormSuccess(d, u, item) {
     GetSelectSuccess(d, u, item).then((result) => {
       useForms.value[configType.value][1].setFieldsValue(result['value']);
-      if (!isNullOrUnDef(data.value[configType.value as string])) {
-        data.value[configType.value as string].map((x) => {
+      if (!isNullOrUnDef(curDtl.value[configType.value as string])) {
+        curDtl.value[configType.value as string].map((x) => {
           Object.getOwnPropertyNames(result['value']).forEach((key) => {
             x[key] = result['value'][key];
           });
         });
       }
       showOtherTable.value = result['isShow'];
-      data.value[result.name] = result['data'];
+      curDtl.value[result.name] = result['data'];
       /* 閲嶆柊useTable锛屽惁鍒欐暟鎹笉鍒锋柊 */
-      useTables.value = GetUseTables(data, emit);
+      useTables.value = GetUseTables(curDtl, emit);
       if (showOtherTable.value[result.name]) {
         showOtherTable.value[result.name] = false;
         setTimeout(() => {
diff --git a/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts b/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts
index 8b9522a..d85f099 100644
--- a/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts
+++ b/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts
@@ -4,7 +4,7 @@
  * @version:
  * @Date: 2024-06-19 20:34:27
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-10-16 00:10:37
+ * @LastEditTime: 2024-10-17 20:56:33
  */
 
 import { Ref, h, ref, render, unref } from 'vue';
@@ -274,6 +274,7 @@
               ItemCode: false,
             };
           }
+          useProdRoute.setcurDtl(result);
           resolve(result);
         } catch (e) {
           reject(e);
@@ -296,6 +297,9 @@
         }
         values.AUTH_ORG = useUserStore().getUserInfo.orgCode;
         values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
+        if(type == 'Action'){
+          values.OPTION_1 = JSON.stringify(useProdRoute.getcurDtl['BAS_PKG_DTL'])
+        }
         SaveEntity(values, true, entityName).then((action) => {
           if (action.IsSuccessed) {
             emit('success');
@@ -512,11 +516,13 @@
           // searchInfo: { TABLE_NAME: 'V_BAS_PKG_DTL' },
           dataSource: data.value['BAS_PKG_DTL'],
           columns: GetBaseColumns('BAS_PKG_DTL', args[0], data),
-          maxHeight: 520,
+          // maxHeight: 520,
+          // scroll: { y: window.screen.width == 1366? 400: 450 },
+          isCanResizeParent: true,
           useSearchForm: false,
           showTableSetting: false,
           bordered: true,
-          canResize: true,
+          // canResize: false,
           showIndexColumn: false,
           // rowSelection: {
           //   type: 'radio', //'checkbox'
@@ -1847,8 +1853,8 @@
     {
       title: '榛樿鍊�',
       dataIndex: 'DEFAULT_VALUE',
-      editRow: true,
-      editRule: true,
+      // editRow: true,
+      // editRule: true,
     },
   ] as BasicColumn[];
 
diff --git a/src/views/tigerprojects/system/lowcode/entityts/WoRouteBinding.ts b/src/views/tigerprojects/system/lowcode/entityts/WoRouteBinding.ts
index 7af8b4f..1a7744c 100644
--- a/src/views/tigerprojects/system/lowcode/entityts/WoRouteBinding.ts
+++ b/src/views/tigerprojects/system/lowcode/entityts/WoRouteBinding.ts
@@ -4,7 +4,7 @@
  * @version:
  * @Date: 2024-06-19 20:34:27
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-10-05 16:49:39
+ * @LastEditTime: 2024-10-17 21:13:17
  */
 
 import { Ref, h, ref, render, unref } from 'vue';
@@ -28,12 +28,14 @@
 import { ContextMenuItem } from '/@/components/TigerTree';
 import { AddOrEditLabelVarByWorkOrder, UpdateWoStatus } from '/@/api/tigerapi/mes/wo';
 import { useForm } from '/@/components/Form';
-import { BAS_LABEL_VAR_WO } from '/@/api/tigerapi/model/mesModel';
+import { BAS_LABEL_VAR_WO, MesRotTree } from '/@/api/tigerapi/model/mesModel';
 import { buildUUID } from '/@/utils/uuid';
 import { mesApi } from '/@/api/tigerapi/mes/mesApi';
+import { useProdRouteStore } from '/@/store/modules/prodRoute';
 
 const { t } = useI18n();
 const { createErrorModal } = useMessage();
+const useProdRoute = useProdRouteStore();
 const { getLocale } = useLocale();
 function _default() {
   /* 瀹氫箟鍙橀噺 */
@@ -90,13 +92,7 @@
     fetchTreeData: async (type: string, wo: string) => {
       let data = { title: '', treeData: [] as any[], fieldNames: {} };
       let prodTreeData = await GetWoPTree({ wo: wo });
-      // let uniqueArr = prodTreeData.reduce((acc, current) => {
-      //   if (!acc.some((x) => x.pid == current.pid && x.id == current.id && x.seq == current.seq && x.type == current.type)) {
-      //     acc.push(current);
-      //   }
-      //   return acc;
-      // }, [] as V_MES_ROUTE_PTREE[]);
-      data.treeData = convertToTree(prodTreeData, 'pid', 'tid', 'root');
+      let _treeData = convertToTree(prodTreeData, 'pid', 'tid', 'root');
       if (data.treeData.length == 0) {
         data.treeData.push({
           pid: 'root',
@@ -110,6 +106,9 @@
       }
       data.title = '宸ュ崟宸ヨ壓璺嚎';
       data.fieldNames = { key: 'tid', title: 'name' };
+      /* 淇濆瓨宸ヨ壓鏍戝舰鏁版嵁鍒扮姸鎬佺鐞� */
+      useProdRoute.setCurProdRotTree(_treeData as unknown as MesRotTree[]);
+      data.treeData = useProdRoute.getCurProdRotTree;
       return data;
     },
     /**
@@ -356,6 +355,7 @@
               ItemCode: false,
             };
           }
+          useProdRoute.setcurDtl(result);
           resolve(result);
         } catch (e) {
           reject(e);
@@ -377,6 +377,9 @@
       }
       values.AUTH_ORG = useUserStore().getUserInfo.orgCode;
       values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
+      if(type == 'Action'){
+        values.OPTION_1 = JSON.stringify(useProdRoute.getcurDtl['BAS_PKG_DTL'])
+      }
       SaveEntity(values, true, entityName).then((action) => {
         if (action.IsSuccessed) {
           emit('success');

--
Gitblit v1.9.3