7e7006194b8916a6cd3e6d2681a794c05735d0bd.svn-base 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div class="tb_left_tree">
  3. <!-- <div class="date_wrapper">年度:-->
  4. <!-- <el-select v-model="year" placeholder="请选择">-->
  5. <!-- <el-option-->
  6. <!-- v-for="item in yearList"-->
  7. <!-- :key="item.id"-->
  8. <!-- :label="item.year"-->
  9. <!-- :value="item.year">-->
  10. <!-- </el-option>-->
  11. <!-- </el-select>-->
  12. <!-- </div>-->
  13. <span style="display: flex;justify-content: center;align-items: center;border-bottom: 1px solid #ebeef5;">
  14. <el-button size="mini" :class="tabType==1 ? 'active' : 'normal'" @click="tabChange('1')">当前数据</el-button>
  15. <!-- <el-button size="mini" :class="tabType==2 ? 'active' : 'normal'" @click="tabChange('2')">历史数据</el-button>-->
  16. <el-button size="mini" :class="tabType==0 ? 'active' : 'normal'" @click="tabChange('0')">全部数据</el-button>
  17. </span>
  18. <div class="tree" style="
  19. height: calc(100% - 50px);
  20. width: 100%;
  21. overflow: auto;
  22. display: inline-flex;">
  23. <el-tree
  24. :highlight-current="true"
  25. :data="treeData"
  26. node-key="id"
  27. :expand-on-click-node="false"
  28. @node-click = 'treeNodeClickHandler'
  29. ref="jigou_tree"
  30. >
  31. <div class="custom-tree-node" slot-scope="{ node, data }">
  32. <span style="float:left;">{{ data.pnm}}</span>
  33. </div>
  34. </el-tree>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import request from '@util/gw_ajax_request.js'
  40. import {getTrees} from '@util/gw_formatTree'
  41. import {getYearList} from '@api/jcOneMapApi'
  42. export default {
  43. props: ['orgType'],
  44. data(){
  45. return{
  46. treeData: [],
  47. lyjg: [],
  48. yearList: [],
  49. year: '',
  50. tabType:"0",//0全部数据,1当前数据,2历史数据
  51. }
  52. },
  53. computed: {
  54. persId() {
  55. return localStorage.getItem("userid")
  56. ? localStorage.getItem("userid")
  57. : "1098101939614724096";
  58. },
  59. },
  60. mounted(){
  61. this.getLeftTreeData()
  62. },
  63. methods:{
  64. tabChange(tabType){
  65. this.tabType = tabType;
  66. this.getLeftTreeData();
  67. this.$emit('changeTabType',tabType)
  68. },
  69. getYearlists(){
  70. getYearList().then(res=>{
  71. this.yearList = res.data;
  72. let lastItemIndex = this.yearList.length - 1
  73. this.year = this.yearList[lastItemIndex].year
  74. })
  75. },
  76. getLeftTreeData(){
  77. var _self = this;
  78. _self.lyjg = [];
  79. request.get('/dc/organization/base/getAllNode',{params:{'userId':this.persId,'orgType':this.orgType,'tabType':this.tabType}}).then((res)=>{
  80. let data = res.data
  81. data.forEach(ele => {
  82. if(ele.pid == null || ele.pid == ''){
  83. ele.pid = '001'
  84. }
  85. if(ele.id.length == 6){
  86. _self.lyjg.push(ele);
  87. }
  88. });
  89. this.$emit('organList',_self.lyjg)
  90. data = getTrees(data)
  91. _self.treeData = data;
  92. console.log(data);
  93. })
  94. },
  95. treeNodeClickHandler:function(data,node,tree){
  96. this.$emit('treeNodeClickHandler',data)
  97. },
  98. },
  99. watch:{
  100. year(val){
  101. if(val){
  102. this.getLeftTreeData()
  103. this.$emit('changeYear',val)
  104. }
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .tb_left_tree{
  111. height: 100%;
  112. width: 100%;
  113. overflow: auto;
  114. .date_wrapper{
  115. padding: 10px 0 5px 10px;
  116. }
  117. }
  118. .active{
  119. background: #3f8eff;
  120. color:white;
  121. margin-top: 5px;
  122. margin-bottom: 5px;
  123. }
  124. .normal{
  125. background: white;
  126. margin-top: 5px;
  127. margin-bottom: 5px;
  128. }
  129. </style>