road-detail-list.vue
8.19 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<template>
<view class="page-container">
<!-- 顶部吸顶区域 -->
<up-sticky>
<view class="sticky-header">
<!-- 状态Tabs -->
<up-tabs
v-model="activeStatus"
:list="statusTabs"
line-width="44rpx"
active-color="#2563EB"
inactive-color="#4B5563"
:scrollable="true"
class="status-tabs"
@click="handleStatusChange"
></up-tabs>
<!-- 搜索框 -->
<up-search
v-model="searchValue"
:placeholder="searchPlaceholder"
bg-color="#f5f5f5"
shape="round"
:show-action="true"
actionText="搜索"
:animation="true"
@search="handleSearch"
@custom="handleSearch"
:clearabled="false"
maxlength="50"
class="search-input"
></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 plan-card-list">
<up-card
:border="false"
:foot-border-top="false"
:head-border-bottom="false"
margin="0"
padding-head="24rpx 24rpx 0"
padding-body="16rpx 24rpx 24rpx"
box-shadow="0 4rpx 16rpx rgba(17, 24, 39, 0.06)"
v-for="(item,index) in planList"
:key="`${item.planNo}_${index}`"
>
<!-- 自定义标题区域 -->
<template #head>
<view class="card-header">
<view class="common-card-title common-name">{{ item.planName || '无计划名称' }}</view>
<!-- 待完成标识 -->
<view v-show="item.finishState == 1 " class="common-pending-tag">待完成</view>
<!-- 已失效标识 -->
<view v-show="item.finishState == 3 " class="common-invalid-tag">已失效</view>
<view v-show="item.finishState == 2 " class="common-finish-tag">已完成</view>
</view>
</template>
<template #body>
<view class="card-body">
<!-- <view class="">-->
<!-- <up-button-->
<!-- type="primary"-->
<!-- size="mini"-->
<!-- @click="submitRecord(item)"-->
<!-- class="submit-record-btn"-->
<!-- :disabled="item.finishState == 3"-->
<!-- >-->
<!-- {{ item.finishState ==3 ? '补交记录' : '提交记录' }}-->
<!-- </up-button>-->
<!-- </view>-->
<view class="u-body-item u-flex">
<view class="u-body-item-title">计划编码:</view>
<view class="u-line-1 u-body-value">{{ item.planNo || '-' }}</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.rate || '-' }}
{{ uni.$dict.getDictLabel('cycle_id_type', item.cycleId) }}
</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.planNum || 0 }}</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.planFinishNum || 0 }}</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 v-if="item.finishState ==3" class="mini-btn mini-btn--plain">补交记录</view>
<view v-else class="mini-btn mini-btn--primary" @click="submitRecord(item)">提交记录</view>
</view>
</view>
</template>
</up-card>
</view>
</z-paging>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { timeFormat } from '@/uni_modules/uview-plus'
import { getRoadDetails } from "@/api/maintain-manage/maintain-manage";
// ========== 基础数据定义 ==========
const statusTabs = ref([
{name: '待完成', id: '1'},
{name: '已失效', id: '3'},
{name: '已完成', id: '2'},
{ name: '已终止', id: '4' }
])
const activeStatus = ref('1')
const searchValue = ref('')
const planList = ref([])
const pagingRef = ref(null)
const roadId = ref('')
const finishState = ref('')
// 搜索占位符
const searchPlaceholder = ref('请输入计划名称')
// ========== 方法定义 ==========
const getUrlParams = (options) => {
if (options?.roadId) {
roadId.value = options.roadId
console.log('从URL获取的roadId:', roadId.value)
}
if (options?.finish_state) {
finishState.value = options.finish_state
// activeStatus.value = options.finish_state
console.log('从URL获取的finish_state:', finishState.value)
}
}
const handleStatusChange = (item) => {
console.log('切换状态:', item)
activeStatus.value = item.id
finishState.value = item.id
pagingRef.value?.reload()
}
const handleSearch = () => {
console.log('搜索关键词:', searchValue.value)
pagingRef.value?.reload()
}
const submitRecord = (item) => {
// 已失效状态下直接返回,不执行跳转
if (item.finishState === '3') {
return
}
console.log('提交记录:', item.planFinishNum)
if (item.planFinishNum == 0) {
uni.navigateTo({
url: `/pages-sub/daily/maintain-manage/add-record?finishState=${item.finishState}&planNo=${item.planNo}&planTypeId=${item.planTypeId}&businessType=${item.busiLine}`
})
} else {
uni.navigateTo({
url: `/pages-sub/daily/maintain-manage/pending-plan-detail?finishState=${item.finishState}&planNo=${item.planNo}&planTypeId=${item.planTypeId}&businessType=${item.busiLine}`
})
}
}
const queryList = async (pageNo, pageSize) => {
try {
const paramsData = {
pageNo: pageNo,
pageSize: pageSize,
roadId: roadId.value,
finishState: activeStatus.value,
planName: searchValue.value.trim()
}
console.log('请求参数:', paramsData)
const res = await getRoadDetails(paramsData)
console.log(res)
const listData = res?.list || res || []
pagingRef.value?.complete(listData)
} catch (error) {
console.error('请求失败:', error)
uni.showToast({title: '加载失败,请重试', icon: 'none'})
pagingRef.value?.complete(false)
}
}
// ========== 生命周期 ==========
onLoad((options) => {
getUrlParams(options)
})
onShow(() => {
// if (roadId.value) {
// pagingRef.value?.reload()
// }
pagingRef.value?.reload()
})
</script>
<style scoped lang="scss">
/* 页面底色:统一浅灰蓝(设计稿 --page-bg) */
.page-container {
min-height: 100vh;
background-color: #F4F6FA;
box-sizing: border-box;
}
// 顶部吸顶区域样式
/* 筛选条:Tabs(44px) + 搜索条上 8px / 左右 12px / 下 12px(设计稿 .tabs + .search-bar) */
.sticky-header {
background-color: #ffffff;
padding-bottom: 24rpx;
border-bottom: 1rpx solid #E8EBF0;
.search-input {
margin: 16rpx 24rpx 0 !important;
}
}
/* 卡片列表:页面左右 24rpx、卡片之间 24rpx(设计稿 .body)
* 顶部留白 = 吸顶筛选条高度(44+8+32+12=96px) + 12px 间距,避免卡片被吸顶区盖住 */
.plan-card-list {
display: flex;
flex-direction: column;
gap: 24rpx;
padding: 216rpx 24rpx 24rpx;
}
/* 卡片体:内边距由 up-card 的 paddingBody 控制,此处不再叠加 */
.card-body {
padding: 0;
}
</style>