manage.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <a-card>
  3. <a-row justify="space-between" >
  4. <a-col span="12" >
  5. <a-form layout="inline" >
  6. <a-form-item label="任务名称" >
  7. <a-input v-model:value="queryParamsState.taskLabel" placeholder="请输入任务名称"/>
  8. </a-form-item>
  9. <a-form-item label='任务状态' >
  10. <a-select
  11. style="width: 170px"
  12. v-model:value="queryParamsState.status"
  13. @change="changeStatus"
  14. >
  15. <a-select-option
  16. v-for="item in statusList"
  17. :key="item.key"
  18. :value="item.key"
  19. >
  20. {{item.label}}
  21. </a-select-option>
  22. </a-select>
  23. </a-form-item >
  24. <a-form-item>
  25. <a-button type="primary" @click="getTaskPage">搜索</a-button>
  26. </a-form-item>
  27. </a-form>
  28. </a-col>
  29. <a-col span="12" >
  30. <a-space>
  31. <a-button type="primary" >新增任务</a-button>
  32. </a-space>
  33. </a-col>
  34. </a-row>
  35. <a-table
  36. style="margin-top: 20px;"
  37. :columns="columns"
  38. :data-source="state.dataSource"
  39. :loading="state.loading"
  40. :pagination="queryParamsState"
  41. @change="changePage"
  42. >
  43. <template #bodyCell="{column, record}">
  44. <template v-if="column.key === 'action'" >
  45. <a-space>
  46. <a >编辑</a>
  47. <a >删除</a>
  48. </a-space>
  49. </template>
  50. </template>
  51. </a-table>
  52. <modal-pro
  53. :label="modalTitle"
  54. :visible="state.visible"
  55. @cancel="state.visible = false"
  56. @ok="ok"
  57. >
  58. </modal-pro>
  59. </a-card>
  60. </template>
  61. <script lang='ts' setup >
  62. import { TaskController } from '@/controller/iot/task'
  63. import { computed, onMounted, reactive } from 'vue'
  64. import { Form } from 'ant-design-vue'
  65. const columns = [
  66. {
  67. title: '任务名称',
  68. dataIndex: 'taskLabel',
  69. key: 'taskLabel'
  70. },
  71. {
  72. title: '任务配置',
  73. dataIndex: 'taskConfig',
  74. key: 'taskConfig'
  75. },
  76. {
  77. title: '任务状态',
  78. dataIndex: 'status',
  79. key: 'status'
  80. },
  81. {
  82. title: '任务描述',
  83. dataIndex: 'taskDescription',
  84. key: 'taskDescription'
  85. },
  86. {
  87. title: 'corn',
  88. dataIndex: 'cornDescr',
  89. key: 'cornDescr'
  90. },
  91. {
  92. title: '操作',
  93. dataIndex: 'action',
  94. key: 'action'
  95. }
  96. ]
  97. const useForm = Form.useForm
  98. const statusList = [
  99. { key: true, label: '开启' },
  100. { key: false, label: '关闭' },
  101. { key: true, label: '' }
  102. ]
  103. const queryParamsState = reactive({
  104. page: 1,
  105. pageSize: 10,
  106. total: 0,
  107. taskLabel: '',
  108. status: ''
  109. })
  110. const modalTitle = computed(() => state.opraState === 'add' ? '新增标题' : '编辑标题')
  111. const state = reactive({
  112. dataSource: [],
  113. loading: false,
  114. opraState: 'add',
  115. visible: false
  116. })
  117. const modalRef = reactive({
  118. })
  119. const { resetFields, validate, validateInfos } = useForm(modalRef, reactive({
  120. }))
  121. const ok = () => {
  122. }
  123. const changeStatus = (value) => {
  124. queryParamsState.status = value
  125. }
  126. const getTaskPage = async () => {
  127. state.loading = true
  128. const { data, sum } = await TaskController.page(queryParamsState)
  129. state.loading = false
  130. state.dataSource = data
  131. queryParamsState.total = sum
  132. }
  133. const changePage = ({ current }) => {
  134. queryParamsState.page = current
  135. getTaskPage()
  136. }
  137. onMounted(() => {
  138. getTaskPage()
  139. })
  140. </script>
  141. <style lang='less' scoped >
  142. </style>