SlcCheck.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <div class="bigBox">
  3. <div class="header">
  4. <h1>{{ flashName + '——' + scdName + '——SLC效验' }}</h1>
  5. </div>
  6. <div class="main">
  7. <div class="treeBox">
  8. <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick" />
  9. </div>
  10. <div class="tableBox">
  11. <div class="allMis">
  12. <el-button type="primary" plain>导出所有结果</el-button>
  13. <el-button style="margin-right: 10px;" type="primary" plain>导出当前节点结果</el-button>
  14. <span style="margin-right: 10px;">全部:{{ errorNum - 0 + warningNum - 0 }}</span>
  15. <span style="margin-right: 10px;">错误:<em style="color: red;">{{ errorNum ? errorNum : 0 }}</em></span>
  16. <span style="margin-right: 10px;">告警:<em style="color: green;">{{ warningNum ? warningNum : 0 }}</em></span>
  17. </div>
  18. <div class="table">
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import { ref, onMounted, toRefs, watch, reactive } from "vue"
  26. import scd from "@/api/scd";
  27. import slc from "@/api/slc/slc"
  28. import systemRow from "@/api/systemRow";
  29. import Pagnation from "../utils/Pagnation.vue";
  30. import { ElMessage, ElLoading } from "element-plus";
  31. export default {
  32. props: {
  33. nowScdId: {
  34. type: String,
  35. required: true
  36. }
  37. },
  38. setup(props, { emit }) {
  39. let scdid = ref('')//scdid
  40. let scdName = ref('')//scd名称
  41. let flashName = ref("")//变电站名称
  42. let treeData = ref([
  43. // {
  44. // label: "1号主变差动",
  45. // children: [],
  46. // pids: '6871',
  47. // name: "area"
  48. // }, {
  49. // label: '一号主变本体',
  50. // children: [],
  51. // pids: "6875",
  52. // name: "area"
  53. // }, {
  54. // label: "公用",
  55. // children: [],
  56. // pids: "6890",
  57. // name: "area"
  58. // }, {
  59. // label: "SCL",
  60. // pids: "572000161",
  61. // children: [],
  62. // name: "SCL"
  63. // }
  64. ])//tree数据
  65. let defaultProps = ref({
  66. label: "title",
  67. id: "id",
  68. pids: "pid",
  69. children: "children",
  70. area: "area_id"
  71. })
  72. let errorNum = ref(0)
  73. let warningNum = ref(0)
  74. watch(() => props.nowScdId, (newVal) => {
  75. scdid.value = newVal
  76. })
  77. let indexs = 0
  78. function reload() {
  79. scdid.value = props.nowScdId
  80. let loading = ElLoading.service({
  81. text: "等待数据中",
  82. lock: true,
  83. background: "rgba(0, 0, 0, 0.7)"
  84. })
  85. Promise.all([
  86. scd.getScdById({ scd_id: scdid.value - 0 }),//获取scd详细信息scd1
  87. slc.getAllMission({ scd_id: scdid.value - 0 }),//slc1
  88. slc.getErrorByLevel({ scd_id: scdid.value - 0 }),//获取报错总数slc2
  89. slc.getScdByIdFromMission({ pageno: 1, pagesize: 20, scd_id: scdid.value - 0 }),//slc3
  90. slc.getScdByIdTree({ scd_id: scdid.value - 0 }),//获取tree数据slc4
  91. systemRow.getChildren({ code: "voltage_level" })
  92. ]).then(([scd1, slc1, slc2, slc3, slc4, flash]) => {
  93. if (scd1.data != null) {
  94. scdName.value = scd1.data.scd_name
  95. flashName.value = scd1.data.station_name
  96. }
  97. if (slc4.data != null) {
  98. treeData.value = slc4.data
  99. }
  100. if (slc2.data != null) {
  101. errorNum.value = slc2.data[0].cnt//错误
  102. warningNum.value = slc2.data[1].cnt//告警
  103. }
  104. // treeData.value[3].children = slc4.data.slice(0, 3).map(item => {
  105. // return {
  106. // label: item.title,
  107. // id: item.id,
  108. // pids: item.pid
  109. // }
  110. // })
  111. // let a = slc4.data.map(item => {
  112. // return flash.data.find(param => item.voltage_level - 0 === param.id - 0);
  113. // })
  114. // a = a.filter((item, index, arr) => item !== undefined && arr.indexOf(item) === index);
  115. // a.forEach(item => {
  116. // // 判断 treeData.value[3].children 是否已经存在相同的元素
  117. // const existingItem = treeData.value[3].children.find(child => child.id === item.id);
  118. // if (!existingItem) {
  119. // // 如果不存在相同元素,则将当前项插入到 children 中
  120. // treeData.value[3].children.splice(indexs, 0, {
  121. // label: item.name,
  122. // id: item.id,
  123. // });
  124. // indexs++; // 插入位置后移
  125. // }
  126. // });
  127. loading.close()
  128. })
  129. }
  130. function handleNodeClick(e) {
  131. console.log(e, 'hand');
  132. }
  133. onMounted(() => {
  134. reload()
  135. })
  136. return {
  137. scdid,//scdid
  138. reload,//初始化组件
  139. scdName,//scd名称
  140. flashName,//变电站名称
  141. treeData,//树形数据
  142. defaultProps,//树形展示
  143. handleNodeClick,//树形每行点击
  144. errorNum,//错误数量
  145. warningNum,//告警数量
  146. }
  147. },
  148. components: {
  149. Pagnation,
  150. }
  151. }
  152. </script>
  153. <style scoped>
  154. em{
  155. font-style: normal;
  156. }
  157. .bigBox {
  158. width: 97%;
  159. height: calc(100vh - 200px);
  160. margin-left: 18px;
  161. }
  162. .header {
  163. width: 100%;
  164. height: auto;
  165. text-align: center;
  166. }
  167. .main {
  168. width: 100%;
  169. height: calc(100vh - 260px);
  170. margin: 0 auto;
  171. border: 1px solid salmon;
  172. display: flex;
  173. justify-content: space-around;
  174. align-items: center;
  175. }
  176. .treeBox {
  177. width: 20%;
  178. height: calc(100vh - 260px);
  179. overflow-y: auto;
  180. overflow-x: hidden;
  181. }
  182. .tableBox {
  183. width: 80%;
  184. height: calc(100vh - 260px);
  185. }
  186. </style>