addForm.vue.vm 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <ant-modal
  3. modalWidth="${modalWidth}"
  4. modalHeight="${modalHeight}"
  5. :visible="open"
  6. :modal-title="formTitle"
  7. :adjust-size="true"
  8. @cancel="cancel"
  9. >
  10. #if(${colSpans} == '1')
  11. #set($colSpanRoot = 24)
  12. #elseif(${colSpans} == '2')
  13. #set($colSpanRoot = 12)
  14. #elseif(${colSpans} == '3')
  15. #set($colSpanRoot = 8)
  16. #elseif(${colSpans} == '4')
  17. #set($colSpanRoot = 6)
  18. #else
  19. #set($colSpanRoot = 12)
  20. #end
  21. <a-form-model ref="form" :model="form" :rules="rules" slot="content" layout="vertical">
  22. <a-row :gutter="32">
  23. <a-col :lg="${colSpanRoot}" :md="${colSpanRoot}" :sm="24">
  24. <a-form-model-item label="上级节点" prop="parentId">
  25. <a-tree-select
  26. v-model="form.parentId"
  27. style="width: 100%"
  28. :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
  29. :tree-data="${businessName}Options"
  30. placeholder="请选择"
  31. :replaceFields="{ children: 'children', title: '${treeName}', key: 'id', value: 'id' }"
  32. tree-default-expand-all
  33. >
  34. </a-tree-select>
  35. </a-form-model-item>
  36. </a-col>
  37. </a-row>
  38. <a-row :gutter="32">
  39. #foreach($column in $editColumns)
  40. #set( $listSize = $!{editColumns.size()})
  41. #set( $next = $!velocityCount - 2 )
  42. #set($dictType=$column.dictType)
  43. #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  44. #set($parentheseIndex=$column.columnComment.indexOf("("))
  45. #if($parentheseIndex != -1)
  46. #set($comment=$column.columnComment.substring(0, $parentheseIndex))
  47. #else
  48. #set($comment=$column.columnComment)
  49. #end
  50. ##这里根据不同新行概念而定,如果需要选择新行后独占一行则开启注释部分
  51. ###if($column.isNewRow == '1' && $velocityCount !=1 && ($next>=0 && $editColumns.get($next).isNewRow != '1'))
  52. ## </a-row>
  53. ## <a-row :gutter="32">
  54. ###end
  55. #if(${colSpans} == '1')
  56. #set($colSpan = $column.colSpan * 24)
  57. #elseif(${colSpans} == '2')
  58. #set($colSpan = $column.colSpan * 12)
  59. #elseif(${colSpans} == '3')
  60. #set($colSpan = $column.colSpan * 8)
  61. #elseif(${colSpans} == '4')
  62. #set($colSpan = $column.colSpan * 6)
  63. #else
  64. #set($colSpan = $column.colSpan * 12)
  65. #end
  66. #if($column.htmlType == "input")
  67. <a-col :span="${colSpan}">
  68. <a-form-model-item label="${comment}" prop="${column.javaField}">
  69. <a-input v-model="form.${column.javaField}" placeholder="请输入${comment}"/>
  70. </a-form-model-item>
  71. </a-col>
  72. #elseif($column.htmlType == "textarea")
  73. <a-col :span="${colSpan}">
  74. <a-form-model-item label="${comment}" prop="${column.javaField}">
  75. <a-textarea v-model="form.${column.javaField}" placeholder="请输入${comment}" :rows="4"/>
  76. </a-form-model-item>
  77. </a-col>
  78. #elseif(($column.htmlType == "number"))
  79. <a-col :span="${colSpan}">
  80. <a-form-model-item label="${comment}" prop="${column.javaField}">
  81. <a-input-number v-model="form.${column.javaField}" :min="0" style="width: 100%"/>
  82. </a-form-model-item>
  83. </a-col>
  84. #elseif(($column.htmlType == "datetime"))
  85. <a-col :span="${colSpan}">
  86. <a-form-model-item label="${comment}" prop="${column.javaField}">
  87. <a-date-picker
  88. v-model="form.${column.javaField}"
  89. valueFormat="YYYY-MM-DD"
  90. :show-today="true"
  91. placeholder="选择日期"
  92. style="width: 100%"
  93. />
  94. </a-form-model-item>
  95. </a-col>
  96. #elseif(($column.htmlType == "time"))
  97. <a-col :span="${colSpan}" >
  98. <a-form-model-item label="${comment}" prop="${column.javaField}">
  99. <a-date-picker
  100. v-model="form.${column.javaField}"
  101. valueFormat="YYYY-MM-DD"
  102. :show-today="true"
  103. placeholder="选择日期"
  104. style="width: 100%"
  105. />
  106. </a-form-model-item>
  107. </a-col>
  108. #elseif(($column.htmlType == "select") && "" != $dictType)
  109. <a-col :span="${colSpan}" >
  110. <a-form-model-item label="${comment}" prop="${column.javaField}">
  111. <a-select
  112. placeholder="请选择${comment}"
  113. v-model="form.${column.javaField}"
  114. :getPopupContainer="
  115. triggerNode => {
  116. return triggerNode.parentNode || document.body
  117. }
  118. "
  119. style="width: 100%"
  120. allow-clear>
  121. <a-select-option v-for="(d, index) in ${column.javaField}Options" :key="index" :value="d.dictValue">{{ d.dictLabel }}</a-select-option>
  122. </a-select>
  123. </a-form-model-item>
  124. </a-col>
  125. #elseif(($column.htmlType == "selectMultiple") && "" != $dictType)
  126. <a-col :span="${colSpan}" >
  127. <a-form-model-item label="${comment}" prop="${column.javaField}">
  128. <a-select
  129. placeholder="请选择${comment}"
  130. v-model="form.${column.javaField}"
  131. :getPopupContainer="
  132. triggerNode => {
  133. return triggerNode.parentNode || document.body
  134. }
  135. "
  136. style="width: 100%"
  137. mode="multiple"
  138. allow-clear>
  139. <a-select-option v-for="(dict, index) in ${column.javaField}Options" :key="index" :value="dict.dictValue">{{ dict.dictLabel }}</a-select-option>
  140. </a-select>
  141. </a-form-model-item>
  142. </a-col>
  143. #elseif(($column.htmlType == "radioButton") && "" != $dictType)
  144. <a-col :span="${colSpan}" >
  145. <a-form-model-item label="${comment}" prop="${column.javaField}">
  146. <a-radio-group v-model="form.${column.javaField}" button-style="solid">
  147. <a-radio-button
  148. v-for="(dict, index) in ${column.javaField}Options"
  149. :key="index"
  150. :value="dict.dictValue"
  151. >
  152. {{ dict.dictLabel }}
  153. </a-radio-button>
  154. </a-radio-group>
  155. </a-form-model-item>
  156. </a-col>
  157. #elseif(($column.htmlType == "radio") && "" != $dictType)
  158. <a-col :span="${colSpan}" >
  159. <a-form-model-item label="${comment}" prop="${column.javaField}">
  160. <a-radio-group v-model="form.${column.javaField}">
  161. <a-radio
  162. v-for="(dict, index) in ${column.javaField}Options"
  163. :key="index"
  164. :value="dict.dictValue"
  165. >
  166. {{ dict.dictLabel }}
  167. </a-radio>
  168. </a-radio-group>
  169. </a-form-model-item>
  170. </a-col>
  171. #elseif(($column.htmlType == "checkbox") && "" != $dictType)
  172. <a-col :span="${colSpan}" >
  173. <a-form-model-item label="${comment}" prop="${column.javaField}">
  174. <a-checkbox-group v-model="form.${column.javaField}" button-style="solid">
  175. <a-checkbox
  176. v-for="(dict, index) in ${column.javaField}Options"
  177. :key="index"
  178. :value="dict.dictValue"
  179. >
  180. {{ dict.dictLabel }}
  181. </a-checkbox >
  182. </a-checkbox-group>
  183. </a-form-model-item>
  184. </a-col>
  185. #elseif(($column.htmlType == "user"))
  186. <a-col :span="${colSpan}" >
  187. <a-form-model-item label="${comment}" prop="${column.javaField}">
  188. <select-user
  189. v-model="form.${column.javaField}"
  190. select-model="single"
  191. />
  192. </a-form-model-item>
  193. </a-col>
  194. #elseif(($column.htmlType == "dept"))
  195. <a-col :span="${colSpan}" >
  196. <a-form-model-item label="${comment}" prop="${column.javaField}">
  197. <select-dept
  198. v-model="form.${column.javaField}"
  199. select-model="single"
  200. select-scope="all"
  201. />
  202. </a-form-model-item>
  203. </a-col>
  204. #end
  205. #if($column.isNewRow == '1' && $listSize != $!velocityCount)
  206. </a-row>
  207. <a-row :gutter="32">
  208. #end
  209. #end
  210. #if($hasAttach)
  211. <a-col :lg="24" :md="24" :sm="24">
  212. <a-form-model-item label="附件">
  213. <sys-upload
  214. key="1"
  215. element-id="1"
  216. form-type="add"
  217. :drag-uploader="true"
  218. :multiple="true"
  219. :file-size-limit="40"
  220. :ref="attachmentRefName"
  221. :allow-encry="false"
  222. :allow-same-name="false"
  223. :allow-preview="true"
  224. :allow-download="true"
  225. :allow-delete="true"
  226. :chunk-enabled="true"
  227. :colspan="2"
  228. :form-id="formId"
  229. :file-num-limit="10"
  230. table-name="${tableName}"
  231. @afterUpload="uploadCompleteFile"
  232. />
  233. </a-form-model-item>
  234. </a-col>
  235. #end
  236. </a-row>
  237. </a-form-model>
  238. <template slot="footer">
  239. <a-button :disabled="disabled" @click="cancel">
  240. 取消
  241. </a-button>
  242. <a-button type="primary" :disabled="disabled" @click="submitForm(true)">
  243. 保存
  244. </a-button>
  245. #if($hasSaveAndAddOption)
  246. <a-button type="primary" :disabled="disabled" @click="submitForm(false)">
  247. 保存并继续添加
  248. </a-button>
  249. #end
  250. </template>
  251. </ant-modal>
  252. </template>
  253. <script>
  254. import ${BusinessName}AddForm from './${BusinessName}Form'
  255. export default {
  256. ...${BusinessName}AddForm
  257. }
  258. </script>