data.ts.vm 6.6 KB

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