index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div class="device-manager-box">
  3. <NormalTable
  4. ref="normalTabel"
  5. :columns="columns"
  6. :searchFormSchema="searchFormSchema"
  7. :list="list"
  8. :formSchema="formSchema"
  9. :deleteById="deleteById"
  10. :batchDelete="batchDeleteById"
  11. :saveOrUpdate="saveOrUpdate"
  12. designScope="substation-tabel"
  13. title="分站列表"
  14. :showTab="false"
  15. >
  16. <template #filterCell="{ column, record }">
  17. <a-tag v-if="column.dataIndex === 'linkstatus'" :color="record.linkstatus == 0 ? '#999' : '#87d068'">{{
  18. record.linkstatus == 1 ? '链接' : '断开'
  19. }}</a-tag>
  20. </template>
  21. <template #action="{ record }">
  22. <a v-if="record['strtype'] == 'http'|| record['strtype'] == 'kafka'" class="table-action-link" @click="addDevices(record)">同步设备</a>
  23. </template>
  24. </NormalTable>
  25. </div>
  26. </template>
  27. <script lang="ts" name="system-user" setup>
  28. //ts语法
  29. import { ref, onMounted, onUnmounted } from 'vue';
  30. import NormalTable from '../comment/NormalTable.vue';
  31. import { columns, searchFormSchema, formSchema } from './substation.data';
  32. import { list, getImportUrl, getExportUrl, deleteById, batchDeleteById, saveOrUpdate, addDevice } from './substation.api';
  33. import { message } from 'ant-design-vue';
  34. const normalTabel = ref();
  35. let timer = undefined ;
  36. function reload() {
  37. timer = setInterval(() => {
  38. if(normalTabel.value)normalTabel.value.reload()
  39. }, 30000)
  40. }
  41. function addDevices(record) {
  42. addDevice({ id: record.id }).then((result) => {
  43. // message.success('同步生成')
  44. }).catch(() => {
  45. message.success('同步失败')
  46. })
  47. }
  48. onMounted(() => {
  49. reload()
  50. })
  51. onUnmounted(() => {
  52. clearInterval(timer)
  53. })
  54. </script>
  55. <style scoped></style>