提交 | 用户 | 时间
|
e7c126
|
1 |
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
H |
2 |
import { dateFormatter } from '@/utils/formatTime' |
|
3 |
|
|
4 |
// 表单校验 |
|
5 |
export const rules = reactive({ |
|
6 |
#foreach ($column in $columns) |
|
7 |
#if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 |
|
8 |
#set($comment=$column.columnComment) |
|
9 |
$column.javaField: [required], |
|
10 |
#end |
|
11 |
#end |
|
12 |
}) |
|
13 |
|
|
14 |
// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/ |
|
15 |
const crudSchemas = reactive<CrudSchema[]>([ |
|
16 |
#foreach($column in $columns) |
|
17 |
#if ($column.listOperation || $column.listOperationResult || $column.createOperation || $column.updateOperation) |
|
18 |
#set ($dictType = $column.dictType) |
|
19 |
#set ($javaField = $column.javaField) |
|
20 |
#set ($javaType = $column.javaType) |
|
21 |
{ |
|
22 |
label: '${column.columnComment}', |
|
23 |
field: '${column.javaField}', |
|
24 |
## ========= 字典部分 ========= |
|
25 |
#if ("" != $dictType)## 有数据字典 |
|
26 |
dictType: DICT_TYPE.$dictType.toUpperCase(), |
|
27 |
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") |
|
28 |
dictClass: 'number', |
|
29 |
#elseif ($javaType == "String") |
|
30 |
dictClass: 'string', |
|
31 |
#elseif ($javaType == "Boolean") |
|
32 |
dictClass: 'boolean', |
|
33 |
#end |
|
34 |
#end |
|
35 |
## ========= Table 表格部分 ========= |
|
36 |
#if (!$column.listOperationResult) |
|
37 |
isTable: false, |
|
38 |
#else |
|
39 |
#if ($column.htmlType == "datetime") |
|
40 |
formatter: dateFormatter, |
|
41 |
#end |
|
42 |
#end |
|
43 |
## ========= Search 表格部分 ========= |
|
44 |
#if ($column.listOperation) |
|
45 |
isSearch: true, |
|
46 |
#if ($column.htmlType == "datetime") |
|
47 |
search: { |
|
48 |
component: 'DatePicker', |
|
49 |
componentProps: { |
|
50 |
valueFormat: 'YYYY-MM-DD HH:mm:ss', |
|
51 |
type: 'daterange', |
|
52 |
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] |
|
53 |
} |
|
54 |
}, |
|
55 |
#end |
|
56 |
#end |
|
57 |
## ========= Form 表单部分 ========= |
|
58 |
#if ((!$column.createOperation && !$column.updateOperation) || $column.primaryKey) |
|
59 |
isForm: false, |
|
60 |
#else |
|
61 |
#if($column.htmlType == "imageUpload")## 图片上传 |
|
62 |
form: { |
|
63 |
component: 'UploadImg' |
|
64 |
}, |
|
65 |
#elseif($column.htmlType == "fileUpload")## 文件上传 |
|
66 |
form: { |
|
67 |
component: 'UploadFile' |
|
68 |
}, |
|
69 |
#elseif($column.htmlType == "editor")## 文本编辑器 |
|
70 |
form: { |
|
71 |
component: 'Editor', |
|
72 |
componentProps: { |
|
73 |
valueHtml: '', |
|
74 |
height: 200 |
|
75 |
} |
|
76 |
}, |
|
77 |
#elseif($column.htmlType == "select")## 下拉框 |
|
78 |
form: { |
|
79 |
component: 'SelectV2' |
|
80 |
}, |
|
81 |
#elseif($column.htmlType == "checkbox")## 多选框 |
|
82 |
form: { |
|
83 |
component: 'Checkbox' |
|
84 |
}, |
|
85 |
#elseif($column.htmlType == "radio")## 单选框 |
|
86 |
form: { |
|
87 |
component: 'Radio' |
|
88 |
}, |
|
89 |
#elseif($column.htmlType == "datetime")## 时间框 |
|
90 |
form: { |
|
91 |
component: 'DatePicker', |
|
92 |
componentProps: { |
|
93 |
type: 'datetime', |
|
94 |
valueFormat: 'x' |
|
95 |
} |
|
96 |
}, |
|
97 |
#elseif($column.htmlType == "textarea")## 文本框 |
|
98 |
form: { |
|
99 |
component: 'Input', |
|
100 |
componentProps: { |
|
101 |
type: 'textarea', |
|
102 |
rows: 4 |
|
103 |
}, |
|
104 |
colProps: { |
|
105 |
span: 24 |
|
106 |
} |
|
107 |
}, |
|
108 |
#elseif(${javaType.toLowerCase()} == "long" || ${javaType.toLowerCase()} == "integer")## 文本框 |
|
109 |
form: { |
|
110 |
component: 'InputNumber', |
|
111 |
value: 0 |
|
112 |
}, |
|
113 |
#end |
|
114 |
#end |
|
115 |
}, |
|
116 |
#end |
|
117 |
#end |
|
118 |
{ |
|
119 |
label: '操作', |
|
120 |
field: 'action', |
|
121 |
isForm: false |
|
122 |
} |
|
123 |
]) |
|
124 |
export const { allSchemas } = useCrudSchemas(crudSchemas) |