Agc.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <HeaderNav @typeFlag="typeFlag" :isAll="true" />
  3. <div class="agc">
  4. <el-scrollbar>
  5. <el-row
  6. v-if="datas.length"
  7. class="panel-groups"
  8. style="box-sizing: border-box"
  9. >
  10. <el-col :span="5.6" v-for="data of datas" :key="data.id">
  11. <AgcPanel :obj="data"></AgcPanel>
  12. </el-col>
  13. </el-row>
  14. </el-scrollbar>
  15. </div>
  16. </template>
  17. <script>
  18. import AgcPanel from "./components/agc-panel.vue";
  19. import { getAgcDatas } from "@/api/monitor/index.js";
  20. import HeaderNav from "@/components/headerNav/index.vue";
  21. export default {
  22. // 名称
  23. name: "Agc", //agc监视
  24. // 使用组件
  25. components: {
  26. AgcPanel,
  27. HeaderNav,
  28. },
  29. // 数据
  30. data() {
  31. return {
  32. timmer: null, // 计时器
  33. datas: [],
  34. activeTab: "all",
  35. tabIndex: 0,
  36. enterpriseIndex: "all",
  37. };
  38. },
  39. // 函数
  40. methods: {
  41. // 头部tab选择
  42. typeFlag(activeTab, enterpriseIndex) {
  43. this.activeTab = activeTab;
  44. this.tabIndex = activeTab == "all" ? 0 : activeTab == "fc" ? -1 : -2;
  45. this.enterpriseIndex = enterpriseIndex;
  46. this.$nextTick(() => {
  47. this.requestData();
  48. });
  49. },
  50. // 请求服务
  51. requestData() {
  52. getAgcDatas({
  53. company:
  54. this.enterpriseIndex == "all" ? "0" : this.enterpriseIndex.toString(),
  55. type: this.tabIndex.toString(),
  56. }).then((res) => {
  57. if (res.data) {
  58. this.datas = res.data.data;
  59. } else {
  60. this.datas = [];
  61. }
  62. });
  63. },
  64. },
  65. watch: {},
  66. created() {
  67. let that = this;
  68. that.$nextTick(() => {
  69. that.requestData();
  70. });
  71. },
  72. mounted() {
  73. this.timmer = setInterval(() => {
  74. this.requestData();
  75. }, 5000);
  76. },
  77. unmounted() {
  78. clearInterval(this.timmer);
  79. this.timmer = null;
  80. },
  81. };
  82. </script>
  83. <style lang="less" scoped>
  84. .agc {
  85. height: calc(100vh - 7.222vh);
  86. overflow: hidden;
  87. .btn-group-tabs {
  88. display: flex;
  89. flex-direction: row;
  90. .photovoltaic {
  91. margin-left: 1.481vh;
  92. }
  93. }
  94. .panel-groups {
  95. display: grid;
  96. justify-content: space-evenly;
  97. grid-template-columns: repeat(auto-fill, 442px);
  98. overflow-y: auto;
  99. overflow-x: hidden;
  100. .el-col + .el-col {
  101. padding-left: 0;
  102. }
  103. }
  104. }
  105. </style>