data.ts.vm 6.9 KB

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