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 |   84 ++++++++++++++++-------------------------
 1 files changed, 33 insertions(+), 51 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/high/index.vue b/src/views/tigerprojects/system/lowcode/high/index.vue
index 2fc2b7a..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 22:51:31
+ * @LastEditTime: 2024-07-04 23:59:15
 -->
 <!--
  *                        _oo0oo_
@@ -105,13 +105,7 @@
   import dtl from './dtl.vue';
   import baseForm from './baseForm.vue';
   import GeneralModal from '/@/views/components/GeneralModal.vue';
-  import {
-    AddAfterDelete,
-    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';
@@ -125,6 +119,7 @@
   import { buildUUID } from '/@/utils/uuid';
   import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
   import { useI18n } from '/@/hooks/web/useI18n';
+  import { isFunction } from 'xe-utils';
 
   const { t } = useI18n();
 
@@ -159,7 +154,7 @@
   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>({});
   const useTables = ref<any>({});
   for (const i in objParams.value['drawers']) {
@@ -167,7 +162,7 @@
   }
   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);
@@ -200,55 +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();
-          //       }
-          //     });
-          //   }
-          // });
-          let where = `${objParams.value['drawers'][0]['code']} = '${others.value[objParams.value['drawers'][0]['code']]}'`;
-          data.value[objParams.value['drawers'][0]['name']].forEach((item) => {
+      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(
-            objParams.value['drawers'][0]['name'],
-            data.value[objParams.value['drawers'][0]['name']],
-            where,
-          ).then((action) => {
+          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() {

--
Gitblit v1.9.3