addForm.vue.vm 8.4 KB

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