Vue3 CRUD Schema 模版,data 部分提交

This commit is contained in:
YunaiV 2023-04-10 23:20:38 +08:00
parent 9a5d7c8646
commit a65b8f63b7

View File

@ -1,4 +1,5 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
const { t } = useI18n() // 国际化 const { t } = useI18n() // 国际化
// 表单校验 // 表单校验
@ -21,9 +22,7 @@ const crudSchemas = reactive<CrudSchema[]>([
{ {
title: '${column.columnComment}', title: '${column.columnComment}',
field: '${column.javaField}', field: '${column.javaField}',
#if (!$column.listOperationResult) ## ========= 字典部分 =========
isTable: false,
#end
#if ("" != $dictType)## 有数据字典 #if ("" != $dictType)## 有数据字典
dictType: DICT_TYPE.$dictType.toUpperCase(), dictType: DICT_TYPE.$dictType.toUpperCase(),
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
@ -34,6 +33,28 @@ const crudSchemas = reactive<CrudSchema[]>([
dictClass: 'boolean', dictClass: 'boolean',
#end #end
#end #end
## ========= Table 表格部分 =========
#if (!$column.listOperationResult)
isTable: false,
#if ($column.htmlType == "datetime")
formatter: dateFormatter,
#end
#end
## ========= Search 表格部分 =========
#if ($column.listOperation)
isSearch: true,
#if ($column.htmlType == "datetime")
search: {
component: 'DatePicker',
componentProps: {
valueFormat: 'YYYY-MM-DD HH:mm:ss',
type: 'daterange',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
}
}
#end
#end
## ========= Form 表单部分 =========
#if ((!$column.createOperation && !$column.updateOperation) || $column.primaryKey) #if ((!$column.createOperation && !$column.updateOperation) || $column.primaryKey)
isForm: false, isForm: false,
#else #else
@ -64,52 +85,40 @@ const crudSchemas = reactive<CrudSchema[]>([
#elseif($column.htmlType == "checkbox")## 单选框 #elseif($column.htmlType == "checkbox")## 单选框
form: { form: {
component: 'Radio' component: 'Radio'
},
#elseif($column.htmlType == "datetime")## 时间框
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
},
#elseif($column.htmlType == "textarea")## 文本框
form: {
component: 'Input',
componentProps: {
type: 'textarea',
rows: 4
},
colProps: {
span: 24
}
},
#elseif(${javaType.toLowerCase()} == "long" || ${javaType.toLowerCase()} == "integer")## 文本框
form: {
component: 'InputNumber',
value: 0
}, },
#end #end
#end #end
#elseif(!("" != $column.dictType))
#if (${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdatetime")
form: {
component: 'DatePicker',
componentProps: {
type: 'datetime',
valueFormat: 'x'
}
},
#elseif($column.htmlType == "textarea")## 文本框
form: {
component: 'Input',
componentProps: {
type: 'textarea',
rows: 4
},
colProps: {
span: 24
}
},
#elseif(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer")## 数字类型
form: {
component: 'InputNumber',
value: 0
},
#end
#end
#if ($column.listOperation)
#if($column.htmlType == "input")
isSearch: true,
#elseif("" != $dictType)
isSearch: true,
#elseif($column.htmlType == "datetime")
formatter: 'formatDate',
search: {
show: true,
itemRender: {
name: 'XDataTimePicker'
}
},
#end
#end
}, },
#end #end
#end
{
label: '操作',
field: 'action',
isForm: false
}
]) ])
export const { allSchemas } = useCrudSchemas(crudSchemas) export const { allSchemas } = useCrudSchemas(crudSchemas)