From f9eb1a419834f97a3ab0124b132de4f977b1973b Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期六, 28 十二月 2024 21:00:56 +0800 Subject: [PATCH] 通用导入Excel更新 --- src/views/tigerprojects/system/lowcode/normal/mainTable.vue | 101 ++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 81 insertions(+), 20 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/normal/mainTable.vue b/src/views/tigerprojects/system/lowcode/normal/mainTable.vue index 1d23510..b2920ca 100644 --- a/src/views/tigerprojects/system/lowcode/normal/mainTable.vue +++ b/src/views/tigerprojects/system/lowcode/normal/mainTable.vue @@ -2,6 +2,7 @@ <div> <BasicTable @register="registerTable"> <template #toolbar> + <!-- 鏍规嵁鑿滃崟璁剧疆鐨勬寜閽紝鑷姩鐢熸垚 --> <a-button type="primary" v-for="item in buttons.filter((m) => m['BUTTON_TYPE'] == 0)" @@ -37,7 +38,7 @@ @cancel="custCancel" :type="cType" :entityName="entityName" - @modalInner="getdtlSlots" + @modal-inner="getdtlSlots" > <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� --> <template #[item.name] v-for="item in dtlSlots" :key="item.name"> @@ -65,6 +66,7 @@ </CustModal> </Suspense> <normalDrawer @register="registerDrawer" @success="handleSuccess" /> + <ImportExcelModal @register="registerImport" :title="ImportTitle" /> </div> </template> <script lang="ts" setup> @@ -76,28 +78,33 @@ import normalDrawer from '../normalDrawer.vue'; import CustModal from '/@/views/components/CustModal.vue'; import RouteViewModal from '/@/views/components/RouteViewModal.vue'; + import ImportExcelModal from '/@/views/components/ImportExcelModal.vue'; import { FlowChartView } from '/@/components/FlowChart'; import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; import { useModal } from '/@/components/Modal'; import { useGo } from '/@/hooks/web/usePage'; - import { DeleteEntity, getEntity, getListByPage } from '/@/api/tigerapi/system'; + import { getListByPage } from '/@/api/tigerapi/system'; import { useI18n } from '/@/hooks/web/useI18n'; import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel'; import { getRoleButtons } from '/@/api/sys/menu'; import { useUserStore } from '/@/store/modules/user'; import { useRouter } from 'vue-router'; - import { GenerateActionButton, initRoute, OpenCustModal } from '../data'; + import { afterFetchFn, GenerateActionButton, initRoute, SearchInfoFn } from '../data'; import LogicFlow from '@logicflow/core'; import { isFunction } from 'xe-utils'; import { CustModalParams } from '/@/api/tigerapi/model/systemModel'; + import { useQueryStore } from '/@/store/modules/queryInpage'; const { t } = useI18n(); const { currentRoute } = useRouter(); + const route = unref(currentRoute); + const useQuery = useQueryStore(); const props = defineProps({ useTableData: { type: Object as PropType<{}>, default: { table: [] } }, crudColSlots: { type: Object as PropType<any> }, }); const objParams = inject('objParams') as Ref<any>; + const savedParams = inject('savedParams') as Ref<any>; const colSlots = ref(objParams.value['colSlots']); const _columns = inject('_columns') as Ref<any[]>; const _searchFormSchema = inject('_searchFormSchema') as Ref<any[]>; @@ -111,6 +118,8 @@ const [registerDrawer, { openDrawer }] = useDrawer(); const [registerRv, { openModal: openRvModal, closeModal: RvcloseModal }] = useModal(); const [registerCust, { openModal: openCustModal }] = useModal(); + const [registerCrud, { openModal: openCrudModal }] = useModal(); + const [registerImport, { openModal: openImportModal }] = useModal(); const cType = ref(''); const formSchemas = ref({}); //寮瑰嚭妗嗗琛ㄥ崟缁撴瀯 const routeData = ref({ @@ -132,7 +141,9 @@ /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ try { custImport.value = await import(`../entityts/${objParams.value['ID']}.ts`); - } catch (e) {} + } catch (e) { + console.log(e); + } const [ { ActionItem: nActionItem, @@ -143,6 +154,7 @@ OpenSelectItem: OpenSelectCust, GetSelectSuccess, CustFunc, + GetTitle, }, ActionColumn, ] = isNullOrUnDef(custImport.value['default']) @@ -153,6 +165,7 @@ ? {} : KeyFieldValues(objParams.value['CODE'], objParams.value['ID']); const dtlSlots = ref<any[]>([]); + const ImportTitle = GetTitle && isFunction(GetTitle)? ref(GetTitle().importTitle): ref(''); const useformdata = GetUseForm && isFunction(GetUseForm) ? GetUseForm() : {}; const useFormData = ref<any>(useformdata); /* 鑷畾涔夋ā鎬佺獥鍙d腑琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 */ @@ -181,10 +194,14 @@ } : '', }, + beforeFetch: (t) => SearchInfoFn(t, route.name, AuthOption.value['BY_ORG'] == 'Y'), + afterFetch: afterFetch, columns: _columns as unknown as BasicColumn[], formConfig: { labelWidth: 140, schemas: _searchFormSchema as unknown as FormSchema[], + submitFunc: () => Search(), //鑷畾涔夋煡璇㈡彁浜ゆ寜閽殑鏂规硶锛岃Е鍙戞煡璇㈡彁浜や簨浠� + resetFunc: () => useQuery.resetFunc(route.name, getForm(), AuthOption.value['BY_ORG'] == 'Y'), }, useSearchForm: true, showTableSetting: true, @@ -206,7 +223,8 @@ () => AuthOption.value, (newVal, oldVal) => { nextTick(() => { - if (!isNullOrEmpty(newVal.BY_ORG)) { + if (!isNullOrEmpty(newVal.BY_ORG) && !isNullOrUnDef(savedParams.value['params'])) { + getForm().setFieldsValue(savedParams.value['params']); setProps({ searchInfo: { TABLE_NAME: objParams.value['ID'], @@ -228,7 +246,39 @@ { deep: true, immediate: true }, ); - onMounted(() => {}); + onMounted(async () => { + if (!isNullOrUnDef(savedParams) && !isNullOrUnDef(savedParams.value['params'])) { + getForm().setFieldsValue(savedParams.value['params']); + reload(); + } + // if ( + // !isNullOrUnDef(useQuery.getCurSearchInfo['searchInfo']) && + // useQuery.getCurSearchInfo['name'] == route.name + // ) { + // getForm().resetFields(); + // const searchInfo = useQuery.getCurSearchInfo['searchInfo']; + // await getForm().setFieldsValue(searchInfo); + // } + }); + + /** + * @description: 鏌ヨ鎻愪氦 + * @return {*} + */ + async function Search() { + useQuery.submitFunc(route.name, getForm(), AuthOption.value['BY_ORG'] == 'Y').then(() => { + reload(); + }); + } + + /** + * @description: 璇锋眰涔嬪悗瀵硅繑鍥炲�艰繘琛屽鐞� + * @param {*} t + * @return {*} + */ + function afterFetch(t) { + afterFetchFn(t, route.name, getForm()); + } const currlf = ref(null) as Ref<LogicFlow | null>; /** @@ -262,12 +312,15 @@ selectVals, colSlots, ifSave: true, + sName: objParams.value['sName'], }; + /* 鏍规嵁鑿滃崟璁剧疆鐨勬寜閽嚜鍔ㄧ敓鎴愭搷浣滃垪涓殑鎸夐挳 */ const actionItem = GenerateActionButton(params, buttons, openDrawer, reload); if (isNullOrUnDef(custImport.value['default'])) { return actionItem; } + /* 鏍规嵁鍔ㄦ�佸姞杞界殑瀹炰綋绫诲悕.ts涓殑ActionItem鏂规硶锛屾覆鏌撴搷浣滃垪涓殑鎸夐挳鏂规硶 */ return nActionItem( params, actionItem, @@ -279,6 +332,7 @@ go, setProps, openCustModal, + openCrudModal, ); } @@ -296,23 +350,26 @@ } /** - * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓� + * @description: 鑾峰彇宸ュ叿鏍忎腑鎸夐挳鐨勮涓� * @return {*} */ function handleCreate(fnName: string) { if (isNullOrUnDef(custImport.value['default'])) { + /* 濡傛灉鍔ㄦ�佸姞杞界殑瀹炰綋绫�.ts涓嶅瓨鍦紝鍒欑洿鎺ユ墦寮�渚ц竟妗� */ openDrawer(true, { - isUpdate: false, - entityName: entityName.value, - formJson: _crudFormSchema.value, - crudColSlots: objParams.value['crudColSlots'], - isExistSql: isExistSql.value, + isUpdate: false, //鏄柊澧炶繕鏄紪杈戯紝false-鏂板|true-缂栬緫 + entityName: entityName.value, //瀹炰綋绫诲悕 + formJson: _crudFormSchema.value, //鏂板缂栬緫鐨勮〃鍗曠粨鏋� + crudColSlots: objParams.value['crudColSlots'], //鏂板缂栬緫鐨勮〃鍗曚腑鐨勬彃妲藉垪琛� + isExistSql: isExistSql.value, //鏄惁瀛樺湪妫�鏌ql锛屾瘮濡�: XXX_CODE = '12345' + ifSave: true, //鏄惁鎻愪氦琛ㄥ崟鏃朵繚瀛樺埌鏁版嵁搴擄紝鍚�-鏆傚瓨|鏄�-淇濆瓨 }); } else { + /* 濡傛灉鍔ㄦ�佸姞杞界殑瀹炰綋绫�.ts瀛樺湪锛屾牴鎹�.ts鏂囦欢涓殑鏂规硶鏉ユ墽琛屾搷浣� */ const [{ CreateAction }] = custImport.value['default'](); - const result = CreateAction(entityName.value, colSlots.value); + const result = CreateAction(entityName.value, fnName); switch (result.action) { - case 'go': + case 'go' /* 璺宠浆椤甸潰 */: // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage sessionStorage.setItem( `${result.params.Name}_params`, @@ -322,15 +379,19 @@ `/${result.url}/${encodeURI(JSON.stringify({ sName: result.params.Name, Name: result.params.Name }))}`, ); break; - case 'drawer': + case 'drawer' /* 鎵撳紑渚ц竟妗� */: openDrawer(true, { - isUpdate: false, - entityName: entityName.value, - formJson: _crudFormSchema.value, - crudColSlots: objParams.value['crudColSlots'], - isExistSql: isExistSql.value, + isUpdate: false, //鏄柊澧炶繕鏄紪杈戯紝false-鏂板|true-缂栬緫 + entityName: entityName.value, //瀹炰綋绫诲悕 + formJson: _crudFormSchema.value, //鏂板缂栬緫鐨勮〃鍗曠粨鏋� + crudColSlots: objParams.value['crudColSlots'], //鏂板缂栬緫鐨勮〃鍗曚腑鐨勬彃妲藉垪琛� + isExistSql: isExistSql.value, //鏄惁瀛樺湪妫�鏌ql锛屾瘮濡�: XXX_CODE = '12345' + ifSave: true, //鏄惁鎻愪氦琛ㄥ崟鏃朵繚瀛樺埌鏁版嵁搴擄紝鍚�-鏆傚瓨|鏄�-淇濆瓨 }); break; + case 'importModal' /* 鎵撳紑瀵煎叆Excel妯℃�佺獥鍙� */: + openImportModal(true, result.params); + break; } } } -- Gitblit v1.9.3