Commit e7be2a03bc9f57c554d6e2fc0c848858d77ca8ac
1 parent
0cfd2143
feat: vben5 codegen
Showing
14 changed files
with
331 additions
and
308 deletions
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/general/views/form.vue.vm
| 1 | 1 | <script lang="ts" setup> |
| 2 | -import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 3 | 2 | import type { Rule } from 'ant-design-vue/es/form'; |
| 3 | +import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 4 | + | |
| 5 | +import { computed, ref } from 'vue'; | |
| 4 | 6 | |
| 5 | 7 | import { useVbenModal } from '@vben/common-ui'; |
| 8 | +import { DICT_TYPE } from '@vben/constants'; | |
| 9 | +import { getDictOptions } from '@vben/hooks'; | |
| 6 | 10 | import { Tinymce as RichTextarea } from '#/components/tinymce'; |
| 7 | 11 | import { ImageUpload, FileUpload } from "#/components/upload"; |
| 8 | 12 | import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue'; |
| 9 | -import { DICT_TYPE, getDictOptions } from '#/utils'; | |
| 10 | 13 | #if($table.templateType == 2)## 树表需要导入这些 |
| 11 | 14 | import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; |
| 12 | 15 | import { handleTree } from '@vben/utils' |
| ... | ... | @@ -20,7 +23,6 @@ import { handleTree } from '@vben/utils' |
| 20 | 23 | #end |
| 21 | 24 | #end |
| 22 | 25 | |
| 23 | -import { computed, ref } from 'vue'; | |
| 24 | 26 | import { $t } from '#/locales'; |
| 25 | 27 | import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; |
| 26 | 28 | |
| ... | ... | @@ -70,7 +72,7 @@ const getTitle = computed(() => { |
| 70 | 72 | #end |
| 71 | 73 | |
| 72 | 74 | /** 重置表单 */ |
| 73 | -const resetForm = () => { | |
| 75 | +function resetForm() { | |
| 74 | 76 | formData.value = { |
| 75 | 77 | #foreach ($column in $columns) |
| 76 | 78 | #if ($column.createOperation || $column.updateOperation) |
| ... | ... | @@ -88,7 +90,7 @@ const resetForm = () => { |
| 88 | 90 | ## 特殊:树表专属逻辑 |
| 89 | 91 | #if ( $table.templateType == 2 ) |
| 90 | 92 | /** 获得${table.classComment}树 */ |
| 91 | -const get${simpleClassName}Tree = async () => { | |
| 93 | +async function get${simpleClassName}Tree() { | |
| 92 | 94 | ${classNameVar}Tree.value = [] |
| 93 | 95 | const data = await get${simpleClassName}List({}); |
| 94 | 96 | data.unshift({ |
| ... | ... | @@ -147,7 +149,6 @@ const [Modal, modalApi] = useVbenModal({ |
| 147 | 149 | emit('success'); |
| 148 | 150 | message.success({ |
| 149 | 151 | content: $t('ui.actionMessage.operationSuccess'), |
| 150 | - key: 'action_process_msg', | |
| 151 | 152 | }); |
| 152 | 153 | } finally { |
| 153 | 154 | modalApi.unlock(); | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/general/views/index.vue.vm
| 1 | 1 | <script lang="ts" setup> |
| 2 | 2 | import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; |
| 3 | -import type { VxeTableInstance } from '#/adapter/vxe-table'; | |
| 3 | + | |
| 4 | +import { ref, h, reactive, onMounted, nextTick } from 'vue'; | |
| 4 | 5 | |
| 5 | 6 | import { Page, useVbenModal } from '@vben/common-ui'; |
| 6 | -import { cloneDeep, formatDateTime } from '@vben/utils'; | |
| 7 | +import { DICT_TYPE } from '@vben/constants'; | |
| 8 | +import { getDictOptions } from '@vben/hooks'; | |
| 9 | +import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table'; | |
| 10 | +import { cloneDeep, downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; | |
| 7 | 11 | import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Input } from 'ant-design-vue'; |
| 8 | -import { DictTag } from '#/components/dict-tag'; | |
| 9 | -import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; | |
| 10 | 12 | import ${simpleClassName}Form from './modules/form.vue'; |
| 11 | 13 | import { Download, Plus, RefreshCw, Search, Trash2 } from '@vben/icons'; |
| 12 | 14 | import { ContentWrap } from '#/components/content-wrap'; |
| 13 | 15 | import { VxeColumn, VxeTable } from '#/adapter/vxe-table'; |
| 14 | -import { TableToolbar } from '#/components/table-toolbar'; | |
| 15 | -import { useTableToolbar } from '#/hooks'; | |
| 16 | 16 | |
| 17 | 17 | ## 特殊:主子表专属逻辑 |
| 18 | 18 | #if ( $table.templateType == 11 || $table.templateType == 12 ) |
| ... | ... | @@ -23,7 +23,6 @@ import { useTableToolbar } from '#/hooks'; |
| 23 | 23 | #end |
| 24 | 24 | #end |
| 25 | 25 | |
| 26 | -import { ref, h, reactive,onMounted,nextTick } from 'vue'; | |
| 27 | 26 | import { $t } from '#/locales'; |
| 28 | 27 | #if (${table.templateType} == 2)## 树表接口 |
| 29 | 28 | import { handleTree,isEmpty } from '@vben/utils' |
| ... | ... | @@ -77,7 +76,7 @@ const queryFormRef = ref() // 搜索的表单 |
| 77 | 76 | const exportLoading = ref(false) // 导出的加载中 |
| 78 | 77 | |
| 79 | 78 | /** 查询列表 */ |
| 80 | -const getList = async () => { | |
| 79 | +async function getList() { | |
| 81 | 80 | loading.value = true |
| 82 | 81 | try { |
| 83 | 82 | const params = cloneDeep(queryParams) as any; |
| ... | ... | @@ -104,7 +103,7 @@ const getList = async () => { |
| 104 | 103 | } |
| 105 | 104 | |
| 106 | 105 | /** 搜索按钮操作 */ |
| 107 | -const handleQuery = () => { | |
| 106 | +function handleQuery() { | |
| 108 | 107 | #if ( $table.templateType != 2 ) |
| 109 | 108 | queryParams.pageNo = 1 |
| 110 | 109 | #end |
| ... | ... | @@ -112,7 +111,7 @@ const handleQuery = () => { |
| 112 | 111 | } |
| 113 | 112 | |
| 114 | 113 | /** 重置按钮操作 */ |
| 115 | -const resetQuery = () => { | |
| 114 | +function resetQuery() { | |
| 116 | 115 | queryFormRef.value.resetFields() |
| 117 | 116 | handleQuery() |
| 118 | 117 | } |
| ... | ... | @@ -182,7 +181,7 @@ function handleRowCheckboxChange({ |
| 182 | 181 | #end |
| 183 | 182 | |
| 184 | 183 | /** 导出表格 */ |
| 185 | -async function onExport() { | |
| 184 | +async function handleExport() { | |
| 186 | 185 | try { |
| 187 | 186 | exportLoading.value = true; |
| 188 | 187 | const data = await export${simpleClassName}(queryParams); |
| ... | ... | @@ -298,7 +297,7 @@ onMounted(() => { |
| 298 | 297 | <!-- 列表 --> |
| 299 | 298 | <ContentWrap title="${table.classComment}"> |
| 300 | 299 | <template #extra> |
| 301 | - <TableToolbar | |
| 300 | + <VbenVxeTableToolbar | |
| 302 | 301 | ref="tableToolbarRef" |
| 303 | 302 | v-model:hidden-search="hiddenSearchBar" |
| 304 | 303 | > |
| ... | ... | @@ -321,7 +320,7 @@ onMounted(() => { |
| 321 | 320 | type="primary" |
| 322 | 321 | class="ml-2" |
| 323 | 322 | :loading="exportLoading" |
| 324 | - @click="onExport" | |
| 323 | + @click="handleExport" | |
| 325 | 324 | v-access:code="['${permissionPrefix}:export']" |
| 326 | 325 | > |
| 327 | 326 | {{ $t('ui.actionTitle.export') }} | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/general/views/modules/form_sub_erp.vue.vm
| ... | ... | @@ -3,107 +3,109 @@ |
| 3 | 3 | #set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 |
| 4 | 4 | #set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) |
| 5 | 5 | <script lang="ts" setup> |
| 6 | - import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 7 | - import type { Rule } from 'ant-design-vue/es/form'; | |
| 6 | +import type { Rule } from 'ant-design-vue/es/form'; | |
| 7 | +import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 8 | 8 | |
| 9 | - import { useVbenModal } from '@vben/common-ui'; | |
| 10 | - import { Tinymce as RichTextarea } from '#/components/tinymce'; | |
| 11 | - import { ImageUpload, FileUpload } from "#/components/upload"; | |
| 12 | - import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue'; | |
| 13 | - import { DICT_TYPE, getDictOptions } from '#/utils'; | |
| 9 | +import { computed, ref } from 'vue'; | |
| 14 | 10 | |
| 15 | - import { computed, ref } from 'vue'; | |
| 16 | - import { $t } from '#/locales'; | |
| 11 | +import { useVbenModal } from '@vben/common-ui'; | |
| 12 | +import { DICT_TYPE } from '@vben/constants'; | |
| 13 | +import { getDictOptions } from '@vben/hooks'; | |
| 14 | +import { cloneDeep, formatDateTime } from '@vben/utils'; | |
| 15 | +import { Tinymce as RichTextarea } from '#/components/tinymce'; | |
| 16 | +import { ImageUpload, FileUpload } from "#/components/upload"; | |
| 17 | +import { message, Tabs, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker, TreeSelect } from 'ant-design-vue'; | |
| 17 | 18 | |
| 18 | - import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 19 | +import { $t } from '#/locales'; | |
| 19 | 20 | |
| 20 | - const emit = defineEmits(['success']); | |
| 21 | - const getTitle = computed(() => { | |
| 22 | - return formData.value?.id | |
| 23 | - ? $t('ui.actionTitle.edit', ['${subTable.classComment}']) | |
| 24 | - : $t('ui.actionTitle.create', ['${subTable.classComment}']); | |
| 25 | - }); | |
| 21 | +import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 26 | 22 | |
| 27 | - const formRef = ref(); | |
| 28 | - const formData = ref<Partial<${simpleClassName}Api.${subSimpleClassName}>>({ | |
| 29 | - #foreach ($column in $subColumns) | |
| 30 | - #if ($column.createOperation || $column.updateOperation) | |
| 31 | - #if ($column.htmlType == "checkbox") | |
| 32 | - $column.javaField: [], | |
| 33 | - #else | |
| 34 | - $column.javaField: undefined, | |
| 35 | - #end | |
| 23 | +const emit = defineEmits(['success']); | |
| 24 | +const getTitle = computed(() => { | |
| 25 | + return formData.value?.id | |
| 26 | + ? $t('ui.actionTitle.edit', ['${subTable.classComment}']) | |
| 27 | + : $t('ui.actionTitle.create', ['${subTable.classComment}']); | |
| 28 | +}); | |
| 29 | + | |
| 30 | +const formRef = ref(); | |
| 31 | +const formData = ref<Partial<${simpleClassName}Api.${subSimpleClassName}>>({ | |
| 32 | + #foreach ($column in $subColumns) | |
| 33 | + #if ($column.createOperation || $column.updateOperation) | |
| 34 | + #if ($column.htmlType == "checkbox") | |
| 35 | + $column.javaField: [], | |
| 36 | + #else | |
| 37 | + $column.javaField: undefined, | |
| 36 | 38 | #end |
| 37 | 39 | #end |
| 38 | - }); | |
| 39 | - const rules: Record<string, Rule[]> = { | |
| 40 | - #foreach ($column in $subColumns) | |
| 41 | - #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 | |
| 42 | - #set($comment=$column.columnComment) | |
| 43 | - $column.javaField: [{ required: true, message: '${comment}不能为空', trigger: #if($column.htmlType == 'select')'change'#else'blur'#end }], | |
| 44 | - #end | |
| 40 | + #end | |
| 41 | +}); | |
| 42 | +const rules: Record<string, Rule[]> = { | |
| 43 | + #foreach ($column in $subColumns) | |
| 44 | + #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 | |
| 45 | + #set($comment=$column.columnComment) | |
| 46 | + $column.javaField: [{ required: true, message: '${comment}不能为空', trigger: #if($column.htmlType == 'select')'change'#else'blur'#end }], | |
| 45 | 47 | #end |
| 46 | - }; | |
| 48 | + #end | |
| 49 | +}; | |
| 50 | + | |
| 51 | +const [Modal, modalApi] = useVbenModal({ | |
| 52 | + async onConfirm() { | |
| 53 | + await formRef.value?.validate(); | |
| 47 | 54 | |
| 48 | - const [Modal, modalApi] = useVbenModal({ | |
| 49 | - async onConfirm() { | |
| 50 | - await formRef.value?.validate(); | |
| 55 | + modalApi.lock(); | |
| 56 | + // 提交表单 | |
| 57 | + const data = formData.value as ${simpleClassName}Api.${subSimpleClassName}; | |
| 58 | + try { | |
| 59 | + await (formData.value?.id ? update${subSimpleClassName}(data) : create${subSimpleClassName}(data)); | |
| 60 | + // 关闭并提示 | |
| 61 | + await modalApi.close(); | |
| 62 | + emit('success'); | |
| 63 | + message.success({ | |
| 64 | + content: $t('ui.actionMessage.operationSuccess'), | |
| 65 | + }); | |
| 66 | + } finally { | |
| 67 | + modalApi.unlock(); | |
| 68 | + } | |
| 69 | + }, | |
| 70 | + async onOpenChange(isOpen: boolean) { | |
| 71 | + if (!isOpen) { | |
| 72 | + resetForm() | |
| 73 | + return; | |
| 74 | + } | |
| 51 | 75 | |
| 76 | + // 加载数据 | |
| 77 | + let data = modalApi.getData<${simpleClassName}Api.${subSimpleClassName}>(); | |
| 78 | + if (!data) { | |
| 79 | + return; | |
| 80 | + } | |
| 81 | + if (data.id) { | |
| 52 | 82 | modalApi.lock(); |
| 53 | - // 提交表单 | |
| 54 | - const data = formData.value as ${simpleClassName}Api.${subSimpleClassName}; | |
| 55 | 83 | try { |
| 56 | - await (formData.value?.id ? update${subSimpleClassName}(data) : create${subSimpleClassName}(data)); | |
| 57 | - // 关闭并提示 | |
| 58 | - await modalApi.close(); | |
| 59 | - emit('success'); | |
| 60 | - message.success({ | |
| 61 | - content: $t('ui.actionMessage.operationSuccess'), | |
| 62 | - key: 'action_process_msg', | |
| 63 | - }); | |
| 84 | + data = await get${subSimpleClassName}(data.id); | |
| 64 | 85 | } finally { |
| 65 | 86 | modalApi.unlock(); |
| 66 | 87 | } |
| 67 | - }, | |
| 68 | - async onOpenChange(isOpen: boolean) { | |
| 69 | - if (!isOpen) { | |
| 70 | - resetForm() | |
| 71 | - return; | |
| 72 | - } | |
| 88 | + } | |
| 89 | + // 设置到 values | |
| 90 | + formData.value = data; | |
| 91 | + }, | |
| 92 | +}); | |
| 73 | 93 | |
| 74 | - // 加载数据 | |
| 75 | - let data = modalApi.getData<${simpleClassName}Api.${subSimpleClassName}>(); | |
| 76 | - if (!data) { | |
| 77 | - return; | |
| 78 | - } | |
| 79 | - if (data.id) { | |
| 80 | - modalApi.lock(); | |
| 81 | - try { | |
| 82 | - data = await get${subSimpleClassName}(data.id); | |
| 83 | - } finally { | |
| 84 | - modalApi.unlock(); | |
| 85 | - } | |
| 86 | - } | |
| 87 | - // 设置到 values | |
| 88 | - formData.value = data; | |
| 89 | - }, | |
| 90 | - }); | |
| 91 | - | |
| 92 | - /** 重置表单 */ | |
| 93 | - const resetForm = () => { | |
| 94 | - formData.value = { | |
| 95 | - #foreach ($column in $subColumns) | |
| 96 | - #if ($column.createOperation || $column.updateOperation) | |
| 97 | - #if ($column.htmlType == "checkbox") | |
| 98 | - $column.javaField: [], | |
| 99 | - #else | |
| 100 | - $column.javaField: undefined, | |
| 101 | - #end | |
| 94 | +/** 重置表单 */ | |
| 95 | +function resetForm(){ | |
| 96 | + formData.value = { | |
| 97 | + #foreach ($column in $subColumns) | |
| 98 | + #if ($column.createOperation || $column.updateOperation) | |
| 99 | + #if ($column.htmlType == "checkbox") | |
| 100 | + $column.javaField: [], | |
| 101 | + #else | |
| 102 | + $column.javaField: undefined, | |
| 102 | 103 | #end |
| 103 | 104 | #end |
| 104 | - }; | |
| 105 | - formRef.value?.resetFields(); | |
| 106 | - } | |
| 105 | + #end | |
| 106 | + }; | |
| 107 | + formRef.value?.resetFields(); | |
| 108 | +} | |
| 107 | 109 | </script> |
| 108 | 110 | |
| 109 | 111 | <template> | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/general/views/modules/form_sub_normal.vue.vm
| ... | ... | @@ -5,12 +5,15 @@ |
| 5 | 5 | #set ($subClassNameVar = $subClassNameVars.get($subIndex)) |
| 6 | 6 | #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 |
| 7 | 7 | <script lang="ts" setup> |
| 8 | - import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 8 | +import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 9 | 9 | |
| 10 | - import { message, Tabs, Form, Input, Textarea,Button, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker } from 'ant-design-vue'; | |
| 11 | - import { computed, ref, h, onMounted,watch,nextTick } from 'vue'; | |
| 12 | - import { $t } from '#/locales'; | |
| 13 | - import { DICT_TYPE, getDictOptions } from '#/utils'; | |
| 10 | +import { computed, ref, h, onMounted,watch,nextTick } from 'vue'; | |
| 11 | + | |
| 12 | +import { DICT_TYPE } from '@vben/constants'; | |
| 13 | +import { getDictOptions } from '@vben/hooks'; | |
| 14 | + | |
| 15 | +import { message, Tabs, Form, Input, Textarea,Button, Select, RadioGroup, Radio, CheckboxGroup, Checkbox, DatePicker } from 'ant-design-vue'; | |
| 16 | +import { $t } from '#/locales'; | |
| 14 | 17 | |
| 15 | 18 | #if ($subTable.subJoinMany) ## 一对多 |
| 16 | 19 | import type { VxeTableInstance } from '#/adapter/vxe-table'; |
| ... | ... | @@ -30,13 +33,14 @@ const props = defineProps<{ |
| 30 | 33 | #if ($subTable.subJoinMany) ## 一对多 |
| 31 | 34 | const list = ref<${simpleClassName}Api.${subSimpleClassName}[]>([]) // 列表的数据 |
| 32 | 35 | const tableRef = ref<VxeTableInstance>(); |
| 36 | + | |
| 33 | 37 | /** 添加${subTable.classComment} */ |
| 34 | -const onAdd = async () => { | |
| 38 | +async function handleAdd() { | |
| 35 | 39 | await tableRef.value?.insertAt({} as ${simpleClassName}Api.${subSimpleClassName}, -1); |
| 36 | 40 | } |
| 37 | 41 | |
| 38 | 42 | /** 删除${subTable.classComment} */ |
| 39 | -const onDelete = async (row: ${simpleClassName}Api.${subSimpleClassName}) => { | |
| 43 | +async function handleDelete(row: ${simpleClassName}Api.${subSimpleClassName}) { | |
| 40 | 44 | await tableRef.value?.remove(row); |
| 41 | 45 | } |
| 42 | 46 | |
| ... | ... | @@ -46,9 +50,11 @@ defineExpose({ |
| 46 | 50 | const data = list.value as ${simpleClassName}Api.${subSimpleClassName}[]; |
| 47 | 51 | const removeRecords = tableRef.value?.getRemoveRecords() as ${simpleClassName}Api.${subSimpleClassName}[]; |
| 48 | 52 | const insertRecords = tableRef.value?.getInsertRecords() as ${simpleClassName}Api.${subSimpleClassName}[]; |
| 49 | - return data | |
| 50 | - .filter((row) => !removeRecords.some((removed) => removed.id === row.id)) | |
| 51 | - ?.concat(insertRecords.map((row: any) => ({ ...row, id: undefined }))); | |
| 53 | + return [ | |
| 54 | + ...data.filter( | |
| 55 | + (row) => !removeRecords.some((removed) => removed.id === row.id), | |
| 56 | + ), | |
| 57 | + ...insertRecords.map((row: any) => ({ ...row, id: undefined })), | |
| 52 | 58 | }, |
| 53 | 59 | }); |
| 54 | 60 | |
| ... | ... | @@ -123,25 +129,25 @@ watch( |
| 123 | 129 | #if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写 |
| 124 | 130 | #elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里 |
| 125 | 131 | <vxe-column field="${javaField}" title="${comment}" align="center"> |
| 126 | - <template #default="{row}"> | |
| 132 | + <template #default="{ row }"> | |
| 127 | 133 | <Input v-model:value="row.${javaField}" /> |
| 128 | 134 | </template> |
| 129 | 135 | </vxe-column> |
| 130 | 136 | #elseif($column.htmlType == "imageUpload")## 图片上传 |
| 131 | 137 | <vxe-column field="${javaField}" title="${comment}" align="center"> |
| 132 | - <template #default="{row}"> | |
| 138 | + <template #default="{ row }"> | |
| 133 | 139 | <ImageUpload v-model:value="row.${javaField}" /> |
| 134 | 140 | </template> |
| 135 | 141 | </vxe-column> |
| 136 | 142 | #elseif($column.htmlType == "fileUpload")## 文件上传 |
| 137 | 143 | <vxe-column field="${javaField}" title="${comment}" align="center"> |
| 138 | - <template #default="{row}"> | |
| 144 | + <template #default="{ row }"> | |
| 139 | 145 | <FileUpload v-model:value="row.${javaField}" /> |
| 140 | 146 | </template> |
| 141 | 147 | </vxe-column> |
| 142 | 148 | #elseif($column.htmlType == "select")## 下拉框 |
| 143 | 149 | <vxe-column field="${javaField}" title="${comment}" align="center"> |
| 144 | - <template #default="{row}"> | |
| 150 | + <template #default="{ row }"> | |
| 145 | 151 | <Select v-model:value="row.${javaField}" placeholder="请选择${comment}"> |
| 146 | 152 | #if ("" != $dictType)## 有数据字典 |
| 147 | 153 | <Select.Option |
| ... | ... | @@ -159,7 +165,7 @@ watch( |
| 159 | 165 | </vxe-column> |
| 160 | 166 | #elseif($column.htmlType == "checkbox")## 多选框 |
| 161 | 167 | <vxe-column field="${javaField}" title="${comment}" align="center"> |
| 162 | - <template #default="{row}"> | |
| 168 | + <template #default="{ row }"> | |
| 163 | 169 | <CheckboxGroup v-model:value="row.${javaField}"> |
| 164 | 170 | #if ("" != $dictType)## 有数据字典 |
| 165 | 171 | <Checkbox |
| ... | ... | @@ -177,7 +183,7 @@ watch( |
| 177 | 183 | </vxe-column> |
| 178 | 184 | #elseif($column.htmlType == "radio")## 单选框 |
| 179 | 185 | <vxe-column field="${javaField}" title="${comment}" align="center"> |
| 180 | - <template #default="{row}"> | |
| 186 | + <template #default="{ row }"> | |
| 181 | 187 | <RadioGroup v-model:value="row.${javaField}"> |
| 182 | 188 | #if ("" != $dictType)## 有数据字典 |
| 183 | 189 | <Radio |
| ... | ... | @@ -195,7 +201,7 @@ watch( |
| 195 | 201 | </vxe-column> |
| 196 | 202 | #elseif($column.htmlType == "datetime")## 时间框 |
| 197 | 203 | <vxe-column field="${javaField}" title="${comment}" align="center"> |
| 198 | - <template #default="{row}"> | |
| 204 | + <template #default="{ row }"> | |
| 199 | 205 | <DatePicker |
| 200 | 206 | v-model:value="row.${javaField}" |
| 201 | 207 | :showTime="true" |
| ... | ... | @@ -206,7 +212,7 @@ watch( |
| 206 | 212 | </vxe-column> |
| 207 | 213 | #elseif($column.htmlType == "textarea" || $column.htmlType == "editor")## 文本框 |
| 208 | 214 | <vxe-column field="${javaField}" title="${comment}" align="center"> |
| 209 | - <template #default="{row}"> | |
| 215 | + <template #default="{ row }"> | |
| 210 | 216 | <Textarea v-model:value="row.${javaField}" /> |
| 211 | 217 | </template> |
| 212 | 218 | </vxe-column> |
| ... | ... | @@ -214,12 +220,12 @@ watch( |
| 214 | 220 | #end |
| 215 | 221 | #end |
| 216 | 222 | <vxe-column field="operation" title="操作" align="center"> |
| 217 | - <template #default="{row}"> | |
| 223 | + <template #default="{ row }"> | |
| 218 | 224 | <Button |
| 219 | 225 | size="small" |
| 220 | 226 | type="link" |
| 221 | 227 | danger |
| 222 | - @click="onDelete(row as any)" | |
| 228 | + @click="handleDelect(row)" | |
| 223 | 229 | v-access:code="['${permissionPrefix}:delete']" |
| 224 | 230 | > |
| 225 | 231 | {{ $t('ui.actionTitle.delete') }} |
| ... | ... | @@ -228,7 +234,7 @@ watch( |
| 228 | 234 | </vxe-column> |
| 229 | 235 | </vxe-table> |
| 230 | 236 | <div class="flex justify-center mt-4"> |
| 231 | - <Button :icon="h(Plus)" type="primary" ghost @click="onAdd" v-access:code="['${permissionPrefix}:create']"> | |
| 237 | + <Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${permissionPrefix}:create']"> | |
| 232 | 238 | {{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }} |
| 233 | 239 | </Button> |
| 234 | 240 | </div> | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/general/views/modules/list_sub_erp.vue.vm
| ... | ... | @@ -6,48 +6,50 @@ |
| 6 | 6 | #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($subIndex)) |
| 7 | 7 | #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 |
| 8 | 8 | <script lang="ts" setup> |
| 9 | - import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 10 | - import type { VxeTableInstance } from '#/adapter/vxe-table'; | |
| 9 | +import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 10 | +import type { VxeTableInstance } from '#/adapter/vxe-table'; | |
| 11 | 11 | |
| 12 | - import { DictTag } from '#/components/dict-tag'; | |
| 13 | - import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; | |
| 14 | - import { VxeColumn, VxeTable } from '#/adapter/vxe-table'; | |
| 15 | - import { reactive,ref, h, nextTick,watch,onMounted } from 'vue'; | |
| 16 | - import { cloneDeep, formatDateTime } from '@vben/utils'; | |
| 17 | - import { ContentWrap } from '#/components/content-wrap'; | |
| 12 | +import { reactive,ref, h, nextTick,watch,onMounted } from 'vue'; | |
| 13 | + | |
| 14 | +import { DICT_TYPE } from '@vben/constants'; | |
| 15 | +import { getDictOptions } from '@vben/hooks'; | |
| 16 | + | |
| 17 | +import { DictTag } from '#/components/dict-tag'; | |
| 18 | +import { getRangePickerDefaultProps } from '#/utils'; | |
| 19 | +import { VxeColumn, VxeTable } from '#/adapter/vxe-table'; | |
| 20 | +import { ContentWrap } from '#/components/content-wrap'; | |
| 18 | 21 | |
| 19 | 22 | #if ($table.templateType == 11) ## erp |
| 20 | - import { useVbenModal } from '@vben/common-ui'; | |
| 21 | - import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue' | |
| 22 | - import { Tinymce as RichTextarea } from '#/components/tinymce'; | |
| 23 | - import { ImageUpload, FileUpload } from "#/components/upload"; | |
| 24 | - import { message,Button, Tabs,Pagination, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox,RangePicker, DatePicker, TreeSelect } from 'ant-design-vue'; | |
| 25 | - import { Plus, Trash2 } from '@vben/icons'; | |
| 26 | - import { $t } from '#/locales'; | |
| 27 | - import { TableToolbar } from '#/components/table-toolbar'; | |
| 28 | - import { useTableToolbar } from '#/hooks'; | |
| 23 | +import { useVbenModal } from '@vben/common-ui'; | |
| 24 | +import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table'; | |
| 25 | +import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue' | |
| 26 | +import { Tinymce as RichTextarea } from '#/components/tinymce'; | |
| 27 | +import { ImageUpload, FileUpload } from "#/components/upload"; | |
| 28 | +import { message,Button, Tabs,Pagination, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox,RangePicker, DatePicker, TreeSelect } from 'ant-design-vue'; | |
| 29 | +import { Plus, Trash2 } from '@vben/icons'; | |
| 30 | +import { $t } from '#/locales'; | |
| 29 | 31 | #end |
| 30 | 32 | |
| 31 | 33 | #if ($table.templateType == 11) ## erp |
| 32 | - import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}List,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 33 | - import { isEmpty } from '@vben/utils'; | |
| 34 | - #else | |
| 35 | - #if ($subTable.subJoinMany) ## 一对多 | |
| 36 | - import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 37 | - #else | |
| 38 | - import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 39 | - #end | |
| 34 | +import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}List,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 35 | +import { isEmpty } from '@vben/utils'; | |
| 36 | +#else | |
| 37 | +#if ($subTable.subJoinMany) ## 一对多 | |
| 38 | +import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 39 | +#else | |
| 40 | +import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 41 | +#end | |
| 40 | 42 | #end |
| 41 | 43 | |
| 42 | 44 | const props = defineProps<{ |
| 43 | - ${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段) | |
| 45 | + ${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段) | |
| 44 | 46 | }>() |
| 45 | 47 | |
| 46 | 48 | #if ($table.templateType == 11) ## erp |
| 47 | - const [FormModal, formModalApi] = useVbenModal({ | |
| 48 | - connectedComponent: ${subSimpleClassName}Form, | |
| 49 | - destroyOnClose: true, | |
| 50 | - }); | |
| 49 | +const [FormModal, formModalApi] = useVbenModal({ | |
| 50 | + connectedComponent: ${subSimpleClassName}Form, | |
| 51 | + destroyOnClose: true, | |
| 52 | +}); | |
| 51 | 53 | |
| 52 | 54 | /** 创建${subTable.classComment} */ |
| 53 | 55 | function handleCreate() { |
| ... | ... | @@ -106,87 +108,87 @@ function handleRowCheckboxChange({ |
| 106 | 108 | #end |
| 107 | 109 | #end |
| 108 | 110 | |
| 109 | - const loading = ref(true) // 列表的加载中 | |
| 110 | - const list = ref<${simpleClassName}Api.${subSimpleClassName}[]>([]) // 列表的数据 | |
| 111 | +const loading = ref(true) // 列表的加载中 | |
| 112 | +const list = ref<${simpleClassName}Api.${subSimpleClassName}[]>([]) // 列表的数据 | |
| 111 | 113 | #if ($table.templateType == 11) ## erp |
| 112 | - const total = ref(0) // 列表的总页数 | |
| 114 | +const total = ref(0) // 列表的总页数 | |
| 113 | 115 | #end |
| 114 | 116 | #if ($table.templateType == 11) ## erp |
| 115 | - const queryFormRef = ref() // 搜索的表单 | |
| 116 | - const queryParams = reactive({ | |
| 117 | - pageNo: 1, | |
| 118 | - pageSize: 10, | |
| 119 | - #foreach ($column in $subColumns) | |
| 120 | - #if ($column.listOperation) | |
| 121 | - #if ($column.listOperationCondition != 'BETWEEN') | |
| 122 | - $column.javaField: undefined, | |
| 123 | - #end | |
| 124 | - #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") | |
| 125 | - $column.javaField: undefined, | |
| 126 | - #end | |
| 127 | - #end | |
| 117 | +const queryFormRef = ref() // 搜索的表单 | |
| 118 | +const queryParams = reactive({ | |
| 119 | + pageNo: 1, | |
| 120 | + pageSize: 10, | |
| 121 | + #foreach ($column in $subColumns) | |
| 122 | + #if ($column.listOperation) | |
| 123 | + #if ($column.listOperationCondition != 'BETWEEN') | |
| 124 | + $column.javaField: undefined, | |
| 128 | 125 | #end |
| 129 | - }) | |
| 126 | + #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") | |
| 127 | + $column.javaField: undefined, | |
| 128 | + #end | |
| 129 | + #end | |
| 130 | + #end | |
| 131 | +}) | |
| 130 | 132 | |
| 131 | 133 | /** 搜索按钮操作 */ |
| 132 | -const handleQuery = () => { | |
| 134 | +function handleQuery() { | |
| 133 | 135 | queryParams.pageNo = 1 |
| 134 | 136 | getList() |
| 135 | 137 | } |
| 136 | 138 | |
| 137 | 139 | /** 重置按钮操作 */ |
| 138 | -const resetQuery = () => { | |
| 140 | +function resetQuery() { | |
| 139 | 141 | queryFormRef.value.resetFields() |
| 140 | 142 | handleQuery() |
| 141 | 143 | } |
| 142 | 144 | #end |
| 143 | 145 | /** 查询列表 */ |
| 144 | - const getList = async () => { | |
| 145 | - loading.value = true | |
| 146 | - try { | |
| 147 | - if (!props.${subJoinColumn.javaField}){ | |
| 148 | - return [] | |
| 149 | - } | |
| 150 | - ## 特殊:树表专属逻辑(树不需要分页接口) | |
| 151 | - #if ($table.templateType == 11) ## erp | |
| 152 | - const params = cloneDeep(queryParams) as any; | |
| 153 | - #foreach ($column in $columns) | |
| 154 | - #if ($column.listOperation) | |
| 155 | - #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") | |
| 156 | - if (params.${column.javaField} && Array.isArray(params.${column.javaField})) { | |
| 157 | - params.${column.javaField} = (params.${column.javaField} as string[]).join(','); | |
| 158 | - } | |
| 159 | - #end | |
| 160 | - #end | |
| 161 | - #end | |
| 162 | - params.${subJoinColumn.javaField} = props.${subJoinColumn.javaField}; | |
| 163 | - const data = await get${subSimpleClassName}Page(params) | |
| 164 | - list.value = data.list | |
| 165 | - total.value = data.total | |
| 166 | - #else | |
| 167 | - #if ($subTable.subJoinMany) ## 一对多 | |
| 168 | - list.value = await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!); | |
| 169 | - #else | |
| 170 | - list.value = [await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]; | |
| 171 | - #end | |
| 172 | - #end | |
| 173 | - } finally { | |
| 174 | - loading.value = false | |
| 146 | +async function getList() { | |
| 147 | + loading.value = true | |
| 148 | + try { | |
| 149 | + if (!props.${subJoinColumn.javaField}){ | |
| 150 | + return [] | |
| 175 | 151 | } |
| 152 | + ## 特殊:树表专属逻辑(树不需要分页接口) | |
| 153 | + #if ($table.templateType == 11) ## erp | |
| 154 | + const params = cloneDeep(queryParams) as any; | |
| 155 | + #foreach ($column in $columns) | |
| 156 | + #if ($column.listOperation) | |
| 157 | + #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") | |
| 158 | + if (params.${column.javaField} && Array.isArray(params.${column.javaField})) { | |
| 159 | + params.${column.javaField} = (params.${column.javaField} as string[]).join(','); | |
| 160 | + } | |
| 161 | + #end | |
| 162 | + #end | |
| 163 | + #end | |
| 164 | + params.${subJoinColumn.javaField} = props.${subJoinColumn.javaField}; | |
| 165 | + const data = await get${subSimpleClassName}Page(params) | |
| 166 | + list.value = data.list | |
| 167 | + total.value = data.total | |
| 168 | + #else | |
| 169 | + #if ($subTable.subJoinMany) ## 一对多 | |
| 170 | + list.value = await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!); | |
| 171 | + #else | |
| 172 | + list.value = [await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]; | |
| 173 | + #end | |
| 174 | + #end | |
| 175 | + } finally { | |
| 176 | + loading.value = false | |
| 176 | 177 | } |
| 178 | +} | |
| 177 | 179 | |
| 178 | - /** 监听主表的关联字段的变化,加载对应的子表数据 */ | |
| 179 | - watch( | |
| 180 | - () => props.${subJoinColumn.javaField}, | |
| 181 | - async (val) => { | |
| 182 | - if (!val) { | |
| 183 | - return; | |
| 184 | - } | |
| 185 | - await nextTick(); | |
| 186 | - await getList() | |
| 187 | - }, | |
| 188 | - { immediate: true }, | |
| 189 | - ); | |
| 180 | +/** 监听主表的关联字段的变化,加载对应的子表数据 */ | |
| 181 | +watch( | |
| 182 | + () => props.${subJoinColumn.javaField}, | |
| 183 | + async (val) => { | |
| 184 | + if (!val) { | |
| 185 | + return; | |
| 186 | + } | |
| 187 | + await nextTick(); | |
| 188 | + await getList() | |
| 189 | + }, | |
| 190 | + { immediate: true }, | |
| 191 | +); | |
| 190 | 192 | |
| 191 | 193 | #if ($table.templateType == 11) ## erp |
| 192 | 194 | /** 初始化 */ |
| ... | ... | @@ -287,7 +289,7 @@ onMounted(() => { |
| 287 | 289 | <!-- 列表 --> |
| 288 | 290 | <ContentWrap title="${table.classComment}"> |
| 289 | 291 | <template #extra> |
| 290 | - <TableToolbar | |
| 292 | + <VbenVxeTableToolbar | |
| 291 | 293 | ref="tableToolbarRef" |
| 292 | 294 | v-model:hidden-search="hiddenSearchBar" |
| 293 | 295 | > | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/form_sub_normal.vue.vm
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/general/views/form.vue.vm
| ... | ... | @@ -3,10 +3,11 @@ import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleCl |
| 3 | 3 | import type { FormRules } from 'element-plus'; |
| 4 | 4 | |
| 5 | 5 | import { useVbenModal } from '@vben/common-ui'; |
| 6 | +import { DICT_TYPE } from '@vben/constants'; | |
| 7 | +import { getDictOptions } from '@vben/hooks'; | |
| 6 | 8 | import { Tinymce as RichTextarea } from '#/components/tinymce'; |
| 7 | 9 | import { ImageUpload, FileUpload } from "#/components/upload"; |
| 8 | 10 | import { ElMessage, ElTabs, ElTabPane, ElForm, ElFormItem, ElInput, ElSelect, ElOption, ElRadioGroup, ElRadio, ElCheckboxGroup, ElCheckbox, ElDatePicker, ElTreeSelect } from 'element-plus'; |
| 9 | -import { DICT_TYPE, getDictOptions } from '#/utils'; | |
| 10 | 11 | #if($table.templateType == 2)## 树表需要导入这些 |
| 11 | 12 | import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; |
| 12 | 13 | import { handleTree } from '@vben/utils' | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/general/views/index.vue.vm
| 1 | 1 | <script lang="ts" setup> |
| 2 | 2 | import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; |
| 3 | -import type { VxeTableInstance } from '#/adapter/vxe-table'; | |
| 3 | + | |
| 4 | +import { ref, h, reactive, onMounted, nextTick } from 'vue'; | |
| 4 | 5 | |
| 5 | 6 | import { Page, useVbenModal } from '@vben/common-ui'; |
| 6 | -import { cloneDeep, formatDateTime } from '@vben/utils'; | |
| 7 | +import { DICT_TYPE } from '@vben/constants'; | |
| 8 | +import { getDictOptions } from '@vben/hooks'; | |
| 9 | +import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table'; | |
| 10 | +import { cloneDeep, downloadFileFromBlobPart, formatDateTime } from '@vben/utils'; | |
| 7 | 11 | import { ElButton, ElMessage, ElLoading, ElTabs, ElTabPane, ElPagination, ElForm, ElFormItem, ElDatePicker, ElSelect, ElOption, ElInput } from 'element-plus'; |
| 8 | -import { DictTag } from '#/components/dict-tag'; | |
| 9 | -import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; | |
| 10 | 12 | import ${simpleClassName}Form from './modules/form.vue'; |
| 11 | 13 | import { Download, Plus, RefreshCw, Search, Trash2 } from '@vben/icons'; |
| 12 | 14 | import { ContentWrap } from '#/components/content-wrap'; |
| 13 | 15 | import { VxeColumn, VxeTable } from '#/adapter/vxe-table'; |
| 14 | -import { TableToolbar } from '#/components/table-toolbar'; | |
| 15 | -import { useTableToolbar } from '#/hooks'; | |
| 16 | 16 | |
| 17 | 17 | ## 特殊:主子表专属逻辑 |
| 18 | 18 | #if ( $table.templateType == 11 || $table.templateType == 12 ) |
| ... | ... | @@ -23,7 +23,6 @@ import { useTableToolbar } from '#/hooks'; |
| 23 | 23 | #end |
| 24 | 24 | #end |
| 25 | 25 | |
| 26 | -import { ref, h, reactive,onMounted,nextTick } from 'vue'; | |
| 27 | 26 | import { $t } from '#/locales'; |
| 28 | 27 | #if (${table.templateType} == 2)## 树表接口 |
| 29 | 28 | import { handleTree,isEmpty } from '@vben/utils' |
| ... | ... | @@ -104,7 +103,7 @@ const getList = async () => { |
| 104 | 103 | } |
| 105 | 104 | |
| 106 | 105 | /** 搜索按钮操作 */ |
| 107 | -const handleQuery = () => { | |
| 106 | +function handleQuery() { | |
| 108 | 107 | #if ( $table.templateType != 2 ) |
| 109 | 108 | queryParams.pageNo = 1 |
| 110 | 109 | #end |
| ... | ... | @@ -112,7 +111,7 @@ const handleQuery = () => { |
| 112 | 111 | } |
| 113 | 112 | |
| 114 | 113 | /** 重置按钮操作 */ |
| 115 | -const resetQuery = () => { | |
| 114 | +function resetQuery() { | |
| 116 | 115 | queryFormRef.value.resetFields() |
| 117 | 116 | handleQuery() |
| 118 | 117 | } |
| ... | ... | @@ -182,7 +181,7 @@ function handleRowCheckboxChange({ |
| 182 | 181 | #end |
| 183 | 182 | |
| 184 | 183 | /** 导出表格 */ |
| 185 | -async function onExport() { | |
| 184 | +async function handleExport() { | |
| 186 | 185 | try { |
| 187 | 186 | exportLoading.value = true; |
| 188 | 187 | const data = await export${simpleClassName}(queryParams); |
| ... | ... | @@ -324,7 +323,7 @@ onMounted(() => { |
| 324 | 323 | type="primary" |
| 325 | 324 | class="ml-2" |
| 326 | 325 | :loading="exportLoading" |
| 327 | - @click="onExport" | |
| 326 | + @click="handleExport" | |
| 328 | 327 | v-access:code="['${permissionPrefix}:export']" |
| 329 | 328 | > |
| 330 | 329 | {{ $t('ui.actionTitle.export') }} | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/general/views/modules/form_sub_erp.vue.vm
| ... | ... | @@ -6,13 +6,15 @@ |
| 6 | 6 | import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; |
| 7 | 7 | import type { FormRules } from 'element-plus'; |
| 8 | 8 | |
| 9 | + import { computed, ref, reactive } from 'vue'; | |
| 10 | + | |
| 9 | 11 | import { useVbenModal } from '@vben/common-ui'; |
| 12 | + import { DICT_TYPE } from '@vben/constants'; | |
| 13 | + import { getDictOptions } from '@vben/hooks'; | |
| 10 | 14 | import { Tinymce as RichTextarea } from '#/components/tinymce'; |
| 11 | 15 | import { ImageUpload, FileUpload } from "#/components/upload"; |
| 12 | 16 | import { ElMessage, ElTabs, ElTabPane, ElForm, ElFormItem, ElInput, ElSelect, ElOption, ElRadioGroup, ElRadio, ElCheckboxGroup, ElCheckbox, ElDatePicker, ElTreeSelect } from 'element-plus'; |
| 13 | - import { DICT_TYPE, getDictOptions } from '#/utils'; | |
| 14 | 17 | |
| 15 | - import { computed, ref, reactive } from 'vue'; | |
| 16 | 18 | import { $t } from '#/locales'; |
| 17 | 19 | |
| 18 | 20 | import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/general/views/modules/form_sub_normal.vue.vm
| ... | ... | @@ -5,12 +5,15 @@ |
| 5 | 5 | #set ($subClassNameVar = $subClassNameVars.get($subIndex)) |
| 6 | 6 | #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 |
| 7 | 7 | <script lang="ts" setup> |
| 8 | - import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 8 | +import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; | |
| 9 | 9 | |
| 10 | - import { ElMessage, ElTabs, ElTabPane, ElForm, ElFormItem, ElInput, ElButton, ElSelect, ElOption, ElRadioGroup, ElRadio, ElCheckboxGroup, ElCheckbox, ElDatePicker } from 'element-plus'; | |
| 11 | - import { computed, ref, reactive, h, onMounted,watch,nextTick } from 'vue'; | |
| 12 | - import { $t } from '#/locales'; | |
| 13 | - import { DICT_TYPE, getDictOptions } from '#/utils'; | |
| 10 | +import { computed, ref, reactive, h, onMounted,watch,nextTick } from 'vue'; | |
| 11 | + | |
| 12 | +import { DICT_TYPE } from '@vben/constants'; | |
| 13 | +import { getDictOptions } from '@vben/hooks'; | |
| 14 | + | |
| 15 | +import { ElMessage, ElTabs, ElTabPane, ElForm, ElFormItem, ElInput, ElButton, ElSelect, ElOption, ElRadioGroup, ElRadio, ElCheckboxGroup, ElCheckbox, ElDatePicker } from 'element-plus'; | |
| 16 | +import { $t } from '#/locales'; | |
| 14 | 17 | |
| 15 | 18 | #if ($subTable.subJoinMany) ## 一对多 |
| 16 | 19 | import type { VxeTableInstance } from '#/adapter/vxe-table'; |
| ... | ... | @@ -31,12 +34,12 @@ const props = defineProps<{ |
| 31 | 34 | const list = ref<${simpleClassName}Api.${subSimpleClassName}[]>([]) // 列表的数据 |
| 32 | 35 | const tableRef = ref<VxeTableInstance>(); |
| 33 | 36 | /** 添加${subTable.classComment} */ |
| 34 | -const onAdd = async () => { | |
| 37 | +async function handleAdd() { | |
| 35 | 38 | await tableRef.value?.insertAt({} as ${simpleClassName}Api.${subSimpleClassName}, -1); |
| 36 | 39 | } |
| 37 | 40 | |
| 38 | 41 | /** 删除${subTable.classComment} */ |
| 39 | -const onDelete = async (row: ${simpleClassName}Api.${subSimpleClassName}) => { | |
| 42 | +async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) { | |
| 40 | 43 | await tableRef.value?.remove(row); |
| 41 | 44 | } |
| 42 | 45 | |
| ... | ... | @@ -46,9 +49,11 @@ defineExpose({ |
| 46 | 49 | const data = list.value as ${simpleClassName}Api.${subSimpleClassName}[]; |
| 47 | 50 | const removeRecords = tableRef.value?.getRemoveRecords() as ${simpleClassName}Api.${subSimpleClassName}[]; |
| 48 | 51 | const insertRecords = tableRef.value?.getInsertRecords() as ${simpleClassName}Api.${subSimpleClassName}[]; |
| 49 | - return data | |
| 50 | - .filter((row) => !removeRecords.some((removed) => removed.id === row.id)) | |
| 51 | - ?.concat(insertRecords.map((row: any) => ({ ...row, id: undefined }))); | |
| 52 | + return [ | |
| 53 | + ...data.filter( | |
| 54 | + (row) => !removeRecords.some((removed) => removed.id === row.id), | |
| 55 | + ), | |
| 56 | + ...insertRecords.map((row: any) => ({ ...row, id: undefined })), | |
| 52 | 57 | }, |
| 53 | 58 | }); |
| 54 | 59 | |
| ... | ... | @@ -227,7 +232,7 @@ watch( |
| 227 | 232 | </vxe-column> |
| 228 | 233 | </vxe-table> |
| 229 | 234 | <div class="flex justify-center mt-4"> |
| 230 | - <el-button :icon="h(Plus)" type="primary" plain @click="onAdd" v-access:code="['${permissionPrefix}:create']"> | |
| 235 | + <el-button :icon="h(Plus)" type="primary" plain @click="handleAdd" v-access:code="['${permissionPrefix}:create']"> | |
| 231 | 236 | {{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }} |
| 232 | 237 | </el-button> |
| 233 | 238 | </div> | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/general/views/modules/list_sub_erp.vue.vm
| ... | ... | @@ -9,23 +9,25 @@ |
| 9 | 9 | import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; |
| 10 | 10 | import type { VxeTableInstance } from '#/adapter/vxe-table'; |
| 11 | 11 | |
| 12 | + import { reactive,ref, h, nextTick,watch,onMounted } from 'vue'; | |
| 13 | + | |
| 14 | + import { DICT_TYPE } from '@vben/constants'; | |
| 15 | + import { getDictOptions } from '@vben/hooks'; | |
| 16 | + | |
| 12 | 17 | import { DictTag } from '#/components/dict-tag'; |
| 13 | - import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; | |
| 18 | + import { getRangePickerDefaultProps } from '#/utils'; | |
| 14 | 19 | import { VxeColumn, VxeTable } from '#/adapter/vxe-table'; |
| 15 | - import { reactive,ref, h, nextTick,watch,onMounted } from 'vue'; | |
| 16 | - import { cloneDeep, formatDateTime } from '@vben/utils'; | |
| 17 | 20 | import { ContentWrap } from '#/components/content-wrap'; |
| 18 | 21 | |
| 19 | 22 | #if ($table.templateType == 11) ## erp |
| 20 | 23 | import { useVbenModal } from '@vben/common-ui'; |
| 24 | + import { useTableToolbar, VbenVxeTableToolbar } from '@vben/plugins/vxe-table'; | |
| 21 | 25 | import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue' |
| 22 | 26 | import { Tinymce as RichTextarea } from '#/components/tinymce'; |
| 23 | 27 | import { ImageUpload, FileUpload } from "#/components/upload"; |
| 24 | 28 | import { ElMessage, ElLoading, ElButton, ElTabs, ElTabPane, ElPagination, ElForm, ElFormItem, ElDatePicker, ElSelect, ElOption, ElInput } from 'element-plus'; |
| 25 | 29 | import { Plus, Trash2 } from '@vben/icons'; |
| 26 | 30 | import { $t } from '#/locales'; |
| 27 | - import { TableToolbar } from '#/components/table-toolbar'; | |
| 28 | - import { useTableToolbar } from '#/hooks'; | |
| 29 | 31 | #end |
| 30 | 32 | |
| 31 | 33 | #if ($table.templateType == 11) ## erp |
| ... | ... | @@ -129,64 +131,64 @@ function handleRowCheckboxChange({ |
| 129 | 131 | }) |
| 130 | 132 | |
| 131 | 133 | /** 搜索按钮操作 */ |
| 132 | -const handleQuery = () => { | |
| 134 | +function handleQuery() { | |
| 133 | 135 | queryParams.pageNo = 1 |
| 134 | 136 | getList() |
| 135 | 137 | } |
| 136 | 138 | |
| 137 | 139 | /** 重置按钮操作 */ |
| 138 | -const resetQuery = () => { | |
| 140 | +function resetQuery() { | |
| 139 | 141 | queryFormRef.value.resetFields() |
| 140 | 142 | handleQuery() |
| 141 | 143 | } |
| 142 | 144 | #end |
| 143 | - /** 查询列表 */ | |
| 144 | - const getList = async () => { | |
| 145 | - loading.value = true | |
| 146 | - try { | |
| 147 | - if (!props.${subJoinColumn.javaField}){ | |
| 148 | - return [] | |
| 149 | - } | |
| 150 | - ## 特殊:树表专属逻辑(树不需要分页接口) | |
| 151 | - #if ($table.templateType == 11) ## erp | |
| 152 | - const params = cloneDeep(queryParams) as any; | |
| 153 | - #foreach ($column in $columns) | |
| 154 | - #if ($column.listOperation) | |
| 155 | - #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") | |
| 156 | - if (params.${column.javaField} && Array.isArray(params.${column.javaField})) { | |
| 157 | - params.${column.javaField} = (params.${column.javaField} as string[]).join(','); | |
| 158 | - } | |
| 159 | - #end | |
| 160 | - #end | |
| 161 | - #end | |
| 162 | - params.${subJoinColumn.javaField} = props.${subJoinColumn.javaField}; | |
| 163 | - const data = await get${subSimpleClassName}Page(params) | |
| 164 | - list.value = data.list | |
| 165 | - total.value = data.total | |
| 166 | - #else | |
| 167 | - #if ($subTable.subJoinMany) ## 一对多 | |
| 168 | - list.value = await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!); | |
| 169 | - #else | |
| 170 | - list.value = [await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]; | |
| 171 | - #end | |
| 172 | - #end | |
| 173 | - } finally { | |
| 174 | - loading.value = false | |
| 145 | +/** 查询列表 */ | |
| 146 | +async function getList() { | |
| 147 | + loading.value = true | |
| 148 | + try { | |
| 149 | + if (!props.${subJoinColumn.javaField}){ | |
| 150 | + return [] | |
| 175 | 151 | } |
| 152 | + ## 特殊:树表专属逻辑(树不需要分页接口) | |
| 153 | + #if ($table.templateType == 11) ## erp | |
| 154 | + const params = cloneDeep(queryParams) as any; | |
| 155 | + #foreach ($column in $columns) | |
| 156 | + #if ($column.listOperation) | |
| 157 | + #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") | |
| 158 | + if (params.${column.javaField} && Array.isArray(params.${column.javaField})) { | |
| 159 | + params.${column.javaField} = (params.${column.javaField} as string[]).join(','); | |
| 160 | + } | |
| 161 | + #end | |
| 162 | + #end | |
| 163 | + #end | |
| 164 | + params.${subJoinColumn.javaField} = props.${subJoinColumn.javaField}; | |
| 165 | + const data = await get${subSimpleClassName}Page(params) | |
| 166 | + list.value = data.list | |
| 167 | + total.value = data.total | |
| 168 | + #else | |
| 169 | + #if ($subTable.subJoinMany) ## 一对多 | |
| 170 | + list.value = await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!); | |
| 171 | + #else | |
| 172 | + list.value = [await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]; | |
| 173 | + #end | |
| 174 | + #end | |
| 175 | + } finally { | |
| 176 | + loading.value = false | |
| 176 | 177 | } |
| 178 | +} | |
| 177 | 179 | |
| 178 | - /** 监听主表的关联字段的变化,加载对应的子表数据 */ | |
| 179 | - watch( | |
| 180 | - () => props.${subJoinColumn.javaField}, | |
| 181 | - async (val) => { | |
| 182 | - if (!val) { | |
| 183 | - return; | |
| 184 | - } | |
| 185 | - await nextTick(); | |
| 186 | - await getList() | |
| 187 | - }, | |
| 188 | - { immediate: true }, | |
| 189 | - ); | |
| 180 | +/** 监听主表的关联字段的变化,加载对应的子表数据 */ | |
| 181 | +watch( | |
| 182 | + () => props.${subJoinColumn.javaField}, | |
| 183 | + async (val) => { | |
| 184 | + if (!val) { | |
| 185 | + return; | |
| 186 | + } | |
| 187 | + await nextTick(); | |
| 188 | + await getList() | |
| 189 | + }, | |
| 190 | + { immediate: true }, | |
| 191 | +); | |
| 190 | 192 | |
| 191 | 193 | #if ($table.templateType == 11) ## erp |
| 192 | 194 | /** 初始化 */ |
| ... | ... | @@ -290,7 +292,7 @@ onMounted(() => { |
| 290 | 292 | <!-- 列表 --> |
| 291 | 293 | <ContentWrap title="${table.classComment}"> |
| 292 | 294 | <template #extra> |
| 293 | - <TableToolbar | |
| 295 | + <VbenVxeTableToolbar | |
| 294 | 296 | ref="tableToolbarRef" |
| 295 | 297 | v-model:hidden-search="hiddenSearchBar" |
| 296 | 298 | > | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/schema/views/modules/form_sub_erp.vue.vm
| ... | ... | @@ -6,13 +6,15 @@ |
| 6 | 6 | <script lang="ts" setup> |
| 7 | 7 | import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName}'; |
| 8 | 8 | |
| 9 | + import { computed, ref } from 'vue'; | |
| 10 | + | |
| 9 | 11 | import { useVbenModal } from '@vben/common-ui'; |
| 12 | + | |
| 10 | 13 | import { ElMessage } from 'element-plus'; |
| 11 | 14 | |
| 12 | - import { computed, ref } from 'vue'; | |
| 13 | - import { $t } from '#/locales'; | |
| 14 | 15 | import { useVbenForm } from '#/adapter/form'; |
| 15 | 16 | import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${table.businessName}'; |
| 17 | + import { $t } from '#/locales'; | |
| 16 | 18 | |
| 17 | 19 | import { use${subSimpleClassName}FormSchema } from '../data'; |
| 18 | 20 | ... | ... |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/schema/views/modules/form_sub_normal.vue.vm
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/schema/views/modules/list_sub_erp.vue.vm
| ... | ... | @@ -42,6 +42,19 @@ const [FormModal, formModalApi] = useVbenModal({ |
| 42 | 42 | destroyOnClose: true, |
| 43 | 43 | }); |
| 44 | 44 | |
| 45 | +/** 刷新表格 */ | |
| 46 | +async function handleRefresh() { | |
| 47 | +#if ($table.templateType == 11) ## erp | |
| 48 | + await gridApi.query(); | |
| 49 | +#else | |
| 50 | + #if ($subTable.subJoinMany) ## 一对多 | |
| 51 | + await gridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!)); | |
| 52 | + #else | |
| 53 | + await gridApi.grid.loadData([await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]); | |
| 54 | + #end | |
| 55 | +#end | |
| 56 | +} | |
| 57 | + | |
| 45 | 58 | /** 创建${subTable.classComment} */ |
| 46 | 59 | function handleCreate() { |
| 47 | 60 | if (!props.${subJoinColumn.javaField}){ |
| ... | ... | @@ -151,19 +164,6 @@ const [Grid, gridApi] = useVbenVxeGrid({ |
| 151 | 164 | #end |
| 152 | 165 | }); |
| 153 | 166 | |
| 154 | -/** 刷新表格 */ | |
| 155 | -async function handleRefresh() { | |
| 156 | -#if ($table.templateType == 11) ## erp | |
| 157 | - await gridApi.query(); | |
| 158 | -#else | |
| 159 | - #if ($subTable.subJoinMany) ## 一对多 | |
| 160 | - await gridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!)); | |
| 161 | - #else | |
| 162 | - await gridApi.grid.loadData([await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]); | |
| 163 | - #end | |
| 164 | -#end | |
| 165 | -} | |
| 166 | - | |
| 167 | 167 | /** 监听主表的关联字段的变化,加载对应的子表数据 */ |
| 168 | 168 | watch( |
| 169 | 169 | () => props.${subJoinColumn.javaField}, | ... | ... |