BoosterStation.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div class="booster-station">
  3. <div class="btn-group-tabs">
  4. <BtnGroup2
  5. :btnGroups="btnGroups"
  6. :rowIndex="rowIndex"
  7. :index="selectIndex"
  8. @select="select"
  9. ></BtnGroup2>
  10. </div>
  11. <!-- <bsx6 class="booster-station-body"></bsx6> -->
  12. <BoosterMCH class="booster-station-body"></BoosterMCH>
  13. </div>
  14. </template>
  15. <script>
  16. import BtnGroup2 from "@com/coms/btn/btn-group-double.vue";
  17. // import bsx6 from "../components/bsx6.vue";
  18. import BoosterMCH from "../components/boosterstation/mch/mch.vue";
  19. export default {
  20. // 名称
  21. name: "BoosterStation",
  22. // 使用组件
  23. components: {
  24. // bsx6,
  25. BtnGroup2,
  26. BoosterMCH,
  27. },
  28. // 数据
  29. data() {
  30. return {
  31. wpId: undefined,
  32. selectIndex: 0,
  33. rowIndex: 0,
  34. btnGroups: [
  35. {
  36. icon: "svg-wind-site",
  37. btns: [],
  38. },
  39. {
  40. icon: "svg-photovoltaic",
  41. btns: [],
  42. },
  43. ],
  44. };
  45. },
  46. created() {
  47. let that = this;
  48. that.wpId = that.$route.params.wpId;
  49. that.$nextTick(() => {
  50. that.getWp();
  51. });
  52. },
  53. // 函数
  54. methods: {
  55. select(res) {
  56. this.$router.replace({
  57. path: `/monitor/windsite/boosterstation/${res.code}`,
  58. });
  59. },
  60. getWp() {
  61. let that = this;
  62. that.API.requestData({
  63. method: "GET",
  64. subUrl: "powercompare/windfarmAllAjax",
  65. success(res) {
  66. let btnGroup = [
  67. {
  68. icon: "svg-wind-site",
  69. btns: [],
  70. },
  71. {
  72. icon: "svg-photovoltaic",
  73. btns: [],
  74. },
  75. ];
  76. res.data.forEach((ele, index) => {
  77. if (ele.id.indexOf("FDC") !== -1) {
  78. btnGroup[0].btns.push({
  79. text: ele.name,
  80. code: ele.id,
  81. });
  82. } else {
  83. btnGroup[1].btns.push({
  84. text: ele.name,
  85. code: ele.id,
  86. });
  87. }
  88. });
  89. that.btnGroups = btnGroup;
  90. that.renderBtnActiveIndex();
  91. },
  92. });
  93. },
  94. renderBtnActiveIndex() {
  95. this.btnGroups.forEach((pEle, pIndex) => {
  96. pEle.btns.forEach((cEle, cIndex) => {
  97. if (cEle.code === this.wpId) {
  98. this.rowIndex = pIndex;
  99. this.selectIndex = cIndex;
  100. }
  101. });
  102. });
  103. },
  104. },
  105. // 生命周期钩子
  106. beforeCreate() {
  107. // 创建前
  108. },
  109. beforeMount() {
  110. // 渲染前
  111. },
  112. mounted() {
  113. // 渲染后
  114. },
  115. beforeUpdate() {
  116. // 数据更新前
  117. },
  118. updated() {
  119. // 数据更新后
  120. },
  121. watch: {
  122. $route(res) {
  123. this.wpId = res.params.wpId;
  124. if (res.params.wpId) {
  125. this.renderBtnActiveIndex();
  126. }
  127. },
  128. },
  129. };
  130. </script>
  131. <style lang="less" scoped>
  132. .booster-station {
  133. width: 100%;
  134. height: calc(100vh - 90px);
  135. display: flex;
  136. flex-direction: column;
  137. .btn-group-tabs {
  138. display: flex;
  139. flex-direction: row;
  140. }
  141. .booster-station-body {
  142. flex-grow: 1;
  143. }
  144. }
  145. </style>