data.ts.vm 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import { BasicColumn, FormSchema, useRender } from '@/components/Table'
  2. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  3. export const columns: BasicColumn[] = [
  4. #foreach($column in $columns)
  5. #if ($column.listOperationResult)
  6. #set ($dictType=$column.dictType)
  7. #set ($javaField = $column.javaField)
  8. #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  9. #set ($comment=$column.columnComment)
  10. #if ($column.javaType == "LocalDateTime")## 时间类型
  11. {
  12. title: '${comment}',
  13. dataIndex: '${javaField}',
  14. width: 180,
  15. customRender: ({ text }) => {
  16. return useRender.renderDate(text)
  17. }
  18. },
  19. #elseif("" != $column.dictType)## 数据字典
  20. {
  21. title: '${comment}',
  22. dataIndex: '${javaField}',
  23. width: 180,
  24. customRender: ({ text }) => {
  25. return useRender.renderDict(text, DICT_TYPE.$dictType.toUpperCase())
  26. }
  27. },
  28. #else
  29. {
  30. title: '${comment}',
  31. dataIndex: '${javaField}',
  32. width: 160
  33. },
  34. #end
  35. #end
  36. #end
  37. ]
  38. export const searchFormSchema: FormSchema[] = [
  39. #foreach($column in $columns)
  40. #if ($column.listOperation)
  41. #set ($dictType=$column.dictType)
  42. #set ($javaField = $column.javaField)
  43. #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  44. #set ($comment=$column.columnComment)
  45. {
  46. label: '${comment}',
  47. field: '${javaField}',
  48. #if ($column.htmlType == "input")
  49. component: 'Input',
  50. #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
  51. component: 'Select',
  52. componentProps: {
  53. #if ("" != $dictType)## 设置了 dictType 数据字典的情况
  54. #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
  55. #set ($dictMethod = "getIntDictOptions")
  56. #elseif ($javaType == "String")
  57. #set ($dictMethod = "getStrDictOptions")
  58. #elseif ($javaType == "Boolean")
  59. #set ($dictMethod = "getBoolDictOptions")
  60. #end
  61. options: $dictMethod(DICT_TYPE.$dictType.toUpperCase())
  62. #else## 未设置 dictType 数据字典的情况
  63. options: []
  64. #end
  65. },
  66. #elseif($column.htmlType == "datetime")
  67. component: 'RangePicker',
  68. #end
  69. colProps: { span: 8 }
  70. },
  71. #end
  72. #end
  73. ]
  74. export const createFormSchema: FormSchema[] = [
  75. {
  76. label: '编号',
  77. field: 'id',
  78. show: false,
  79. component: 'Input'
  80. },
  81. #foreach($column in $columns)
  82. #if ($column.createOperation)
  83. #set ($dictType = $column.dictType)
  84. #set ($javaField = $column.javaField)
  85. #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  86. #set ($comment = $column.columnComment)
  87. #if (!$column.primaryKey)## 忽略主键,不用在表单里
  88. {
  89. label: '${comment}',
  90. field: '${javaField}',
  91. #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
  92. required: true,
  93. #end
  94. #if ($column.htmlType == "input")
  95. component: 'Input'
  96. #elseif($column.htmlType == "imageUpload")## 图片上传
  97. component: 'Upload'
  98. #elseif($column.htmlType == "fileUpload")## 文件上传
  99. component: 'Upload'
  100. #elseif($column.htmlType == "editor")## 文本编辑器
  101. component: 'InputTextArea'
  102. #elseif($column.htmlType == "select")## 下拉框
  103. component: 'Select',
  104. componentProps: {
  105. #if ("" != $dictType)## 有数据字典
  106. #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
  107. #set ($dictMethod = "getIntDictOptions")
  108. #elseif ($javaType == "String")
  109. #set ($dictMethod = "getStrDictOptions")
  110. #elseif ($javaType == "Boolean")
  111. #set ($dictMethod = "getBoolDictOptions")
  112. #end
  113. options: $dictMethod(DICT_TYPE.$dictType.toUpperCase())
  114. #else##没数据字典
  115. options:[]
  116. #end
  117. }
  118. #elseif($column.htmlType == "checkbox")## 多选框
  119. component: 'Checkbox',
  120. componentProps: {
  121. #if ("" != $dictType)## 有数据字典
  122. options: getIntDictOptions(DICT_TYPE.COMMON_STATUS)
  123. #else##没数据字典
  124. options:[]
  125. #end
  126. }
  127. #elseif($column.htmlType == "radio")## 单选框
  128. component: 'Radio',
  129. componentProps: {
  130. #if ("" != $dictType)## 有数据字典
  131. options: getIntDictOptions(DICT_TYPE.COMMON_STATUS)
  132. #else##没数据字典
  133. options:[]
  134. #end
  135. }
  136. #elseif($column.htmlType == "datetime")## 时间框
  137. component: 'DatePicker'
  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: 'Upload'
  170. #elseif($column.htmlType == "fileUpload")## 文件上传
  171. component: 'Upload'
  172. #elseif($column.htmlType == "editor")## 文本编辑器
  173. component: 'Editor'
  174. #elseif($column.htmlType == "select")## 下拉框
  175. component: 'Select',
  176. componentProps: {
  177. #if ("" != $dictType)## 有数据字典
  178. #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
  179. #set ($dictMethod = "getIntDictOptions")
  180. #elseif ($javaType == "String")
  181. #set ($dictMethod = "getStrDictOptions")
  182. #elseif ($javaType == "Boolean")
  183. #set ($dictMethod = "getBoolDictOptions")
  184. #end
  185. options: $dictMethod(DICT_TYPE.$dictType.toUpperCase())
  186. #else##没数据字典
  187. options:[]
  188. #end
  189. }
  190. #elseif($column.htmlType == "checkbox")## 多选框
  191. component: 'Checkbox',
  192. componentProps: {
  193. #if ("" != $dictType)## 有数据字典
  194. options: getIntDictOptions(DICT_TYPE.COMMON_STATUS)
  195. #else##没数据字典
  196. options:[]
  197. #end
  198. }
  199. #elseif($column.htmlType == "radio")## 单选框
  200. component: 'Radio',
  201. componentProps: {
  202. #if ("" != $dictType)## 有数据字典
  203. options: getIntDictOptions(DICT_TYPE.COMMON_STATUS)
  204. #else##没数据字典
  205. options:[]
  206. #end
  207. }
  208. #elseif($column.htmlType == "datetime")## 时间框
  209. component: 'DatePicker'
  210. #elseif($column.htmlType == "textarea")## 文本域
  211. component: 'InputTextArea'
  212. #end
  213. },
  214. #end
  215. #end
  216. #end
  217. ]