index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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
  23. v-if="record['strtype'] == 'http' || record['strtype'] == 'kafka' || record['strtype'] == 'ftp' || record['strtype'] == 'database'"
  24. class="table-action-link"
  25. @click="addDevices(record)"
  26. >同步设备</a
  27. >
  28. </template>
  29. </NormalTable>
  30. </div>
  31. </template>
  32. <script lang="ts" name="system-user" setup>
  33. //ts语法
  34. import { ref, onMounted, onUnmounted } from 'vue';
  35. import NormalTable from '../comment/NormalTable.vue';
  36. import { columns, searchFormSchema, formSchema } from './substation.data';
  37. import { list, getImportUrl, getExportUrl, deleteById, batchDeleteById, saveOrUpdate, addDevice } from './substation.api';
  38. import { message } from 'ant-design-vue';
  39. const normalTabel = ref();
  40. let timer = undefined;
  41. function reload() {
  42. timer = setInterval(() => {
  43. if (normalTabel.value) normalTabel.value.reload();
  44. }, 30000);
  45. }
  46. function addDevices(record) {
  47. addDevice({ id: record.id })
  48. .then((result) => {
  49. // message.success('同步生成')
  50. })
  51. .catch(() => {
  52. message.success('同步失败');
  53. });
  54. }
  55. onMounted(() => {
  56. reload();
  57. });
  58. onUnmounted(() => {
  59. clearInterval(timer);
  60. });
  61. </script>
  62. <style scoped></style>