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