track.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <a-card>
  3. <a-row>
  4. <a-space>
  5. <a-col>
  6. <a-range-picker v-model:value="time" format="YYYY/MM/DD" />
  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. :open="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: '',
  77. end: '',
  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 (time.value && time.value.length === 2) {
  92. queryParamsState.start = new Date(dayjs(time.value[0])).getTime()
  93. queryParamsState.end = new Date(dayjs(time.value[1])).getTime()
  94. } else {
  95. queryParamsState.start = ''
  96. queryParamsState.end = ''
  97. }
  98. },
  99. {
  100. deep: true
  101. }
  102. )
  103. const openModal = (opraState: 'preview', id: string) => {
  104. state.opraState = opraState
  105. state.id = id
  106. }
  107. const changePage = ({ current }) => {
  108. queryParamsState.page = current
  109. getTrackTaskList()
  110. }
  111. const getTrackTaskList = async () => {
  112. state.loading = true
  113. const { data } = await TaskController.trackTaskPage(queryParamsState)
  114. state.loading = false
  115. state.dataSource = data
  116. }
  117. onMounted(() => {
  118. getTrackTaskList()
  119. })
  120. </script>
  121. <style lang='less' scoped >
  122. </style>