traplamp.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <!-- 外联测报灯列表 -->
  3. <view>
  4. <!-- 搜索框 -->
  5. <!-- <ui-search placeholder="请输入设备ID" @confirm="searchDevice"></ui-search> -->
  6. <!-- 搜索框end -->
  7. <!-- 列表 -->
  8. <block v-for="(item,index) in deviceList" :key="index">
  9. <view class="ui-card forecast-item" @click="openDeviceDetails(item)">
  10. <view class="flex-1 info">
  11. <view class="font-16 title on">设备名称:{{item.device_name}}</view>
  12. <view class="text">设备ID:{{item.device_id}}</view>
  13. <!-- <view class="text">最新上报时间:{{item.addtime | timeFrom}}</view> -->
  14. </view>
  15. <!-- <ui-state :state="item.is_online"></ui-state> -->
  16. </view>
  17. </block>
  18. <!-- 外联测报灯列表end -->
  19. <ui-empty v-if="deviceList.length==0"></ui-empty>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. getList
  25. } from '@/api/traplamp.js'
  26. export default {
  27. data() {
  28. return {
  29. // 列表搜索条件
  30. params: {
  31. page: 1,
  32. page_size: 999,
  33. device_type: 3 // 3外联测报灯站
  34. },
  35. deviceList: [], // 设备列表
  36. };
  37. },
  38. async onLoad(options) {
  39. await this.$onLaunched;
  40. this.getDeviceList();
  41. },
  42. //下拉刷新
  43. onPullDownRefresh() {
  44. this.refreshDeviceList();
  45. uni.stopPullDownRefresh()
  46. },
  47. methods: {
  48. // 刷新设备列表
  49. refreshDeviceList(){
  50. this.params.page = 1;
  51. this.deviceList=[];
  52. this.getDeviceList();
  53. },
  54. // 获取设备列表
  55. async getDeviceList() {
  56. this.$api.loading('加载中...');
  57. const {
  58. data
  59. } = await getList(this.params);
  60. this.$api.hide();
  61. this.deviceList = data;
  62. },
  63. //详情
  64. openDeviceDetails(item) {
  65. console.log(item)
  66. uni.navigateTo({
  67. url:`detail/detail?id=${item.device_id}`
  68. })
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss">
  74. </style>