Browse Source

优化

master
陈裕财 2 years ago
parent
commit
b73fd7fbbe
  1. 5
      src/views/mdp/form/formDef/Form.vue
  2. 44
      src/views/mdp/form/source/Index.vue

5
src/views/mdp/form/formDef/Form.vue

@ -58,7 +58,7 @@
</el-row> </el-row>
</template> </template>
</mdp-dialog> </mdp-dialog>
<mdp-dialog refs="sourceDialog">
<mdp-dialog ref="sourceDialog">
<template v-slot="{visible,data,dialog}"> <template v-slot="{visible,data,dialog}">
<mdp-source :form-def="editForm" :form-fields="formFields"></mdp-source> <mdp-source :form-def="editForm" :form-fields="formFields"></mdp-source>
</template> </template>
@ -71,11 +71,12 @@ import * as FormDefApi from '@/api/mdp/form/formDef';
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { MdpFormMixin } from '@/components/mdp-ui/mixin/MdpFormMixin.js'; import { MdpFormMixin } from '@/components/mdp-ui/mixin/MdpFormMixin.js';
import FormField from '../formField/Index' import FormField from '../formField/Index'
import MdpSource from '../source/Index'
export default { export default {
name:'formDefForm', name:'formDefForm',
mixins:[MdpFormMixin], mixins:[MdpFormMixin],
components: { components: {
FormField
FormField,MdpSource
}, },
computed: { computed: {
pkOptions(){ pkOptions(){

44
src/views/mdp/form/source/Index.vue

@ -1,6 +1,6 @@
<template> <template>
<section> <section>
<div v-text="createSource()"></div>
<pre><code>{{createSource()}}</code></pre>
</section> </section>
</template> </template>
@ -8,10 +8,7 @@
import treeTool from '@/components/mdp-ui/js/treeTool.js' import treeTool from '@/components/mdp-ui/js/treeTool.js'
export default { export default {
computed: {
...mapGetters([
'userInfo'
])
computed: {
}, },
props:{ props:{
visible:{ visible:{
@ -165,23 +162,48 @@ export default {
var sourceStr=""; var sourceStr="";
this.fields=treeTool.translateDataToTree(this.formFields,'pid','id') this.fields=treeTool.translateDataToTree(this.formFields,'pid','id')
this.fields.forEach(f=>{ this.fields.forEach(f=>{
sourceStr="<start>"+this.createSubSource(f.children)+"</end>"
if(!f.children || f.children.length==0){
sourceStr=sourceStr+
"\n<start field-name="+f.title+">"+
"\n</end>"
}else{
sourceStr=sourceStr+
"\n<start field-name="+f.title+">\n"+
"\t"+this.createSubSource(1,f.children)+
"\n</end>"
}
}) })
return sourceStr; return sourceStr;
}, },
createSubSource(children){
createSubSource(lvl,children){
var sourceStr="" var sourceStr=""
if(!children || children.length==0){ if(!children || children.length==0){
return sourceStr; return sourceStr;
}else{
} }
children.forEach(f=>{ children.forEach(f=>{
sourceStr=sourceStr+"<start>"+this.createSubSource(f.children)+"</end>"
if( !f.children || f.children.length==0){
sourceStr=sourceStr+"\n"+
this.getTabByLvl(lvl)+"<start field-name='"+f.title+"'>\n"+
this.getTabByLvl(lvl)+"</end>"
}else{
sourceStr=sourceStr+"\n"+
this.getTabByLvl(lvl)+"<start field-name='"+f.title+"'>\n"+
this.getTabByLvl(lvl+1)+this.createSubSource(lvl+1,f.children)+"\n"+
this.getTabByLvl(lvl)+"</end>"
}
}) })
return sourceStr; return sourceStr;
}
},
getTabByLvl(lvl){
var str=""
for(var i=0;i<lvl;i++){
str=str+"\t"
}
return str
}
},//end method },//end method
components: { components: {
}, },

Loading…
Cancel
Save