index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div class="device-manager-box">
  3. <div class="content">
  4. <a-tabs class="tab-box" v-model:activeKey="activeKey" @change="onChangeTab">
  5. <a-tab-pane tab="分站列表" key="device" />
  6. <a-tab-pane tab="历史数据" key="history" />
  7. </a-tabs>
  8. <div class="box-content">
  9. <div class="now-content" v-if="activeKey == 'device'">
  10. <NormalTable
  11. ref="normalTabel"
  12. :columns="columns"
  13. :searchFormSchema="searchFormSchema"
  14. :list="list"
  15. :formSchema="formSchema"
  16. :deleteById="deleteById"
  17. :batchDelete="batchDeleteById"
  18. :saveOrUpdate="saveOrUpdate"
  19. designScope="substation-tabel"
  20. title="分站列表"
  21. :showTab="false"
  22. >
  23. <template #filterCell="{ column, record }">
  24. <a-tag v-if="column.dataIndex === 'linkstatus'" :color="record.linkstatus == 0 ? '#999' : '#87d068'">{{
  25. record.linkstatus == 1 ? '链接' : '断开'
  26. }}</a-tag>
  27. </template>
  28. <template #action="{ record }">
  29. <a
  30. v-if="
  31. record['strtype'] == 'http' ||
  32. record['strtype'] == 'kafka' ||
  33. record['strtype'] == 'ftp' ||
  34. record['strtype'] == 'database' ||
  35. record['strtype'] == 'txt'
  36. "
  37. class="table-action-link"
  38. @click="addDevices(record)"
  39. >同步设备</a
  40. >
  41. </template>
  42. </NormalTable>
  43. </div>
  44. <div class="history-content tab-item" v-if="activeKey == 'history'">
  45. <HistoryTable :scroll="scroll" :historyColumns="historyColumns" />
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script lang="ts" name="system-user" setup>
  52. //ts语法
  53. import { ref, onMounted, reactive, onUnmounted } from 'vue';
  54. import NormalTable from '../comment/NormalTable.vue';
  55. import HistoryTable from '../comment/HistoryTable.vue';
  56. import { historyColumns, columns, searchFormSchema, formSchema } from './substation.data';
  57. import { list, getImportUrl, getExportUrl, deleteById, getHistory, batchDeleteById, saveOrUpdate, addDevice } from './substation.api';
  58. import { message } from 'ant-design-vue';
  59. // import dayjs from 'dayjs';
  60. const normalTabel = ref();
  61. let timer = undefined;
  62. let activeKey = ref('device');
  63. const scroll = reactive({
  64. y: 710,
  65. });
  66. function reload() {
  67. timer = setInterval(() => {
  68. if (normalTabel.value) normalTabel.value.reload();
  69. }, 30000);
  70. }
  71. function addDevices(record) {
  72. addDevice({ id: record.id })
  73. .then((result) => {
  74. // message.success('同步生成')
  75. })
  76. .catch(() => {
  77. message.success('同步失败');
  78. });
  79. }
  80. //tab选项切换
  81. function onChangeTab(tab) {
  82. activeKey.value = tab;
  83. if (activeKey.value == 'device') {
  84. // clearTimeout(timer1);
  85. } else {
  86. }
  87. }
  88. onMounted(() => {
  89. reload();
  90. });
  91. onUnmounted(() => {
  92. clearInterval(timer);
  93. });
  94. </script>
  95. <style lang="less" scoped>
  96. .content {
  97. .tab-box {
  98. display: flex;
  99. color: #fff;
  100. position: relative;
  101. background: linear-gradient(#001325, #012e4f);
  102. :deep(.zxm-tabs-nav) {
  103. margin: 0 !important;
  104. .zxm-tabs-tab {
  105. width: 180px;
  106. height: 45px;
  107. background: url('/@/assets/images/top-btn.png') center no-repeat;
  108. background-size: cover;
  109. display: flex;
  110. justify-content: center;
  111. font-size: 16px;
  112. }
  113. .zxm-tabs-tab-active {
  114. width: 180px;
  115. position: relative;
  116. background: url('/@/assets/images/top-btn-select.png') center no-repeat;
  117. background-size: cover;
  118. .zxm-tabs-tab-btn {
  119. color: #fff !important;
  120. }
  121. }
  122. .zxm-tabs-ink-bar {
  123. width: 0 !important;
  124. }
  125. .zxm-tabs-tab + .zxm-tabs-tab {
  126. margin: 0 !important;
  127. }
  128. }
  129. }
  130. }
  131. .search-area {
  132. padding: 5px;
  133. margin: 10px;
  134. box-sizing: border-box;
  135. }
  136. ::v-deep(.zxm-form-item-label > label) {
  137. color: #fff !important;
  138. }
  139. </style>