1d4fd5dfb64660e9314c7564d8e5554a4d0f3cbe.svn-base 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <#include "/common/utils.ftl">
  2. <#list subTables as sub>
  3. <#if sub.foreignRelationType=='1'>
  4. #segment#${sub.entityName}Form.vue
  5. <template>
  6. <j-form-container :disabled="disabled">
  7. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  8. <a-row>
  9. <#assign form_popup = false>
  10. <#assign form_cat_tree = false>
  11. <#assign form_cat_back = "">
  12. <#assign form_span = 24>
  13. <#if tableVo.fieldRowNum == 2>
  14. <#assign form_span = 12>
  15. <#elseif tableVo.fieldRowNum==3>
  16. <#assign form_span = 8>
  17. <#elseif tableVo.fieldRowNum==4>
  18. <#assign form_span = 6>
  19. </#if>
  20. <#list sub.colums as po>
  21. <#if po.isShow =='Y' && po.fieldName != 'id'>
  22. <#assign form_field_dictCode="">
  23. <#if po.dictTable?default("")?trim?length gt 1 && po.dictText?default("")?trim?length gt 1 && po.dictField?default("")?trim?length gt 1>
  24. <#assign form_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
  25. <#elseif po.dictField?default("")?trim?length gt 1>
  26. <#assign form_field_dictCode="${po.dictField}">
  27. </#if>
  28. <#if po.classType =='textarea'>
  29. <a-col :span="24">
  30. <a-form-model-item label="${po.filedComment}" :labelCol="labelCol2" :wrapperCol="wrapperCol2" prop="${autoStringSuffixForModel(po)}">
  31. <#else>
  32. <a-col :span="${form_span}">
  33. <a-form-model-item label="${po.filedComment}" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="${autoStringSuffixForModel(po)}">
  34. </#if>
  35. <#if po.classType =='date'>
  36. <j-date placeholder="请选择${po.filedComment}" v-model="model.${po.fieldName}" style="width: 100%"/>
  37. <#elseif po.classType =='datetime'>
  38. <j-date placeholder="请选择${po.filedComment}" v-model="model.${po.fieldName}" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%"/>
  39. <#elseif po.classType =='time'>
  40. <j-time placeholder="请选择${po.filedComment}" v-model="model.${po.fieldName}" style="width: 100%" <#if po.readonly=='Y'>disabled</#if>/>
  41. <#elseif po.classType =='popup'>
  42. <#assign form_popup=true>
  43. <j-popup
  44. v-model="model.${po.fieldName}"
  45. field="${po.fieldName}"
  46. org-fields="${po.dictField}"
  47. dest-fields="${Format.underlineToHump(po.dictText)}"
  48. code="${po.dictTable}"
  49. :multi="${po.extendParams.popupMulti?c}"
  50. @input="popupCallback"/>
  51. <#elseif po.classType =='sel_depart'>
  52. <j-select-depart v-model="model.${po.fieldName}" multi/>
  53. <#elseif po.classType =='switch'>
  54. <j-switch v-model="model.${po.fieldName}" <#if po.dictField!= 'is_open'>:options="${po.dictField}"</#if>></j-switch>
  55. <#elseif po.classType =='pca'>
  56. <j-area-linkage type="cascader" v-model="model.${po.fieldName}" placeholder="请输入省市区"/>
  57. <#elseif po.classType =='markdown'>
  58. <j-markdown-editor v-model="model.${autoStringSuffixForModel(po)}" id="${po.fieldName}"></j-markdown-editor>
  59. <#elseif po.classType =='password'>
  60. <a-input-password v-model="model.${po.fieldName}" placeholder="请输入${po.filedComment}"/>
  61. <#elseif po.classType =='sel_user'>
  62. <j-select-user-by-dep v-model="model.${po.fieldName}"/>
  63. <#elseif po.classType =='textarea'>
  64. <a-textarea v-model="model.${autoStringSuffixForModel(po)}" rows="4" placeholder="请输入${po.filedComment}"/>
  65. <#elseif po.classType=='list' || po.classType=='radio'>
  66. <j-dict-select-tag type="${po.classType}" v-model="model.${po.fieldName}" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
  67. <#elseif po.classType=='list_multi' || po.classType=='checkbox'>
  68. <j-multi-select-tag type="${po.classType}" v-model="model.${po.fieldName}" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}"/>
  69. <#elseif po.classType=='sel_search'>
  70. <j-search-select-tag v-model="model.${po.fieldName}" dict="${form_field_dictCode}" />
  71. <#elseif po.classType=='cat_tree'>
  72. <#assign form_cat_tree = true>
  73. <j-category-select v-model="model.${po.fieldName}" pcode="${po.dictField?default("")}" placeholder="请选择${po.filedComment}" <#if po.dictText?default("")?trim?length gt 1>back="${dashedToCamel(po.dictText)}" @change="handleCategoryChange"</#if>/>
  74. <#if po.dictText?default("")?trim?length gt 1>
  75. <#assign form_cat_back = "${po.dictText}">
  76. </#if>
  77. <#elseif po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
  78. <a-input-number v-model="model.${po.fieldName}" placeholder="请输入${po.filedComment}" style="width: 100%"/>
  79. <#elseif po.classType=='file'>
  80. <j-upload v-model="model.${po.fieldName}"></j-upload>
  81. <#elseif po.classType=='image'>
  82. <j-image-upload isMultiple v-model="model.${po.fieldName}"></j-image-upload>
  83. <#elseif po.classType=='umeditor'>
  84. <j-editor v-model="model.${autoStringSuffixForModel(po)}"/>
  85. <#elseif po.fieldDbType=='Blob'>
  86. <a-input v-model="model.${autoStringSuffixForModel(po)}" placeholder="请输入${po.filedComment}"></a-input>
  87. <#else>
  88. <a-input v-model="model.${po.fieldName}" placeholder="请输入${po.filedComment}"></a-input>
  89. </#if>
  90. </a-form-model-item>
  91. </a-col>
  92. </#if>
  93. </#list>
  94. </a-row>
  95. </a-form-model>
  96. </j-form-container>
  97. </template>
  98. <script>
  99. import { getAction } from '@/api/manage'
  100. import { validateDuplicateValue } from '@/utils/util'
  101. import { VALIDATE_NO_PASSED } from '@/utils/JEditableTableUtil'
  102. export default {
  103. name: '${sub.entityName}Form',
  104. components: {
  105. },
  106. props:{
  107. disabled: {
  108. type: Boolean,
  109. default: false,
  110. required: false
  111. }
  112. },
  113. data () {
  114. return {
  115. model:{
  116. <#include "/common/init/initValueSub.ftl">
  117. },
  118. labelCol: {
  119. xs: { span: 24 },
  120. sm: { span: 6 },
  121. },
  122. wrapperCol: {
  123. xs: { span: 24 },
  124. sm: { span: 16 },
  125. },
  126. labelCol2: {
  127. xs: { span: 24 },
  128. sm: { span: 3 },
  129. },
  130. wrapperCol2: {
  131. xs: { span: 24 },
  132. sm: { span: 20 },
  133. },
  134. <#include "/common/validatorRulesTemplate/sub.ftl">
  135. confirmLoading: false,
  136. }
  137. },
  138. created () {
  139. //备份model原始值
  140. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  141. },
  142. methods:{
  143. initFormData(url,id){
  144. this.clearFormData()
  145. if(!id){
  146. this.edit(this.modelDefault)
  147. }else{
  148. getAction(url,{id:id}).then(res=>{
  149. if(res.success){
  150. let records = res.result
  151. if(records && records.length>0){
  152. this.edit(records[0])
  153. }
  154. }
  155. })
  156. }
  157. },
  158. edit(record){
  159. this.model = Object.assign({}, record)
  160. console.log("${sub.entityName}Form-edit",this.model);
  161. },
  162. getFormData(){
  163. let formdata_arr = []
  164. this.$refs.form.validate(valid => {
  165. if (valid) {
  166. let isNullObj = true
  167. Object.keys(this.model).forEach(key=>{
  168. if(this.model[key]){
  169. isNullObj = false
  170. }
  171. })
  172. if(!isNullObj){
  173. formdata_arr.push(this.model)
  174. }
  175. }else{
  176. this.$emit("validateError","${sub.ftlDescription}表单校验未通过");
  177. }
  178. })
  179. return formdata_arr;
  180. },
  181. validate(index){
  182. return new Promise((resolve, reject) => {
  183. // 验证主表表单
  184. this.$refs.form.validate(valid => {
  185. !valid ? reject({ error: VALIDATE_NO_PASSED ,index}) : resolve()
  186. })
  187. }).then(values => {
  188. return Promise.resolve()
  189. }).catch(error => {
  190. return Promise.reject(error)
  191. })
  192. },
  193. <#if form_popup>
  194. popupCallback(value,row){
  195. this.model = Object.assign(this.model, row);
  196. },
  197. </#if>
  198. clearFormData(){
  199. this.$refs.form.clearValidate()
  200. },
  201. <#if form_cat_tree>
  202. handleCategoryChange(value,backObj){
  203. this.model = Object.assign(backObj,this.model);
  204. }
  205. </#if>
  206. }
  207. }
  208. </script>
  209. </#if>
  210. </#list>