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
@ -65,10 +86,7 @@ const crudSchemas = reactive<CrudSchema[]>([
form: { form: {
component: 'Radio' component: 'Radio'
}, },
#end #elseif($column.htmlType == "datetime")## 时间框
#end
#elseif(!("" != $column.dictType))
#if (${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdatetime")
form: { form: {
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
@ -87,29 +105,20 @@ const crudSchemas = reactive<CrudSchema[]>([
span: 24 span: 24
} }
}, },
#elseif(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer")## 数字类型 #elseif(${javaType.toLowerCase()} == "long" || ${javaType.toLowerCase()} == "integer")## 文本框
form: { form: {
component: 'InputNumber', component: 'InputNumber',
value: 0 value: 0
}, },
#end #end
#end #end
#if ($column.listOperation) },
#if($column.htmlType == "input") #end
isSearch: true, #end
#elseif("" != $dictType) {
isSearch: true, label: '操作',
#elseif($column.htmlType == "datetime") field: 'action',
formatter: 'formatDate', isForm: false
search: {
show: true,
itemRender: {
name: 'XDataTimePicker'
} }
},
#end
#end
},
#end
]) ])
export const { allSchemas } = useCrudSchemas(crudSchemas) export const { allSchemas } = useCrudSchemas(crudSchemas)