提交 | 用户 | 时间
|
e7c126
|
1 |
import type {BasicColumn, FormSchema} from '@/components/Table' |
H |
2 |
import {useRender} from '@/components/Table' |
|
3 |
import {DICT_TYPE, getDictOptions} from '@/utils/dict' |
|
4 |
|
|
5 |
export const columns: BasicColumn[] = [ |
|
6 |
#foreach($column in $columns) |
|
7 |
#if ($column.listOperationResult) |
|
8 |
#set ($dictType=$column.dictType) |
|
9 |
#set ($javaField = $column.javaField) |
|
10 |
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
|
11 |
#set ($comment=$column.columnComment) |
|
12 |
#if ($column.javaType == "LocalDateTime")## 时间类型 |
|
13 |
{ |
|
14 |
title: '${comment}', |
|
15 |
dataIndex: '${javaField}', |
|
16 |
width: 180, |
|
17 |
customRender: ({ text }) => { |
|
18 |
return useRender.renderDate(text) |
|
19 |
}, |
|
20 |
}, |
|
21 |
#elseif("" != $column.dictType)## 数据字典 |
|
22 |
{ |
|
23 |
title: '${comment}', |
|
24 |
dataIndex: '${javaField}', |
|
25 |
width: 180, |
|
26 |
customRender: ({ text }) => { |
|
27 |
return useRender.renderDict(text, DICT_TYPE.$dictType.toUpperCase()) |
|
28 |
}, |
|
29 |
}, |
|
30 |
#else |
|
31 |
{ |
|
32 |
title: '${comment}', |
|
33 |
dataIndex: '${javaField}', |
|
34 |
width: 160, |
|
35 |
}, |
|
36 |
#end |
|
37 |
#end |
|
38 |
#end |
|
39 |
] |
|
40 |
|
|
41 |
export const searchFormSchema: FormSchema[] = [ |
|
42 |
#foreach($column in $columns) |
|
43 |
#if ($column.listOperation) |
|
44 |
#set ($dictType=$column.dictType) |
|
45 |
#set ($javaField = $column.javaField) |
|
46 |
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
|
47 |
#set ($comment=$column.columnComment) |
|
48 |
{ |
|
49 |
label: '${comment}', |
|
50 |
field: '${javaField}', |
|
51 |
#if ($column.htmlType == "input") |
|
52 |
component: 'Input', |
|
53 |
#elseif ($column.htmlType == "select") |
|
54 |
component: 'Select', |
|
55 |
componentProps: { |
|
56 |
#if ("" != $dictType)## 设置了 dictType 数据字典的情况 |
|
57 |
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase()), |
|
58 |
#else## 未设置 dictType 数据字典的情况 |
|
59 |
options: [], |
|
60 |
#end |
|
61 |
}, |
|
62 |
#elseif ($column.htmlType == "radio") |
|
63 |
component: 'Radio', |
|
64 |
componentProps: { |
|
65 |
#if ("" != $dictType)## 设置了 dictType 数据字典的情况 |
|
66 |
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase()), |
|
67 |
#else## 未设置 dictType 数据字典的情况 |
|
68 |
options: [], |
|
69 |
#end |
|
70 |
}, |
|
71 |
#elseif($column.htmlType == "datetime") |
|
72 |
component: 'RangePicker', |
|
73 |
#end |
|
74 |
colProps: { span: 8 }, |
|
75 |
}, |
|
76 |
#end |
|
77 |
#end |
|
78 |
] |
|
79 |
|
|
80 |
export const createFormSchema: FormSchema[] = [ |
|
81 |
{ |
|
82 |
label: '编号', |
|
83 |
field: 'id', |
|
84 |
show: false, |
|
85 |
component: 'Input', |
|
86 |
}, |
|
87 |
#foreach($column in $columns) |
|
88 |
#if ($column.createOperation) |
|
89 |
#set ($dictType = $column.dictType) |
|
90 |
#set ($javaField = $column.javaField) |
|
91 |
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
|
92 |
#set ($comment = $column.columnComment) |
|
93 |
#if (!$column.primaryKey)## 忽略主键,不用在表单里 |
|
94 |
{ |
|
95 |
label: '${comment}', |
|
96 |
field: '${javaField}', |
|
97 |
#if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 |
|
98 |
required: true, |
|
99 |
#end |
|
100 |
#if ($column.htmlType == "input") |
|
101 |
component: 'Input', |
|
102 |
#elseif($column.htmlType == "imageUpload")## 图片上传 |
|
103 |
component: 'FileUpload', |
|
104 |
componentProps: { |
|
105 |
fileType: 'image', |
|
106 |
maxCount: 1, |
|
107 |
}, |
|
108 |
#elseif($column.htmlType == "fileUpload")## 文件上传 |
|
109 |
component: 'FileUpload', |
|
110 |
componentProps: { |
|
111 |
fileType: 'file', |
|
112 |
maxCount: 1, |
|
113 |
}, |
|
114 |
#elseif($column.htmlType == "editor")## 文本编辑器 |
|
115 |
component: 'Editor', |
|
116 |
#elseif($column.htmlType == "select")## 下拉框 |
|
117 |
component: 'Select', |
|
118 |
componentProps: { |
|
119 |
#if ("" != $dictType)## 有数据字典 |
|
120 |
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), |
|
121 |
#else##没数据字典 |
|
122 |
options:[], |
|
123 |
#end |
|
124 |
}, |
|
125 |
#elseif($column.htmlType == "checkbox")## 多选框 |
|
126 |
component: 'Checkbox', |
|
127 |
componentProps: { |
|
128 |
#if ("" != $dictType)## 有数据字典 |
|
129 |
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), |
|
130 |
#else##没数据字典 |
|
131 |
options:[], |
|
132 |
#end |
|
133 |
}, |
|
134 |
#elseif($column.htmlType == "radio")## 单选框 |
|
135 |
component: 'RadioButtonGroup', |
|
136 |
componentProps: { |
|
137 |
#if ("" != $dictType)## 有数据字典 |
|
138 |
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), |
|
139 |
#else##没数据字典 |
|
140 |
options:[], |
|
141 |
#end |
|
142 |
}, |
|
143 |
#elseif($column.htmlType == "datetime")## 时间框 |
|
144 |
component: 'DatePicker', |
|
145 |
componentProps: { |
|
146 |
showTime: true, |
|
147 |
format: 'YYYY-MM-DD HH:mm:ss', |
|
148 |
valueFormat: 'x', |
|
149 |
}, |
|
150 |
#elseif($column.htmlType == "textarea")## 文本域 |
|
151 |
component: 'InputTextArea', |
|
152 |
#end |
|
153 |
}, |
|
154 |
#end |
|
155 |
#end |
|
156 |
#end |
|
157 |
] |
|
158 |
|
|
159 |
export const updateFormSchema: FormSchema[] = [ |
|
160 |
{ |
|
161 |
label: '编号', |
|
162 |
field: 'id', |
|
163 |
show: false, |
|
164 |
component: 'Input', |
|
165 |
}, |
|
166 |
#foreach($column in $columns) |
|
167 |
#if ($column.updateOperation) |
|
168 |
#set ($dictType = $column.dictType) |
|
169 |
#set ($javaField = $column.javaField) |
|
170 |
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
|
171 |
#set ($comment = $column.columnComment) |
|
172 |
#if (!$column.primaryKey)## 忽略主键,不用在表单里 |
|
173 |
{ |
|
174 |
label: '${comment}', |
|
175 |
field: '${javaField}', |
|
176 |
#if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 |
|
177 |
required: true, |
|
178 |
#end |
|
179 |
#if ($column.htmlType == "input") |
|
180 |
component: 'Input', |
|
181 |
#elseif($column.htmlType == "imageUpload")## 图片上传 |
|
182 |
component: 'FileUpload', |
|
183 |
componentProps: { |
|
184 |
fileType: 'image', |
|
185 |
maxCount: 1, |
|
186 |
}, |
|
187 |
#elseif($column.htmlType == "fileUpload")## 文件上传 |
|
188 |
component: 'FileUpload', |
|
189 |
componentProps: { |
|
190 |
fileType: 'file', |
|
191 |
maxCount: 1, |
|
192 |
}, |
|
193 |
#elseif($column.htmlType == "editor")## 文本编辑器 |
|
194 |
component: 'Editor', |
|
195 |
#elseif($column.htmlType == "select")## 下拉框 |
|
196 |
component: 'Select', |
|
197 |
componentProps: { |
|
198 |
#if ("" != $dictType)## 有数据字典 |
|
199 |
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), |
|
200 |
#else##没数据字典 |
|
201 |
options:[], |
|
202 |
#end |
|
203 |
}, |
|
204 |
#elseif($column.htmlType == "checkbox")## 多选框 |
|
205 |
component: 'Checkbox', |
|
206 |
componentProps: { |
|
207 |
#if ("" != $dictType)## 有数据字典 |
|
208 |
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), |
|
209 |
#else##没数据字典 |
|
210 |
options:[], |
|
211 |
#end |
|
212 |
}, |
|
213 |
#elseif($column.htmlType == "radio")## 单选框 |
|
214 |
component: 'RadioButtonGroup', |
|
215 |
componentProps: { |
|
216 |
#if ("" != $dictType)## 有数据字典 |
|
217 |
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), 'number'), |
|
218 |
#else##没数据字典 |
|
219 |
options:[], |
|
220 |
#end |
|
221 |
}, |
|
222 |
#elseif($column.htmlType == "datetime")## 时间框 |
|
223 |
component: 'DatePicker', |
|
224 |
componentProps: { |
|
225 |
showTime: true, |
|
226 |
format: 'YYYY-MM-DD HH:mm:ss', |
|
227 |
valueFormat: 'x', |
|
228 |
}, |
|
229 |
#elseif($column.htmlType == "textarea")## 文本域 |
|
230 |
component: 'InputTextArea', |
|
231 |
#end |
|
232 |
}, |
|
233 |
#end |
|
234 |
#end |
|
235 |
#end |
|
236 |
] |