From e34d8f9133f196f17667d8051a6a9d080b0385fb Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期六, 06 七月 2024 22:25:10 +0800
Subject: [PATCH] 优化提示

---
 src/views/tigerprojects/system/lowcode/high/index.vue |  116 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 70 insertions(+), 46 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/high/index.vue b/src/views/tigerprojects/system/lowcode/high/index.vue
index 8a05ce8..7209fc6 100644
--- a/src/views/tigerprojects/system/lowcode/high/index.vue
+++ b/src/views/tigerprojects/system/lowcode/high/index.vue
@@ -4,7 +4,7 @@
  * @version: 
  * @Date: 2024-06-18 15:09:48
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-07-02 03:42:25
+ * @LastEditTime: 2024-07-04 23:59:15
 -->
 <!--
  *                        _oo0oo_
@@ -49,12 +49,12 @@
     @back="goBack"
   >
     <Suspense>
-      <baseForm />
+      <baseForm :entityName="entityName" />
     </Suspense>
     <!-- <a-card :title="titleInfo['baseTableTitle']" :bordered="false" class="!mt-5"> -->
-      <Suspense>
-        <dtl :entityName="entityName" />
-      </Suspense>
+    <Suspense>
+      <dtl :entityName="entityName" @search="dtlFormSearch" />
+    </Suspense>
     <!-- </a-card> -->
     <a-card
       :title="item.title"
@@ -105,7 +105,7 @@
   import dtl from './dtl.vue';
   import baseForm from './baseForm.vue';
   import GeneralModal from '/@/views/components/GeneralModal.vue';
-  import { AddListEntity, DeleteWhere, SaveEntity, getEntity } from '/@/api/tigerapi/system';
+  import { AddAfterDelete, SaveEntity } from '/@/api/tigerapi/system';
   import { useGlobSetting } from '/@/hooks/setting';
   import { useRoute, useRouter } from 'vue-router';
   import CustModal from '/@/views/components/CustModal.vue';
@@ -119,7 +119,7 @@
   import { buildUUID } from '/@/utils/uuid';
   import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
   import { useI18n } from '/@/hooks/web/useI18n';
-import { Reactified } from '@vueuse/core';
+  import { isFunction } from 'xe-utils';
 
   const { t } = useI18n();
 
@@ -135,9 +135,12 @@
     return tabStore.getTabList.find((item) => item.fullPath === route.fullPath)!;
   }
   const currentTab = getCurrentTab();
-  const objParams = ref(JSON.parse(decodeURI(route.params?.id as string)));
+  const routeParams = ref(JSON.parse(decodeURI(route.params?.id as string)));
+  const entityName = ref(routeParams.value.Name);
+  // 浠巗essionStorage涓鍙栧弬鏁板苟杞崲鍥炲璞�
+  const savedParams = sessionStorage.getItem(`${routeParams.value.sName}_params`);
+  const objParams = savedParams ? ref(JSON.parse(decodeURI(savedParams))) : ref({});
   const titleInfo = ref({}); //getTitle(objParams.value.Name);
-  const entityName = ref(objParams.value.Name);
   const isAllUpdate = ref(objParams.value.CODE != '0');
   const globSetting = useGlobSetting();
   const formSchemas = ref({}); //寮瑰嚭妗嗘垨楂樼骇椤甸潰澶氳〃鍗曠粨鏋�
@@ -151,16 +154,18 @@
   const otherCards = ref([] as any[]);
   const isMounted = ref(false);
   const custImport = ref<any[]>([]);
-  const others = ref<any>(null);
+  const keyFieldValues = ref<any>(null);
   const data = ref<any>({});
