123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <template>
- <view class="device-list">
- <up-search v-model="searchValue"></up-search>
- <view class="stat-ctl">
- <view class="u-page__tag-item" v-for="(item, index) in DeviceState" :key="index">
- <up-tag
- :text="item.label"
- :plain="selectTag === item.value"
- :plainFill="true"
- bgColor="#007aff"
- :name="item.value"
- @click="()=>radioClick(item)"
- >
- </up-tag>
- </view>
- </view>
- <view class="u-page-list" style="padding-bottom: 100rpx">
- <up-list @scrolltolower="scrolltolower">
- <up-list-item
- v-for="(item, index) in indexList"
- :key="item.id"
- >
- <view class="item-content">
- <up-image
- :showLoading="true"
- :src="getDevImg(item.devImg)"
- width="160rpx"
- height="150rpx"
- :lazy-load="true"
- >
- <template #error>
- <view style="font-size: 24rpx;">加载失败</view>
- </template>
- </up-image>
- <view class="content-info">
- <view>
- <up-text :lines="1" :text="`设备名称: ${formatTxt(item.deviceNickname)}`" size="24rpx"/>
- <up-tag :text="item.statusName" plain size="mini" :bgColor="valueToConst(DeviceState,item.status).color"
- class="tag-stat"></up-tag>
- <up-text text="详情>" color="#007aff" style="flex:none;width: auto"
- @click="()=>onDetailClick(item)"></up-text>
- </view>
- <view>
- <up-text :lines="1" :text="`设备编码:${formatTxt(item.name)}`" size="24rpx"/>
- </view>
- <view>
- <up-text :lines="1" :text="`上线时间:${formatTxt(item.lastOnlineTime)}`" size="24rpx"/>
- </view>
- </view>
- </view>
- </up-list-item>
- <up-loading-icon v-if="loading" text="加载中" textSize="12"></up-loading-icon>
- <up-text
- v-if="!loadmoreFlag" text="已经到底了" style="justify-content: center;"
- size="24rpx"
- color="gray"
- >
- </up-text>
- </up-list>
- </view>
- </view>
- </template>
- <script setup lang="ts">
- import {ref} from "vue"
- import {DeviceState} from '@/common/consts/DeviceConst.js'
- import {valueToConst} from '@/common/consts/CommonConst.js'
- import {onLoad} from '@dcloudio/uni-app';
- import {formatTxt, getDevImg, navigateTo,} from '@/util/index.js'
- import {getDeviceList} from "@/api/device.js";
- const page = ref(1)
- onLoad(() => {
- page.value = 1
- loading.value = true;
- loadmore();
- });
- let searchValue = ref("")
- let indexList = ref([])
- let selectTag = ref(DeviceState.ALL.value)
- let loadmoreFlag = ref(true)
- let loading = ref(false)
- function radioClick(item) {
- selectTag.value = item.value
- }
- const loadmore = async () => {
- const {records} = await getDeviceList({
- page: page.value,
- deviceNickName: searchValue.value,
- deviceState: selectTag.value,
- })
- if (records && records.length > 0) {
- indexList.value = indexList.value.concat(records)
- page.value += 1
- if (records.length < 10) {
- loadmoreFlag.value = false;
- }
- } else {
- loadmoreFlag.value = false;
- }
- loading.value = false;
- };
- const scrolltolower = () => {
- if (!loadmoreFlag.value) return;
- loading.value = true;
- loadmore();
- };
- const onDetailClick = (item) => {
- navigateTo({
- url: "/pages/workbenchsub/device/detail",
- param: item
- })
- }
- </script>
- <style lang="scss">
- .device-list {
- width: 680rpx;
- margin: 14rpx auto 0;
- .u-search__content {
- background: $uni-bg-color !important;
- .u-search__content__input {
- background-color: $uni-bg-color !important;
- }
- }
- .u-page-list {
- margin-top: 14rpx;
- }
- .item-content {
- width: 100%;
- border-radius: $comm-border-radius;
- display: flex;
- box-sizing: border-box;
- align-items: center;
- justify-content: flex-start;
- background: $uni-bg-color;
- margin-bottom: 14rpx;
- padding: 14rpx;
- .content-info {
- flex: 1;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: flex-start;
- margin-left: 14rpx;
- > view {
- font-size: inherit;
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- .tag-stat {
- margin-left: auto;
- margin-right: 14rpx;
- .u-tag--mini {
- height: 35rpx;
- }
- .u-tag--primary--plain {
- border-color: transparent !important;
- .u-tag__text--primary--plain {
- color: $uni-bg-color !important;
- font-size: 18rpx !important;
- }
- }
- }
- .u-link {
- flex: none;
- }
- &:not(:first-child) {
- margin-top: 14rpx;
- }
- }
- }
- }
- }
- </style>
|