111 lines
2.8 KiB
Plaintext
111 lines
2.8 KiB
Plaintext
import { reactive } from 'vue'
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
|
|
import { DICT_TYPE } from '@/utils/dict'
|
|
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 }],
|
|
#end
|
|
#end
|
|
})
|
|
// CrudSchema
|
|
const crudSchemas = reactive<CrudSchema[]>([
|
|
#foreach($column in $columns)
|
|
#if ($column.listOperation || $column.listOperationResult || $column.createOperation || $column.updateOperation)
|
|
#set ($dictType = $column.dictType)
|
|
{
|
|
label: '${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
|
|
},
|
|
#elseif(!("" != $column.dictType))
|
|
form: {
|
|
show: true,
|
|
#if ($column.htmlType == "datetime")## 时间框
|
|
component: 'DatePicker',
|
|
componentProps: {
|
|
type: 'datetime',
|
|
valueFormat: 'YYYY-MM-DD HH:mm:ss'
|
|
}
|
|
#elseif($column.htmlType == "editor")## 文本编辑器
|
|
component: 'Editor',
|
|
colProps: {
|
|
span: 24
|
|
},
|
|
componentProps: {
|
|
valueHtml: ''
|
|
}
|
|
#elseif($column.htmlType == "textarea")## 文本框
|
|
component: 'Input',
|
|
componentProps: {
|
|
type: 'textarea',
|
|
rows: 4
|
|
},
|
|
colProps: {
|
|
span: 24
|
|
}
|
|
#end
|
|
},
|
|
#end
|
|
#if ($column.listOperationResult)
|
|
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'
|
|
}
|
|
#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
|
|
{
|
|
label: t('table.action'),
|
|
field: 'action',
|
|
width: '240px',
|
|
form: {
|
|
show: false
|
|
},
|
|
detail: {
|
|
show: false
|
|
}
|
|
}
|
|
])
|
|
|
|
export const { allSchemas } = useCrudSchemas(crudSchemas) |