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 | 130 ++++++++++++++++++++++++++---------------- 1 files changed, 80 insertions(+), 50 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/high/index.vue b/src/views/tigerprojects/system/lowcode/high/index.vue index f7b98a0..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-06-25 14:42:29 + * @LastEditTime: 2024-07-04 23:59:15 --> <!-- * _oo0oo_ @@ -49,13 +49,13 @@ @back="goBack" > <Suspense> - <baseForm /> + <baseForm :entityName="entityName" /> </Suspense> - <a-card :title="titleInfo['baseTableTitle']" :bordered="false" class="!mt-5"> - <Suspense> - <dtl :entityName="entityName" /> - </Suspense> - </a-card> + <!-- <a-card :title="titleInfo['baseTableTitle']" :bordered="false" class="!mt-5"> --> + <Suspense> + <dtl :entityName="entityName" @search="dtlFormSearch" /> + </Suspense> + <!-- </a-card> --> <a-card :title="item.title" :bordered="false" @@ -99,18 +99,18 @@ </PageWrapper> </template> <script lang="ts" setup> - import { Ref, h, nextTick, onMounted, provide, ref, unref } from 'vue'; + import { Ref, h, nextTick, onMounted, provide, reactive, ref, unref } from 'vue'; import { Card } from 'ant-design-vue'; import { PageWrapper } from '/@/components/Page'; 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'; import { BasicForm, useForm } from '/@/components/Form/index'; - import { custOnChange, OpenCustModal, getTitle } from '../data'; + import { custOnChange, OpenCustModal } from '../data'; import { useModal } from '/@/components/Modal'; import { useLocale } from '/@/locales/useLocale'; import { useGo } from '/@/hooks/web/usePage'; @@ -119,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(); @@ -134,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 titleInfo = getTitle(objParams.value.Name); - const entityName = ref(objParams.value.Name); + 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 isAllUpdate = ref(objParams.value.CODE != '0'); const globSetting = useGlobSetting(); const formSchemas = ref({}); //寮瑰嚭妗嗘垨楂樼骇椤甸潰澶氳〃鍗曠粨鏋� @@ -150,13 +154,18 @@ const otherCards = ref([] as any[]); const isMounted = ref(false); const custImport = ref<any[]>([]); - const others = ref<any>(null); - const data = ref<Recordable[]>([]); - provide<Ref<any>>('objParams', objParams.value); - provide<Ref<Recordable[]>>('data', data); - provide<Ref<any>>('others', others); + const keyFieldValues = ref<any>(null); + const data = ref<any>({}); + 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); + provide<Ref<any>>('data', data); + 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(); @@ -176,6 +185,8 @@ /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ try { custImport.value = await import(`../entityts/${entityName.value}.ts`); + const [{ GetTitle }] = custImport.value['default'](); + titleInfo.value = GetTitle(); } catch (e) {} isMounted.value = true; }); @@ -184,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() { @@ -243,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