From 21a4e09672b1177d40c2bb5b937a8780c5eaa7fb Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期六, 08 三月 2025 15:03:34 +0800
Subject: [PATCH] 一些更新

---
 src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts |  292 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 271 insertions(+), 21 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts
index 457ad5e..a3ff82d 100644
--- a/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts
+++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts
@@ -4,15 +4,17 @@
  * @version:
  * @Date: 2024-06-19 20:34:27
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-07-06 23:15:08
+ * @LastEditTime: 2024-09-11 20:51:11
  */
 
-import { Ref, ref } from 'vue';
-import { DeleteEntity, getEntity } from '/@/api/tigerapi/system';
+import { Ref, ref, unref } from 'vue';
+import { DeleteEntity, getEntity, SaveEntity } from '/@/api/tigerapi/system';
 import { ActionItem, BasicColumn, FormSchema, useTable } from '/@/components/Table';
 import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
 import { useDrawer } from '/@/components/Drawer';
 import { EditOperation, Search, custDel } from '../data';
+import { SaveBasPkgRule } from '/@/api/tigerapi/mes/baserule';
+import { BAS_PKG_RULE } from '/@/api/tigerapi/model/mesModel';
 
 function _default(): any[] {
   const ActionColumn: BasicColumn = {
@@ -34,7 +36,7 @@
      * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓�
      * @return {*}
      */
-    CreateAction: (fnName: string) => {
+    CreateAction: (type: string) => {
       return {
         action: 'drawer', //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�)
       };
@@ -57,22 +59,36 @@
      * @param {*} u
      * @return {*}
      */
-    EditOperation: (data: Ref<any[]>, d, u, item) => {
+    EditOperation: (data: Ref<any[]>, d, u, name) => {
       //鏇存柊
-      var _data = data.value[item].map((item) => {
-        if (item['ID'] == d.ID)
-          return {
-            ...item,
-            PKG_CODE: d.PKG_CODE,
-            PKG_NAME: d.PKG_NAME,
-            PKG_LEVEL: d.PKG_LEVEL,
-            PKG_QTY: d.PKG_QTY,
-            LABEL_CODE: d.LABEL_CODE,
-            REMARK: d.REMARK,
-          };
+      var _data = data.value[name].map((item) => {
+        if (item['ID'] == d.ID) {
+          if (name == 'BAS_PKG_DTL') {
+            return {
+              ...item,
+              PKG_CODE: d.PKG_CODE,
+              PKG_NAME: d.PKG_NAME,
+              PKG_LEVEL: d.PKG_LEVEL,
+              PKG_QTY: d.PKG_QTY,
+              LABEL_CODE: d.LABEL_CODE,
+              REMARK: d.REMARK,
+            };
+          }
+          if (name == 'BAS_PKG_PROD') {
+            return {
+              ...item,
+              ITEM_CODE: d.ITEM_CODE,
+              MIN_WEIGHT: d.MIN_WEIGHT,
+              MIN_UNIT: d.MIN_UNIT,
+              MAX_WEIGHT: d.MAX_WEIGHT,
+              MAX_UNIT: d.MAX_UNIT,
+              REMARK: d.REMARK,
+            };
+          }
+        }
         return item;
       });
-      EditOperation(data, d, u, item, _data);
+      EditOperation(data, d, u, name, _data);
     },
     /**
      * @description: 楂樼骇琛ㄥ崟鍜岃鎯呴〉闈㈣繑鍥炰富椤甸潰鐨剈rl
@@ -197,6 +213,9 @@
         {
           BAS_PKG_DTL: useDrawer(),
         },
+        {
+          BAS_PKG_PROD: useDrawer(),
+        },
       ];
     },
     /**
@@ -229,6 +248,28 @@
             fixed: 'right',
           }, //鑷畾涔夋搷浣滃垪
         }),
+        BAS_PKG_PROD: useTable({
+          title: '鍒楄〃淇℃伅',
+          dataSource: data.value['BAS_PKG_PROD'],
+          columns: baseColumns['BAS_PKG_PROD'],
+          formConfig: {
+            labelWidth: 140,
+            schemas: searchForms['BAS_PKG_PROD'],
+            submitFunc: () => Search('BAS_PKG_PROD', data, args[0]), //鑷畾涔夋煡璇㈡彁浜ゆ寜閽殑鏂规硶锛岃Е鍙戞煡璇㈡彁浜や簨浠�
+          },
+          useSearchForm: true,
+          showTableSetting: false,
+          bordered: true,
+          canResize: true,
+          showIndexColumn: false,
+          actionColumn: {
+            width: 130,
+            title: '鎿嶄綔',
+            dataIndex: 'action',
+            slots: { customRender: 'action' },
+            fixed: 'right',
+          }, //鑷畾涔夋搷浣滃垪
+        }),
       };
     },
     /**
@@ -242,6 +283,12 @@
         case 'BAS_PKG_DTL':
           data = d.data.value[d.type].filter((item) => item.PKG_CODE.includes(d.values.PKG_CODE));
           if (isNullOrEmpty(d.values.PKG_CODE)) {
+            data = d.data.value[d.type];
+          }
+          break;
+        case 'BAS_PKG_PROD':
+          data = d.data.value[d.type].filter((item) => item.ITEM_CODE.includes(d.values.ITEM_CODE));
+          if (isNullOrEmpty(d.values.ITEM_CODE)) {
             data = d.data.value[d.type];
           }
           break;
@@ -259,11 +306,48 @@
         pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀瑰寘瑁呰鍒欏拰鍖呰淇℃伅銆�',
         tableTitle: {
           BAS_PKG_DTL: '鍖呰淇℃伅绠$悊',
+          BAS_PKG_PROD: '绉伴噸鑼冨洿绠$悊',
         },
       };
     },
     GetUseForm: () => {
       return {};
+    },
+    /**
+     * @description: 鎻愪氦鎵�鏈�
+     * @return {*}
+     */
+    SubmitAll: (data: Ref<any[]>, keyFieldValues: Ref<{}>, ...args) => {
+      const validates = args[1].validates;
+      const Keys = args[1].Keys;
+      const isAllUpdate = args[1].isAllUpdate;
+      const baseCards = args[1].baseCards;
+      const IsExist = args[1].IsExist;
+      /* 寰幆淇濆瓨楂樼骇琛ㄥ崟涓富琛ㄥ崟淇℃伅锛屽鏋滄湁澶氫釜鐨勮瘽锛屾墍浠ヨ寰幆 */
+      let i;
+      let p = [] as Promise<any>[];
+      for (i = 0; i < Keys.length; i++) {
+        p.push(
+          SaveEntity(
+            validates[Keys[i]],
+            unref(isAllUpdate),
+            baseCards.value[i]['entityName'],
+            `${IsExist}='${validates[Keys[i]][IsExist]}'`,
+            true,
+          ),
+        );
+      }
+      Promise.all(p).then(() => {
+        SaveBasPkgRule({
+          PkgDtl: data.value['BAS_PKG_DTL'],
+          PkgProd: data.value['BAS_PKG_PROD'],
+          PkgRule: {} as unknown as BAS_PKG_RULE,
+        }).then((action) => {
+          if (action.IsSuccessed) {
+            args[0]();
+          }
+        });
+      });
     },
   };
 
@@ -317,6 +401,16 @@
         },
       },
     ] as FormSchema[],
+    BAS_PKG_PROD: [
+      {
+        field: 'ITEM_CODE',
+        label: '鐗╂枡缂栫爜',
+        component: 'Input',
+        colProps: {
+          span: 8,
+        },
+      },
+    ] as FormSchema[],
   };
 
   const baseColumns = {
@@ -350,6 +444,49 @@
         dataIndex: 'PKG_QTY',
       },
       {
+        title: '鏍囩妯℃澘',
+        dataIndex: 'LABEL_CODE',
+      },
+      {
+        title: '鍖呰瑙勫垯ID',
+        dataIndex: 'PKG_RULE_ID',
+        ifShow: false,
+      },
+      {
+        title: '澶囨敞',
+        dataIndex: 'REMARK',
+      },
+      {
+        title: '鏇存柊鏃堕棿',
+        dataIndex: 'UPDATE_TIME',
+      },
+      {
+        title: '鏇存柊浜�',
+        dataIndex: 'UPDATE_USER',
+      },
+    ] as BasicColumn[],
+    BAS_PKG_PROD: [
+      {
+        title: '鐗╂枡缂栫爜',
+        dataIndex: 'ITEM_CODE',
+      },
+      {
+        title: '绉伴噸涓嬮檺',
+        dataIndex: 'MIN_WEIGHT',
+      },
+      {
+        title: '绉伴噸涓嬮檺鍗曚綅',
+        dataIndex: 'MIN_UNIT',
+      },
+      {
+        title: '绉伴噸涓婇檺',
+        dataIndex: 'MAX_WEIGHT',
+      },
+      {
+        title: '绉伴噸涓婇檺鍗曚綅',
+        dataIndex: 'MAX_UNIT',
+      },
+      {
         title: '鍖呰瑙勫垯ID',
         dataIndex: 'PKG_RULE_ID',
         ifShow: false,
@@ -369,6 +506,7 @@
     ] as BasicColumn[],
   };
 
+  let disableQty = false;
   const crudForms = {
     BAS_PKG_DTL: [
       {
@@ -391,10 +529,18 @@
           span: 24,
         },
         componentProps: ({ formModel }) => {
-          formModel.PKG_LEVEL =
-            _data['BAS_PKG_DTL'].reduce((max, item) => {
-              return max < Number(item.PKG_LEVEL) ? Number(item.PKG_LEVEL) : max;
-            }, 0) + 1;
+          if (isNullOrEmpty(formModel.PKG_LEVEL) || Number(formModel.PKG_LEVEL) == 0) {
+            formModel.PKG_LEVEL =
+              _data['BAS_PKG_DTL'].reduce((max, item) => {
+                return max < Number(item.PKG_LEVEL) ? Number(item.PKG_LEVEL) : max;
+              }, 0) + 1;
+          }
+          // if (formModel.PKG_LEVEL == 1) {
+          //   disableQty = true;
+          //   formModel.PKG_QTY = 1;
+          // } else {
+          //   disableQty = false;
+          // }
           return {
             onChange: (e) => {},
           };
@@ -442,6 +588,27 @@
         colProps: {
           span: 24,
         },
+        dynamicDisabled: ({ values }) => {
+          return disableQty;
+        },
+      },
+      {
+        field: 'LABEL_CODE',
+        label: '妯℃澘缂栫爜',
+        component: 'Input',
+        show: true,
+        // required: true,
+        colProps: {
+          span: 22,
+        },
+      },
+      {
+        field: 'BAS_LABEL_TEMP1PSelect_0', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+PSelect_0锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝PSelect_0杩欐槸涓浐瀹氬悗缂�
+        label: '1',
+        defaultValue: 'BAS_LABEL_TEMP',
+        component: 'Input',
+        colProps: { span: 2 },
+        colSlot: 'BAS_LABEL_TEMP1add', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+add锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝add杩欐槸涓浐瀹氬悗缂�
       },
       {
         label: '鍖呰鍚嶇О',
@@ -470,6 +637,89 @@
         show: false,
       },
     ] as FormSchema[],
+    BAS_PKG_PROD: [
+      {
+        label: '鍖呰瑙勫垯ID',
+        field: 'PKG_RULE_ID',
+        component: 'Input',
+        colProps: {
+          span: 24,
+        },
+        dynamicDisabled: ({ values }) => {
+          return true;
+        },
+      },
+      {
+        label: '鐗╂枡缂栫爜',
+        field: 'ITEM_CODE',
+        component: 'Input',
+        required: true,
+        colProps: {
+          span: 22,
+        },
+      },
+      {
+        field: 'BAS_ITEM1PSelect_0', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+PSelect_0锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝PSelect_0杩欐槸涓浐瀹氬悗缂�
+        label: '1',
+        defaultValue: 'BAS_ITEM',
+        component: 'Input',
+        colProps: { span: 2 },
+        colSlot: 'BAS_ITEM1add', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+add锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝add杩欐槸涓浐瀹氬悗缂�
+      },
+      {
+        label: '绉伴噸涓嬮檺',
+        field: 'MIN_WEIGHT',
+        component: 'Input',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '绉伴噸涓嬮檺鍗曚綅',
+        field: 'MIN_UNIT',
+        required: true,
+        component: 'Input',
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '绉伴噸涓婇檺',
+        field: 'MAX_WEIGHT',
+        required: true,
+        component: 'Input',
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '绉伴噸涓婇檺鍗曚綅',
+        field: 'MAX_UNIT',
+        required: true,
+        component: 'Input',
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '澶囨敞',
+        field: 'REMARK',
+        component: 'Input',
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: 'ID',
+        field: 'ID',
+        component: 'Input',
+        colProps: {
+          span: 24,
+        },
+        show: false,
+      },
+    ] as FormSchema[],
   };
 
   return [methods, ActionColumn];

--
Gitblit v1.9.3