perf: vben codegen
This commit is contained in:
parent
5e9e41c045
commit
092e48b9d5
|
@ -3,27 +3,27 @@ import { defHttp } from '@/utils/http/axios'
|
|||
|
||||
// 查询${table.classComment}列表
|
||||
export function get${simpleClassName}Page(params) {
|
||||
return defHttp.get({ url: '${baseURL}/page', params })
|
||||
return defHttp.get({ url: '${baseURL}/page', params })
|
||||
}
|
||||
|
||||
// 查询${table.classComment}详情
|
||||
export function get${simpleClassName}(id: number) {
|
||||
return defHttp.get({ url: '${baseURL}/get?id=' + id })
|
||||
return defHttp.get({ url: `${baseURL}/get?id=${id}` })
|
||||
}
|
||||
|
||||
// 新增${table.classComment}
|
||||
export function create${simpleClassName}(data) {
|
||||
return defHttp.post({ url: '${baseURL}/create', data })
|
||||
return defHttp.post({ url: '${baseURL}/create', data })
|
||||
}
|
||||
|
||||
// 修改${table.classComment}
|
||||
export function update${simpleClassName}(data) {
|
||||
return defHttp.put({ url: '${baseURL}/update', data })
|
||||
return defHttp.put({ url: '${baseURL}/update', data })
|
||||
}
|
||||
|
||||
// 删除${table.classComment}
|
||||
export function delete${simpleClassName}(id: number) {
|
||||
return defHttp.delete({ url: '${baseURL}/delete?id=' + id })
|
||||
return defHttp.delete({ url: `${baseURL}/delete?id=${id}` })
|
||||
}
|
||||
|
||||
// 导出${table.classComment} Excel
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { BasicColumn, FormSchema, useRender } from '@/components/Table'
|
||||
import type { BasicColumn, FormSchema } from '@/components/Table'
|
||||
import { useRender } from '@/components/Table'
|
||||
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
|
@ -92,13 +93,13 @@ export const createFormSchema: FormSchema[] = [
|
|||
#elseif($column.htmlType == "imageUpload")## 图片上传
|
||||
component: 'FileUpload',
|
||||
componentProps: {
|
||||
fileType: 'file',
|
||||
fileType: 'image',
|
||||
maxCount: 1,
|
||||
},
|
||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||
component: 'FileUpload',
|
||||
componentProps: {
|
||||
fileType: 'image',
|
||||
fileType: 'file',
|
||||
maxCount: 1,
|
||||
},
|
||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||
|
@ -132,6 +133,11 @@ export const createFormSchema: FormSchema[] = [
|
|||
},
|
||||
#elseif($column.htmlType == "datetime")## 时间框
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
#elseif($column.htmlType == "textarea")## 文本域
|
||||
component: 'InputTextArea',
|
||||
#end
|
||||
|
@ -154,7 +160,7 @@ export const updateFormSchema: FormSchema[] = [
|
|||
#set ($javaField = $column.javaField)
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set ($comment = $column.columnComment)
|
||||
#if (!$column.primaryKey)## 忽略主键,不用在表单里
|
||||
#if (!$column.primaryKey)## 忽略主键,不用在表单里
|
||||
{
|
||||
label: '${comment}',
|
||||
field: '${javaField}',
|
||||
|
@ -164,45 +170,57 @@ export const updateFormSchema: FormSchema[] = [
|
|||
#if ($column.htmlType == "input")
|
||||
component: 'Input',
|
||||
#elseif($column.htmlType == "imageUpload")## 图片上传
|
||||
component: 'Upload',
|
||||
component: 'FileUpload',
|
||||
componentProps: {
|
||||
fileType: 'image',
|
||||
maxCount: 1,
|
||||
},
|
||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||
component: 'Upload',
|
||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||
component: 'Editor',
|
||||
component: 'FileUpload',
|
||||
componentProps: {
|
||||
fileType: 'file',
|
||||
maxCount: 1,
|
||||
},
|
||||
#elseif($column.htmlType == "editor")## 文本编辑器component: 'Editor',
|
||||
#elseif($column.htmlType == "select")## 下拉框
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
#if ("" != $dictType)## 有数据字典
|
||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
||||
#else##没数据字典
|
||||
options:[],
|
||||
options:[],
|
||||
#end
|
||||
},
|
||||
#elseif($column.htmlType == "checkbox")## 多选框
|
||||
component: 'Checkbox',
|
||||
componentProps: {
|
||||
#if ("" != $dictType)## 有数据字典
|
||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
||||
#else##没数据字典
|
||||
options:[],
|
||||
options:[],
|
||||
#end
|
||||
},
|
||||
#elseif($column.htmlType == "radio")## 单选框
|
||||
component: 'RadioButtonGroup',
|
||||
componentProps: {
|
||||
#if ("" != $dictType)## 有数据字典
|
||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'),
|
||||
#else##没数据字典
|
||||
options:[],
|
||||
options:[],
|
||||
#end
|
||||
},
|
||||
#elseif($column.htmlType == "datetime")## 时间框
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
#elseif($column.htmlType == "textarea")## 文本域
|
||||
component: 'InputTextArea',
|
||||
#end
|
||||
},
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
]
|
|
@ -9,9 +9,10 @@ import { create${simpleClassName}, get${simpleClassName}, update${simpleClassNam
|
|||
|
||||
defineOptions({ name: '${table.className}Modal' })
|
||||
|
||||
const emit = defineEmits(['success', 'register'])
|
||||
|
||||
const { t } = useI18n()
|
||||
const { createMessage } = useMessage()
|
||||
const emit = defineEmits(['success', 'register'])
|
||||
const isUpdate = ref(true)
|
||||
|
||||
const [registerForm, { setFieldsValue, resetFields, resetSchema, validate }] = useForm({
|
||||
|
@ -37,11 +38,11 @@ async function handleSubmit() {
|
|||
try {
|
||||
const values = await validate()
|
||||
setModalProps({ confirmLoading: true })
|
||||
if (unref(isUpdate)) {
|
||||
if (unref(isUpdate))
|
||||
await update${simpleClassName}(values)
|
||||
} else {
|
||||
else
|
||||
await create${simpleClassName}(values)
|
||||
}
|
||||
|
||||
closeModal()
|
||||
emit('success')
|
||||
createMessage.success(t('common.saveSuccessText'))
|
||||
|
@ -51,7 +52,7 @@ async function handleSubmit() {
|
|||
}
|
||||
</script>
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="isUpdate ? t('action.edit') : t('action.create')" @ok="handleSubmit">
|
||||
<BasicModal v-bind="$attrs" :title="isUpdate ? t('action.edit') : t('action.create')" @register="registerModal" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
|
@ -1,12 +1,12 @@
|
|||
<script lang="ts" setup>
|
||||
import ${simpleClassName}Modal from './${simpleClassName}Modal.vue'
|
||||
import ${ simpleClassName }Modal from './${simpleClassName}Modal.vue'
|
||||
import { columns, searchFormSchema } from './${classNameVar}.data'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { useMessage } from '@/hooks/web/useMessage'
|
||||
import { useModal } from '@/components/Modal'
|
||||
import { IconEnum } from '@/enums/appEnum'
|
||||
import { BasicTable, useTable, TableAction } from '@/components/Table'
|
||||
import { delete${simpleClassName}, export${simpleClassName}, get${simpleClassName}Page } from '@/api/${table.moduleName}/${classNameVar}'
|
||||
import { delete${ simpleClassName }, export${ simpleClassName }, get${ simpleClassName } Page } from '@/api/${table.moduleName}/${classNameVar}'
|
||||
|
||||
defineOptions({ name: '${table.className}' })
|
||||
|
||||
|
@ -16,17 +16,17 @@ const [registerModal, { openModal }] = useModal()
|
|||
|
||||
const [registerTable, { getForm, reload }] = useTable({
|
||||
title: '${table.classComment}列表',
|
||||
api: get${simpleClassName}Page,
|
||||
columns,
|
||||
formConfig: { labelWidth: 120, schemas: searchFormSchema },
|
||||
useSearchForm: true,
|
||||
showTableSetting: true,
|
||||
actionColumn: {
|
||||
width: 140,
|
||||
title: t('common.action'),
|
||||
dataIndex: 'action',
|
||||
fixed: 'right',
|
||||
},
|
||||
api: get${ simpleClassName }Page,
|
||||
columns,
|
||||
formConfig: { labelWidth: 120, schemas: searchFormSchema },
|
||||
useSearchForm: true,
|
||||
showTableSetting: true,
|
||||
actionColumn: {
|
||||
width: 140,
|
||||
title: t('common.action'),
|
||||
dataIndex: 'action',
|
||||
fixed: 'right',
|
||||
},
|
||||
})
|
||||
|
||||
function handleCreate() {
|
||||
|
@ -43,14 +43,14 @@ async function handleExport() {
|
|||
iconType: 'warning',
|
||||
content: t('common.exportMessage'),
|
||||
async onOk() {
|
||||
await export${simpleClassName}(getForm().getFieldsValue())
|
||||
await export${ simpleClassName } (getForm().getFieldsValue())
|
||||
createMessage.success(t('common.exportSuccessText'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(record: Recordable) {
|
||||
await delete${simpleClassName}(record.id)
|
||||
await delete${ simpleClassName } (record.id)
|
||||
createMessage.success(t('common.delSuccessText'))
|
||||
reload()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue