| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <template>
- <el-tree
- highlight-current
- class="el-treeWhite"
- :data="treeData"
- :props="treeProps"
- :expand-on-click-node="false"
- @node-click="nodeClick"
- node-key="id"
- :default-expanded-keys="tableDefaultExpandedKeys"
- lazy
- :load="loadAddvData"
- style="max-height:100%;overflow:auto;"
- ></el-tree>
- </template>
- <script>
- import { getOrgByPid } from "../api/duChaAPI.js";
- export default {
- components: {},
- props:['rootCode'],
- data() {
- return {
- treeData: [],
- tableDefaultExpandedKeys: [],
- treeProps: {
- label: "name",
- children: "children",
- disabled: false,
- expandOnClickNode: false ,
- first:true,
- }
- };
- },
- mounted: function() {
- this.loadTreeListData();
- },
- methods: {
- loadTreeListData:function(){
- if(this.rootCode&&this.rootCode!=''){
- getOrgByPid(this.rootCode).then((res) =>{
- console.log(res);
- let children = [];
- res.data.forEach((element,index)=>{
- children.push({
- 'code':element.orgId,
- 'name':element.orgNm
- })
- });
- this.treeData = children;
- // if(children.length && children[0].code != '11' && children[0].code != '12'){
- // this.$emit("provTreeSelectChange", { code:children[0].code, name: children[0].name});
- // }
- },(err) =>{});
- }else{
- getOrgByPid("").then((res) =>{
- console.log(res);
- let children = [];
- res.data.forEach((element,index)=>{
- children.push({
- 'code':element.orgId,
- 'name':element.orgNm
- })
- });
- this.treeData = children;
- },(err) =>{});
- }
- },
- nodeClick: function(data) {
- // alert(data.code+data.name+data.type);
- this.$emit("provTreeSelectChange", { code:data.code, name: data.name});
- },
- loadAddvData: function(node, resolve) {
- var _self = this;
- try {
- if(this.treeProps.first){
- this.treeProps.first = false;
- }else{
- getOrgByPid(node.data.code).then(
- response => {
- var data = response.data;
- let children = [];
- response.data.forEach((element,index)=>{
- children.push({
- 'code':element.orgId,
- 'name':element.orgNm
- })
- });
- resolve(children);
- },
- response => {}
- );
- }
- } catch (e) {
- }
- },
- }
- };
- </script>
- <style scoped>
- /deep/.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
- background-color: #beceeb;
- }
- </style>
|