From 323e576c64129723df20fd18effb20d96d8d18b3 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期一, 22 七月 2024 10:27:50 +0800
Subject: [PATCH] 工单更新

---
 src/views/tigerprojects/system/lowcode/detail/detail.vue |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 110 insertions(+), 4 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/detail/detail.vue b/src/views/tigerprojects/system/lowcode/detail/detail.vue
index 4705ff7..14ba342 100644
--- a/src/views/tigerprojects/system/lowcode/detail/detail.vue
+++ b/src/views/tigerprojects/system/lowcode/detail/detail.vue
@@ -4,9 +4,9 @@
       <template #toolbar>
         <a-button
           type="primary"
+          v-for="item in buttons.filter((m) => m['BUTTON_TYPE'] == 0)"
           @click="handleCreate(item['DO_METHOD'])"
           :preIcon="item['ICON_URL']"
-          v-for="item in buttons.filter((m) => m['BUTTON_TYPE'] == 0)"
           :key="item"
         >
           {{ item['FUNC_NAME'] }}
@@ -30,16 +30,47 @@
         />
       </template>
     </BasicTable>
+    <Suspense>
+      <CustModal
+        @register="registerCust"
+        @success="custSuccess"
+        @cancel="custCancel"
+        :type="cType"
+        :entityName="entityName"
+        @modalInner="getdtlSlots"
+      >
+        <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� -->
+        <template #[item.name] v-for="item in dtlSlots" :key="item.name">
+          <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]">
+            <!-- 鐢ㄦ彃妲借嚜瀹氫箟寮瑰嚭閫夋嫨妗� -->
+            <template #[name]="{ field }" v-for="name in item.slots" :key="name">
+              <a-button
+                class="mt-1 ml-1"
+                size="small"
+                @click="handleCustClick(field)"
+                :preIcon="item.preIcons[name]"
+              />
+              <GeneralModal
+                @register="useModalData[name][0]"
+                @success="(d, u) => handleEntSuccess(d, u, item.name)"
+              />
+            </template>
+          </BasicForm>
+          <!-- 鑷畾涔夊唴瀹� -->
+        </template>
+      </CustModal>
+    </Suspense>
     <normalDrawer @register="registerDrawer" @success="handleSuccess" />
   </div>
 </template>
 <script lang="ts" setup>
   import { Ref, inject, onMounted, ref } from 'vue';
   import { BasicTable, useTable, TableAction } from '/@/components/Table';
-  import { useForm } from '/@/components/Form/index';
+  import { BasicForm, useForm } from '/@/components/Form/index';
   import { useDrawer } from '/@/components/Drawer';
   import GeneralModal from '/@/views/components/GeneralModal.vue';
   import normalDrawer from '../normalDrawer.vue';
+  import CustModal from '/@/views/components/CustModal.vue';
   import { isFunction, isNullOrUnDef } from '/@/utils/is';
   import { useModal } from '/@/components/Modal';
   import { useGo } from '/@/hooks/web/usePage';
@@ -62,11 +93,11 @@
   const go = useGo();
   const [registerDrawer, { openDrawer }] = useDrawer();
   const [registerItemAdd, { openModal: openItemModal }] = useModal();
+  const [registerCust, { openModal: openCustModal }] = useModal();
   const cType = ref('');
+  const selectVals = ref({});
   const colSlots = ref<any>(objParams['colSlots']); //鎸夐挳鎻掓Ы
   const dtlSlots = ref([] as any[]);
-  const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶
-  const useFormData = ref({});
   const custImport = ref<any[]>([]);
   const EntityCustFunction = ref([
     {
@@ -94,6 +125,8 @@
       KeyFieldValues,
       GetSelectSuccess,
       OpenSelectItem,
+      GetUseForm,
+      GetUseModals,
     },
   ] = isNullOrUnDef(custImport.value['default'])
     ? EntityCustFunction.value
@@ -103,6 +136,11 @@
     KeyFieldValues && isFunction(KeyFieldValues)
       ? KeyFieldValues(objParams['CODE'], objParams['ID'])
       : [];
+  const useformdata = GetUseForm && isFunction(GetUseForm) ? GetUseForm() : {};
+  const useFormData = ref<any>(useformdata);
+  /* 琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 */
+  const modals = GetUseModals && isFunction(GetUseModals) ? GetUseModals() : { useModalData: {} };
+  const useModalData = ref(modals['useModalData']);
   const [registerTable, { getForm, reload, setProps }] = useTable({
     title: `${objParams['firstTitle']}鍒楄〃`,
     api: getListByPage,
@@ -146,6 +184,8 @@
       useFormData,
       crudColSlots: colSlots.value,
       data,
+      selectVals,
+      colSlots,
     };
     const actionItem = GenerateActionButton(params, buttons, openDrawer, reload);
     if (isNullOrUnDef(custImport.value['default'])) {
@@ -161,6 +201,7 @@
       useModal,
       go,
       setProps,
+      openCustModal,
     );
   }
 
@@ -241,4 +282,69 @@
   function handleSelectItem(item) {
     OpenSelectItem(openItemModal);
   }
+
+  /**
+   * @description: 寮瑰嚭妗嗙‘瀹氳繑鍥�
+   * @param {*} d
+   * @return {*}
+   */
+  function custSuccess(d) {
+    reload();
+  }
+
+  /**
+   * @description: 寮瑰嚭妗嗗彇娑堣繑鍥�
+   * @param {*} reload
+   * @return {*}
+   */
+  function custCancel() {
+    reload();
+  }
+
+  /**
+   * @description: 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉�
+   * @param {*} d
+   * @param {*} u
+   * @param {*} item
+   * @return {*}
+   */
+  function handleEntSuccess(d, u, item) {
+    /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */
+    try {
+      var values = GetSelectSuccess(d, u);
+      selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋�
+      let _val = {};
+      d.returnFieldName.map((x) => {
+        _val[x] = values[x];
+      });
+      useFormData.value[item][1].setFieldsValue(_val);
+    } catch (e) {}
+  }
+
+  /**
+   * @description: 鎵撳紑琛ㄥ崟涓殑妯℃�佹
+   * @param {*} item
+   * @return {*}
+   */
+  function handleCustClick(item) {
+    OpenSelectItem(
+      useModalData.value[item][1].openModal, //甯﹀叆openModal鏂规硶
+      item,
+      null,
+      selectVals,
+    );
+  }
+
+  /**
+   * @description: 鑾峰彇澶氳〃鍗曟彃妲藉垪琛�
+   * @param {*} d
+   * @return {*}
+   */
+  function getdtlSlots(d, callback) {
+    dtlSlots.value = d;
+    callback();
+    // setTimeout(() => {
+    //   callback();
+    // }, 100);
+  }
 </script>

--
Gitblit v1.9.3