6de3dd645545fe0ac1116cb99c88b8b7d09a150e.svn-base 9.0 KB

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