57235859c61ac3ac8223777951445fc8816d81ef.svn-base 10 KB

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