data.ts.vm 7.9 KB

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