refactor: codegen

This commit is contained in:
xingyu4j
2022-11-23 13:59:13 +08:00
parent b1a2dfb09b
commit 7ff6db9ac7
8 changed files with 227 additions and 281 deletions

View File

@ -1,7 +1,7 @@
import { reactive } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { required } from '@/utils/formRules'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
const { t } = useI18n() // 国际化
// 表单校验
@ -12,54 +12,45 @@ export const rules = reactive({
})
// CrudSchema
const crudSchemas = reactive<CrudSchema[]>([
{
label: t('common.index'),
field: 'id',
type: 'index',
isForm: false,
isDetail: false
},
{
label: '表名称',
field: 'tableName',
isSearch: true
},
{
label: '表描述',
field: 'tableComment',
isSearch: true
},
{
label: '实体',
field: 'className',
isSearch: true
},
{
label: t('common.createTime'),
field: 'createTime',
isForm: false,
search: {
show: true,
component: 'DatePicker',
componentProps: {
type: 'datetimerange',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]
const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: 'seq',
action: true,
actionWidth: '400px',
columns: [
{
title: '表名称',
field: 'tableName',
isSearch: true
},
{
title: '表描述',
field: 'tableComment',
isSearch: true
},
{
title: '实体',
field: 'className',
isSearch: true
},
{
title: t('common.createTime'),
field: 'createTime',
formatter: 'formatDate',
isForm: false,
search: {
show: true,
itemRender: {
name: 'XDataTimePicker'
}
}
},
{
title: t('common.updateTime'),
field: 'updateTime',
formatter: 'formatDate',
isForm: false
}
},
{
label: t('common.updateTime'),
field: 'updateTime',
isForm: false
},
{
label: t('table.action'),
field: 'action',
width: '350px',
isForm: false,
isDetail: false
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)