提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<el-form ref="formRef" :model="formData" :rules="rules" label-width="150px"> |
|
3 |
<el-row> |
|
4 |
<el-col :span="12"> |
|
5 |
<el-form-item label="生成模板" prop="templateType"> |
|
6 |
<el-select v-model="formData.templateType"> |
|
7 |
<el-option |
|
8 |
v-for="dict in getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE)" |
|
9 |
:key="dict.value" |
|
10 |
:label="dict.label" |
|
11 |
:value="dict.value" |
|
12 |
/> |
|
13 |
</el-select> |
|
14 |
</el-form-item> |
|
15 |
</el-col> |
|
16 |
<el-col :span="12"> |
|
17 |
<el-form-item label="前端类型" prop="frontType"> |
|
18 |
<el-select v-model="formData.frontType"> |
|
19 |
<el-option |
|
20 |
v-for="dict in getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_FRONT_TYPE)" |
|
21 |
:key="dict.value" |
|
22 |
:label="dict.label" |
|
23 |
:value="dict.value" |
|
24 |
/> |
|
25 |
</el-select> |
|
26 |
</el-form-item> |
|
27 |
</el-col> |
|
28 |
|
|
29 |
<el-col :span="12"> |
|
30 |
<el-form-item label="生成场景" prop="scene"> |
|
31 |
<el-select v-model="formData.scene"> |
|
32 |
<el-option |
|
33 |
v-for="dict in getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_SCENE)" |
|
34 |
:key="dict.value" |
|
35 |
:label="dict.label" |
|
36 |
:value="dict.value" |
|
37 |
/> |
|
38 |
</el-select> |
|
39 |
</el-form-item> |
|
40 |
</el-col> |
|
41 |
<el-col :span="12"> |
|
42 |
<el-form-item> |
|
43 |
<template #label> |
|
44 |
<span> |
|
45 |
上级菜单 |
|
46 |
<el-tooltip content="分配到指定菜单下,例如 系统管理" placement="top"> |
|
47 |
<Icon icon="ep:question-filled" /> |
|
48 |
</el-tooltip> |
|
49 |
</span> |
|
50 |
</template> |
|
51 |
<el-tree-select |
|
52 |
v-model="formData.parentMenuId" |
|
53 |
:data="menus" |
|
54 |
:props="menuTreeProps" |
|
55 |
check-strictly |
|
56 |
node-key="id" |
|
57 |
placeholder="请选择系统菜单" |
|
58 |
/> |
|
59 |
</el-form-item> |
|
60 |
</el-col> |
|
61 |
|
|
62 |
<!-- <el-col :span="12">--> |
|
63 |
<!-- <el-form-item prop="packageName">--> |
|
64 |
<!-- <span slot="label">--> |
|
65 |
<!-- 生成包路径--> |
|
66 |
<!-- <el-tooltip content="生成在哪个java包下,例如 com.ruoyi.system" placement="top">--> |
|
67 |
<!-- <i class="el-icon-question"></i>--> |
|
68 |
<!-- </el-tooltip>--> |
|
69 |
<!-- </span>--> |
|
70 |
<!-- <el-input v-model="formData.packageName" />--> |
|
71 |
<!-- </el-form-item>--> |
|
72 |
<!-- </el-col>--> |
|
73 |
|
|
74 |
<el-col :span="12"> |
|
75 |
<el-form-item prop="moduleName"> |
|
76 |
<template #label> |
|
77 |
<span> |
|
78 |
模块名 |
|
79 |
<el-tooltip |
|
80 |
content="模块名,即一级目录,例如 system、infra、tool 等等" |
|
81 |
placement="top" |
|
82 |
> |
|
83 |
<Icon icon="ep:question-filled" /> |
|
84 |
</el-tooltip> |
|
85 |
</span> |
|
86 |
</template> |
|
87 |
<el-input v-model="formData.moduleName" /> |
|
88 |
</el-form-item> |
|
89 |
</el-col> |
|
90 |
|
|
91 |
<el-col :span="12"> |
|
92 |
<el-form-item prop="businessName"> |
|
93 |
<template #label> |
|
94 |
<span> |
|
95 |
业务名 |
|
96 |
<el-tooltip |
|
97 |
content="业务名,即二级目录,例如 user、permission、dict 等等" |
|
98 |
placement="top" |
|
99 |
> |
|
100 |
<Icon icon="ep:question-filled" /> |
|
101 |
</el-tooltip> |
|
102 |
</span> |
|
103 |
</template> |
|
104 |
<el-input v-model="formData.businessName" /> |
|
105 |
</el-form-item> |
|
106 |
</el-col> |
|
107 |
|
|
108 |
<!-- <el-col :span="12">--> |
|
109 |
<!-- <el-form-item prop="businessPackage">--> |
|
110 |
<!-- <span slot="label">--> |
|
111 |
<!-- 业务包--> |
|
112 |
<!-- <el-tooltip content="业务包,自定义二级目录。例如说,我们希望将 dictType 和 dictData 归类成 dict 业务" placement="top">--> |
|
113 |
<!-- <i class="el-icon-question"></i>--> |
|
114 |
<!-- </el-tooltip>--> |
|
115 |
<!-- </span>--> |
|
116 |
<!-- <el-input v-model="formData.businessPackage" />--> |
|
117 |
<!-- </el-form-item>--> |
|
118 |
<!-- </el-col>--> |
|
119 |
|
|
120 |
<el-col :span="12"> |
|
121 |
<el-form-item prop="className"> |
|
122 |
<template #label> |
|
123 |
<span> |
|
124 |
类名称 |
|
125 |
<el-tooltip |
|
126 |
content="类名称(首字母大写),例如SysUser、SysMenu、SysDictData 等等" |
|
127 |
placement="top" |
|
128 |
> |
|
129 |
<Icon icon="ep:question-filled" /> |
|
130 |
</el-tooltip> |
|
131 |
</span> |
|
132 |
</template> |
|
133 |
<el-input v-model="formData.className" /> |
|
134 |
</el-form-item> |
|
135 |
</el-col> |
|
136 |
|
|
137 |
<el-col :span="12"> |
|
138 |
<el-form-item prop="classComment"> |
|
139 |
<template #label> |
|
140 |
<span> |
|
141 |
类描述 |
|
142 |
<el-tooltip content="用作类描述,例如 用户" placement="top"> |
|
143 |
<Icon icon="ep:question-filled" /> |
|
144 |
</el-tooltip> |
|
145 |
</span> |
|
146 |
</template> |
|
147 |
<el-input v-model="formData.classComment" /> |
|
148 |
</el-form-item> |
|
149 |
</el-col> |
|
150 |
|
|
151 |
<el-col v-if="formData.genType === '1'" :span="24"> |
|
152 |
<el-form-item prop="genPath"> |
|
153 |
<template #label> |
|
154 |
<span> |
|
155 |
自定义路径 |
|
156 |
<el-tooltip |
|
157 |
content="填写磁盘绝对路径,若不填写,则生成到当前Web项目下" |
|
158 |
placement="top" |
|
159 |
> |
|
160 |
<Icon icon="ep:question-filled" /> |
|
161 |
</el-tooltip> |
|
162 |
</span> |
|
163 |
</template> |
|
164 |
<el-input v-model="formData.genPath"> |
|
165 |
<template #append> |
|
166 |
<el-dropdown> |
|
167 |
<el-button type="primary"> |
|
168 |
最近路径快速选择 |
|
169 |
<i class="el-icon-arrow-down el-icon--right"></i> |
|
170 |
</el-button> |
|
171 |
<template #dropdown> |
|
172 |
<el-dropdown-menu> |
|
173 |
<el-dropdown-item @click="formData.genPath = '/'"> |
|
174 |
恢复默认的生成基础路径 |
|
175 |
</el-dropdown-item> |
|
176 |
</el-dropdown-menu> |
|
177 |
</template> |
|
178 |
</el-dropdown> |
|
179 |
</template> |
|
180 |
</el-input> |
|
181 |
</el-form-item> |
|
182 |
</el-col> |
|
183 |
</el-row> |
|
184 |
|
|
185 |
<!-- 树表信息 --> |
|
186 |
<el-row v-if="formData.templateType == 2"> |
|
187 |
<el-col :span="24"> |
|
188 |
<h4 class="form-header">树表信息</h4> |
|
189 |
</el-col> |
|
190 |
<el-col :span="12"> |
|
191 |
<el-form-item prop="treeParentColumnId"> |
|
192 |
<template #label> |
|
193 |
<span> |
|
194 |
父编号字段 |
|
195 |
<el-tooltip content="树显示的父编码字段名, 如:parent_Id" placement="top"> |
|
196 |
<Icon icon="ep:question-filled" /> |
|
197 |
</el-tooltip> |
|
198 |
</span> |
|
199 |
</template> |
|
200 |
<el-select v-model="formData.treeParentColumnId" placeholder="请选择"> |
|
201 |
<el-option |
|
202 |
v-for="(column, index) in props.columns" |
|
203 |
:key="index" |
|
204 |
:label="column.columnName + ':' + column.columnComment" |
|
205 |
:value="column.id" |
|
206 |
/> |
|
207 |
</el-select> |
|
208 |
</el-form-item> |
|
209 |
</el-col> |
|
210 |
<el-col :span="12"> |
|
211 |
<el-form-item prop="treeNameColumnId"> |
|
212 |
<template #label> |
|
213 |
<span> |
|
214 |
树名称字段 |
|
215 |
<el-tooltip content="树节点的显示名称字段名, 如:dept_name" placement="top"> |
|
216 |
<Icon icon="ep:question-filled" /> |
|
217 |
</el-tooltip> |
|
218 |
</span> |
|
219 |
</template> |
|
220 |
<el-select v-model="formData.treeNameColumnId" placeholder="请选择"> |
|
221 |
<el-option |
|
222 |
v-for="(column, index) in props.columns" |
|
223 |
:key="index" |
|
224 |
:label="column.columnName + ':' + column.columnComment" |
|
225 |
:value="column.id" |
|
226 |
/> |
|
227 |
</el-select> |
|
228 |
</el-form-item> |
|
229 |
</el-col> |
|
230 |
</el-row> |
|
231 |
|
|
232 |
<!-- 主表信息 --> |
|
233 |
<el-row v-if="formData.templateType == 15"> |
|
234 |
<el-col :span="24"> |
|
235 |
<h4 class="form-header">主表信息</h4> |
|
236 |
</el-col> |
|
237 |
<el-col :span="12"> |
|
238 |
<el-form-item prop="masterTableId"> |
|
239 |
<template #label> |
|
240 |
<span> |
|
241 |
关联的主表 |
|
242 |
<el-tooltip content="关联主表(父表)的表名, 如:system_user" placement="top"> |
|
243 |
<Icon icon="ep:question-filled" /> |
|
244 |
</el-tooltip> |
|
245 |
</span> |
|
246 |
</template> |
|
247 |
<el-select v-model="formData.masterTableId" placeholder="请选择"> |
|
248 |
<el-option |
|
249 |
v-for="(table0, index) in tables" |
|
250 |
:key="index" |
|
251 |
:label="table0.tableName + ':' + table0.tableComment" |
|
252 |
:value="table0.id" |
|
253 |
/> |
|
254 |
</el-select> |
|
255 |
</el-form-item> |
|
256 |
</el-col> |
|
257 |
<el-col :span="12"> |
|
258 |
<el-form-item prop="subJoinColumnId"> |
|
259 |
<template #label> |
|
260 |
<span> |
|
261 |
子表关联的字段 |
|
262 |
<el-tooltip content="子表关联的字段, 如:user_id" placement="top"> |
|
263 |
<Icon icon="ep:question-filled" /> |
|
264 |
</el-tooltip> |
|
265 |
</span> |
|
266 |
</template> |
|
267 |
<el-select v-model="formData.subJoinColumnId" placeholder="请选择"> |
|
268 |
<el-option |
|
269 |
v-for="(column, index) in props.columns" |
|
270 |
:key="index" |
|
271 |
:label="column.columnName + ':' + column.columnComment" |
|
272 |
:value="column.id" |
|
273 |
/> |
|
274 |
</el-select> |
|
275 |
</el-form-item> |
|
276 |
</el-col> |
|
277 |
<el-col :span="12"> |
|
278 |
<el-form-item prop="subJoinMany"> |
|
279 |
<template #label> |
|
280 |
<span> |
|
281 |
关联关系 |
|
282 |
<el-tooltip content="主表与子表的关联关系" placement="top"> |
|
283 |
<Icon icon="ep:question-filled" /> |
|
284 |
</el-tooltip> |
|
285 |
</span> |
|
286 |
</template> |
|
287 |
<el-radio-group v-model="formData.subJoinMany" placeholder="请选择"> |
|
288 |
<el-radio :label="true">一对多</el-radio> |
|
289 |
<el-radio :label="false">一对一</el-radio> |
|
290 |
</el-radio-group> |
|
291 |
</el-form-item> |
|
292 |
</el-col> |
|
293 |
</el-row> |
|
294 |
</el-form> |
|
295 |
</template> |
|
296 |
<script lang="ts" setup> |
|
297 |
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
|
298 |
import { handleTree } from '@/utils/tree' |
|
299 |
import * as CodegenApi from '@/api/infra/codegen' |
|
300 |
import * as MenuApi from '@/api/system/menu' |
|
301 |
import { PropType } from 'vue' |
|
302 |
|
|
303 |
defineOptions({ name: 'InfraCodegenGenerateInfoForm' }) |
|
304 |
|
|
305 |
const message = useMessage() // 消息弹窗 |
|
306 |
const props = defineProps({ |
|
307 |
table: { |
|
308 |
type: Object as PropType<Nullable<CodegenApi.CodegenTableVO>>, |
|
309 |
default: () => null |
|
310 |
}, |
|
311 |
columns: { |
|
312 |
type: Array as unknown as PropType<CodegenApi.CodegenColumnVO[]>, |
|
313 |
default: () => null |
|
314 |
} |
|
315 |
}) |
|
316 |
|
|
317 |
const formRef = ref() |
|
318 |
const formData = ref({ |
|
319 |
templateType: null, |
|
320 |
frontType: null, |
|
321 |
scene: null, |
|
322 |
moduleName: '', |
|
323 |
businessName: '', |
|
324 |
className: '', |
|
325 |
classComment: '', |
|
326 |
parentMenuId: null, |
|
327 |
genPath: '', |
|
328 |
genType: '', |
|
329 |
masterTableId: undefined, |
|
330 |
subJoinColumnId: undefined, |
|
331 |
subJoinMany: undefined, |
|
332 |
treeParentColumnId: undefined, |
|
333 |
treeNameColumnId: undefined |
|
334 |
}) |
|
335 |
|
|
336 |
const rules = reactive({ |
|
337 |
templateType: [required], |
|
338 |
frontType: [required], |
|
339 |
scene: [required], |
|
340 |
moduleName: [required], |
|
341 |
businessName: [required], |
|
342 |
businessPackage: [required], |
|
343 |
className: [required], |
|
344 |
classComment: [required], |
|
345 |
masterTableId: [required], |
|
346 |
subJoinColumnId: [required], |
|
347 |
subJoinMany: [required], |
|
348 |
treeParentColumnId: [required], |
|
349 |
treeNameColumnId: [required] |
|
350 |
}) |
|
351 |
|
|
352 |
const tables = ref([]) // 表定义列表 |
|
353 |
const menus = ref<any[]>([]) |
|
354 |
const menuTreeProps = { |
|
355 |
label: 'name' |
|
356 |
} |
|
357 |
|
|
358 |
watch( |
|
359 |
() => props.table, |
|
360 |
async (table) => { |
|
361 |
if (!table) return |
|
362 |
formData.value = table as any |
|
363 |
// 加载表列表 |
|
364 |
if (table.dataSourceConfigId >= 0) { |
|
365 |
tables.value = await CodegenApi.getCodegenTableList(formData.value.dataSourceConfigId) |
|
366 |
} |
|
367 |
}, |
|
368 |
{ |
|
369 |
deep: true, |
|
370 |
immediate: true |
|
371 |
} |
|
372 |
) |
|
373 |
|
|
374 |
onMounted(async () => { |
|
375 |
try { |
|
376 |
// 加载菜单 |
|
377 |
const resp = await MenuApi.getSimpleMenusList() |
|
378 |
menus.value = handleTree(resp) |
|
379 |
} catch {} |
|
380 |
}) |
|
381 |
|
|
382 |
defineExpose({ |
|
383 |
validate: async () => unref(formRef)?.validate() |
|
384 |
}) |
|
385 |
</script> |