detection-business/pages/index/staffProjectList/staffProjectList.vue
2025-05-13 13:16:32 +08:00

136 lines
3.3 KiB
Vue

<template>
<view>
<headersVue :titles="title">
<u-icon name="arrow-left" color="#fff" size="18"></u-icon>
</headersVue>
<view class="content">
<scroll-view class="school-scroll-view" scroll-y @scrolltolower="onReachBottomCus"
:style="{ height: scrollHeight + 'px' }" refresher-enabled @refresherrefresh="onRefresherrefresh"
:refresher-triggered="isTriggered">
<order-item v-for="(item, index) in orderList" :key="index" :order-data="item" @click="goDetail(item)" />
</scroll-view>
</view>
</view>
</template>
<script>
import headersVue from '../../../components/header/headers.vue';
import OrderItem from '@/components/order-list.vue'
import request from '../../../utils/request';
export default {
data() {
return {
scrollHeight: 0,
isTriggered: false,
userId: null,
orderList: null,
pageNo: 1,
pageSize: 10,
totalPages: 0,
title: undefined
}
},
methods: {
/**
* 上滑加载数据
*/
onReachBottomCus() {
//判断 如果页码*页容量大于等于总条数,提示该页数据加载完毕
console.log('totalPages', this.totalPages);
if (this.pageNo >= this.totalPages) {
uni.$u.toast('没有更多数据了')
return
}
//页码+1,调用获取数据的方法获取第二页数据
this.pageNo++
//此处调用自己获取数据列表的方法
this.getList()
},
/**
* 下拉刷新数据
*/
onRefresherrefresh() {
this.isTriggered = true
this.pageNo = 1
this.total = 0
this.schoolList = []
this.getList()
},
goDetail(data){
console.log('data', data)
uni.navigateTo({
url: "/pages/index/orderdetails?inspectionInfoId=" + data.inspectionInfoId
})
},
calculateScrollHeight() {
// 获取屏幕高度
const screenHeight = uni.getSystemInfoSync().windowHeight;
// 获取顶部区域高度
const topHeight = 130;
// 计算滚动区域高度
this.scrollHeight = screenHeight - topHeight;
},
async getList() {
const res = await request({
url: `/inspectionStaff/getFinishProjectByUserId`,
methods: 'GET',
params: {
pageNo: this.pageNo,
pageSize: this.pageSize,
userId: this.userId
}
})
if (this.pageNo == 1) {
this.orderList = res.data.records
} else {
this.orderList = this.orderList.concat(res.data.records)
}
let total = res.data.total
this.totalPages = Math.ceil(total / this.pageSize);
this.isTriggered = false
},
async getUserInfo() {
const res = await request({
url: `/system/user/get?id=${this.userId}`,
methods: 'get'
})
console.log('当前登陆人', res.data);
this.title = res.data.nickname + '项目列表'
},
},
onReady() {
// 动态计算滚动区域高度
this.calculateScrollHeight();
},
onLoad(data) {
if (data.userId) {
this.userId = data.userId
this.getUserInfo()
this.getList()
}
},
components: {
headersVue,
OrderItem // 这里使用大驼峰命名
},
}
</script>
<style>
.content {
background-color: #f7f8fa;
/* min-height: 100vh; */
padding: 20rpx;
box-sizing: border-box;
padding-top: 200rpx;
}
.school-scroll-view {
border-radius: 16rpx;
overflow: hidden;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
background-color: #ffffff;
padding: 10rpx 0;
}
</style>