f778ebdaa7079a406ecbcf44d32ed59ffc3cad96.svn-base 8.5 KB

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