DeviceManagement.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div>
  3. <Navbar title="设备信息" :is-go-back="false" />
  4. <a-card>
  5. <a-form ref="formRef" :model="formState">
  6. <a-row :gutter="24">
  7. <a-col :span="6">
  8. <a-form-item name="name" :label="'查询条件'">
  9. <a-input v-model:value="formState.condition" placeholder="请输入终端名称或位置" @press-enter="searchDatas" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :span="2">
  13. <a-button type="primary" :icon="h(SearchOutlined)" @click="searchDatas">搜索</a-button>
  14. </a-col>
  15. </a-row>
  16. </a-form>
  17. </a-card>
  18. <CommonTable
  19. ref="table" :data-source="dataSource" :columns="columns" :is-loading="isLoading" :total="total"
  20. @get-pager="getPageParams"
  21. >
  22. <template #bodyCell="{ column, record }">
  23. <template v-if="column.dataIndex === 'status'">
  24. <a-tag v-if="record.status" color="success">在线</a-tag>
  25. <a-tag v-if="record.status === false" color="warning">离线</a-tag>
  26. </template>
  27. </template>
  28. </CommonTable>
  29. </div>
  30. </template>
  31. <script setup>
  32. import { ref, h, onMounted } from 'vue';
  33. import { message } from 'ant-design-vue';
  34. import Common from '../common/Common.js';
  35. import CommonTable from '../common/CommonTable.vue';
  36. import { ajaxApi } from '../api/workflow/workflow.js';
  37. import { SearchOutlined } from '@ant-design/icons-vue';
  38. const table = ref();
  39. const isLoading = ref(false);
  40. const dataSource = ref([]);
  41. const formState = ref({
  42. condition: '',
  43. });
  44. const total = ref(0);
  45. const pagination = ref({
  46. start: 1,
  47. length: 20,
  48. });
  49. onMounted(() => {
  50. searchDatas();
  51. });
  52. // 查询,回到第一页
  53. const searchDatas = () => {
  54. table.value.backFirstPage();
  55. };
  56. // 获取分页参数
  57. const getPageParams = (start, length) => {
  58. pagination.value.start = (start - 1) * length;
  59. pagination.value.length = length;
  60. queryDevice();
  61. };
  62. // 查询终端数据
  63. const queryDevice = () => {
  64. const params = {
  65. condition: formState.value.condition,
  66. range: { ...pagination.value },
  67. };
  68. isLoading.value = true;
  69. const url = 'api/DeviceManagementResource/queryDeviceManagementDtoByNameAndPosition';
  70. ajaxApi(url, params).then(
  71. success => {
  72. if (success.dataList && success.dataList.length > 0) {
  73. dataSource.value = success.dataList;
  74. total.value = success.totalSize;
  75. } else {
  76. total.value = 0;
  77. dataSource.value = [];
  78. }
  79. isLoading.value = false;
  80. },
  81. error => {
  82. isLoading.value = false;
  83. Common.processException(error);
  84. },
  85. );
  86. };
  87. const columns = ref([
  88. {
  89. title: '终端名称',
  90. dataIndex: 'name',
  91. key: 'name',
  92. },
  93. {
  94. title: '终端类型',
  95. dataIndex: 'terminalTypeName',
  96. key: 'terminalTypeName',
  97. },
  98. {
  99. title: '终端位置',
  100. dataIndex: 'position',
  101. key: 'position',
  102. },
  103. {
  104. title: '状态',
  105. dataIndex: 'status',
  106. key: 'status',
  107. },
  108. ]);
  109. // 清空查询条件
  110. const clearInfo = () => {
  111. formState.value.name = '';
  112. formState.value.position = '';
  113. };
  114. </script>
  115. <style scoped>
  116. :deep(.ant-card .ant-card-body) {
  117. padding-bottom: 0px !important;
  118. }
  119. </style>