-  for(const i in objParams.value['drawers']){
+  const useTables = ref<any>({});
+  for (const i in objParams.value['drawers']) {
     data.value[objParams.value['drawers'][i]['name']] = ref<Recordable[]>([]);
   }
-  provide<Ref<any>>('objParams', objParams.value);
+  provide<Ref<any>>('objParams', objParams);
   provide<Ref<any>>('data', data);
-  provide<Ref<any>>('others', others);
+  provide<Ref<any>>('keyFieldValues', keyFieldValues);
   provide<Ref<{}>>('useFormData', useFormData);
   provide<Ref<any>>('baseCards', baseCards);
+  provide<Ref<any>>('useTables', useTables);
 
   const [registerCust, { openModal: openCustomModal, closeModal }] = useModal();
   const { setTitle } = useTabs();
@@ -180,7 +185,7 @@
     /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */
     try {
       custImport.value = await import(`../entityts/${entityName.value}.ts`);
-      const [{GetTitle}] = custImport.value['default']();
+      const [{ GetTitle }] = custImport.value['default']();
       titleInfo.value = GetTitle();
     } catch (e) {}
     isMounted.value = true;
@@ -190,42 +195,42 @@
    * @description: 寮傛鍏ㄩ儴鎻愪氦鏂规硶
    * @return {*}
    */
-  function submitAll() {
+  async function submitAll() {
     try {
-      validate().then((res) => {
-        const Keys = Object.getOwnPropertyNames(useFormData.value);
-        let i;
-        let p = [] as Promise<any>[];
-        for (i = 0; i < Keys.length; i++) {
-          p.push(SaveEntity(res[Keys[i]], unref(isAllUpdate), baseCards.value[i]['entityName']));
-        }
-        Promise.all(p).then((action) => {
-          DeleteWhere(
-            ` ${objParams.value.pCode} = '${others.value[objParams.value.pCode]}'`,
-            entityName.value,
-          ).then((res) => {
-            if (res.IsSuccessed) {
-              data.value.forEach((item) => {
-                item.ID = buildUUID();
-              });
-              AddListEntity(data.value, entityName.value).then((action) => {
-                if (action.IsSuccessed) {
-                  cancel();
-                }
-              });
+      const validates = await validate();
+      const Keys = Object.getOwnPropertyNames(useFormData.value);
+      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']),
+        );
+      }
+      await Promise.all(p);
+      if (
+        !custImport.value['default']()[0].SubmitAll &&
+        !isFunction(custImport.value['default']()[0].SubmitAll)
+      ) {
+        /* 榛樿鎻愪氦 */
+        objParams.value['drawers'].forEach((d) => {
+          let where = `${d['code']} = '${keyFieldValues.value[d['code']]}'`;
+          /* type: all-琛ㄧず闇�瑕乧ode鐨勬墍鏈夌殑鍊� */
+          if (d['type'] == 'all' && data.value[d['keyName']].length > 0) {
+            where = `${d['code']} in (${data.value[d['keyName']].map((value) => `'${value[d['code']]}'`).join(',')})`;
+          }
+          data.value[d['name']].map((item) => {
+            item.ID = buildUUID();
+          });
+          AddAfterDelete(d['name'], data.value[d['name']], where).then((action) => {
+            if (action.IsSuccessed) {
+              cancel();
             }
           });
         });
-      });
-      // values.ID = params.RULE_ID;
-      // const action = await SaveRule({ ...values, ...testValues });
-      // if (action.IsSuccessed) {
-      //   await DeleteRuleDtl(params.RULE_ID);
-      //   const dtlAction = await SaveRuleDtl(data.value);
-      //   if (dtlAction.IsSuccessed) {
-      //     cancel();
-      //   }
-      // }
+      } else {
+        /* 濡傛灉鑷畾涔夋彁浜ゆ柟娉曞瓨鍦ㄥ氨鐢ㄨ嚜瀹氫箟鎻愪氦 */
+        custImport.value['default']()[0].SubmitAll(data, keyFieldValues, cancel);
+      }
     } catch (error) {}
   }
   async function cancel() {
@@ -249,6 +254,25 @@
   }
 
   /**
+   * @description: 琛ㄦ牸鏌ヨ鍥炶皟锛屾牴鎹搴斿瓙缁勪欢涓〃鏍肩殑鏌ヨ鎸夐挳鎻愪氦浜嬩欢杞叆鍔ㄦ�佽皟鐢ㄧ殑瀹炰綋鍚嶆柟娉曞幓鎵ц瀵瑰簲鐨勬煡璇㈤�昏緫锛岃繑鍥炲悗鍒锋柊鏁版嵁
+   * @param {*} d
+   * @return {*}
+   */
+  function dtlFormSearch(d) {
+    try {
+      var values = useTables.value[d.type][1].getForm().getFieldsValue();
+      let data = custImport.value['default']()[0].FormSearch({ ...d, ...{ values: values } });
+      useTables.value[d.type][1].setProps({
+        dataSource: [],
+      });
+      useTables.value[d.type][1].setProps({
+        dataSource: data,
+      });
+      useTables.value[d.type][1].reload();
+    } catch (e) {}
+  }
+
+  /**
    * @description: Select 鑷畾涔塷nChange鏂规硶
    * @param {*} obj
    * @return {*}

--
Gitblit v1.9.3