巡检记录接口对接
This commit is contained in:
@@ -17,16 +17,16 @@
|
||||
<image lazy-load src="/static/imgs/home.png" class="icon" mode=""></image>
|
||||
<view class="instrument_info">
|
||||
<view class="instrument_title">
|
||||
<text>{{ item.title }}</text>
|
||||
<text>{{ item.addressCn }}</text>
|
||||
</view>
|
||||
<view class="instrument_time">
|
||||
<text>换新时间时间:{{ item.time }}</text>
|
||||
<text>换新时间时间:{{ item.createTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="instrument_type">
|
||||
<text v-if="item.type === 2">电表</text>
|
||||
<text v-else>水表</text>
|
||||
<text v-if="item.deviceType === '1'">电表</text>
|
||||
<text v-else-if="item.deviceType === '2'">水表</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 底部加载状态提示 -->
|
||||
@@ -42,7 +42,10 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import TabsComponents from '@/components/tabs/tabs.vue'
|
||||
import { getReplaceMainList } from '@/api/instrument.js'
|
||||
|
||||
/** 加载状态 */
|
||||
const statusmore = computed(() => {
|
||||
if (isLoading.value === true) {
|
||||
@@ -65,25 +68,35 @@ const tabslist = [
|
||||
},
|
||||
{
|
||||
name: '水表',
|
||||
value: 1
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
name: '电表',
|
||||
value: 2
|
||||
value: 1
|
||||
}
|
||||
]
|
||||
|
||||
// 切换tabs
|
||||
function handleChangeTabs(val: number) {
|
||||
queryParmas.value.deviceType = val
|
||||
if (val === 0) {
|
||||
queryParmas.value.deviceType = undefined
|
||||
}
|
||||
queryParmas.value.pageNum = 1
|
||||
infolist.value = []
|
||||
hasMore.value = true
|
||||
getlist()
|
||||
}
|
||||
// ---------------------------------------------------------------------
|
||||
const infolist = ref([])
|
||||
const queryParmas = ref({
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
pageSize: 10,
|
||||
deviceType: undefined
|
||||
})
|
||||
const total = ref(21)
|
||||
// 总数
|
||||
const total = ref(0)
|
||||
// 上滑加载
|
||||
function scrolltolower() {
|
||||
// 必须加这两个判断!
|
||||
if (isLoading.value || !hasMore.value) {
|
||||
@@ -92,6 +105,7 @@ function scrolltolower() {
|
||||
queryParmas.value.pageNum += 1
|
||||
getlist()
|
||||
}
|
||||
|
||||
function getlist() {
|
||||
// 1. 如果正在加载或没有更多数据,直接返回
|
||||
if (isLoading.value || !hasMore.value) return
|
||||
@@ -101,29 +115,29 @@ function getlist() {
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
const { pageNum, pageSize } = queryParmas.value
|
||||
|
||||
const startId = (pageNum - 1) * pageSize + 1
|
||||
const arr = Array.from({ length: pageSize }).map((_, index) => {
|
||||
const realId = startId + index // ✅ 修复 ID 错误
|
||||
|
||||
// ✅ 随机生成 0、1、2
|
||||
const randomStatus = Math.floor(Math.random() * 2)
|
||||
return {
|
||||
title: 'M2栋3单元18' + realId + '室(M2-3-1801)',
|
||||
time: '2023-08-01 10:05:46',
|
||||
type: randomStatus //1水表 2电表
|
||||
}
|
||||
const { pageNum, pageSize, deviceType } = queryParmas.value
|
||||
getReplaceMainList({
|
||||
pageNum,
|
||||
pageSize,
|
||||
deviceType
|
||||
})
|
||||
|
||||
// 追加数据(正确方式)
|
||||
infolist.value = [...infolist.value, ...arr]
|
||||
// 判断是否还有更多
|
||||
hasMore.value = infolist.value.length < total.value
|
||||
isLoading.value = false
|
||||
uni.hideLoading()
|
||||
.then(res => {
|
||||
infolist.value = [...infolist.value, ...res.rows]
|
||||
total.value = res.total
|
||||
hasMore.value = infolist.value.length < total.value
|
||||
})
|
||||
.finally(() => {
|
||||
isLoading.value = false
|
||||
uni.hideLoading()
|
||||
})
|
||||
}
|
||||
getlist()
|
||||
onShow(() => {
|
||||
infolist.value = []
|
||||
hasMore.value = true
|
||||
getlist()
|
||||
})
|
||||
|
||||
// 重置
|
||||
function resetList() {
|
||||
infolist.value = []
|
||||
queryParmas.value.pageNum = 1
|
||||
@@ -131,6 +145,7 @@ function resetList() {
|
||||
getlist()
|
||||
}
|
||||
|
||||
// 跳转到 仪表换新
|
||||
function handleClick() {
|
||||
uni.navigateTo({
|
||||
url: '/pageSubPack/instrument/addreplacement'
|
||||
|
||||
Reference in New Issue
Block a user