From 46c3d28c5633baaddad0da441185310b9360a45b Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期三, 03 七月 2024 14:56:21 +0800 Subject: [PATCH] 高级表单优化 --- src/views/tigerprojects/system/lowcode/high/dtl.vue | 59 +++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/high/dtl.vue b/src/views/tigerprojects/system/lowcode/high/dtl.vue index 389a2b9..27ee060 100644 --- a/src/views/tigerprojects/system/lowcode/high/dtl.vue +++ b/src/views/tigerprojects/system/lowcode/high/dtl.vue @@ -16,7 +16,6 @@ <TableAction :actions="createActions(record, index, item.name)" /> </template> <template #[item]="{ field }" v-for="item in colSlots" :key="item"> - <!-- <template #form-BAS_REASON3aadd="{ field }"> --> <a-button v-if="field" class="mt-1 ml-1" @@ -38,9 +37,9 @@ </div> </template> <script lang="ts" setup> - import { Ref, inject, nextTick, onMounted, ref, watch } from 'vue'; - import { BasicTable, useTable, TableAction } from '/@/components/Table'; - import { BasicForm, useForm } from '/@/components/Form/index'; + import { Ref, inject, onMounted, ref, watch } from 'vue'; + import { BasicTable, TableAction } from '/@/components/Table'; + import { useForm } from '/@/components/Form/index'; import GeneralModal from '/@/views/components/GeneralModal.vue'; import normalDrawer from '../normalDrawer.vue'; import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; @@ -60,27 +59,25 @@ entityName: { type: String }, crudColSlots: { type: Object as PropType<any> }, }); + /* 涓婚〉闈㈡敞鍏ョ殑鍙橀噺 */ const objParams = inject('objParams') as Ref<any>; const data = inject('data') as Ref<any>; const _useTables = inject('useTables') as Ref<any>; const useFormData = inject('useFormData') as Ref<{}>; - const others = inject('others') as Ref<Recordable[]>; + const keyFieldValues = inject('keyFieldValues') as Ref<Recordable[]>; + const go = useGo(); const [registerItemAdd, { openModal: openItemModal }] = useModal(); const cType = ref(''); const dtlSlots = ref([] as any[]); - const selectVals = ref({}); - const baseCards = ref([] as any[]); const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 const custImport = ref<any[]>([]); const EntityCustFunction = ref([ { ActionItem(params, data, ...args) {}, EditOperation(data, d, u, item) {}, - GetBaseColumns(type: string | undefined) {}, - GetSearchForm(type: string | undefined) {}, GetCrudForm(type: string | undefined, ...args) {}, - OthersValues(val, id) {}, + KeyFieldValues(val, id) {}, GetTitle(type: string | undefined) {}, GetUseTables(data: Ref<Recordable[]>, ...args) {}, GetUseDrawers() {}, @@ -94,10 +91,8 @@ { ActionItem: nActionItem, EditOperation, - GetBaseColumns, - GetSearchForm, GetCrudForm, - OthersValues, + KeyFieldValues, GetTitle, GetUseTables, GetUseDrawers, @@ -105,11 +100,11 @@ ] = isNullOrUnDef(custImport.value['default']) ? EntityCustFunction.value : custImport.value['default'](); - others.value = OthersValues(objParams.value['CODE'], objParams.value['ID']); - const drawers = ref<any[]>(objParams.value['drawers']); - const useTables = GetUseTables(data, emit); - const useDrawers = GetUseDrawers(); - _useTables.value = useTables; + keyFieldValues.value = KeyFieldValues(objParams.value['CODE'], objParams.value['ID']); //鑾峰彇涓�浜涘叾浠栨湁闇�瑕佹彁渚涚殑鍊硷紝杩欓噷鏄富椤甸潰璺宠浆杩囨潵鏃跺甫鐨勫叧閿瓧娈靛�� + const drawers = ref<any[]>(objParams.value['drawers']); //鏄彸渚ц竟妗嗗垪琛紝閲岄潰鐨刵ame琛ㄧず鏄摢涓�涓疄浣擄紝涔熷氨鏄珮绾ц〃鍗曚腑琛ㄦ牸鐨勫悕瀛楋紝寰堝鏂规硶闇�瑕佷互杩欎釜鍚嶅瓧涓簁ey + const useTables = GetUseTables(data, emit); //楂樼骇琛ㄥ崟涓悇涓〃鏍�(Table)鐨剈seTable鏂规硶瀹炵幇鍒楄〃 + const useDrawers = GetUseDrawers(); //楂樼骇琛ㄥ崟涓悇涓〃鏍�(Table)鐨勫彸渚ц竟妗�(Drawer)鐨剈seDrawer鏂规硶瀹炵幇鍒楄〃 + _useTables.value = useTables; //鎶妘seTable鐨勫垪琛ㄥ搷搴斿埌浠庝富椤甸潰娉ㄥ叆鐨刜useTables锛岃繖鏍蜂富椤甸潰鑳芥嬁鍒皍seTable鐨勭粨鏋滐紝浠庤�屽彲浠ヤ娇鐢ㄥ悇涓〃鏍肩殑鍐呯疆鏂规硶 // watch( // () => props.dataSource, // (newVal, oldVal) => { @@ -126,11 +121,15 @@ // { deep: true, immediate: true }, // ); + /** + * @description: 鎸傝浇缁勪欢瀹屾垚鏃� + * @return {*} + */ onMounted(async () => { for (const i in drawers.value) { let sqlcmd = ' 1 =1 '; - if (!isNullOrEmpty(others.value[drawers.value[i].code])) { - sqlcmd += ` And ${drawers.value[i].code} = '${others.value[drawers.value[i].code]}'`; + if (!isNullOrEmpty(keyFieldValues.value[drawers.value[i].code])) { + sqlcmd += ` And ${drawers.value[i].code} = '${keyFieldValues.value[drawers.value[i].code]}'`; } const list = await getEntity({ sqlcmd: sqlcmd, @@ -154,7 +153,7 @@ * @param {*} record * @return {*} */ - function createActions(record,index, item) { + function createActions(record, index, item) { const params = { record, isUpdate: true, @@ -167,6 +166,7 @@ useFormData, crudColSlots: props.crudColSlots, data, + name: item, //drawers鍒楄〃閲岄潰鐨刵ame锛岃〃绀烘槸鍝竴涓疄浣擄紝涔熷氨鏄珮绾ц〃鍗曚腑琛ㄦ牸鐨勫悕瀛� }; const actionItem = [ { @@ -239,12 +239,18 @@ return validates; } + /** + * @description: 鏂板鎸夐挳鏂规硶 + * @param {*} index + * @param {*} item + * @return {*} + */ function handleCreate(index, item) { validate().then((res) => { const Keys = Object.getOwnPropertyNames(useFormData.value); let i; for (i = 0; i < Keys.length; i++) { - others.value[objParams.value['pCode']] = objParams.value['IsID'] + keyFieldValues.value[objParams.value['pCode']] = objParams.value['IsID'] ? res[Keys[i]]['ID'] : res[Keys[i]][objParams.value['pCode']] == '0' || isNullOrUnDef(res[Keys[i]][objParams.value['pCode']]) @@ -255,9 +261,9 @@ isUpdate: false, ifSave: true, entityName: props.entityName, - formJson: GetCrudForm(item, data), //getFormSchema(`${entityName.value}_Crud`), + formJson: GetCrudForm(item, data), //鑾峰彇澧炲垹鏀硅〃鍗曞瓧娈� crudColSlots: props.crudColSlots, - others: others.value, + keyFieldValues: keyFieldValues.value, }); }); } @@ -266,8 +272,9 @@ * @description: 鏂板缂栬緫杩斿洖鎴愬姛鏂规硶 * @param {*} d * @param {*} u + * @param {*} item 椤甸潰涓婂惊鐜娊灞夊垪琛ㄤ紶鍏ョ殑瀹炰綋鍚嶅瓧锛屼綔涓哄悇琛ㄦ牸鐩稿叧鏂规硶鐨刱ey锛屼粠鑰岃皟鐢ㄥ悇琛ㄦ牸鐩稿叧鐨勬柟娉曪紝濡傦細useTables[item][1].setProps * @return {*} - */ + */ function handleSuccess(d, u, item) { if (!isNullOrUnDef(custImport.value)) { /* 鑷畾涔夌紪杈戞柟娉曪紝鏍规嵁瀹炰綋鍚嶅幓璋冪敤 */ @@ -286,7 +293,7 @@ * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� * @param {*} d * @param {*} u - * @param {*} item + * @param {*} item 椤甸潰涓婂惊鐜娊灞夊垪琛ㄤ紶鍏ョ殑瀹炰綋鍚嶅瓧锛屼綔涓哄悇琛ㄦ牸鐩稿叧鏂规硶鐨刱ey锛屼粠鑰岃皟鐢ㄥ悇琛ㄦ牸鐩稿叧鐨勬柟娉曪紝濡傦細useTables[item][1].getForm() * @return {*} */ function handleItemSuccess(d, u, item) { -- Gitblit v1.9.3