track.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <a-card>
  3. <a-row>
  4. <a-space>
  5. <a-col>
  6. <a-range-picker v-model:value="time" :format="['DD/MM/YYYY', 'DD/MM/YYYY']" />
  7. </a-col>
  8. <a-col>
  9. <a-button type="primary" @click="getTrackTaskList">搜索</a-button>
  10. </a-col>
  11. </a-space>
  12. </a-row>
  13. <a-table
  14. style="margin-top: 20px;"
  15. :columns="columns"
  16. :data-source="state.dataSource"
  17. :loading="state.loading"
  18. :pagination="queryParamsState"
  19. @change="changePage"
  20. >
  21. <template #bodyCell="{column, record}">
  22. <template v-if="column.key === 'ts'" >
  23. {{dayjs(record.ts).format('YYYY/MM/DD HH:MM:ss')}}
  24. </template>
  25. <template v-if="column.key === 'action'" >
  26. <a-space>
  27. <a @click="openModal('preview', record.id)" >详情</a>
  28. </a-space>
  29. </template>
  30. </template>
  31. </a-table>
  32. </a-card>
  33. <modal-pro
  34. style="width: 700px;overflow: hidden;"
  35. label="最终详情"
  36. :visible="state.visable"
  37. @cancel="state.visable = false"
  38. @ok="state.visable = false"
  39. >
  40. </modal-pro>
  41. </template>
  42. <script lang='ts' setup >
  43. import { TaskController } from '@/controller/iot/task'
  44. import { onMounted, reactive, ref, watch } from 'vue'
  45. import dayjs from 'dayjs'
  46. const columns = [
  47. {
  48. title: '任务id',
  49. dataIndex: 'taskId'
  50. },
  51. {
  52. title: '执行时间',
  53. dataIndex: 'ts',
  54. key: 'ts'
  55. },
  56. {
  57. title: '任务参数',
  58. dataIndex: 'params',
  59. key: 'params'
  60. },
  61. {
  62. title: '任务结果',
  63. dataIndex: 'ret',
  64. key: 'ret'
  65. },
  66. {
  67. title: '操作',
  68. dataIndex: 'action',
  69. key: 'action'
  70. }
  71. ]
  72. const time = ref([])
  73. const queryParamsState = reactive({
  74. page: 1,
  75. pageSize: 10,
  76. start: 0,
  77. end: 0,
  78. taskId: ''
  79. })
  80. const state = reactive({
  81. taskList: [],
  82. dataSource: [],
  83. loading: false,
  84. visable: false,
  85. opraState: '',
  86. id: ''
  87. })
  88. watch(
  89. () => time.value,
  90. () => {
  91. if (dayjs(time.value).format('YYYY/MM/DD') === 'Invalid Date') {
  92. queryParamsState.start = ''
  93. queryParamsState.end = ''
  94. } else {
  95. queryParamsState.start = new Date(dayjs(time.value[0])).getTime()
  96. queryParamsState.end = new Date(dayjs(time.value[1])).getTime()
  97. }
  98. }
  99. )
  100. const openModal = (opraState: 'preview', id: string) => {
  101. state.opraState = opraState
  102. state.id = id
  103. }
  104. const changePage = ({ current }) => {
  105. queryParamsState.page = current
  106. getTrackTaskList()
  107. }
  108. const getTrackTaskList = async () => {
  109. state.loading = true
  110. const { data } = await TaskController.trackTaskPage(queryParamsState)
  111. state.loading = false
  112. state.dataSource = data
  113. }
  114. onMounted(() => {
  115. getTrackTaskList()
  116. })
  117. </script>
  118. <style lang='less' scoped >
  119. </style>