data.ts.vm 6.1 KB

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