mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-17 04:25:06 +08:00
feat: vue3 codegen
This commit is contained in:
@ -1,51 +1,51 @@
|
||||
import { reactive } from 'vue'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
|
||||
import { DICT_TYPE } from '@/utils/dict'
|
||||
import { required } from '@/utils/formRules'
|
||||
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
|
||||
const { t } = useI18n() // 国际化
|
||||
// 表单校验
|
||||
export const rules = reactive({
|
||||
#foreach ($column in $columns)
|
||||
#if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
|
||||
#set($comment=$column.columnComment)
|
||||
$column.javaField: [{ required: true, message: '${comment}不能为空', trigger: #if($column.htmlType == "select")'change'#else'blur'#end }],
|
||||
$column.javaField: [required],
|
||||
#end
|
||||
#end
|
||||
})
|
||||
// CrudSchema
|
||||
const crudSchemas = reactive<CrudSchema[]>([
|
||||
const crudSchemas = reactive<VxeCrudSchema>({
|
||||
primaryKey: 'id', // 默认的主键ID
|
||||
primaryTitle: t('common.index'), // 默认显示的值
|
||||
primaryType: 'seq', // 默认为seq,序号模式
|
||||
action: true,
|
||||
actionWidth: '200', // 3个按钮默认200,如有删减对应增减即可
|
||||
columns: [
|
||||
#foreach($column in $columns)
|
||||
#if ($column.listOperation || $column.listOperationResult || $column.createOperation || $column.updateOperation)
|
||||
#set ($dictType = $column.dictType)
|
||||
#if(!$column.primaryKey)
|
||||
{
|
||||
label: '${column.columnComment}',
|
||||
title: '${column.columnComment}',
|
||||
field: '${column.javaField}',
|
||||
#if ("" != $dictType)## 有数据字典
|
||||
dictType: DICT_TYPE.$dictType.toUpperCase(),
|
||||
#end
|
||||
#if($column.primaryKey)
|
||||
type: 'index',
|
||||
form: {
|
||||
show: false
|
||||
},
|
||||
detail: {
|
||||
show: false
|
||||
}
|
||||
#else
|
||||
#if (!$column.createOperation && !$column.updateOperation)
|
||||
form: {
|
||||
show: false
|
||||
},
|
||||
isForm: false
|
||||
#elseif(!("" != $column.dictType))
|
||||
#if ($column.htmlType == "datetime")## 时间框
|
||||
form: {
|
||||
show: true,
|
||||
#if ($column.htmlType == "datetime")## 时间框
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
type: 'datetime',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss'
|
||||
}
|
||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||
}
|
||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||
form: {
|
||||
show: true,
|
||||
component: 'Editor',
|
||||
colProps: {
|
||||
span: 24
|
||||
@ -53,7 +53,10 @@ const crudSchemas = reactive<CrudSchema[]>([
|
||||
componentProps: {
|
||||
valueHtml: ''
|
||||
}
|
||||
#elseif($column.htmlType == "textarea")## 文本框
|
||||
}
|
||||
#elseif($column.htmlType == "textarea")## 文本框
|
||||
form: {
|
||||
show: true,
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
type: 'textarea',
|
||||
@ -62,50 +65,27 @@ const crudSchemas = reactive<CrudSchema[]>([
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
#end
|
||||
},
|
||||
}
|
||||
#end
|
||||
#end
|
||||
#if ($column.listOperationResult)
|
||||
#if($column.htmlType == "input")
|
||||
isSearch: true
|
||||
#elseif("" != $dictType)
|
||||
isSearch: true
|
||||
#elseif($column.htmlType == "datetime")
|
||||
search: {
|
||||
#if($column.htmlType == "input")
|
||||
show: true
|
||||
#else
|
||||
#if($column.htmlType == "datetime")
|
||||
show: true,
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
type: 'datetimerange',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss'
|
||||
itemRender: {
|
||||
name: 'XDataTimePicker'
|
||||
}
|
||||
#elseif($column.htmlType == "select" || $column.htmlType == "radio")
|
||||
#if ("" == $dictType)## 没有数据字典
|
||||
show: true,
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
option: [{'','请选择字典生成'}]
|
||||
}
|
||||
#else
|
||||
show: true
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
#end
|
||||
#end
|
||||
{
|
||||
label: t('table.action'),
|
||||
field: 'action',
|
||||
width: '240px',
|
||||
form: {
|
||||
show: false
|
||||
},
|
||||
detail: {
|
||||
show: false
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
||||
]
|
||||
})
|
||||
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
|
Reference in New Issue
Block a user