index_20240401153138.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!--
  2. *@description: 数据中心 数据分布
  3. *@author: yh Fu
  4. *@date: 2023-08-23 14:45:16
  5. *@version: V1.0.5
  6. -->
  7. <template>
  8. <!-- 右侧 -->
  9. <div class="rightbar" v-if="showSearch == true">
  10. <div class="forthis">
  11. <dv-border-box-13
  12. backgroundColor="rgba(12, 19, 38, .90)"
  13. style="padding-bottom: 1rem"
  14. >
  15. <img
  16. src="@/assets/images/integrated/light.png"
  17. style="width: 100%; margin-top: 0.4rem"
  18. />
  19. <div class="this-title">
  20. <span>数据分布</span>
  21. <dv-decoration-3
  22. style="width: 150px; height: 15px; margin-right: 1rem"
  23. />
  24. </div>
  25. <div class="i-list-con h-73">
  26. <div class="head-container tree-scrollbar" style="height: 39vh; overflow-y: auto">
  27. <el-tree :data="treeDept" :props="defaultProps" :expand-on-click-node="false"
  28. :filter-node-method="filterNode" ref="tree" node-key="id" :default-expanded-keys="[100]"
  29. @node-click="indentleftByDeptIdSetMarkersForParent" />
  30. </div>
  31. <div class="overflow-y" style="height: 34vh">
  32. <div id="data-chart" style="width: 100%; height: 34vh"></div>
  33. </div>
  34. </div>
  35. </dv-border-box-13>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import {treeselect} from "@/api/system/dept";
  41. export default {
  42. name:'Distribution',
  43. // 是否展示Flag 资源列表数据 当前资源索引
  44. props:['showSearch','deptGroupList','listCurrentIndex'],
  45. data() {
  46. return {
  47. treeDept:[],
  48. deptOptions:[],
  49. defaultProps: {
  50. children: "children",
  51. label: "label",
  52. },
  53. }
  54. },
  55. mounted(){
  56. this.getTreeselect();
  57. this.deptOptions = this.deptGroupList
  58. this.setDeptNum(this.deptOptions);
  59. },
  60. methods:{
  61. indentleftByDeptIdSetMarkersForParent(deptId){
  62. this.$emit('indentleftByDeptIdSetMarkersOfParent',deptId)
  63. },
  64. /**
  65. * deptList:树型结构集合
  66. * this.deptDataList:接口返回的数据项(统计用)
  67. * this.message:要展示在页面的数据项
  68. */
  69. setDeptNum(deptList){
  70. deptList.forEach((item, i) => {
  71. item.count = 0;
  72. item.label = item.label.indexOf('(') > -1 ? item.label.substring(0,item.label.indexOf('(')):item.label;
  73. this.deptGroupList.forEach((itemy, y) => {
  74. if(item.id==itemy.deptId){
  75. item.count=itemy.count
  76. }
  77. })
  78. if(item.hasOwnProperty("children")){
  79. this.setDeptNum(item.children)
  80. item.count = item.count+item.children.reduce((sum, itemz) => sum + itemz.count, 0);
  81. }
  82. item.label = item.label+"("+item.count+")";
  83. })
  84. this.treeDept = deptList;
  85. },
  86. getTreeselect() {
  87. treeselect().then((response) => {
  88. this.deptOptions = response.data;
  89. });
  90. },
  91. filterNode(value, data) {
  92. if (!value) return true;
  93. return data.label.indexOf(value) !== -1;
  94. },
  95. },
  96. }
  97. </script>