| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <template>
- <!--虫情监测列表 -->
- <view>
- <!-- 搜索框 -->
- <ui-search placeholder="请输入设备ID" @confirm="searchLampList"></ui-search>
- <!-- 搜索框end -->
- <!-- 监测列表 -->
- <block v-for="(item,index) in lampList" :key="index">
- <view class="ui-card forecast-item" @click="openLampDetails(item)">
- <view class="flex-1 info">
- <view class="font-16 title" :class="item.is_online?'on':'off'">{{item.device_name}}</view>
- <view class="text">设备ID:{{item.imei}}</view>
- <view class="text">最新上报时间:{{ item.uptime | timeFrom}}</view>
- </view>
- <ui-state :state="item.is_online"></ui-state>
- </view>
- </block>
- <!-- 监测列表end -->
- </view>
- </template>
- <script>
- import {
- getWormLampList
- } from '@/api/worm.js'
- export default {
- data() {
- return {
- // 列表搜索条件
- params: {
- device_type_id: 3, //3虫情测报灯 7孢子仪
- device_id: '', // 搜索项,设备号、设备名称搜索
- page: 1,
- page_size: 10,
- // device_status: // 筛选项 1在线 0离线
- },
- total: 0, // 设备总数
- lampList: [], // 测报灯列表
- };
- },
- onLoad() {
- this.getLampList();
- },
- // 触底请求
- onReachBottom(e) {
- if (this.lampList.length >= this.total) {
- return;
- }
- this.params.page += 1;
- this.getLampList();
- },
- //下拉刷新
- onPullDownRefresh() {
- this.refreshLampList();
- uni.stopPullDownRefresh()
- },
- methods: {
- // 刷新测试灯列表
- refreshLampList() {
- this.params.page = 1;
- this.lampList = [];
- this.getLampList();
- },
- // 获取测试灯列表
- async getLampList() {
- const {
- ids,
- nums
- } = await getWormLampList();
- this.lampList = [...this.lampList, ...ids];
- this.total = nums ?? 0;
- },
- /**
- * 测试灯
- * @param {String} val 搜索内容
- */
- searchLampList(val) {
- this.params.device_id = val;
- this.refreshLampList();
- },
- // 打开虫情详情列表
- openLampDetails(item) {
- let params = {
- equip_name: item.equip_name, //设备名称
- equip_id: item.equip_id, //设备号
- address: item.address, //组织地址
- is_online: item.is_online, //在线状态 0离线 1在线
- uptime: item.uptime //数据更新时间 秒级时间戳
- }
- uni.navigateTo({
- url: `details?params=${JSON.stringify(params)}`
- })
- }
- },
- }
- </script>
|