worsoft-frontend-codegen-local-mcp 0.1.50 → 0.1.52
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.
- package/assets/templates/master_child_jump/api.tpl +6 -0
- package/assets/templates/master_child_jump/form.tpl +29 -9
- package/assets/templates/master_child_jump/index.tpl +48 -1
- package/assets/templates/master_child_jump/options.tpl +9 -5
- package/assets/templates/single_table_dialog/api.tpl +6 -0
- package/assets/templates/single_table_dialog/form.tpl +20 -5
- package/assets/templates/single_table_dialog/index.tpl +39 -0
- package/assets/templates/single_table_dialog/options.tpl +9 -5
- package/assets/templates/single_table_jump/api.tpl +7 -1
- package/assets/templates/single_table_jump/form.tpl +28 -9
- package/assets/templates/single_table_jump/index.tpl +47 -1
- package/assets/templates/single_table_jump/options.tpl +9 -5
- package/mcp_server.js +297 -189
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
// 请求工具
|
|
1
2
|
import request from '/@/utils/request';
|
|
2
3
|
|
|
4
|
+
// 查询分页列表
|
|
3
5
|
export function fetchList(query?: object) {
|
|
4
6
|
return request({
|
|
5
7
|
url: '/{{API_PATH}}/page',
|
|
@@ -8,6 +10,7 @@ export function fetchList(query?: object) {
|
|
|
8
10
|
});
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
// 新增数据
|
|
11
14
|
export function addObj(obj?: object) {
|
|
12
15
|
return request({
|
|
13
16
|
url: '/{{API_PATH}}/save',
|
|
@@ -16,6 +19,7 @@ export function addObj(obj?: object) {
|
|
|
16
19
|
});
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
// 查询详情数据
|
|
19
23
|
export function getObj(obj?: object) {
|
|
20
24
|
return request({
|
|
21
25
|
url: '/{{API_PATH}}/getById',
|
|
@@ -24,6 +28,7 @@ export function getObj(obj?: object) {
|
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
// 删除数据
|
|
27
32
|
export function delObjs(ids?: object) {
|
|
28
33
|
return request({
|
|
29
34
|
url: '/{{API_PATH}}/removeByIds',
|
|
@@ -32,6 +37,7 @@ export function delObjs(ids?: object) {
|
|
|
32
37
|
});
|
|
33
38
|
}
|
|
34
39
|
|
|
40
|
+
// 更新数据
|
|
35
41
|
export function putObj(obj?: object) {
|
|
36
42
|
return request({
|
|
37
43
|
url: '/{{API_PATH}}/updateById',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
<template>
|
|
2
2
|
<div class="layout-padding-auto layout-padding-view">
|
|
3
3
|
<el-card shadow="never" class="w100">
|
|
4
4
|
<template #header>
|
|
@@ -29,25 +29,42 @@
|
|
|
29
29
|
</template>
|
|
30
30
|
|
|
31
31
|
<script setup lang="ts" name="{{CLASS_NAME}}Form">
|
|
32
|
+
// 标签页关闭总线
|
|
32
33
|
import mittBus from '/@/utils/mitt';
|
|
34
|
+
// 本地会话存储
|
|
33
35
|
import { Session } from '/@/utils/storage';
|
|
36
|
+
// 通用消息提示
|
|
34
37
|
import { useMessage } from '/@/hooks/message';
|
|
38
|
+
// 表单数据接口
|
|
35
39
|
import { getObj, addObj, putObj } from '/@/api/{{API_MODULE_PATH}}';
|
|
40
|
+
// 字典数据加载
|
|
36
41
|
import { useDict } from '/@/hooks/dict';
|
|
42
|
+
// 表单字段元数据能力
|
|
37
43
|
import { useCrudPageMeta } from '/@/hooks/useCrudPageMeta';
|
|
44
|
+
// 国际化能力
|
|
38
45
|
import { useI18n } from 'vue-i18n';
|
|
46
|
+
// 当前页面的字段配置
|
|
39
47
|
import { allDictTypes, childFieldGroups, dataMasterEntity } from './options';
|
|
40
48
|
|
|
49
|
+
// 页面所需的字典引用
|
|
41
50
|
const dictRefs = useDict(...allDictTypes);
|
|
51
|
+
// 国际化方法
|
|
42
52
|
const { t } = useI18n();
|
|
43
53
|
|
|
54
|
+
// 子表表格组件
|
|
44
55
|
const scFormTable = defineAsyncComponent(() => import('/@/components/FormTable/index.vue'));
|
|
56
|
+
// 当前路由信息
|
|
45
57
|
const route = useRoute();
|
|
58
|
+
// 路由跳转能力
|
|
46
59
|
const router = useRouter();
|
|
60
|
+
// 当前页面的国际化命名空间
|
|
47
61
|
const pageI18nKey = '{{I18N_NAMESPACE}}';
|
|
48
62
|
|
|
63
|
+
// 表单引用
|
|
49
64
|
const dataFormRef = ref();
|
|
65
|
+
// 页面加载状态
|
|
50
66
|
const loading = ref(false);
|
|
67
|
+
// 是否详情模式
|
|
51
68
|
const detail = ref(false);
|
|
52
69
|
|
|
53
70
|
// 主表和子表字段的双语、字典和校验提示统一由公共 hook 提供
|
|
@@ -65,13 +82,13 @@ const {
|
|
|
65
82
|
// 子表分组标题从功能级词条中读取
|
|
66
83
|
const childSectionTitle = (groupName: string) => t(`${pageI18nKey}.children.${groupName}.title`);
|
|
67
84
|
|
|
68
|
-
//
|
|
85
|
+
// 统一维护表单默认值
|
|
69
86
|
const createDefaultFormState = () => ({
|
|
70
87
|
{{FORM_DEFAULTS}}
|
|
71
88
|
{{CHILD_FORM_LIST_DEFAULTS}}
|
|
72
89
|
});
|
|
73
90
|
|
|
74
|
-
//
|
|
91
|
+
// 表单响应式数据
|
|
75
92
|
const form = reactive(createDefaultFormState());
|
|
76
93
|
|
|
77
94
|
// 各子表新增行时使用的临时对象
|
|
@@ -128,14 +145,16 @@ const handleBack = () => {
|
|
|
128
145
|
router.back();
|
|
129
146
|
};
|
|
130
147
|
|
|
131
|
-
//
|
|
148
|
+
// 保存、提交和流转共用同一套提交逻辑
|
|
132
149
|
const onSubmit = async (actionType?: string) => {
|
|
133
150
|
loading.value = true;
|
|
134
151
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
152
|
+
if (actionType !== 'save') {
|
|
153
|
+
const valid = await dataFormRef.value.validate().catch(() => {});
|
|
154
|
+
if (!valid) {
|
|
155
|
+
loading.value = false;
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
139
158
|
}
|
|
140
159
|
|
|
141
160
|
try {
|
|
@@ -154,11 +173,12 @@ const onSubmit = async (actionType?: string) => {
|
|
|
154
173
|
}
|
|
155
174
|
};
|
|
156
175
|
|
|
157
|
-
//
|
|
176
|
+
// 子表删除仅处理前端行状态
|
|
158
177
|
const deleteChild = (_obj: Record<string, any>, _childPkAttr: string) => {
|
|
159
178
|
return true;
|
|
160
179
|
};
|
|
161
180
|
|
|
181
|
+
// 页面挂载后初始化数据
|
|
162
182
|
onMounted(() => {
|
|
163
183
|
initPage();
|
|
164
184
|
});
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
>
|
|
25
25
|
<template #actions="{ row }">
|
|
26
26
|
<el-button text type="primary" icon="view" v-auth="'{{PERMISSION_PREFIX}}_view'" @click="handleDetail(row.{{PK_ATTR}})">{{ t('common.viewBtn') }}</el-button>
|
|
27
|
-
<el-button icon="edit-pen" text type="primary" v-auth="'{{PERMISSION_PREFIX}}_edit'" @click="handleEdit(row.{{PK_ATTR}})">{{ t('common.editBtn') }}</el-button>
|
|
27
|
+
<el-button{{BUSINESS_EDIT_IF}} icon="edit-pen" text type="primary" v-auth="'{{PERMISSION_PREFIX}}_edit'" @click="handleEdit(row.{{PK_ATTR}})">{{ t('common.editBtn') }}</el-button>
|
|
28
28
|
<el-button text type="primary" icon="check" @click="handleQuickAction(row, 'submit')">{{ commonActionLabel('submit') }}</el-button>
|
|
29
29
|
<el-button text type="success" icon="position" @click="handleQuickAction(row, 'flow')">{{ commonActionLabel('flow') }}</el-button>
|
|
30
30
|
<el-button icon="delete" text type="primary" v-auth="'{{PERMISSION_PREFIX}}_del'" @click="handleDelete([row.{{PK_ATTR}}])">{{ t('common.delBtn') }}</el-button>
|
|
@@ -37,24 +37,42 @@
|
|
|
37
37
|
</template>
|
|
38
38
|
|
|
39
39
|
<script setup lang="ts" name="system{{CLASS_NAME}}">
|
|
40
|
+
// 列表接口
|
|
40
41
|
import { fetchList, delObjs } from '/@/api/{{API_MODULE_PATH}}';
|
|
42
|
+
// 通用消息与确认弹窗
|
|
41
43
|
import { useMessage, useMessageBox } from '/@/hooks/message';
|
|
44
|
+
// 字典数据加载
|
|
42
45
|
import { useDict } from '/@/hooks/dict';
|
|
46
|
+
// 列表页字段元数据能力
|
|
43
47
|
import { useCrudPageMeta } from '/@/hooks/useCrudPageMeta';
|
|
48
|
+
// 列表页查询与分页状态
|
|
44
49
|
import { useSchemaListQuery } from '/@/hooks/useSchemaListQuery';
|
|
50
|
+
// 统一列表工具栏组件
|
|
45
51
|
import SchemaListToolbar from '/@/components/schema-list/SchemaListToolbar.vue';
|
|
52
|
+
// 统一列表表格组件
|
|
46
53
|
import SchemaListTable from '/@/components/schema-list/SchemaListTable.vue';
|
|
54
|
+
// 国际化能力
|
|
47
55
|
import { useI18n } from 'vue-i18n';
|
|
56
|
+
// 当前页面的 schema 与字段配置
|
|
48
57
|
import { allDictTypes, crudSchema, dataMasterEntity } from './options';
|
|
58
|
+
// 业务状态编辑控制(按需生成)
|
|
59
|
+
{{BUSINESS_STATUS_IMPORTS}}
|
|
49
60
|
|
|
61
|
+
// 页面所需的字典引用
|
|
50
62
|
const dictRefs = useDict(...allDictTypes);
|
|
63
|
+
// 国际化方法
|
|
51
64
|
const { t } = useI18n();
|
|
65
|
+
// 路由跳转能力
|
|
52
66
|
const router = useRouter();
|
|
53
67
|
|
|
68
|
+
// 导入组件引用
|
|
54
69
|
const excelUploadRef = ref();
|
|
70
|
+
// 列表勾选主键集合
|
|
55
71
|
const selectObjs = ref<string[]>([]);
|
|
72
|
+
// 批量删除按钮状态
|
|
56
73
|
const multiple = ref(true);
|
|
57
74
|
|
|
75
|
+
// 统一管理列表查询、分页、排序和导出
|
|
58
76
|
const { state, getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, tableStyle, exportExcel: runExportExcel, resetQueryForm } = useSchemaListQuery({
|
|
59
77
|
schema: crudSchema,
|
|
60
78
|
pageList: fetchList,
|
|
@@ -62,8 +80,10 @@ const { state, getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHan
|
|
|
62
80
|
exportFileName: '{{FUNCTION_NAME}}.xlsx',
|
|
63
81
|
});
|
|
64
82
|
|
|
83
|
+
// 提供字段标签、字典选项和查询区描述
|
|
65
84
|
const { resolveLabel, getDictOptions, commonActionLabel, visibleTableColumns, searchKeywordTooltip, queryableDictFields } = useCrudPageMeta(dataMasterEntity, dictRefs);
|
|
66
85
|
|
|
86
|
+
// 自定义查询区的字典字段配置
|
|
67
87
|
const queryableDictOptions = computed(() =>
|
|
68
88
|
queryableDictFields.value.map((field) => ({
|
|
69
89
|
...field,
|
|
@@ -71,6 +91,7 @@ const queryableDictOptions = computed(() =>
|
|
|
71
91
|
}))
|
|
72
92
|
);
|
|
73
93
|
|
|
94
|
+
// 列表表格列配置
|
|
74
95
|
const tableColumns = computed(() =>
|
|
75
96
|
visibleTableColumns.value.map((column) => ({
|
|
76
97
|
prop: column.prop,
|
|
@@ -81,6 +102,7 @@ const tableColumns = computed(() =>
|
|
|
81
102
|
}))
|
|
82
103
|
);
|
|
83
104
|
|
|
105
|
+
// 工具栏透传属性
|
|
84
106
|
const toolbarProps = computed(() => ({
|
|
85
107
|
keyword: state.queryForm.smartVal,
|
|
86
108
|
searchPlaceholder: searchKeywordTooltip.value,
|
|
@@ -91,6 +113,7 @@ const toolbarProps = computed(() => ({
|
|
|
91
113
|
exportPermission: '{{PERMISSION_PREFIX}}_export',
|
|
92
114
|
}));
|
|
93
115
|
|
|
116
|
+
// 表格透传属性
|
|
94
117
|
const tableProps = computed(() => ({
|
|
95
118
|
data: state.dataList,
|
|
96
119
|
loading: !!state.loading,
|
|
@@ -99,20 +122,28 @@ const tableProps = computed(() => ({
|
|
|
99
122
|
tableStyle,
|
|
100
123
|
}));
|
|
101
124
|
|
|
125
|
+
// 表单页路由路径
|
|
102
126
|
const getFormPath = () => '/{{VIEW_MODULE_PATH}}/form';
|
|
103
127
|
|
|
128
|
+
// 跳转新增页
|
|
104
129
|
const handleCreate = () => {
|
|
105
130
|
router.push({ path: getFormPath(), query: { tagsViewName: t('common.addBtn') } });
|
|
106
131
|
};
|
|
107
132
|
|
|
133
|
+
// 跳转详情页
|
|
108
134
|
const handleDetail = (id: string) => {
|
|
109
135
|
router.push({ path: getFormPath(), query: { id, detail: '1', tagsViewName: t('common.viewBtn') } });
|
|
110
136
|
};
|
|
111
137
|
|
|
138
|
+
// 跳转编辑页
|
|
112
139
|
const handleEdit = (id: string) => {
|
|
113
140
|
router.push({ path: getFormPath(), query: { id, tagsViewName: t('common.editBtn') } });
|
|
114
141
|
};
|
|
115
142
|
|
|
143
|
+
// 业务状态按钮控制(按需生成)
|
|
144
|
+
{{BUSINESS_STATUS_HELPERS}}
|
|
145
|
+
|
|
146
|
+
// 列表页快捷提交流转
|
|
116
147
|
const handleQuickAction = async (_row: any, actionType: string) => {
|
|
117
148
|
const actionName = commonActionLabel(actionType);
|
|
118
149
|
try {
|
|
@@ -128,10 +159,12 @@ const handleQuickAction = async (_row: any, actionType: string) => {
|
|
|
128
159
|
}
|
|
129
160
|
};
|
|
130
161
|
|
|
162
|
+
// 导出当前勾选数据
|
|
131
163
|
const exportExcel = () => {
|
|
132
164
|
runExportExcel(selectObjs.value);
|
|
133
165
|
};
|
|
134
166
|
|
|
167
|
+
// 应用自定义查询条件
|
|
135
168
|
const handleQueryFilterConfirm = (values: Record<string, any>) => {
|
|
136
169
|
queryableDictFields.value.forEach((field) => {
|
|
137
170
|
const nextValue = values[field.prop];
|
|
@@ -144,11 +177,13 @@ const handleQueryFilterConfirm = (values: Record<string, any>) => {
|
|
|
144
177
|
getDataList();
|
|
145
178
|
};
|
|
146
179
|
|
|
180
|
+
// 重置查询条件
|
|
147
181
|
const resetQuery = () => {
|
|
148
182
|
resetQueryForm();
|
|
149
183
|
getDataList();
|
|
150
184
|
};
|
|
151
185
|
|
|
186
|
+
// 删除列表数据
|
|
152
187
|
const handleDelete = async (ids: string[]) => {
|
|
153
188
|
try {
|
|
154
189
|
await useMessageBox().confirm(t('common.delConfirmText'));
|
|
@@ -165,51 +200,63 @@ const handleDelete = async (ids: string[]) => {
|
|
|
165
200
|
}
|
|
166
201
|
};
|
|
167
202
|
|
|
203
|
+
// 工具栏新增事件
|
|
168
204
|
const handleToolbarAdd = () => {
|
|
169
205
|
handleCreate();
|
|
170
206
|
};
|
|
171
207
|
|
|
208
|
+
// 工具栏导入事件
|
|
172
209
|
const handleToolbarImport = () => {
|
|
173
210
|
excelUploadRef.value?.show();
|
|
174
211
|
};
|
|
175
212
|
|
|
213
|
+
// 工具栏批量删除事件
|
|
176
214
|
const handleToolbarDelete = () => {
|
|
177
215
|
handleDelete(selectObjs.value);
|
|
178
216
|
};
|
|
179
217
|
|
|
218
|
+
// 工具栏查询事件
|
|
180
219
|
const handleToolbarQuery = () => {
|
|
181
220
|
getDataList();
|
|
182
221
|
};
|
|
183
222
|
|
|
223
|
+
// 工具栏重置事件
|
|
184
224
|
const handleToolbarReset = () => {
|
|
185
225
|
resetQuery();
|
|
186
226
|
};
|
|
187
227
|
|
|
228
|
+
// 工具栏高级查询确认事件
|
|
188
229
|
const handleToolbarCustomQueryConfirm = (payload: { values: Record<string, any> }) => {
|
|
189
230
|
handleQueryFilterConfirm(payload.values);
|
|
190
231
|
};
|
|
191
232
|
|
|
233
|
+
// 工具栏导出事件
|
|
192
234
|
const handleToolbarExport = () => {
|
|
193
235
|
exportExcel();
|
|
194
236
|
};
|
|
195
237
|
|
|
238
|
+
// 工具栏刷新事件
|
|
196
239
|
const handleToolbarRefresh = () => {
|
|
197
240
|
getDataList();
|
|
198
241
|
};
|
|
199
242
|
|
|
243
|
+
// 表格勾选变化事件
|
|
200
244
|
const handleTableSelectionChange = (payload: { ids: Array<string | number> }) => {
|
|
201
245
|
selectObjs.value = payload.ids.map((id) => String(id));
|
|
202
246
|
multiple.value = !payload.ids.length;
|
|
203
247
|
};
|
|
204
248
|
|
|
249
|
+
// 表格排序事件
|
|
205
250
|
const handleTableSortChange = (payload: { raw: any }) => {
|
|
206
251
|
sortChangeHandle(payload.raw);
|
|
207
252
|
};
|
|
208
253
|
|
|
254
|
+
// 分页大小变化事件
|
|
209
255
|
const handleTableSizeChange = (payload: { size: number }) => {
|
|
210
256
|
sizeChangeHandle(payload.size);
|
|
211
257
|
};
|
|
212
258
|
|
|
259
|
+
// 当前页变化事件
|
|
213
260
|
const handleTableCurrentChange = (payload: { current: number }) => {
|
|
214
261
|
currentChangeHandle(payload.current);
|
|
215
262
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
// 字典注册表
|
|
1
2
|
{{DICT_REGISTRY_IMPORT_BLOCK}}
|
|
3
|
+
// schema 构建工具
|
|
2
4
|
import { createCrudSchema } from '/@/utils/crudSchema';
|
|
5
|
+
// schema 类型定义
|
|
3
6
|
import type { CrudSchemaDefinition } from '/@/utils/crudSchema';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* {{TABLE_NAME}} 页面字段声明
|
|
7
|
-
*
|
|
10
|
+
* 这里维护字段 key、双语 key、字典类型和显示元数据
|
|
8
11
|
*/
|
|
9
12
|
const definition: CrudSchemaDefinition = {
|
|
10
13
|
master: [
|
|
@@ -15,17 +18,18 @@ const definition: CrudSchemaDefinition = {
|
|
|
15
18
|
},
|
|
16
19
|
};
|
|
17
20
|
|
|
18
|
-
//
|
|
21
|
+
// 将页面字段声明转换为 index/form 共用的 schema 结果
|
|
19
22
|
const schema = createCrudSchema(definition);
|
|
20
23
|
|
|
24
|
+
// 完整 CRUD schema
|
|
21
25
|
export const crudSchema = schema;
|
|
22
26
|
// 主表字段配置,供列表页和表单页使用
|
|
23
27
|
export const dataMasterEntity = schema.master;
|
|
24
|
-
//
|
|
28
|
+
// 子表字段配置,供主子表区域读取
|
|
25
29
|
export const childFieldGroups = schema.children;
|
|
26
|
-
//
|
|
30
|
+
// 列表/查询使用的主表字段类型映射
|
|
27
31
|
export const filterTypes = schema.filterTypes;
|
|
28
32
|
// 子表字段类型映射
|
|
29
33
|
export const childFilterTypes = schema.childFilterTypes;
|
|
30
|
-
//
|
|
34
|
+
// 当前页面需要一次性加载的全部字典类型
|
|
31
35
|
export const allDictTypes = schema.allDictTypes;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
// 请求工具
|
|
1
2
|
import request from '/@/utils/request';
|
|
2
3
|
|
|
4
|
+
// 查询分页列表
|
|
3
5
|
export function fetchList(query?: object) {
|
|
4
6
|
return request({
|
|
5
7
|
url: '/{{API_PATH}}/page',
|
|
@@ -8,6 +10,7 @@ export function fetchList(query?: object) {
|
|
|
8
10
|
});
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
// 新增数据
|
|
11
14
|
export function addObj(obj?: object) {
|
|
12
15
|
return request({
|
|
13
16
|
url: '/{{API_PATH}}',
|
|
@@ -16,6 +19,7 @@ export function addObj(obj?: object) {
|
|
|
16
19
|
});
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
// 查询详情数据
|
|
19
23
|
export function getObj(obj?: object) {
|
|
20
24
|
return request({
|
|
21
25
|
url: '/{{API_PATH}}/details',
|
|
@@ -24,6 +28,7 @@ export function getObj(obj?: object) {
|
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
// 删除数据
|
|
27
32
|
export function delObjs(ids?: object) {
|
|
28
33
|
return request({
|
|
29
34
|
url: '/{{API_PATH}}',
|
|
@@ -32,6 +37,7 @@ export function delObjs(ids?: object) {
|
|
|
32
37
|
});
|
|
33
38
|
}
|
|
34
39
|
|
|
40
|
+
// 更新数据
|
|
35
41
|
export function putObj(obj?: object) {
|
|
36
42
|
return request({
|
|
37
43
|
url: '/{{API_PATH}}',
|
|
@@ -15,20 +15,33 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<script setup lang="ts" name="{{CLASS_NAME}}Dialog">
|
|
18
|
+
// 通用消息提示
|
|
18
19
|
import { useMessage } from '/@/hooks/message';
|
|
20
|
+
// 本地会话存储
|
|
19
21
|
import { Session } from '/@/utils/storage';
|
|
22
|
+
// 表单数据接口
|
|
20
23
|
import { getObj, addObj, putObj } from '/@/api/{{API_MODULE_PATH}}';
|
|
24
|
+
// 字典数据加载
|
|
21
25
|
import { useDict } from '/@/hooks/dict';
|
|
26
|
+
// 表单字段元数据能力
|
|
22
27
|
import { useCrudPageMeta } from '/@/hooks/useCrudPageMeta';
|
|
28
|
+
// 国际化能力
|
|
23
29
|
import { useI18n } from 'vue-i18n';
|
|
30
|
+
// 当前页面的字段配置
|
|
24
31
|
import { allDictTypes, dataMasterEntity } from './options';
|
|
25
32
|
|
|
33
|
+
// 页面所需的字典引用
|
|
26
34
|
const dictRefs = useDict(...allDictTypes);
|
|
35
|
+
// 国际化方法
|
|
27
36
|
const { t } = useI18n();
|
|
37
|
+
// 弹窗刷新事件
|
|
28
38
|
const emit = defineEmits(['refresh']);
|
|
29
39
|
|
|
40
|
+
// 表单引用
|
|
30
41
|
const dataFormRef = ref();
|
|
42
|
+
// 弹窗显示状态
|
|
31
43
|
const visible = ref(false);
|
|
44
|
+
// 提交加载状态
|
|
32
45
|
const loading = ref(false);
|
|
33
46
|
|
|
34
47
|
// 主表字段的双语、字典和校验提示统一由公共 hook 提供
|
|
@@ -41,14 +54,15 @@ const {
|
|
|
41
54
|
fieldRequiredMessage,
|
|
42
55
|
} = useCrudPageMeta(dataMasterEntity, dictRefs);
|
|
43
56
|
|
|
44
|
-
//
|
|
57
|
+
// 统一维护表单默认值
|
|
45
58
|
const createDefaultFormState = () => ({
|
|
46
59
|
{{FORM_DEFAULTS}}
|
|
47
60
|
});
|
|
48
61
|
|
|
62
|
+
// 表单响应式数据
|
|
49
63
|
const form = reactive(createDefaultFormState());
|
|
50
64
|
|
|
51
|
-
//
|
|
65
|
+
// 表单校验规则
|
|
52
66
|
const dataRules = ref({
|
|
53
67
|
{{FORM_RULES}}
|
|
54
68
|
});
|
|
@@ -66,7 +80,7 @@ const get{{CLASS_NAME}}Data = async (id: string) => {
|
|
|
66
80
|
}
|
|
67
81
|
};
|
|
68
82
|
|
|
69
|
-
//
|
|
83
|
+
// 重置表单为初始状态
|
|
70
84
|
const resetFormState = () => {
|
|
71
85
|
Object.assign(form, createDefaultFormState());
|
|
72
86
|
nextTick(() => {
|
|
@@ -74,7 +88,7 @@ const resetFormState = () => {
|
|
|
74
88
|
});
|
|
75
89
|
};
|
|
76
90
|
|
|
77
|
-
//
|
|
91
|
+
// 打开弹窗并按需加载详情
|
|
78
92
|
const openDialog = async (id?: string) => {
|
|
79
93
|
visible.value = true;
|
|
80
94
|
resetFormState();
|
|
@@ -85,7 +99,7 @@ const openDialog = async (id?: string) => {
|
|
|
85
99
|
}
|
|
86
100
|
};
|
|
87
101
|
|
|
88
|
-
//
|
|
102
|
+
// 提交弹窗表单
|
|
89
103
|
const onSubmit = async () => {
|
|
90
104
|
loading.value = true;
|
|
91
105
|
|
|
@@ -107,6 +121,7 @@ const onSubmit = async () => {
|
|
|
107
121
|
}
|
|
108
122
|
};
|
|
109
123
|
|
|
124
|
+
// 向父组件暴露打开弹窗方法
|
|
110
125
|
defineExpose({
|
|
111
126
|
openDialog,
|
|
112
127
|
});
|
|
@@ -35,25 +35,42 @@
|
|
|
35
35
|
</template>
|
|
36
36
|
|
|
37
37
|
<script setup lang="ts" name="system{{CLASS_NAME}}">
|
|
38
|
+
// 列表接口
|
|
38
39
|
import { fetchList, delObjs{{DICT_API_IMPORTS}} } from '/@/api/{{API_MODULE_PATH}}';
|
|
40
|
+
// 通用消息与确认弹窗
|
|
39
41
|
import { useMessage, useMessageBox } from '/@/hooks/message';
|
|
42
|
+
// 字典数据加载
|
|
40
43
|
import { useDict } from '/@/hooks/dict';
|
|
44
|
+
// 列表页字段元数据能力
|
|
41
45
|
import { useCrudPageMeta } from '/@/hooks/useCrudPageMeta';
|
|
46
|
+
// 列表页查询与分页状态
|
|
42
47
|
import { useSchemaListQuery } from '/@/hooks/useSchemaListQuery';
|
|
48
|
+
// 统一列表工具栏组件
|
|
43
49
|
import SchemaListToolbar from '/@/components/schema-list/SchemaListToolbar.vue';
|
|
50
|
+
// 统一列表表格组件
|
|
44
51
|
import SchemaListTable from '/@/components/schema-list/SchemaListTable.vue';
|
|
52
|
+
// 国际化能力
|
|
45
53
|
import { useI18n } from 'vue-i18n';
|
|
54
|
+
// 当前页面的 schema 与字段配置
|
|
46
55
|
import { allDictTypes, crudSchema, dataMasterEntity } from './options';
|
|
47
56
|
|
|
57
|
+
// 表单弹窗组件
|
|
48
58
|
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
|
59
|
+
// 页面所需的字典引用
|
|
49
60
|
const dictRefs = useDict(...allDictTypes);
|
|
61
|
+
// 国际化方法
|
|
50
62
|
const { t } = useI18n();
|
|
51
63
|
|
|
64
|
+
// 表单弹窗引用
|
|
52
65
|
const formDialogRef = ref();
|
|
66
|
+
// 导入组件引用
|
|
53
67
|
const excelUploadRef = ref();
|
|
68
|
+
// 列表勾选主键集合
|
|
54
69
|
const selectObjs = ref<string[]>([]);
|
|
70
|
+
// 批量删除按钮状态
|
|
55
71
|
const multiple = ref(true);
|
|
56
72
|
|
|
73
|
+
// 统一管理列表查询、分页、排序和导出
|
|
57
74
|
const { state, getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, tableStyle, exportExcel: runExportExcel, resetQueryForm } = useSchemaListQuery({
|
|
58
75
|
schema: crudSchema,
|
|
59
76
|
pageList: fetchList,
|
|
@@ -61,8 +78,10 @@ const { state, getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHan
|
|
|
61
78
|
exportFileName: '{{FUNCTION_NAME}}.xlsx',
|
|
62
79
|
});
|
|
63
80
|
|
|
81
|
+
// 提供字段标签、字典选项和查询区描述
|
|
64
82
|
const { resolveLabel, getDictOptions, visibleTableColumns, searchKeywordTooltip, queryableDictFields } = useCrudPageMeta(dataMasterEntity, dictRefs);
|
|
65
83
|
|
|
84
|
+
// 自定义查询区的字典字段配置
|
|
66
85
|
const queryableDictOptions = computed(() =>
|
|
67
86
|
queryableDictFields.value.map((field) => ({
|
|
68
87
|
...field,
|
|
@@ -70,6 +89,7 @@ const queryableDictOptions = computed(() =>
|
|
|
70
89
|
}))
|
|
71
90
|
);
|
|
72
91
|
|
|
92
|
+
// 列表表格列配置
|
|
73
93
|
const tableColumns = computed(() =>
|
|
74
94
|
visibleTableColumns.value.map((column) => ({
|
|
75
95
|
prop: column.prop,
|
|
@@ -80,6 +100,7 @@ const tableColumns = computed(() =>
|
|
|
80
100
|
}))
|
|
81
101
|
);
|
|
82
102
|
|
|
103
|
+
// 工具栏透传属性
|
|
83
104
|
const toolbarProps = computed(() => ({
|
|
84
105
|
keyword: state.queryForm.smartVal,
|
|
85
106
|
searchPlaceholder: searchKeywordTooltip.value,
|
|
@@ -94,6 +115,7 @@ const toolbarProps = computed(() => ({
|
|
|
94
115
|
showRightTools: {{SHOW_RIGHT_TOOLS}},
|
|
95
116
|
}));
|
|
96
117
|
|
|
118
|
+
// 表格透传属性
|
|
97
119
|
const tableProps = computed(() => ({
|
|
98
120
|
data: state.dataList,
|
|
99
121
|
loading: !!state.loading,
|
|
@@ -102,12 +124,15 @@ const tableProps = computed(() => ({
|
|
|
102
124
|
tableStyle,
|
|
103
125
|
}));
|
|
104
126
|
|
|
127
|
+
// 字典页动作按钮控制(按需生成)
|
|
105
128
|
{{DICT_LIST_HELPERS}}
|
|
106
129
|
|
|
130
|
+
// 导出当前勾选数据
|
|
107
131
|
const exportExcel = () => {
|
|
108
132
|
runExportExcel(selectObjs.value);
|
|
109
133
|
};
|
|
110
134
|
|
|
135
|
+
// 应用自定义查询条件
|
|
111
136
|
const handleQueryFilterConfirm = (values: Record<string, any>) => {
|
|
112
137
|
queryableDictFields.value.forEach((field) => {
|
|
113
138
|
const nextValue = values[field.prop];
|
|
@@ -120,11 +145,13 @@ const handleQueryFilterConfirm = (values: Record<string, any>) => {
|
|
|
120
145
|
getDataList();
|
|
121
146
|
};
|
|
122
147
|
|
|
148
|
+
// 重置查询条件
|
|
123
149
|
const resetQuery = () => {
|
|
124
150
|
resetQueryForm();
|
|
125
151
|
getDataList();
|
|
126
152
|
};
|
|
127
153
|
|
|
154
|
+
// 删除列表数据
|
|
128
155
|
const handleDelete = async (ids: string[]) => {
|
|
129
156
|
try {
|
|
130
157
|
await useMessageBox().confirm(t('common.delConfirmText'));
|
|
@@ -141,51 +168,63 @@ const handleDelete = async (ids: string[]) => {
|
|
|
141
168
|
}
|
|
142
169
|
};
|
|
143
170
|
|
|
171
|
+
// 工具栏新增事件
|
|
144
172
|
const handleToolbarAdd = () => {
|
|
145
173
|
formDialogRef.value?.openDialog();
|
|
146
174
|
};
|
|
147
175
|
|
|
176
|
+
// 工具栏导入事件
|
|
148
177
|
const handleToolbarImport = () => {
|
|
149
178
|
excelUploadRef.value?.show();
|
|
150
179
|
};
|
|
151
180
|
|
|
181
|
+
// 工具栏批量删除事件
|
|
152
182
|
const handleToolbarDelete = () => {
|
|
153
183
|
handleDelete(selectObjs.value);
|
|
154
184
|
};
|
|
155
185
|
|
|
186
|
+
// 工具栏查询事件
|
|
156
187
|
const handleToolbarQuery = () => {
|
|
157
188
|
getDataList();
|
|
158
189
|
};
|
|
159
190
|
|
|
191
|
+
// 工具栏重置事件
|
|
160
192
|
const handleToolbarReset = () => {
|
|
161
193
|
resetQuery();
|
|
162
194
|
};
|
|
163
195
|
|
|
196
|
+
// 工具栏高级查询确认事件
|
|
164
197
|
const handleToolbarCustomQueryConfirm = (payload: { values: Record<string, any> }) => {
|
|
165
198
|
handleQueryFilterConfirm(payload.values);
|
|
166
199
|
};
|
|
167
200
|
|
|
201
|
+
// 工具栏导出事件
|
|
168
202
|
const handleToolbarExport = () => {
|
|
169
203
|
exportExcel();
|
|
170
204
|
};
|
|
171
205
|
|
|
206
|
+
// 工具栏刷新事件
|
|
172
207
|
const handleToolbarRefresh = () => {
|
|
173
208
|
getDataList();
|
|
174
209
|
};
|
|
175
210
|
|
|
211
|
+
// 表格勾选变化事件
|
|
176
212
|
const handleTableSelectionChange = (payload: { ids: Array<string | number> }) => {
|
|
177
213
|
selectObjs.value = payload.ids.map((id) => String(id));
|
|
178
214
|
multiple.value = !payload.ids.length;
|
|
179
215
|
};
|
|
180
216
|
|
|
217
|
+
// 表格排序事件
|
|
181
218
|
const handleTableSortChange = (payload: { raw: any }) => {
|
|
182
219
|
sortChangeHandle(payload.raw);
|
|
183
220
|
};
|
|
184
221
|
|
|
222
|
+
// 分页大小变化事件
|
|
185
223
|
const handleTableSizeChange = (payload: { size: number }) => {
|
|
186
224
|
sizeChangeHandle(payload.size);
|
|
187
225
|
};
|
|
188
226
|
|
|
227
|
+
// 当前页变化事件
|
|
189
228
|
const handleTableCurrentChange = (payload: { current: number }) => {
|
|
190
229
|
currentChangeHandle(payload.current);
|
|
191
230
|
};
|