index.vue
6.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<template>
<view class="page-container">
<!-- 顶部固定区域:Tabs + 搜索框 -->
<up-sticky>
<view class="sticky-header">
<u-tabs
:list="tabList"
:is-scroll="false"
:activeStyle="{
color: '#2563EB',
fontWeight: 'bold',
transform: 'scale(1.05)'
}"
:inactiveStyle="{
color: '#606266',
transform: 'scale(1)'
}"
font-size="28rpx"
@change="handleTabChange"
></u-tabs>
<up-search
v-model="searchValue"
placeholder="请输入道路名称"
bg-color="#f5f5f5"
shape="round"
:show-action="true" actionText="搜索" :animation="true"
@search="handleSearch"
@custom="handleSearch"
:clearabled="false"
maxlength="50"
style="margin: 16rpx 24rpx 0"
></up-search>
</view>
</up-sticky>
<z-paging
ref="pagingRef"
v-model="planList"
@query="queryList"
:auto-show-system-loading="true"
>
<template #empty>
<empty-view/>
</template>
<!-- 计划卡片列表 -->
<view class="common-card-list" style="padding-top: 108px;">
<view class="plan-card" v-for="(item,index) in planList" :key="`${item.batchNo}_${index}`">
<!-- 卡片标题:道路名称 + 状态标签 -->
<view class="plan-card__head">
<view class="plan-card__title">{{ item.roadName || '-' }}</view>
<view class="status-tag"
:class="activeTab === '1' ? 'common-pending-tag' : (activeTab === '2' ? 'common-finish-tag' : 'common-invalid-tag')">
{{ activeTab === '1' ? '待完成' : (activeTab === '2' ? '已完成' : (activeTab === '3' ? '已失效' : '已终止')) }}
</view>
</view>
<view class="u-body-item u-flex">
<view class="u-body-item-title">计划编码:</view>
<view class="u-line-1 u-body-value">{{ item.batchNo || '-' }}</view>
</view>
<view class="u-body-item u-flex">
<view class="u-body-item-title">所属街道:</view>
<view class="u-line-1 u-body-value">{{ item.streetName }}
</view>
</view>
<view class="u-body-item u-flex">
<view class="u-body-item-title">养护级别:</view>
<view class="u-line-1 u-body-value">{{uni.$dict.getDictLabel('conserve_level', item.levelId) || '-'}}</view>
</view>
<view class="u-body-item u-flex">
<view class="u-body-item-title">计划类型:</view>
<view class="u-line-1 u-body-value">{{uni.$dict.getDictLabel('inspection_maintain_type', item.planTypeId)}}</view>
</view>
<view class="u-body-item u-flex">
<view class="u-body-item-title">计划时间:</view>
<view class="u-line-1 u-body-value">{{ timeFormat(item.beginTime, 'yyyy-mm-dd') || '-' }} 至
{{ timeFormat(item.endTime, 'yyyy-mm-dd') || '-' }}
</view>
</view>
<!-- 底部操作区(分隔线 + 右对齐按钮) -->
<view class="card-action-row">
<view class="mini-btn mini-btn--primary" @click="gotoDetail(item)">计划明细</view>
</view>
</view>
</view>
</z-paging>
</view>
</template>
<script setup>
import { timeFormat } from '@/uni_modules/uview-plus';
import { ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { inspectionPlanPage } from "@/api/patrol-manage/patrol-plan";
import { convertArrToDateStr } from "@/common/utils/common";
// Tabs 配置
const tabList = ref([
{name: '待完成', id: '1'},
{name: '已失效', id: '3'},
{name: '已完成', id: '2'},
{ name: '已终止', id: '4' }
]);
const pagingRef = ref(null)
const activeTab = ref('1');
// 搜索相关
const searchValue = ref('');
// 分页相关
// const pageNo = ref(1);
// const pageSize = ref(10);
const planList = ref([]);
// Tab切换
const handleTabChange = (val) => {
console.log(val)
console.log(activeTab.value)
activeTab.value = val.id
searchValue.value = ''
pagingRef.value.reload()
};
// 搜索/清空搜索
const handleSearch = () => {
// searchValue.value = '';
console.log(searchValue.value)
pagingRef.value.reload()
};
const handleSearchClear = () => {
// searchValue.value = ''
pagingRef.value.reload()
};
// 加载数据
const queryList = async (pageNo, pageSize) => {
try {
const params = {
roadName: searchValue.value.trim() || '',
pageNo: pageNo,
pageSize: pageSize,
finishState: activeTab.value
};
console.log('请求参数:', params);
const res = await inspectionPlanPage(params);
console.log('接口返回:', res);
pagingRef.value.complete(res.list);
} catch (error) {
console.error('加载失败:', error);
// 修复点4:加载失败调用complete(false)
pagingRef.value?.complete(false);
uni.showToast({title: '加载失败,请重试', icon: 'none'});
}
};
// 跳转明细
const gotoDetail = (item) => {
uni.navigateTo({
url: `/pages-sub/daily/patrol-manage/pending-plan-detail?batchNo=${item.batchNo}&status=${activeTab.value}&busiLine=${item.busiLine}`
});
};
// 修复点5:优化页面生命周期逻辑
onLoad(() => {
// auto=true时,z-pagingRef会自动触发query,此处可省略手动调用;若需强制初始化,可加:
// pagingRef.value?.triggerQuery();
});
// 仅在页面从明细页返回时,若有数据则刷新当前tab数据(避免干扰上拉加载)
onShow(() => {
pagingRef.value?.reload()
});
</script>
<style scoped lang="scss">
.page-container {
}
.sticky-header {
background-color: #ffffff;
padding-bottom: 24rpx;
border-bottom: 1rpx solid #E8EBF0;
.search-input {
margin: 16rpx 24rpx 0 !important;
}
}
/* 计划卡片:白底圆角 + 标题/状态 + 底部操作区(设计稿 .tcard) */
.plan-card {
margin: 0 24rpx 24rpx;
padding: 28rpx 28rpx 24rpx;
background-color: #ffffff;
border-radius: 16rpx;
box-shadow: 0 4rpx 16rpx rgba(17, 24, 39, 0.06);
}
.plan-card__head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20rpx;
}
.plan-card__title {
flex: 1;
min-width: 0;
margin-right: 16rpx;
font-size: 32rpx;
font-weight: 500;
color: #1F2937;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.plan-card .u-body-item {
margin-bottom: 12rpx;
}
</style>