这一版本优化了很多
This commit is contained in:
@@ -66,11 +66,11 @@
|
||||
<view class="stat-label">逾期</view>
|
||||
</view>
|
||||
<view class="stat-item stat-completed">
|
||||
<view class="stat-num">{{ statistics.completed }}</view>
|
||||
<view class="stat-num">{{ statistics.onTimeCompleted }}</view>
|
||||
<view class="stat-label">已完成</view>
|
||||
</view>
|
||||
<view class="stat-item stat-pending">
|
||||
<view class="stat-num">{{ statistics.pending }}</view>
|
||||
<view class="stat-num">{{ statistics.completed }}</view>
|
||||
<view class="stat-label">待处理</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -130,6 +130,9 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<u-loadmore :status="loadStatus" v-if="dataList.length > 0" style="margin-top: 20rpx; margin-bottom: 20rpx;" />
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view v-if="dataList.length === 0" class="empty-tip">
|
||||
<text>暂无数据</text>
|
||||
@@ -139,7 +142,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { onShow, onReachBottom } from '@dcloudio/uni-app'
|
||||
import { getInspectionWarningList } from '@/request/api.js'
|
||||
|
||||
// 搜索表单
|
||||
@@ -156,7 +159,7 @@ const startDateValue = ref(Number(new Date()))
|
||||
const endDateValue = ref(Number(new Date()))
|
||||
|
||||
// 统计数据
|
||||
const statistics = reactive({
|
||||
const statistics = reactive({ total: 0, overdue: 0, pending: 0, completed: 0, overdueCompleted: 0, onTimeCompleted: 0 }); const _old_stats = reactive({
|
||||
total: 0,
|
||||
overdue: 0,
|
||||
completed: 0,
|
||||
@@ -167,6 +170,7 @@ const statistics = reactive({
|
||||
const dataList = ref([])
|
||||
const pageNum = ref(1)
|
||||
const pageSize = ref(20)
|
||||
const loadStatus = ref('loadmore')
|
||||
|
||||
// 状态筛选 Tab
|
||||
const statusTabs = ref([
|
||||
@@ -179,7 +183,7 @@ const statusTabs = ref([
|
||||
])
|
||||
const activeStatusTab = ref(0)
|
||||
|
||||
const switchStatusTab = (index) => {
|
||||
const switchStatusTab = (index) => { activeStatusTab.value = index; pageNum.value = 1; dataList.value = []; fetchData(); }; const _unused_tab = (index) => {
|
||||
activeStatusTab.value = index
|
||||
pageNum.value = 1
|
||||
fetchData()
|
||||
@@ -197,14 +201,14 @@ const formatDate = (timestamp) => {
|
||||
// 日期选择确认(开始日期补 00:00:00)
|
||||
const onStartDateConfirm = (e) => {
|
||||
const dateStr = formatDate(e.value)
|
||||
searchForm.startDate = `${dateStr} 00:00:00`
|
||||
searchForm.startDate = dateStr
|
||||
showStartDatePicker.value = false
|
||||
}
|
||||
|
||||
// 日期选择确认(结束日期补 23:59:59)
|
||||
const onEndDateConfirm = (e) => {
|
||||
const dateStr = formatDate(e.value)
|
||||
searchForm.endDate = `${dateStr} 23:59:59`
|
||||
searchForm.endDate = dateStr
|
||||
showEndDatePicker.value = false
|
||||
}
|
||||
|
||||
@@ -239,38 +243,43 @@ const getStatusText = (overdueDays, statusName) => {
|
||||
// 获取数据
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const params = {
|
||||
pageNum: pageNum.value,
|
||||
pageSize: pageSize.value
|
||||
}
|
||||
// 添加查询条件
|
||||
if (searchForm.startDate) {
|
||||
params.startDate = searchForm.startDate
|
||||
}
|
||||
if (searchForm.endDate) {
|
||||
params.endDate = searchForm.endDate
|
||||
}
|
||||
if (searchForm.deptName && searchForm.deptName.trim()) {
|
||||
params.deptName = searchForm.deptName.trim()
|
||||
}
|
||||
// 状态筛选
|
||||
const params = { pageNum: pageNum.value, pageSize: pageSize.value }
|
||||
if (searchForm.startDate) params.startDate = searchForm.startDate
|
||||
if (searchForm.endDate) params.endDate = searchForm.endDate
|
||||
if (searchForm.deptName && searchForm.deptName.trim()) params.deptName = searchForm.deptName.trim()
|
||||
const statusValue = statusTabs.value[activeStatusTab.value].value
|
||||
if (statusValue !== 0) {
|
||||
params.inspectionStatus = statusValue
|
||||
}
|
||||
|
||||
if (statusValue !== 0) params.inspectionStatus = statusValue
|
||||
const res = await getInspectionWarningList(params)
|
||||
if (res.code === 0) {
|
||||
// 更新统计数据
|
||||
if (res.data.statistics) {
|
||||
statistics.total = res.data.statistics.total || 0
|
||||
statistics.overdue = res.data.statistics.overdue || 0
|
||||
statistics.completed = res.data.statistics.completed || 0
|
||||
statistics.pending = res.data.statistics.pending || 0
|
||||
statistics.completed = res.data.statistics.completed || 0
|
||||
statistics.overdueCompleted = res.data.statistics.overdueCompleted || 0
|
||||
statistics.onTimeCompleted = res.data.statistics.onTimeCompleted || 0
|
||||
statusTabs.value[0].count = res.data.statistics.total || 0
|
||||
statusTabs.value[1].count = res.data.statistics.overdue || 0
|
||||
statusTabs.value[2].count = res.data.statistics.pending || 0
|
||||
statusTabs.value[3].count = res.data.statistics.completed || 0
|
||||
statusTabs.value[4].count = res.data.statistics.overdueCompleted || 0
|
||||
statusTabs.value[5].count = res.data.statistics.onTimeCompleted || 0
|
||||
}
|
||||
// 更新列表数据
|
||||
if (res.data.page && res.data.page.records) {
|
||||
dataList.value = res.data.page.records
|
||||
const records = res.data.page.records
|
||||
if (pageNum.value === 1) {
|
||||
dataList.value = records
|
||||
} else {
|
||||
dataList.value = [...dataList.value, ...records]
|
||||
}
|
||||
const totalRecords = res.data.page.total || 0
|
||||
if (dataList.value.length >= totalRecords) {
|
||||
loadStatus.value = 'nomore'
|
||||
} else {
|
||||
loadStatus.value = 'loadmore'
|
||||
}
|
||||
} else {
|
||||
loadStatus.value = 'nomore'
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -281,9 +290,18 @@ const fetchData = async () => {
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
pageNum.value = 1
|
||||
dataList.value = []
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 监听触底上拉加载更多
|
||||
onReachBottom(() => {
|
||||
if (loadStatus.value === 'loadmore') {
|
||||
pageNum.value++
|
||||
fetchData()
|
||||
}
|
||||
})
|
||||
|
||||
// 页面加载
|
||||
onShow(() => {
|
||||
fetchData()
|
||||
|
||||
Reference in New Issue
Block a user