Commit 47f3c560fad2b8f98dea8784445592cf51cde565
1 parent
ddc42c2a
feat: vue3 codegen
Showing
8 changed files
with
215 additions
and
269 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java
| ... | ... | @@ -91,8 +91,6 @@ public class CodegenEngine { |
| 91 | 91 | vue3FilePath("views/${table.moduleName}/${classNameVar}/${classNameVar}.data.ts")) |
| 92 | 92 | .put(vue3TemplatePath("api/api.ts"), |
| 93 | 93 | vue3FilePath("api/${table.moduleName}/${classNameVar}/index.ts")) |
| 94 | - .put(vue3TemplatePath("api/types.ts"), | |
| 95 | - vue3FilePath("api/${table.moduleName}/${classNameVar}/types.ts")) | |
| 96 | 94 | // SQL |
| 97 | 95 | .put("codegen/sql/sql.vm", "sql/sql.sql") |
| 98 | 96 | .put("codegen/sql/h2.vm", "sql/h2.sql") | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm
| 1 | 1 | import request from '@/config/axios' |
| 2 | -import { ${simpleClassName}VO, ${simpleClassName}PageReqVO, ${simpleClassName}ExcelReqVO } from './types' | |
| 3 | 2 | |
| 3 | +export interface ${simpleClassName}VO { | |
| 4 | +#foreach ($column in $columns) | |
| 5 | +#if ($column.createOperation || $column.updateOperation) | |
| 6 | +#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer") | |
| 7 | + ${column.javaField}?: number | |
| 8 | +#elseif(${column.javaType.toLowerCase()} == "date") | |
| 9 | + ${column.javaField}?: string | |
| 10 | +#else | |
| 11 | + ${column.javaField}?: ${column.javaType.toLowerCase()} | |
| 12 | +#end | |
| 13 | +#end | |
| 14 | +#end | |
| 15 | +} | |
| 16 | + | |
| 17 | +export interface ${simpleClassName}PageReqVO extends PageParam { | |
| 18 | +#foreach ($column in $columns) | |
| 19 | +#if (${column.listOperation})##查询操作 | |
| 20 | +#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer") | |
| 21 | + ${column.javaField}?: number | |
| 22 | +#elseif(${column.javaType.toLowerCase()} == "date") | |
| 23 | + ${column.javaField}?: string | |
| 24 | +#else | |
| 25 | + ${column.javaField}?: ${column.javaType.toLowerCase()} | |
| 26 | +#end | |
| 27 | +#end | |
| 28 | +#end | |
| 29 | +} | |
| 30 | + | |
| 31 | +export interface ${simpleClassName}ExcelReqVO { | |
| 32 | + #foreach ($column in $columns) | |
| 33 | + #if (${column.listOperation})##查询操作 | |
| 34 | + #if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer") | |
| 35 | + ${column.javaField}: number | |
| 36 | + #elseif(${column.javaType.toLowerCase()} == "date") | |
| 37 | + ${column.javaField}: string | |
| 38 | + #else | |
| 39 | + ${column.javaField}: ${column.javaType.toLowerCase()} | |
| 40 | + #end | |
| 41 | + #end | |
| 42 | + #end | |
| 43 | +} | |
| 4 | 44 | #set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}") |
| 45 | + | |
| 5 | 46 | // 查询${table.classComment}列表 |
| 6 | 47 | export const get${simpleClassName}PageApi = async (params: ${simpleClassName}PageReqVO) => { |
| 7 | 48 | return await request.get({ url: '${baseURL}/page', params }) | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/api/types.ts.vm deleted
| 1 | -export type ${simpleClassName}VO = { | |
| 2 | -#foreach ($column in $columns) | |
| 3 | -#if ($column.createOperation || $column.updateOperation) | |
| 4 | -#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer") | |
| 5 | - ${column.javaField}: number | |
| 6 | -#elseif(${column.javaType.toLowerCase()} == "date") | |
| 7 | - ${column.javaField}: string | |
| 8 | -#else | |
| 9 | - ${column.javaField}: ${column.javaType.toLowerCase()} | |
| 10 | -#end | |
| 11 | -#end | |
| 12 | -#end | |
| 13 | -} | |
| 14 | - | |
| 15 | -export type ${simpleClassName}PageReqVO = { | |
| 16 | -#foreach ($column in $columns) | |
| 17 | -#if (${column.listOperation})##查询操作 | |
| 18 | -#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer") | |
| 19 | - ${column.javaField}: number | |
| 20 | -#elseif(${column.javaType.toLowerCase()} == "date") | |
| 21 | - ${column.javaField}: string | |
| 22 | -#else | |
| 23 | - ${column.javaField}: ${column.javaType.toLowerCase()} | |
| 24 | -#end | |
| 25 | -#end | |
| 26 | -#end | |
| 27 | -} | |
| 28 | - | |
| 29 | -export type ${simpleClassName}ExcelReqVO = { | |
| 30 | -#foreach ($column in $columns) | |
| 31 | -#if (${column.listOperation})##查询操作 | |
| 32 | -#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer") | |
| 33 | - ${column.javaField}: number | |
| 34 | -#elseif(${column.javaType.toLowerCase()} == "date") | |
| 35 | - ${column.javaField}: string | |
| 36 | -#else | |
| 37 | - ${column.javaField}: ${column.javaType.toLowerCase()} | |
| 38 | -#end | |
| 39 | -#end | |
| 40 | -#end | |
| 41 | -} | |
| 42 | 0 | \ No newline at end of file |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/data.ts.vm
| 1 | 1 | import { reactive } from 'vue' |
| 2 | 2 | import { useI18n } from '@/hooks/web/useI18n' |
| 3 | -import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' | |
| 4 | 3 | import { DICT_TYPE } from '@/utils/dict' |
| 4 | +import { required } from '@/utils/formRules' | |
| 5 | +import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas' | |
| 5 | 6 | const { t } = useI18n() // 国际化 |
| 6 | 7 | // 表单校验 |
| 7 | 8 | export const rules = reactive({ |
| 8 | 9 | #foreach ($column in $columns) |
| 9 | 10 | #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 |
| 10 | 11 | #set($comment=$column.columnComment) |
| 11 | - $column.javaField: [{ required: true, message: '${comment}不能为空', trigger: #if($column.htmlType == "select")'change'#else'blur'#end }], | |
| 12 | + $column.javaField: [required], | |
| 12 | 13 | #end |
| 13 | 14 | #end |
| 14 | 15 | }) |
| 15 | 16 | // CrudSchema |
| 16 | -const crudSchemas = reactive<CrudSchema[]>([ | |
| 17 | +const crudSchemas = reactive<VxeCrudSchema>({ | |
| 18 | + primaryKey: 'id', // 默认的主键ID | |
| 19 | + primaryTitle: t('common.index'), // 默认显示的值 | |
| 20 | + primaryType: 'seq', // 默认为seq,序号模式 | |
| 21 | + action: true, | |
| 22 | + actionWidth: '200', // 3个按钮默认200,如有删减对应增减即可 | |
| 23 | + columns: [ | |
| 17 | 24 | #foreach($column in $columns) |
| 18 | 25 | #if ($column.listOperation || $column.listOperationResult || $column.createOperation || $column.updateOperation) |
| 19 | 26 | #set ($dictType = $column.dictType) |
| 27 | + #if(!$column.primaryKey) | |
| 20 | 28 | { |
| 21 | - label: '${column.columnComment}', | |
| 29 | + title: '${column.columnComment}', | |
| 22 | 30 | field: '${column.javaField}', |
| 23 | 31 | #if ("" != $dictType)## 有数据字典 |
| 24 | 32 | dictType: DICT_TYPE.$dictType.toUpperCase(), |
| 25 | 33 | #end |
| 26 | - #if($column.primaryKey) | |
| 27 | - type: 'index', | |
| 28 | - form: { | |
| 29 | - show: false | |
| 30 | - }, | |
| 31 | - detail: { | |
| 32 | - show: false | |
| 33 | - } | |
| 34 | - #else | |
| 35 | 34 | #if (!$column.createOperation && !$column.updateOperation) |
| 36 | - form: { | |
| 37 | - show: false | |
| 38 | - }, | |
| 35 | + isForm: false | |
| 39 | 36 | #elseif(!("" != $column.dictType)) |
| 37 | + #if ($column.htmlType == "datetime")## 时间框 | |
| 40 | 38 | form: { |
| 41 | 39 | show: true, |
| 42 | - #if ($column.htmlType == "datetime")## 时间框 | |
| 43 | 40 | component: 'DatePicker', |
| 44 | 41 | componentProps: { |
| 45 | 42 | type: 'datetime', |
| 46 | 43 | valueFormat: 'YYYY-MM-DD HH:mm:ss' |
| 47 | 44 | } |
| 48 | - #elseif($column.htmlType == "editor")## 文本编辑器 | |
| 45 | + } | |
| 46 | + #elseif($column.htmlType == "editor")## 文本编辑器 | |
| 47 | + form: { | |
| 48 | + show: true, | |
| 49 | 49 | component: 'Editor', |
| 50 | 50 | colProps: { |
| 51 | 51 | span: 24 |
| ... | ... | @@ -53,7 +53,10 @@ const crudSchemas = reactive<CrudSchema[]>([ |
| 53 | 53 | componentProps: { |
| 54 | 54 | valueHtml: '' |
| 55 | 55 | } |
| 56 | - #elseif($column.htmlType == "textarea")## 文本框 | |
| 56 | + } | |
| 57 | + #elseif($column.htmlType == "textarea")## 文本框 | |
| 58 | + form: { | |
| 59 | + show: true, | |
| 57 | 60 | component: 'Input', |
| 58 | 61 | componentProps: { |
| 59 | 62 | type: 'textarea', |
| ... | ... | @@ -62,50 +65,27 @@ const crudSchemas = reactive<CrudSchema[]>([ |
| 62 | 65 | colProps: { |
| 63 | 66 | span: 24 |
| 64 | 67 | } |
| 65 | - #end | |
| 66 | - }, | |
| 68 | + } | |
| 69 | + #end | |
| 67 | 70 | #end |
| 68 | 71 | #if ($column.listOperationResult) |
| 72 | + #if($column.htmlType == "input") | |
| 73 | + isSearch: true | |
| 74 | + #elseif("" != $dictType) | |
| 75 | + isSearch: true | |
| 76 | + #elseif($column.htmlType == "datetime") | |
| 69 | 77 | search: { |
| 70 | - #if($column.htmlType == "input") | |
| 71 | - show: true | |
| 72 | - #else | |
| 73 | - #if($column.htmlType == "datetime") | |
| 74 | 78 | show: true, |
| 75 | - component: 'DatePicker', | |
| 76 | - componentProps: { | |
| 77 | - type: 'datetimerange', | |
| 78 | - valueFormat: 'YYYY-MM-DD HH:mm:ss' | |
| 79 | - } | |
| 80 | - #elseif($column.htmlType == "select" || $column.htmlType == "radio") | |
| 81 | - #if ("" == $dictType)## 没有数据字典 | |
| 82 | - show: true, | |
| 83 | - component: 'Select', | |
| 84 | - componentProps: { | |
| 85 | - option: [{'','请选择字典生成'}] | |
| 79 | + itemRender: { | |
| 80 | + name: 'XDataTimePicker' | |
| 86 | 81 | } |
| 87 | - #else | |
| 88 | - show: true | |
| 89 | - #end | |
| 90 | - #end | |
| 91 | - #end | |
| 92 | 82 | } |
| 93 | 83 | #end |
| 94 | 84 | #end |
| 85 | + #end | |
| 95 | 86 | }, |
| 96 | 87 | #end |
| 97 | 88 | #end |
| 98 | - { | |
| 99 | - label: t('table.action'), | |
| 100 | - field: 'action', | |
| 101 | - width: '240px', | |
| 102 | - form: { | |
| 103 | - show: false | |
| 104 | - }, | |
| 105 | - detail: { | |
| 106 | - show: false | |
| 107 | - } | |
| 108 | - } | |
| 109 | -]) | |
| 110 | - | |
| 111 | -export const { allSchemas } = useCrudSchemas(crudSchemas) | |
| 112 | 89 | \ No newline at end of file |
| 90 | + ] | |
| 91 | +}) | |
| 92 | +export const { allSchemas } = useVxeCrudSchemas(crudSchemas) | |
| 113 | 93 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm
| 1 | +<template> | |
| 2 | + <ContentWrap> | |
| 3 | + <!-- 列表 --> | |
| 4 | + <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar"> | |
| 5 | + <template #toolbar_buttons> | |
| 6 | + <!-- 操作:新增 --> | |
| 7 | + <XButton | |
| 8 | + type="primary" | |
| 9 | + preIcon="ep:zoom-in" | |
| 10 | + :title="t('action.add')" | |
| 11 | + v-hasPermi="['${permissionPrefix}:create']" | |
| 12 | + @click="handleCreate()" | |
| 13 | + /> | |
| 14 | + <!-- 操作:导出 --> | |
| 15 | + <XButton | |
| 16 | + type="warning" | |
| 17 | + preIcon="ep:download" | |
| 18 | + :title="t('action.export')" | |
| 19 | + v-hasPermi="['${permissionPrefix}:export']" | |
| 20 | + @click="handleExport()" | |
| 21 | + /> | |
| 22 | + </template> | |
| 23 | + <template #actionbtns_default="{ row }"> | |
| 24 | + <!-- 操作:修改 --> | |
| 25 | + <XTextButton | |
| 26 | + preIcon="ep:edit" | |
| 27 | + :title="t('action.edit')" | |
| 28 | + v-hasPermi="['${permissionPrefix}:update']" | |
| 29 | + @click="handleUpdate(row.id)" | |
| 30 | + /> | |
| 31 | + <!-- 操作:详情 --> | |
| 32 | + <XTextButton | |
| 33 | + preIcon="ep:view" | |
| 34 | + :title="t('action.detail')" | |
| 35 | + v-hasPermi="['${permissionPrefix}:query']" | |
| 36 | + @click="handleDetail(row.id)" | |
| 37 | + /> | |
| 38 | + <!-- 操作:删除 --> | |
| 39 | + <XTextButton | |
| 40 | + preIcon="ep:delete" | |
| 41 | + :title="t('action.del')" | |
| 42 | + v-hasPermi="['${permissionPrefix}:delete']" | |
| 43 | + @click="handleDelete(row.id)" | |
| 44 | + /> | |
| 45 | + </template> | |
| 46 | + </vxe-grid> | |
| 47 | + </ContentWrap> | |
| 48 | + <!-- 弹窗 --> | |
| 49 | + <XModal id="${classNameVar}Model" :loading="modelLoading" v-model="modelVisible" :title="modelTitle"> | |
| 50 | + <!-- 表单:添加/修改 --> | |
| 51 | + <Form | |
| 52 | + ref="formRef" | |
| 53 | + v-if="['create', 'update'].includes(actionType)" | |
| 54 | + :schema="allSchemas.formSchema" | |
| 55 | + :rules="rules" | |
| 56 | + /> | |
| 57 | + <!-- 表单:详情 --> | |
| 58 | + <Descriptions | |
| 59 | + v-if="actionType === 'detail'" | |
| 60 | + :schema="allSchemas.detailSchema" | |
| 61 | + :data="detailData" | |
| 62 | + /> | |
| 63 | + <template #footer> | |
| 64 | + <!-- 按钮:保存 --> | |
| 65 | + <XButton | |
| 66 | + v-if="['create', 'update'].includes(actionType)" | |
| 67 | + type="primary" | |
| 68 | + :title="t('action.save')" | |
| 69 | + :loading="actionLoading" | |
| 70 | + @click="submitForm()" | |
| 71 | + /> | |
| 72 | + <!-- 按钮:关闭 --> | |
| 73 | + <XButton :loading="actionLoading" :title="t('dialog.close')" @click="modelVisible = false" /> | |
| 74 | + </template> | |
| 75 | + </XModal> | |
| 76 | +</template> | |
| 1 | 77 | <script setup lang="ts"> |
| 78 | +// 全局相关的 import | |
| 2 | 79 | import { ref, unref } from 'vue' |
| 3 | -import dayjs from 'dayjs' | |
| 4 | -import { ElMessage } from 'element-plus' | |
| 5 | -import { DICT_TYPE } from '@/utils/dict' | |
| 6 | -import { useTable } from '@/hooks/web/useTable' | |
| 7 | 80 | import { useI18n } from '@/hooks/web/useI18n' |
| 81 | +import { useMessage } from '@/hooks/web/useMessage' | |
| 82 | +import { useVxeGrid } from '@/hooks/web/useVxeGrid' | |
| 83 | +import { VxeGridInstance } from 'vxe-table' | |
| 8 | 84 | import { FormExpose } from '@/components/Form' |
| 9 | -import type { ${simpleClassName}VO } from '@/api/${table.moduleName}/${classNameVar}/types' | |
| 85 | +// 业务相关的 import | |
| 10 | 86 | import { rules, allSchemas } from './${classNameVar}.data' |
| 11 | 87 | import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}' |
| 88 | + | |
| 12 | 89 | const { t } = useI18n() // 国际化 |
| 90 | +const message = useMessage() // 消息弹窗 | |
| 13 | 91 | |
| 14 | -// ========== 列表相关 ========== | |
| 15 | -const { register, tableObject, methods } = useTable<${simpleClassName}VO>({ | |
| 92 | +// 列表相关的变量 | |
| 93 | +const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref | |
| 94 | +const { gridOptions, reloadList, deleteData, exportList } = useVxeGrid<${simpleClassName}Api.${simpleClassName}VO>({ | |
| 95 | + allSchemas: allSchemas, | |
| 16 | 96 | getListApi: ${simpleClassName}Api.get${simpleClassName}PageApi, |
| 17 | - delListApi: ${simpleClassName}Api.delete${simpleClassName}Api, | |
| 97 | + deleteApi: ${simpleClassName}Api.delete${simpleClassName}Api, | |
| 18 | 98 | exportListApi: ${simpleClassName}Api.export${simpleClassName}Api |
| 19 | 99 | }) |
| 20 | -const { getList, setSearchParams, delList, exportList } = methods | |
| 21 | 100 | |
| 22 | -// ========== CRUD 相关 ========== | |
| 23 | -const actionLoading = ref(false) // 遮罩层 | |
| 101 | +// 弹窗相关的变量 | |
| 102 | +const modelVisible = ref(false) // 是否显示弹出层 | |
| 103 | +const modelTitle = ref('edit') // 弹出层标题 | |
| 104 | +const modelLoading = ref(false) // 弹出层loading | |
| 24 | 105 | const actionType = ref('') // 操作按钮的类型 |
| 25 | -const dialogVisible = ref(false) // 是否显示弹出层 | |
| 26 | -const dialogTitle = ref('edit') // 弹出层标题 | |
| 106 | +const actionLoading = ref(false) // 按钮 Loading | |
| 27 | 107 | const formRef = ref<FormExpose>() // 表单 Ref |
| 108 | +const detailData = ref() // 详情 Ref | |
| 28 | 109 | |
| 29 | 110 | // 设置标题 |
| 30 | 111 | const setDialogTile = (type: string) => { |
| 31 | - dialogTitle.value = t('action.' + type) | |
| 112 | + modelLoading.value = true | |
| 113 | + modelTitle.value = t('action.' + type) | |
| 32 | 114 | actionType.value = type |
| 33 | - dialogVisible.value = true | |
| 115 | + modelVisible.value = true | |
| 34 | 116 | } |
| 35 | 117 | |
| 36 | 118 | // 新增操作 |
| 37 | 119 | const handleCreate = () => { |
| 38 | 120 | setDialogTile('create') |
| 39 | - // 重置表单 | |
| 40 | - unref(formRef)?.getElFormRef()?.resetFields() | |
| 121 | + modelLoading.value = false | |
| 122 | +} | |
| 123 | + | |
| 124 | +// 导出操作 | |
| 125 | +const handleExport = async () => { | |
| 126 | + await exportList(xGrid, '导出.xls') | |
| 41 | 127 | } |
| 42 | 128 | |
| 43 | 129 | // 修改操作 |
| 44 | -const handleUpdate = async (row: ${simpleClassName}VO) => { | |
| 130 | +const handleUpdate = async (rowId: number) => { | |
| 45 | 131 | setDialogTile('update') |
| 46 | 132 | // 设置数据 |
| 47 | - const res = await ${simpleClassName}Api.get${simpleClassName}Api(row.id) | |
| 133 | + const res = await ${simpleClassName}Api.get${simpleClassName}Api(rowId) | |
| 48 | 134 | unref(formRef)?.setValues(res) |
| 135 | + modelLoading.value = false | |
| 136 | +} | |
| 137 | + | |
| 138 | +// 详情操作 | |
| 139 | +const handleDetail = async (rowId: number) => { | |
| 140 | + setDialogTile('detail') | |
| 141 | + const res = await ${simpleClassName}Api.get${simpleClassName}Api(rowId) | |
| 142 | + detailData.value = res | |
| 143 | + modelLoading.value = false | |
| 144 | +} | |
| 145 | + | |
| 146 | +// 删除操作 | |
| 147 | +const handleDelete = async (rowId: number) => { | |
| 148 | + await deleteData(xGrid, rowId) | |
| 49 | 149 | } |
| 50 | 150 | |
| 51 | 151 | // 提交按钮 |
| ... | ... | @@ -57,156 +157,23 @@ const submitForm = async () => { |
| 57 | 157 | actionLoading.value = true |
| 58 | 158 | // 提交请求 |
| 59 | 159 | try { |
| 60 | - const data = unref(formRef)?.formModel as ${simpleClassName}VO | |
| 160 | + const data = unref(formRef)?.formModel as ${simpleClassName}Api.${simpleClassName}VO | |
| 61 | 161 | if (actionType.value === 'create') { |
| 62 | 162 | await ${simpleClassName}Api.create${simpleClassName}Api(data) |
| 63 | - ElMessage.success(t('common.createSuccess')) | |
| 163 | + message.success(t('common.createSuccess')) | |
| 64 | 164 | } else { |
| 65 | 165 | await ${simpleClassName}Api.update${simpleClassName}Api(data) |
| 66 | - ElMessage.success(t('common.updateSuccess')) | |
| 166 | + message.success(t('common.updateSuccess')) | |
| 67 | 167 | } |
| 68 | - // 操作成功,重新加载列表 | |
| 69 | 168 | dialogVisible.value = false |
| 70 | - await getList() | |
| 71 | 169 | } finally { |
| 72 | 170 | actionLoading.value = false |
| 171 | + // 刷新列表 | |
| 172 | + await reloadList(xGrid) | |
| 73 | 173 | } |
| 74 | 174 | } |
| 75 | 175 | }) |
| 76 | 176 | } |
| 77 | 177 | |
| 78 | -// ========== 详情相关 ========== | |
| 79 | -const detailRef = ref() // 详情 Ref | |
| 80 | - | |
| 81 | -// 详情操作 | |
| 82 | -const handleDetail = async (row: ${simpleClassName}VO) => { | |
| 83 | - // 设置数据 | |
| 84 | - detailRef.value = row | |
| 85 | - setDialogTile('detail') | |
| 86 | -} | |
| 87 | - | |
| 88 | -// ========== 初始化 ========== | |
| 89 | -getList() | |
| 90 | 178 | </script> |
| 91 | 179 | |
| 92 | -<template> | |
| 93 | - <!-- 搜索工作区 --> | |
| 94 | - <ContentWrap> | |
| 95 | - <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" /> | |
| 96 | - </ContentWrap> | |
| 97 | - <ContentWrap> | |
| 98 | - <!-- 操作工具栏 --> | |
| 99 | - <div class="mb-10px"> | |
| 100 | - <XButton | |
| 101 | - type="primary" | |
| 102 | - preIcon="ep:zoom-in" | |
| 103 | - :title="t('action.add')" | |
| 104 | - v-hasPermi="['${permissionPrefix}:create']" | |
| 105 | - @click="handleCreate()" | |
| 106 | - /> | |
| 107 | - <XButton | |
| 108 | - type="warning" | |
| 109 | - preIcon="ep:download" | |
| 110 | - :title="t('action.export')" | |
| 111 | - v-hasPermi="['${permissionPrefix}:export']" | |
| 112 | - @click="exportList('数据.xls')" | |
| 113 | - /> | |
| 114 | - </div> | |
| 115 | - <!-- 列表 --> | |
| 116 | - <Table | |
| 117 | - :columns="allSchemas.tableColumns" | |
| 118 | - :selection="false" | |
| 119 | - :data="tableObject.tableList" | |
| 120 | - :loading="tableObject.loading" | |
| 121 | - :pagination="{ | |
| 122 | - total: tableObject.total | |
| 123 | - }" | |
| 124 | - v-model:pageSize="tableObject.pageSize" | |
| 125 | - v-model:currentPage="tableObject.currentPage" | |
| 126 | - @register="register" | |
| 127 | - > | |
| 128 | -#foreach($column in $columns) | |
| 129 | -#if ($column.listOperationResult) | |
| 130 | - #set ($dictType=$column.dictType) | |
| 131 | - #if ($column.javaType == "LocalDateTime")## 时间类型 | |
| 132 | - <template #${column.javaField}="{ row }"> | |
| 133 | - <span>{{ dayjs(row.${column.javaField}).format('YYYY-MM-DD HH:mm:ss') }}</span> | |
| 134 | - </template> | |
| 135 | - #elseif("" != $column.dictType)## 数据字典 | |
| 136 | - <template #${column.javaField}="{ row }"> | |
| 137 | - <DictTag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${column.javaField}" /> | |
| 138 | - </template> | |
| 139 | - #end | |
| 140 | -#end | |
| 141 | -#end | |
| 142 | - <template #action="{ row }"> | |
| 143 | - <XButton | |
| 144 | - link | |
| 145 | - type="primary" | |
| 146 | - preIcon="ep:edit" | |
| 147 | - :title="t('action.edit')" | |
| 148 | - v-hasPermi="['${permissionPrefix}:update']" | |
| 149 | - @click="handleUpdate(row.id)" | |
| 150 | - /> | |
| 151 | - <XButton | |
| 152 | - link | |
| 153 | - type="primary" | |
| 154 | - preIcon="ep:view" | |
| 155 | - :title="t('action.detail')" | |
| 156 | - v-hasPermi="['${permissionPrefix}:update']" | |
| 157 | - @click="handleDetail(row)" | |
| 158 | - /> | |
| 159 | - <XButton | |
| 160 | - link | |
| 161 | - type="primary" | |
| 162 | - preIcon="ep:delete" | |
| 163 | - :title="t('action.del')" | |
| 164 | - v-hasPermi="['${permissionPrefix}:delete']" | |
| 165 | - @click="handleDelete(row.id)" | |
| 166 | - /> | |
| 167 | - </template> | |
| 168 | - </Table> | |
| 169 | - </ContentWrap> | |
| 170 | - | |
| 171 | - <Dialog v-model="dialogVisible" :title="dialogTitle"> | |
| 172 | - <!-- 对话框(添加 / 修改) --> | |
| 173 | - <Form | |
| 174 | - v-if="['create', 'update'].includes(actionType)" | |
| 175 | - :schema="allSchemas.formSchema" | |
| 176 | - :rules="rules" | |
| 177 | - ref="formRef" | |
| 178 | - /> | |
| 179 | - <!-- 对话框(详情) --> | |
| 180 | - <Descriptions | |
| 181 | - v-if="actionType === 'detail'" | |
| 182 | - :schema="allSchemas.detailSchema" | |
| 183 | - :data="detailRef" | |
| 184 | - > | |
| 185 | -#foreach($column in $columns) | |
| 186 | - #if ($column.listOperationResult) | |
| 187 | - #set ($dictType=$column.dictType) | |
| 188 | - #if ($column.javaType == "LocalDateTime")## 时间类型 | |
| 189 | - <template #${column.javaField}="{ row }"> | |
| 190 | - <span>{{ dayjs(row.${column.javaField}).format('YYYY-MM-DD HH:mm:ss') }}</span> | |
| 191 | - </template> | |
| 192 | - #elseif("" != $column.dictType)## 数据字典 | |
| 193 | - <template #${column.javaField}="{ row }"> | |
| 194 | - <DictTag :type="DICT_TYPE.$dictType.toUpperCase()" :value="row.${column.javaField}" /> | |
| 195 | - </template> | |
| 196 | - #end | |
| 197 | - #end | |
| 198 | -#end | |
| 199 | - </Descriptions> | |
| 200 | - <!-- 操作按钮 --> | |
| 201 | - <template #footer> | |
| 202 | - <XButton | |
| 203 | - v-if="['create', 'update'].includes(actionType)" | |
| 204 | - :loading="actionLoading" | |
| 205 | - :title="t('action.save')" | |
| 206 | - type="primary" | |
| 207 | - @click="submitForm" | |
| 208 | - /> | |
| 209 | - <XButton :loading="actionLoading" :title="t('dialog.close')" @click="dialogVisible = false" /> | |
| 210 | - </template> | |
| 211 | - </Dialog> | |
| 212 | -</template> | ... | ... |
yudao-ui-admin-vue3/src/views/infra/codegen/components/Preview.vue
| ... | ... | @@ -117,15 +117,17 @@ defineExpose({ |
| 117 | 117 | <XModal title="预览" v-model="preview.open"> |
| 118 | 118 | <div class="flex"> |
| 119 | 119 | <el-card class="w-1/4" :gutter="12" shadow="hover"> |
| 120 | - <el-tree | |
| 121 | - ref="treeRef" | |
| 122 | - node-key="id" | |
| 123 | - :data="preview.fileTree" | |
| 124 | - :expand-on-click-node="false" | |
| 125 | - default-expand-all | |
| 126 | - highlight-current | |
| 127 | - @node-click="handleNodeClick" | |
| 128 | - /> | |
| 120 | + <el-scrollbar height="calc(100vh - 88px - 40px - 50px)"> | |
| 121 | + <el-tree | |
| 122 | + ref="treeRef" | |
| 123 | + node-key="id" | |
| 124 | + :data="preview.fileTree" | |
| 125 | + :expand-on-click-node="false" | |
| 126 | + default-expand-all | |
| 127 | + highlight-current | |
| 128 | + @node-click="handleNodeClick" | |
| 129 | + /> | |
| 130 | + </el-scrollbar> | |
| 129 | 131 | </el-card> |
| 130 | 132 | <el-card class="w-3/4" style="margin-left: 10px" :gutter="12" shadow="hover"> |
| 131 | 133 | <el-tabs v-model="preview.activeName"> | ... | ... |
yudao-ui-admin-vue3/src/views/system/post/index.vue
| 1 | 1 | <template> |
| 2 | 2 | <ContentWrap> |
| 3 | 3 | <!-- 列表 --> |
| 4 | - <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar" :class="isDark"> | |
| 4 | + <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar"> | |
| 5 | 5 | <template #toolbar_buttons> |
| 6 | 6 | <!-- 操作:新增 --> |
| 7 | 7 | <XButton |
| ... | ... | @@ -86,8 +86,6 @@ import { FormExpose } from '@/components/Form' |
| 86 | 86 | import * as PostApi from '@/api/system/post' |
| 87 | 87 | import { rules, allSchemas } from './post.data' |
| 88 | 88 | |
| 89 | -import { useDark } from '@vueuse/core' | |
| 90 | -const isDark = useDark() | |
| 91 | 89 | const { t } = useI18n() // 国际化 |
| 92 | 90 | const message = useMessage() // 消息弹窗 |
| 93 | 91 | // 列表相关的变量 |
| ... | ... | @@ -125,6 +123,7 @@ const handleCreate = () => { |
| 125 | 123 | const handleExport = async () => { |
| 126 | 124 | await exportList(xGrid, '岗位列表.xls') |
| 127 | 125 | } |
| 126 | + | |
| 128 | 127 | // 修改操作 |
| 129 | 128 | const handleUpdate = async (rowId: number) => { |
| 130 | 129 | setDialogTile('update') | ... | ... |