feat: 表格异步初始化column

This commit is contained in:
RubyLiu 2023-11-01 10:52:27 +08:00 committed by 刘瑞斌
parent 85b5d49bd6
commit 721f9115c1
12 changed files with 23 additions and 18 deletions

View File

@ -39,7 +39,7 @@ export default function useTableProps<T>(
data: [], // 表格数据 data: [], // 表格数据
/** /**
* *
* showSetting为true时,TableStore.initColumn(tableKey: string, column: MsTableColumn) * showSetting为true时, await tableStore.initColumn(tableKey: string, column: MsTableColumn)
* showSetting为false时 * showSetting为false时
*/ */
columns: [] as MsTableColumn, columns: [] as MsTableColumn,

View File

@ -3,7 +3,9 @@
<transition name="fade" mode="out-in" appear> <transition name="fade" mode="out-in" appear>
<!-- transition内必须有且只有一个根元素不然会导致二级路由的组件无法渲染 --> <!-- transition内必须有且只有一个根元素不然会导致二级路由的组件无法渲染 -->
<div v-show="true" class="page-content"> <div v-show="true" class="page-content">
<component :is="Component" v-if="!route.meta.isCache" :key="route.fullPath" /> <Suspense v-if="!route.meta.isCache">
<component :is="Component" :key="route.fullPath" />
</Suspense>
<keep-alive v-else> <keep-alive v-else>
<component :is="Component" :key="route.fullPath" /> <component :is="Component" :key="route.fullPath" />
</keep-alive> </keep-alive>

View File

@ -157,7 +157,7 @@
const tableStore = useTableStore(); const tableStore = useTableStore();
tableStore.initColumn(TableKeyEnum.API_TEST, columns, 'drawer'); await tableStore.initColumn(TableKeyEnum.API_TEST, columns, 'drawer');
const { propsRes, propsEvent, loadList } = useTable(getTableList, { const { propsRes, propsEvent, loadList } = useTable(getTableList, {
columns, columns,

View File

@ -168,7 +168,7 @@
showInTable: true, showInTable: true,
}, },
]; ];
tableStore.initColumn(TableKeyEnum.PROJECT_MEMBER, columns, 'drawer'); await tableStore.initColumn(TableKeyEnum.PROJECT_MEMBER, columns, 'drawer');
const tableBatchActions = { const tableBatchActions = {
baseAction: [ baseAction: [

View File

@ -204,7 +204,7 @@
showDrag: false, showDrag: false,
}, },
]; ];
tableStore.initColumn(TableKeyEnum.ORGANIZATION_MEMBER, columns, 'drawer'); await tableStore.initColumn(TableKeyEnum.ORGANIZATION_MEMBER, columns, 'drawer');
const tableBatchActions = { const tableBatchActions = {
baseAction: [ baseAction: [

View File

@ -171,7 +171,7 @@
} }
}; };
tableStore.initColumn(TableKeyEnum.ORGANIZATION_PROJECT, organizationColumns, 'drawer'); await tableStore.initColumn(TableKeyEnum.ORGANIZATION_PROJECT, organizationColumns, 'drawer');
const { propsRes, propsEvent, loadList, setKeyword, setLoadListParams } = useTable( const { propsRes, propsEvent, loadList, setKeyword, setLoadListParams } = useTable(
postProjectTableByOrg, postProjectTableByOrg,

View File

@ -129,7 +129,7 @@
showDrag: false, showDrag: false,
}, },
]; ];
tableStore.initColumn(TableKeyEnum.ORGANIZATION_TEMPLATE_FIELD_SETTING, fieldColumns, 'drawer'); await tableStore.initColumn(TableKeyEnum.ORGANIZATION_TEMPLATE_FIELD_SETTING, fieldColumns, 'drawer');
const { propsRes, propsEvent, loadList, setLoadListParams, setProps } = useTable(getFieldList, { const { propsRes, propsEvent, loadList, setLoadListParams, setProps } = useTable(getFieldList, {
tableKey: TableKeyEnum.ORGANIZATION_TEMPLATE_FIELD_SETTING, tableKey: TableKeyEnum.ORGANIZATION_TEMPLATE_FIELD_SETTING,

View File

@ -107,7 +107,7 @@
}, },
]; ];
tableStore.initColumn(TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT, fieldColumns, 'drawer'); await tableStore.initColumn(TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT, fieldColumns, 'drawer');
const { propsRes, propsEvent, loadList, setLoadListParams, setProps } = useTable(getOrganizeTemplateList, { const { propsRes, propsEvent, loadList, setLoadListParams, setProps } = useTable(getOrganizeTemplateList, {
tableKey: TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT, tableKey: TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT,
scroll: { x: '1000px' }, scroll: { x: '1000px' },

View File

@ -139,7 +139,7 @@
}; };
} }
tableStore.initColumn(TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT_FIELD, columns.value, 'drawer'); await tableStore.initColumn(TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT_FIELD, columns.value, 'drawer');
const { propsRes, propsEvent, setProps } = useTable(undefined, { const { propsRes, propsEvent, setProps } = useTable(undefined, {
tableKey: TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT_FIELD, tableKey: TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT_FIELD,
scroll: { x: '1800px' }, scroll: { x: '1800px' },

View File

@ -156,7 +156,6 @@
}, },
]; ];
tableStore.initColumn(TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT_STEP, templateFieldColumns, 'drawer');
const { propsRes, propsEvent, setProps } = useTable(undefined, { const { propsRes, propsEvent, setProps } = useTable(undefined, {
tableKey: TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT_STEP, tableKey: TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT_STEP,
scroll: { x: '800px' }, scroll: { x: '800px' },
@ -235,15 +234,15 @@
formRules.value = result; formRules.value = result;
} }
}; };
defineExpose({
getFormRules,
});
onMounted(() => { onMounted(() => {
setProps({ data: [{ id: 1, showStep: false, showExpected: false }] }); setProps({ data: [{ id: 1, showStep: false, showExpected: false }] });
getFormRules(); getFormRules();
}); });
await tableStore.initColumn(TableKeyEnum.ORGANIZATION_TEMPLATE_MANAGEMENT_STEP, templateFieldColumns, 'drawer');
defineExpose({
getFormRules,
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">

View File

@ -158,8 +158,6 @@
} }
}; };
tableStore.initColumn(TableKeyEnum.SYSTEM_ORGANIZATION, organizationColumns, 'drawer');
const { propsRes, propsEvent, loadList, setKeyword, setLoading } = useTable( const { propsRes, propsEvent, loadList, setKeyword, setLoading } = useTable(
postOrgTable, postOrgTable,
{ {
@ -306,9 +304,15 @@
setLoading(false); setLoading(false);
} }
}; };
defineExpose({ defineExpose({
fetchData, fetchData,
}); });
onMounted(() => {
fetchData();
});
await tableStore.initColumn(TableKeyEnum.SYSTEM_ORGANIZATION, organizationColumns, 'drawer');
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -156,8 +156,6 @@
} }
}; };
tableStore.initColumn(TableKeyEnum.SYSTEM_PROJECT, organizationColumns, 'drawer');
const { propsRes, propsEvent, loadList, setKeyword } = useTable( const { propsRes, propsEvent, loadList, setKeyword } = useTable(
postProjectTable, postProjectTable,
{ {
@ -304,6 +302,8 @@
defineExpose({ defineExpose({
fetchData, fetchData,
}); });
await tableStore.initColumn(TableKeyEnum.SYSTEM_PROJECT, organizationColumns, 'drawer');
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>