| | |
| | | <template> |
| | | <avue-input-tree ref="referTree" :props="props" :disabled="disabled" :lazy="lazy" :tree-load="treeLoad" :node-click="nodeClick" :checked="checked" :blur="valueChange" :leaf-only="referConfig.onlyLeaf" :multiple="isMuti" v-model="value" :placeholder="title" :dic="treeData"></avue-input-tree> |
| | | <avue-input-tree ref="referTree" :props="props" :disabled="disabled" :lazy="lazy" :tree-load="treeLoad" :node-click="nodeClick" :checked="checked" |
| | | :leaf-only="referConfig.onlyLeaf" :multiple="isMuti" v-model="value" :placeholder="title" :dic="treeData"></avue-input-tree> |
| | | </template> |
| | | |
| | | <script> |
| | |
| | | props:["referConfig","value","text","title","disabled"], |
| | | data() { |
| | | return { |
| | | visible: false, |
| | | options: this.referConfig.options, |
| | | lazy: this.referConfig.options.loadType == 'node', |
| | | isMuti:("true" == this.referConfig.options.isMuti || this.referConfig.options.isMuti == true || this.referConfig.options.muti == true) ? true : false, |
| | |
| | | |
| | | }, |
| | | getTree() { |
| | | //加载全部 |
| | | getTree(this.params, this.treeUrl).then(res => { |
| | | res.data.map(item => { |
| | | if (!item.attribute) { |
| | | item.attribute = { |
| | | if (!item.attributes) { |
| | | item.attributes = { |
| | | data: {} |
| | | } |
| | | } else { |
| | | item.attribute.data = item.attribute.data || {} |
| | | item.attributes.data = item.attributes.data || {} |
| | | } |
| | | return { |
| | | ...item, |
| | |
| | | }) |
| | | }, |
| | | treeLoad: function (treeNode, resolve) { |
| | | //逐级加载 |
| | | const parentOid = (treeNode.level === 0) ? 0 : treeNode.data.oid; |
| | | this.params.parentOid=parentOid.indexOf('@vcitreesep@') > -1 ? parentOid.split('@vcitreesep@')[1] : parentOid; |
| | | this.params.parentValue=this.params.parentOid; |
| | |
| | | } |
| | | getLazyTree(this.params,this.treeUrl).then(res => { |
| | | resolve(res.data.data.map(item => { |
| | | if(!item.attribute){ |
| | | item.attribute={ |
| | | if(!item.attributes){ |
| | | item.attributes={ |
| | | data:{} |
| | | } |
| | | }else{ |
| | | item.attribute.data=item.attribute.data || {} |
| | | item.attributes.data=item.attributes.data || {} |
| | | } |
| | | return { |
| | | ...item, |
| | |
| | | } |
| | | }, |
| | | checked(checkedNode, checkedData) { |
| | | this.checkedData=checkedData |
| | | }, |
| | | valueChange(){ |
| | | if(this.isMuti){ |
| | | // this.setValue(this.checkedData) |
| | | } |
| | | this.setValue(checkedData) |
| | | }, |
| | | setValue:function (checkedData){ |
| | | this.checkedData=checkedData |
| | | var value = []; |
| | | var text = []; |
| | | const textSep =this.config.textSep; |
| | |
| | | fieldMap:mapFields |
| | | }); |
| | | } |
| | | }, |
| | | watch:{} |
| | | } |
| | | } |
| | | </script> |
| | | |