AssociationDevices.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div v-loading="loading" style="height: 100%">
  3. <ContentWrap>
  4. <!-- 搜索工作栏 -->
  5. <el-form
  6. class="-mb-15px"
  7. :model="queryParams"
  8. ref="queryFormRef"
  9. :inline="true"
  10. label-width="68px"
  11. >
  12. <el-form-item label="设备编码" prop="deviceCode">
  13. <el-input
  14. v-model="queryParams.deviceCode"
  15. placeholder="请输入设备编码"
  16. clearable
  17. @keyup.enter="handleQuery"
  18. class="!w-200px"
  19. />
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button @click="handleQuery"
  23. ><Icon icon="ep:search" class="mr-5px" /> {{ t('devicePerson.search') }}</el-button
  24. >
  25. <el-button @click="resetQuery"
  26. ><Icon icon="ep:refresh" class="mr-5px" /> {{ t('devicePerson.reset') }}</el-button
  27. >
  28. </el-form-item>
  29. </el-form>
  30. </ContentWrap>
  31. <el-table :data="deviceList" style="width: 100%">
  32. <!-- 序号 -->
  33. <el-table-column :label="t('monitor.serial')" width="70" align="center">
  34. <template #default="scope">
  35. {{ scope.$index + 1 }}
  36. </template>
  37. </el-table-column>
  38. <el-table-column prop="groupName" label="成套名称" align="center" />
  39. <el-table-column prop="deviceName" :label="t('iotDevice.name')" align="center" />
  40. <el-table-column prop="deviceCode" label="设备编码" align="center" />
  41. <el-table-column prop="ifMaster" label="是否主设备" align="center">
  42. <template #default="scope">
  43. <el-tag v-if="scope.row.ifMaster" class="text-[#62a66a]">是</el-tag>
  44. <el-tag v-else class="text-[#9093a6]" type="info">否</el-tag>
  45. </template>
  46. </el-table-column>
  47. <el-table-column prop="ifMaster" label="创建时间" align="center">
  48. <template #default="scope">
  49. {{ formatToDate(scope.row.createTime) }}
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. <!-- 分页 -->
  54. <Pagination
  55. :total="total"
  56. v-model:page="queryParams.pageNo"
  57. v-model:limit="queryParams.pageSize"
  58. @pagination="getDeviceList(props.deviceId)"
  59. />
  60. </div>
  61. </template>
  62. <script setup lang="ts">
  63. import { ref } from 'vue'
  64. import { formatToDate } from '@/utils/dateUtil'
  65. import { IotDeviceApi } from '@/api/pms/device'
  66. const { t } = useI18n() // 国际化
  67. defineOptions({
  68. name: 'AssociationDevices'
  69. })
  70. const queryParams = reactive({
  71. pageNo: 1,
  72. pageSize: 10,
  73. deviceId: '',
  74. deviceCode: ''
  75. })
  76. const loading = ref(false)
  77. const total = ref(0) // 列表的总页数
  78. const deviceList = ref([])
  79. const props = defineProps({
  80. deviceId: Number
  81. })
  82. const handleQuery = () => {
  83. queryParams.pageNo = 1
  84. getDeviceList(props.deviceId)
  85. }
  86. const resetQuery = () => {
  87. queryParams.deviceCode = ''
  88. handleQuery()
  89. }
  90. const getDeviceList = async (id) => {
  91. loading.value = true
  92. try {
  93. queryParams.deviceId = id
  94. const res = await IotDeviceApi.getIotDeviceSetRelation(queryParams)
  95. deviceList.value = res.list
  96. total.value = res.total
  97. } catch (error) {
  98. } finally {
  99. loading.value = false
  100. }
  101. }
  102. onMounted(() => {
  103. getDeviceList(props.deviceId)
  104. })
  105. </script>
  106. <style lang="scss" scoped></style>