@slice_cy/mint 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +697 -0
  2. package/app/common/base-response.js +10 -0
  3. package/app/common/business-error.js +10 -0
  4. package/app/common/error-code.js +22 -0
  5. package/app/common/return-utils.js +40 -0
  6. package/app/common/router-schema-validator.js +25 -0
  7. package/app/controller/base.js +24 -0
  8. package/app/controller/project.js +90 -0
  9. package/app/controller/view.js +13 -0
  10. package/app/docs/dsl-doc.js +148 -0
  11. package/app/extend/logger.js +30 -0
  12. package/app/extend/params-valid.js +6 -0
  13. package/app/extend/return-utils.js +9 -0
  14. package/app/middleware/api-sign-verify.js +25 -0
  15. package/app/middleware/err-handler.js +18 -0
  16. package/app/middleware/project-handler.js +25 -0
  17. package/app/pages/boot.js +34 -0
  18. package/app/pages/dashboard/complex-view/header-view/index.vue +108 -0
  19. package/app/pages/dashboard/complex-view/iframe-view/index.vue +37 -0
  20. package/app/pages/dashboard/complex-view/schema-view/complex-view/search-panel/index.vue +36 -0
  21. package/app/pages/dashboard/complex-view/schema-view/complex-view/table-panel/index.vue +123 -0
  22. package/app/pages/dashboard/complex-view/schema-view/components/component-config.js +14 -0
  23. package/app/pages/dashboard/complex-view/schema-view/components/createForm/index.vue +72 -0
  24. package/app/pages/dashboard/complex-view/schema-view/components/detailPanel/index.vue +52 -0
  25. package/app/pages/dashboard/complex-view/schema-view/components/editForm/index.vue +87 -0
  26. package/app/pages/dashboard/complex-view/schema-view/hook/use-schema.js +113 -0
  27. package/app/pages/dashboard/complex-view/schema-view/index.vue +114 -0
  28. package/app/pages/dashboard/complex-view/sider-view/index.vue +116 -0
  29. package/app/pages/dashboard/entry.dashboard.js +44 -0
  30. package/app/pages/dashboard/index.vue +60 -0
  31. package/app/pages/service/index.js +70 -0
  32. package/app/pages/store/index.js +4 -0
  33. package/app/pages/store/menu.js +86 -0
  34. package/app/pages/store/project.js +9 -0
  35. package/app/pages/utils/index.js +26 -0
  36. package/app/pages/widgets/header-container/assets/avatar.png +0 -0
  37. package/app/pages/widgets/header-container/assets/icon.png +0 -0
  38. package/app/pages/widgets/header-container/index.vue +108 -0
  39. package/app/pages/widgets/schema-form/components/input/index.vue +155 -0
  40. package/app/pages/widgets/schema-form/components/input-number/index.vue +148 -0
  41. package/app/pages/widgets/schema-form/components/select/index.vue +132 -0
  42. package/app/pages/widgets/schema-form/form-item-cofnig.js +18 -0
  43. package/app/pages/widgets/schema-form/index.vue +137 -0
  44. package/app/pages/widgets/schema-search-bar/component/date-range-picker/index.vue +55 -0
  45. package/app/pages/widgets/schema-search-bar/component/dynamic-select/index.vue +70 -0
  46. package/app/pages/widgets/schema-search-bar/component/input/index.vue +54 -0
  47. package/app/pages/widgets/schema-search-bar/component/select/index.vue +65 -0
  48. package/app/pages/widgets/schema-search-bar/index.vue +143 -0
  49. package/app/pages/widgets/schema-search-bar/search-item-config.js +20 -0
  50. package/app/pages/widgets/schema-table/index.vue +198 -0
  51. package/app/pages/widgets/sider-container/index.vue +30 -0
  52. package/app/post-router.js +9 -0
  53. package/app/pre-middleware.js +37 -0
  54. package/app/public/dist/entry.dashboard.tpl +2 -0
  55. package/app/public/dist/entry.project-list.tpl +2 -0
  56. package/app/public/dist/prod/css/async.609.bcbe5779.css +1 -0
  57. package/app/public/dist/prod/css/async.952.9bc7c180.css +1 -0
  58. package/app/public/dist/prod/css/common.1a98227b.css +1 -0
  59. package/app/public/dist/prod/css/entry.project-list.14f64dd9.css +1 -0
  60. package/app/public/dist/prod/js/142.56646c73.bundle.js +1 -0
  61. package/app/public/dist/prod/js/609.8270b20d.bundle.js +1 -0
  62. package/app/public/dist/prod/js/68.2813fafe.bundle.js +1 -0
  63. package/app/public/dist/prod/js/952.c76c04fb.bundle.js +1 -0
  64. package/app/public/dist/prod/js/common.9985f827.bundle.js +1 -0
  65. package/app/public/dist/prod/js/entry.dashboard.cd7591e4.bundle.js +1 -0
  66. package/app/public/dist/prod/js/entry.project-list.beb0fa9d.bundle.js +1 -0
  67. package/app/public/dist/prod/js/runtime.5602b906.bundle.js +1 -0
  68. package/app/public/dist/prod/js/vendor.709fbf32.bundle.js +53 -0
  69. package/app/public/dist/prod/static/images/avatar.78e68eaa.png +0 -0
  70. package/app/public/dist/static/logo.png +0 -0
  71. package/app/public/dist/static/normalize.css +1 -0
  72. package/app/public/static/logo.png +0 -0
  73. package/app/public/static/normalize.css +267 -0
  74. package/app/router/project.js +6 -0
  75. package/app/router/view.js +5 -0
  76. package/app/router-schema/project.js +14 -0
  77. package/app/service/base.js +22 -0
  78. package/app/service/project.js +49 -0
  79. package/app/view/entry.tpl +18 -0
  80. package/app/webpack/config/webpack.base.js +288 -0
  81. package/app/webpack/config/webpack.dev.js +53 -0
  82. package/app/webpack/config/webpack.prod.js +106 -0
  83. package/app/webpack/dev.js +34 -0
  84. package/app/webpack/libs/block.js +1 -0
  85. package/app/webpack/prod.js +21 -0
  86. package/config/config.default.js +5 -0
  87. package/index.js +37 -0
  88. package/mint-core/env.js +23 -0
  89. package/mint-core/index.js +101 -0
  90. package/mint-core/loader/config.js +59 -0
  91. package/mint-core/loader/controller.js +59 -0
  92. package/mint-core/loader/extend.js +42 -0
  93. package/mint-core/loader/middleware.js +54 -0
  94. package/mint-core/loader/router-schema.js +39 -0
  95. package/mint-core/loader/router.js +36 -0
  96. package/mint-core/loader/service.js +57 -0
  97. package/model/index.js +94 -0
  98. package/package.json +93 -0
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <div
3
+ v-if="Object.keys(searchSchema?.properties || {}).length"
4
+ class="search-panel"
5
+ >
6
+ <schema-search-bar
7
+ :schema="searchSchema"
8
+ @search="onSearch"
9
+ @load="onLoad"
10
+ @reset="reset"
11
+ ></schema-search-bar>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup>
16
+ import { inject } from "vue";
17
+ import SchemaSearchBar from "$mintWidgets/schema-search-bar/index.vue";
18
+
19
+ const emits = defineEmits(["search"]);
20
+
21
+ const { searchSchema } = inject("schemaViewData");
22
+
23
+ const onSearch = (searchParams) => {
24
+ emits("search", searchParams);
25
+ };
26
+
27
+ const onLoad = (searchParams) => {
28
+ emits("search", searchParams);
29
+ };
30
+
31
+ const reset = () => {
32
+ emits("search", {});
33
+ };
34
+ </script>
35
+
36
+ <style lang="less" scoped></style>
@@ -0,0 +1,123 @@
1
+ <template>
2
+ <div class="table-panel">
3
+ <div
4
+ v-if="(tableConfig.headerButtons || []).length"
5
+ class="operation-panel"
6
+ >
7
+ <a-flex
8
+ justify="flex-end"
9
+ :gap="12"
10
+ align="center"
11
+ >
12
+ <a-button
13
+ v-for="(btnConfig, index) in tableConfig.headerButtons"
14
+ :key="index"
15
+ v-bind="getButtonConfig(btnConfig.uiButtonConfig)"
16
+ @click="operationHandler({ buttonConfig: btnConfig })"
17
+ >
18
+ {{ btnConfig.label }}
19
+ </a-button>
20
+ </a-flex>
21
+ </div>
22
+ <div
23
+ v-if="Object.keys(tableSchema?.properties || {}).length"
24
+ class="schema-table-panel"
25
+ >
26
+ <schema-table
27
+ ref="schemaTableRef"
28
+ :api="api"
29
+ :search-params="searchParams"
30
+ :schema="tableSchema"
31
+ :buttons="tableConfig.rowButtons"
32
+ @operation="operationHandler"
33
+ ></schema-table>
34
+ </div>
35
+ </div>
36
+ </template>
37
+
38
+ <script setup>
39
+ import { inject, ref } from "vue";
40
+ import SchemaTable from "$mintWidgets/schema-table/index.vue";
41
+ import { message, Modal } from "ant-design-vue";
42
+ import { httpDelete } from "$mintService";
43
+
44
+ const emit = defineEmits(["operation"]);
45
+
46
+ const { api, tableSchema, tableConfig, searchParams } = inject("schemaViewData");
47
+ const EventHandlerMap = {
48
+ remove: removeHandler,
49
+ };
50
+
51
+ const schemaTableRef = ref();
52
+
53
+ /**
54
+ * 按钮交互分发操作函数
55
+ * @param {object} param
56
+ */
57
+ const operationHandler = ({ buttonConfig, rowData }) => {
58
+ const { eventKey } = buttonConfig;
59
+ if (EventHandlerMap[eventKey]) {
60
+ EventHandlerMap[eventKey]({ buttonConfig, rowData });
61
+ return;
62
+ }
63
+ // 如果没有找到继续往上分发
64
+ emit("operation", { buttonConfig, rowData });
65
+ };
66
+
67
+ /**
68
+ * 获取按钮配置(兼容性考虑:DSL中没有配置改选项,默认给空对象)
69
+ * @param {object} buttonConfig
70
+ */
71
+ const getButtonConfig = (buttonConfig) => {
72
+ return {
73
+ ...(buttonConfig || {}),
74
+ };
75
+ };
76
+
77
+ /**
78
+ * 解析schema中的参数
79
+ * @param {object} params 举例: { [paramsKey]: 固定值 | schema::字段名(字段名从rowData中匹配获取) }
80
+ * @param {object} rowData 列表行数据
81
+ * @returns {object} { [key]: value }
82
+ */
83
+ function parseSchemaParams(params = {}, rowData = {}) {
84
+ return Object.entries(params).reduce((pre, [key, value]) => {
85
+ return {
86
+ ...pre,
87
+ [key]: value.replace(/schema::(.*)/, (_, key) => rowData[key]),
88
+ };
89
+ }, {});
90
+ }
91
+
92
+ /**
93
+ * 删除操作,映射 eventKey === remove 的 handler方法
94
+ * @param {object} param
95
+ */
96
+ async function removeHandler({ buttonConfig, rowData }) {
97
+ const { eventOption } = buttonConfig;
98
+ const { params } = eventOption;
99
+ const requestParams = parseSchemaParams(params, rowData);
100
+ Modal.confirm({
101
+ title: "确定要删除该数据吗?",
102
+ okText: "确定",
103
+ cancelText: "取消",
104
+ onOk: async () => {
105
+ await httpDelete(api.value, requestParams);
106
+ message.success("删除成功");
107
+ schemaTableRef.value?.getTableList("search");
108
+ },
109
+ });
110
+ }
111
+
112
+ const getTableList = (...args) => {
113
+ schemaTableRef.value?.getTableList(...args);
114
+ };
115
+
116
+ defineExpose({ getTableList });
117
+ </script>
118
+
119
+ <style lang="less" scoped>
120
+ .operation-panel {
121
+ margin-bottom: 24px;
122
+ }
123
+ </style>
@@ -0,0 +1,14 @@
1
+ import businessComponentConfig from "$businessComponentConfig";
2
+
3
+ export default {
4
+ createForm: {
5
+ loader: () => import(/* webpackChunkName: "schema-create-form" */ "./createForm/index.vue"),
6
+ },
7
+ editForm: {
8
+ loader: () => import(/* webpackChunkName: "schema-edit-form" */ "./editForm/index.vue"),
9
+ },
10
+ detailPanel: {
11
+ loader: () => import(/* webpackChunkName: "schema-detail-panel" */ "./detailPanel/index.vue"),
12
+ },
13
+ ...businessComponentConfig,
14
+ };
@@ -0,0 +1,72 @@
1
+ <template>
2
+ <div class="create-form">
3
+ <a-drawer
4
+ v-model:open="visible"
5
+ :title="title"
6
+ >
7
+ <a-spin :spinning="loading">
8
+ <schema-form
9
+ ref="schemaFormRef"
10
+ :schema="schema"
11
+ ></schema-form>
12
+ </a-spin>
13
+
14
+ <template #footer>
15
+ <a-button
16
+ type="primary"
17
+ @click="save"
18
+ >
19
+ {{ saveBtnText }}
20
+ </a-button>
21
+ </template>
22
+ </a-drawer>
23
+ </div>
24
+ </template>
25
+
26
+ <script setup>
27
+ import { ref, inject } from "vue";
28
+ import SchemaForm from "$mintWidgets/schema-form/index.vue";
29
+ import { httpPost } from "$mintService";
30
+ import { message } from "ant-design-vue";
31
+ const emit = defineEmits(["command"]);
32
+
33
+ const { components, api } = inject("schemaViewData");
34
+
35
+ const name = "createForm";
36
+
37
+ const { schema, config } = components.value[name];
38
+
39
+ const visible = ref(false);
40
+ const schemaFormRef = ref();
41
+ const title = ref("");
42
+ const saveBtnText = ref("");
43
+
44
+ const loading = ref(false);
45
+ const show = ({ buttonConfig, rowData }) => {
46
+ title.value = config.title;
47
+ saveBtnText.value = config.saveBtnText;
48
+ visible.value = true;
49
+ };
50
+
51
+ const save = async () => {
52
+ try {
53
+ if (loading.value) return;
54
+ loading.value = true;
55
+ const valid = await schemaFormRef.value.validate();
56
+ if (!valid) return;
57
+ await httpPost(api.value, schemaFormRef.value.getValue());
58
+ message.success("保存成功");
59
+ visible.value = false;
60
+ emit("command", {
61
+ eventKey: config.eventKey,
62
+ });
63
+ } finally {
64
+ loading.value = false;
65
+ }
66
+ };
67
+
68
+ defineExpose({
69
+ show,
70
+ name,
71
+ });
72
+ </script>
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <a-drawer
3
+ :title="title"
4
+ :visible="visible"
5
+ @close="close"
6
+ >
7
+ <a-spin :spinning="loading">
8
+ <schema-form
9
+ :schema="components[name].schema"
10
+ :model="dtoModel"
11
+ />
12
+ </a-spin>
13
+ </a-drawer>
14
+ </template>
15
+
16
+ <script setup>
17
+ import { ref, inject } from "vue";
18
+ import { httpGet } from "$mintService";
19
+ import SchemaForm from "$mintWidgets/schema-form/index.vue";
20
+ const { api, components } = inject("schemaViewData");
21
+
22
+ const name = "detailPanel";
23
+
24
+ const visible = ref(false);
25
+ const loading = ref(false);
26
+ const title = ref("");
27
+ const dtoModel = ref({});
28
+
29
+ const show = async ({ buttonConfig, rowData }) => {
30
+ try {
31
+ const { config } = components.value[name];
32
+ loading.value = true;
33
+ title.value = config.title;
34
+ const mainKeyValue = rowData[config.mainKey];
35
+ const { data } = await httpGet(`${api.value}/${mainKeyValue}`, {});
36
+ dtoModel.value = { ...data };
37
+ } finally {
38
+ loading.value = false;
39
+ }
40
+ visible.value = true;
41
+ };
42
+
43
+ const close = () => {
44
+ visible.value = false;
45
+ };
46
+ defineExpose({
47
+ name,
48
+ show,
49
+ });
50
+ </script>
51
+
52
+ <style scoped lang="less"></style>
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <div class="edit-form">
3
+ <a-drawer
4
+ v-model:open="visible"
5
+ :title="title"
6
+ >
7
+ <a-spin :spinning="loading">
8
+ <schema-form
9
+ ref="schemaFormRef"
10
+ :schema="components[name].schema"
11
+ :model="dtoModel"
12
+ ></schema-form>
13
+ </a-spin>
14
+
15
+ <template #footer>
16
+ <a-button
17
+ type="primary"
18
+ @click="save"
19
+ >
20
+ {{ saveBtnText }}
21
+ </a-button>
22
+ </template>
23
+ </a-drawer>
24
+ </div>
25
+ </template>
26
+
27
+ <script setup>
28
+ import { ref, inject } from "vue";
29
+ import SchemaForm from "$mintWidgets/schema-form/index.vue";
30
+ import { httpPut, httpGet } from "$mintService";
31
+ import { message } from "ant-design-vue";
32
+ const emit = defineEmits(["command"]);
33
+
34
+ const { components, api } = inject("schemaViewData");
35
+
36
+ const name = "editForm";
37
+
38
+ const visible = ref(false);
39
+ const schemaFormRef = ref();
40
+ const title = ref("");
41
+ const saveBtnText = ref("");
42
+ const dtoModel = ref({});
43
+ const loading = ref(false);
44
+ const rowDataValue = ref({});
45
+ const show = async ({ buttonConfig, rowData }) => {
46
+ const { config } = components.value[name];
47
+ title.value = config.title;
48
+ saveBtnText.value = config.saveBtnText;
49
+ visible.value = true;
50
+ rowData && (rowDataValue.value = rowData);
51
+ try {
52
+ loading.value = true;
53
+ // 获取数据
54
+ const mainKeyValue = rowData[config.mainKey];
55
+ const { data } = await httpGet(`${api.value}/${mainKeyValue}`, {});
56
+ dtoModel.value = { ...data };
57
+ } finally {
58
+ loading.value = false;
59
+ }
60
+ };
61
+
62
+ const save = async () => {
63
+ try {
64
+ if (loading.value) return;
65
+ const { config } = components.value[name];
66
+ loading.value = true;
67
+ const valid = await schemaFormRef.value.validate();
68
+ if (!valid) return;
69
+ await httpPut(`${api.value}/${1}`, {
70
+ ...schemaFormRef.value.getValue(),
71
+ [config.mainKey]: rowDataValue.value[config.mainKey],
72
+ });
73
+ message.success("保存成功");
74
+ visible.value = false;
75
+ emit("command", {
76
+ eventKey: config.eventKey,
77
+ });
78
+ } finally {
79
+ loading.value = false;
80
+ }
81
+ };
82
+
83
+ defineExpose({
84
+ show,
85
+ name,
86
+ });
87
+ </script>
@@ -0,0 +1,113 @@
1
+ import { ref, watch, onMounted } from "vue";
2
+ import { useRoute } from "vue-router";
3
+ import { useMenuStore } from "$mintPage/store/menu";
4
+
5
+ /**
6
+ * 解析DSL配置最开始的地方
7
+ * @returns
8
+ */
9
+ const useSchema = () => {
10
+ const route = useRoute();
11
+ const menuStore = useMenuStore();
12
+
13
+ const api = ref("");
14
+ const tableSchema = ref({});
15
+ const tableConfig = ref({});
16
+ const searchSchema = ref({});
17
+ const searchConfig = ref({});
18
+ const components = ref({});
19
+
20
+ const initData = () => {
21
+ const { sider_key, key } = route.query;
22
+ const menuItem = menuStore.findMenuItem({
23
+ key: "key",
24
+ value: sider_key || key,
25
+ });
26
+ if (!menuItem) return;
27
+ if (!menuItem.schemaConfig) return;
28
+ resetData();
29
+ const { schemaConfig: sConfig } = menuItem;
30
+ api.value = sConfig.api;
31
+ tableSchema.value = buildSchema(sConfig.schema, "table");
32
+ tableConfig.value = sConfig.tableConfig;
33
+
34
+ searchSchema.value = buildSchema(sConfig.schema, "search");
35
+ const routeQuery = route.query;
36
+ Object.entries(routeQuery).forEach(([key, value]) => {
37
+ if (searchSchema.value?.properties?.[key] && routeQuery[key] !== undefined) {
38
+ searchSchema.value.properties[key].option.default = value;
39
+ }
40
+ });
41
+ searchConfig.value = sConfig.searchConfig;
42
+
43
+ // 处理动态组件配置
44
+ components.value = Object.entries(sConfig.componentConfig || {}).reduce((pre, cur) => {
45
+ const [comName, comConfig] = cur;
46
+ // 构建动态数据
47
+ pre[comName] = {
48
+ schema: buildSchema(sConfig.schema, comName),
49
+ config: comConfig,
50
+ };
51
+ return pre;
52
+ }, {});
53
+ };
54
+
55
+ const resetData = () => {
56
+ api.value = "";
57
+ tableSchema.value = {};
58
+ tableConfig.value = {};
59
+ searchSchema.value = {};
60
+ searchConfig.value = {};
61
+ };
62
+
63
+ const buildSchema = (schema, type) => {
64
+ if (!schema?.properties) return {};
65
+ const newSchema = {
66
+ type: "object",
67
+ properties: {},
68
+ };
69
+
70
+ const { properties, required } = schema;
71
+ for (let [key, value] of Object.entries(properties)) {
72
+ if (value[`${type}Option`]) {
73
+ const newProps = {};
74
+ for (let valueKey in value) {
75
+ if (valueKey.indexOf("Option") <= -1) {
76
+ newProps[valueKey] = value[valueKey];
77
+ }
78
+ }
79
+ Object.assign(newProps, {
80
+ option: {
81
+ ...(value[`${type}Option`] || {}),
82
+ required: required?.includes(key) ? true : false,
83
+ },
84
+ });
85
+ newSchema.properties[key] = newProps;
86
+ }
87
+ }
88
+ return newSchema;
89
+ };
90
+
91
+ watch(
92
+ [() => route.query.sider_key, () => route.query.key, () => menuStore.menuList],
93
+ () => {
94
+ initData();
95
+ },
96
+ { deep: true },
97
+ );
98
+
99
+ onMounted(() => {
100
+ initData();
101
+ });
102
+
103
+ return {
104
+ api,
105
+ tableSchema,
106
+ tableConfig,
107
+ searchSchema,
108
+ searchConfig,
109
+ components,
110
+ };
111
+ };
112
+
113
+ export default useSchema;
@@ -0,0 +1,114 @@
1
+ <template>
2
+ <div class="schema-view">
3
+ <search-panel
4
+ ref="searchPanelRef"
5
+ @search="onSearch"
6
+ ></search-panel>
7
+ <table-panel
8
+ ref="tablePanelRef"
9
+ @operation="handleOperation"
10
+ ></table-panel>
11
+ <component
12
+ :is="loadedComponentMap[comName]"
13
+ v-for="comName in loadedComponentNames"
14
+ ref="componentRefList"
15
+ :key="comName"
16
+ @command="handleCommand"
17
+ ></component>
18
+ </div>
19
+ </template>
20
+
21
+ <script setup>
22
+ import { computed, nextTick, provide, ref, shallowRef, watch } from "vue";
23
+ import SearchPanel from "./complex-view/search-panel/index.vue";
24
+ import TablePanel from "./complex-view/table-panel/index.vue";
25
+ import useSchema from "./hook/use-schema";
26
+ import { message } from "ant-design-vue";
27
+ import componentConfig from "./components/component-config";
28
+ const { api, tableConfig, tableSchema, searchSchema, searchConfig, components } = useSchema();
29
+ const searchParams = ref({});
30
+ const onSearch = (params) => {
31
+ searchParams.value = params;
32
+ };
33
+
34
+ const componentRefList = ref([]);
35
+ const tablePanelRef = ref();
36
+ const searchPanelRef = ref();
37
+ const loadedComponentMap = shallowRef({});
38
+ const loadedComponentNames = computed(() =>
39
+ Object.keys(components.value).filter((comName) => loadedComponentMap.value[comName]),
40
+ );
41
+ provide("schemaViewData", {
42
+ api,
43
+ tableConfig,
44
+ tableSchema,
45
+ searchSchema,
46
+ searchConfig,
47
+ searchParams,
48
+ components,
49
+ });
50
+
51
+ const EventKeyMap = {
52
+ showComponent: showComponentHandler,
53
+ };
54
+
55
+ watch(
56
+ () => components.value,
57
+ () => {
58
+ loadedComponentMap.value = {};
59
+ componentRefList.value = [];
60
+ },
61
+ );
62
+
63
+ async function loadComponent(comName) {
64
+ if (loadedComponentMap.value[comName]) return;
65
+ const config = componentConfig[comName];
66
+ if (!config) return;
67
+ const loadedModule = config.loader ? await config.loader() : null;
68
+ const component = config.component || loadedModule?.default;
69
+ if (!component) return;
70
+ loadedComponentMap.value = {
71
+ ...loadedComponentMap.value,
72
+ [comName]: component,
73
+ };
74
+ await nextTick();
75
+ }
76
+
77
+ async function showComponentHandler({ buttonConfig, rowData }) {
78
+ console.log("{ buttonConfig, rawData }", { buttonConfig, rowData });
79
+ const { eventOption } = buttonConfig;
80
+ const { comName } = eventOption;
81
+ if (!comName) {
82
+ message.error("请配置comName");
83
+ return;
84
+ }
85
+
86
+ await loadComponent(comName);
87
+ const component = componentRefList.value.find((i) => i.name === comName);
88
+ if (!component) {
89
+ message.error("无法找到组件");
90
+ return;
91
+ }
92
+ component?.show?.({ buttonConfig, rowData });
93
+ }
94
+ const handleOperation = ({ buttonConfig, rowData }) => {
95
+ const { eventKey } = buttonConfig;
96
+ if (EventKeyMap[eventKey]) {
97
+ EventKeyMap[eventKey]({ buttonConfig, rowData });
98
+ return;
99
+ }
100
+ message.error("暂不支持该操作");
101
+ };
102
+
103
+ const handleCommand = ({ eventKey }) => {
104
+ if (eventKey === "loadTableList") {
105
+ tablePanelRef.value.getTableList("search");
106
+ }
107
+ };
108
+ </script>
109
+
110
+ <style scoped>
111
+ .schema-view {
112
+ padding: 24px;
113
+ }
114
+ </style>