Commit 834a3df1473fe0aa7ae9097c82c4df84bd5fefa3
1 parent
5cb33b90
养护计划列表
Showing
6 changed files
with
774 additions
and
30 deletions
api/maintain-manage/maintain-manage.js
0 → 100644
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | +import { post, get } from '@/common/utils/request'; | |
| 5 | + | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 道路汇总 | |
| 9 | + * @returns {Promise} | |
| 10 | + */ | |
| 11 | +export const roadPage = (params) => { | |
| 12 | + return get('/app-api/app/garden/maintain-plan/page/road',params); | |
| 13 | +}; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * 类型汇总 | |
| 17 | + * @returns {Promise} | |
| 18 | + */ | |
| 19 | +export const planTypePage = (params) => { | |
| 20 | + return get('/app-api/app/garden/maintain-plan/page/plan-type-id',params); | |
| 21 | +}; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * 道路列表 | |
| 25 | + * @returns {Promise} | |
| 26 | + */ | |
| 27 | +export const getRoadDetails = (params) => { | |
| 28 | + return get('/app-api/app/garden/maintain-plan-detail/get/details-road',params); | |
| 29 | +}; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * 巡查计划完成详情 | |
| 33 | + * @returns {Promise} | |
| 34 | + */ | |
| 35 | +export const inspectionCreate = (data) => { | |
| 36 | + return get('/app-api/app/garden/inspection-plan-commit/create',data); | |
| 37 | +}; | ... | ... |
api/patrol-manage/patrol-plan.js
| 1 | -// api/user.js | |
| 2 | 1 | import { post, get } from '@/common/utils/request'; |
| 3 | 2 | |
| 4 | 3 | /** |
| 5 | - * 登录接口 | |
| 6 | - * @param {Object} params {mobile, password, code} | |
| 7 | - * @returns {Promise} | |
| 8 | - */ | |
| 9 | -export const login = (params) => { | |
| 10 | - return post('/admin-api/system/auth/login', params); | |
| 11 | -}; | |
| 12 | - | |
| 13 | -/** | |
| 14 | 4 | * 巡检计划汇总 |
| 15 | 5 | * @returns {Promise} |
| 16 | 6 | */ |
| ... | ... | @@ -27,7 +17,6 @@ export const inspectionPlanDetail = (data) => { |
| 27 | 17 | }; |
| 28 | 18 | |
| 29 | 19 | |
| 30 | -// app-api/app/garden/inspection-plan-commit/get/by/plan_no?plan_no=P1765032669066674' | |
| 31 | 20 | /** |
| 32 | 21 | * 巡查计划完成详情 |
| 33 | 22 | * @returns {Promise} | ... | ... |
pages-sub/daily/maintain-manage/index.vue
| 1 | -<script setup lang="ts"> | |
| 1 | +<template> | |
| 2 | + <view class="main-container"> | |
| 3 | + <!-- 吸顶区域 --> | |
| 4 | + <up-sticky> | |
| 5 | + <view class="sticky-wrap"> | |
| 6 | + <!-- 第一行标签:养护类型 --> | |
| 7 | + <up-tabs | |
| 8 | + v-model="activeType" | |
| 9 | + :list="typeTabs" | |
| 10 | + line-width="40rpx" | |
| 11 | + active-color="#1989fa" | |
| 12 | + inactive-color="#666" | |
| 13 | + :scrollable="true" | |
| 14 | + class="first-tabs" | |
| 15 | + @click="handleTypeChange" | |
| 16 | + ></up-tabs> | |
| 2 | 17 | |
| 3 | -</script> | |
| 18 | + <!-- 第二行标签:状态筛选 --> | |
| 19 | + <up-tabs | |
| 20 | + v-model="activeStatus" | |
| 21 | + :list="statusTabs" | |
| 22 | + line-width="40rpx" | |
| 23 | + active-color="#1989fa" | |
| 24 | + inactive-color="#666" | |
| 25 | + :scrollable="true" | |
| 26 | + class="second-tabs" | |
| 27 | + @click="handleStatusChange" | |
| 28 | + ></up-tabs> | |
| 4 | 29 | |
| 5 | -<template> | |
| 30 | + <!-- 动态搜索框(道路名称/计划名称) --> | |
| 31 | + <up-search | |
| 32 | + v-model="searchValue" | |
| 33 | + :placeholder="searchPlaceholder" | |
| 34 | + bg-color="#f5f5f5" | |
| 35 | + shape="round" | |
| 36 | + :show-action="true" | |
| 37 | + actionText="搜索" | |
| 38 | + :animation="true" | |
| 39 | + @search="handleSearch" | |
| 40 | + @custom="handleSearch" | |
| 41 | + :clearabled="false" | |
| 42 | + maxlength="50" | |
| 43 | + style="margin: 20rpx 20rpx 0" | |
| 44 | + ></up-search> | |
| 45 | + </view> | |
| 46 | + </up-sticky> | |
| 47 | + | |
| 48 | + <!-- 内容区域 - 集成z-paging分页 --> | |
| 49 | + <z-paging | |
| 50 | + ref="pagingRef" | |
| 51 | + v-model="currentList" | |
| 52 | + @query="fetchData" | |
| 53 | + :top="200" | |
| 54 | + :bottom="20" | |
| 55 | + :page-size="pageSize" | |
| 56 | + > | |
| 57 | + <!-- 空数据提示 --> | |
| 58 | + <template #empty> | |
| 59 | + <empty-view/> | |
| 60 | + </template> | |
| 61 | + | |
| 62 | + <!-- 加载中提示(z-paging内置,可自定义) --> | |
| 63 | + <template #loading> | |
| 64 | + <view class="loading-tip"> | |
| 65 | + <up-loading-page text="加载中..."></up-loading-page> | |
| 66 | + </view> | |
| 67 | + </template> | |
| 6 | 68 | |
| 69 | + <!-- 列表内容 --> | |
| 70 | + <view class="content-wrap"> | |
| 71 | + <!-- 道路类型卡片 --> | |
| 72 | + <view v-if="activeType === '道路'" class="card-list"> | |
| 73 | + <view | |
| 74 | + class="card-item" | |
| 75 | + v-for="(item, index) in currentList" | |
| 76 | + :key="index" | |
| 77 | + > | |
| 78 | + <view class="card-content"> | |
| 79 | + <view class="card-text up-line-1"> | |
| 80 | + <span class="field-name">道路名称:</span>{{ item.roadName || '-' }} | |
| 81 | + </view> | |
| 82 | + <view class="card-text up-line-1"> | |
| 83 | + <span class="field-name">所属街道:</span>{{ item.streetName || '-' }} | |
| 84 | + </view> | |
| 85 | + <!-- 养护级别行增加计划明细按钮 --> | |
| 86 | + <view class="card-text up-line-1"> | |
| 87 | + <span class="field-name">养护级别:</span>{{uni.$dict.getDictLabel('conserve_level', item.levelId) || '-'}} | |
| 88 | + <view class="inline-action" @click="goToDetail(item)"> | |
| 89 | + 计划明细 | |
| 90 | + </view> | |
| 91 | + </view> | |
| 92 | + <view class="card-text up-line-1"> | |
| 93 | + <span class="field-name">计划时间:</span>{{ timeFormat(item.beginTime,'yyyy-mm-dd') || '-'}} 至 {{ timeFormat(item.endTime,'yyyy-mm-dd') || '-'}} | |
| 94 | + </view> | |
| 95 | + </view> | |
| 96 | + </view> | |
| 97 | + </view> | |
| 98 | + | |
| 99 | + <!-- 其他养护类型卡片(补植/浇水等) --> | |
| 100 | + <view v-else class="card-list"> | |
| 101 | + <view | |
| 102 | + class="card-item" | |
| 103 | + v-for="(item, index) in currentList" | |
| 104 | + :key="index" | |
| 105 | + > | |
| 106 | + <view class="card-content"> | |
| 107 | + <view class="card-text up-line-1 font-bold">{{ item.planName || '-' }}</view> | |
| 108 | + <view class="card-text up-line-1"> | |
| 109 | + <span class="field-name">计划编码:</span>{{ item.planNo || '-' }} | |
| 110 | + </view> | |
| 111 | + <view class="card-text up-line-1"> | |
| 112 | + <span class="field-name">养护周期:</span>{{ item.rate || '-' }} {{ uni.$dict.getDictLabel('cycle_id_type', item.cycleId) }} | |
| 113 | + </view> | |
| 114 | + <view class="card-text up-line-1"> | |
| 115 | + <span class="field-name">计划完成次数:</span>{{ item.planNum || 0 }} | |
| 116 | + </view> | |
| 117 | + <!-- 已完成次数行增加提交记录按钮 --> | |
| 118 | + <view class="card-text up-line-1"> | |
| 119 | + <span class="field-name">完成比较:</span>{{ item.finishPercent || 0 }}% | |
| 120 | + <view class="inline-action submit-btn" @click="submitRecord(item)"> | |
| 121 | + 提交记录 | |
| 122 | + </view> | |
| 123 | + </view> | |
| 124 | + <view class="card-text up-line-1"> | |
| 125 | + <span class="field-name">计划有效期:</span> {{timeFormat(item.beginTime,'yy-mm-dd hh:MM:ss')}} 至 {{timeFormat(item.endTime,'yy-mm-dd hh:MM:ss')}} | |
| 126 | + </view> | |
| 127 | + </view> | |
| 128 | + </view> | |
| 129 | + </view> | |
| 130 | + </view> | |
| 131 | + </z-paging> | |
| 132 | + </view> | |
| 7 | 133 | </template> |
| 8 | 134 | |
| 9 | -<style scoped> | |
| 135 | +<script setup> | |
| 136 | +import { ref, computed, onMounted } from 'vue' | |
| 137 | +import { onLoad } from '@dcloudio/uni-app' | |
| 138 | +import { roadPage, getRoadDetails, planTypePage } from "@/api/maintain-manage/maintain-manage"; | |
| 139 | +import { timeFormat } from '@/uni_modules/uview-plus'; | |
| 140 | + | |
| 141 | +// 初始化响应式数据 | |
| 142 | +const typeTabs = ref([]) | |
| 143 | +const statusTabs = ref([ | |
| 144 | + { name: '待完成', id: '1' }, | |
| 145 | + { name: '已失效', id: '3' }, | |
| 146 | + { name: '已完成', id: '2' } | |
| 147 | +]) | |
| 148 | + | |
| 149 | +// 核心响应式数据 | |
| 150 | +const activeType = ref('道路') | |
| 151 | +const activeStatus = ref('1') | |
| 152 | +const searchValue = ref('') | |
| 153 | +const pagingRef = ref(null) // z-paging实例 | |
| 154 | + | |
| 155 | +// 分页参数 | |
| 156 | +const pageSize = ref(10) | |
| 157 | +const currentList = ref([]) // z-paging绑定的列表 | |
| 158 | + | |
| 159 | +// 处理字典数据的方法 | |
| 160 | +const handleDictData = () => { | |
| 161 | + // 获取养护类型字典 | |
| 162 | + const tabList = uni.$dict.getDictSimpleList('maintain_type') | |
| 163 | + console.log('原始字典数据:', tabList) | |
| 164 | + | |
| 165 | + if (!tabList || tabList.length === 0) { | |
| 166 | + console.warn('养护类型字典数据为空,请检查字典配置') | |
| 167 | + typeTabs.value = [{ name: '道路', planTypeId: '', id: '道路' }] | |
| 168 | + return | |
| 169 | + } | |
| 170 | + | |
| 171 | + // 1. 过滤掉临时养护(包含"临时养护"的项) | |
| 172 | + const filteredList = tabList.filter(item => !item.label.includes('临时养护')) | |
| 173 | + | |
| 174 | + // 2. 转换为 {name: 字典原生标签, planTypeId: 字典值, id: 标签名} 格式 | |
| 175 | + const convertedList = filteredList.map(item => ({ | |
| 176 | + name: item.label, // 直接使用字典原始名称 | |
| 177 | + planTypeId: item.value, | |
| 178 | + id: item.label // 兼容up-tabs的id字段 | |
| 179 | + })) | |
| 180 | + | |
| 181 | + // 3. 补充道路类型(放在第一位) | |
| 182 | + convertedList.unshift({ | |
| 183 | + name: '道路', | |
| 184 | + planTypeId: '', | |
| 185 | + id: '道路' | |
| 186 | + }) | |
| 187 | + | |
| 188 | + // 赋值给typeTabs | |
| 189 | + typeTabs.value = convertedList | |
| 190 | + console.log('处理后的字典数据:', typeTabs.value) | |
| 191 | +} | |
| 192 | + | |
| 193 | +// 动态搜索框占位符 | |
| 194 | +const searchPlaceholder = computed(() => { | |
| 195 | + return activeType.value === '道路' ? '请输入道路名称' : '请输入计划名称' | |
| 196 | +}) | |
| 197 | + | |
| 198 | +// 养护类型切换 | |
| 199 | +const handleTypeChange = (item) => { | |
| 200 | + console.log('切换养护类型:', item) | |
| 201 | + activeType.value = item.name | |
| 202 | + searchValue.value = '' | |
| 203 | + // 重置分页并刷新 | |
| 204 | + pagingRef.value?.reload() | |
| 205 | +} | |
| 206 | + | |
| 207 | +// 状态筛选切换 | |
| 208 | +const handleStatusChange = (item) => { | |
| 209 | + console.log('切换状态:', item) | |
| 210 | + activeStatus.value = item.id | |
| 211 | + // 重置分页并刷新 | |
| 212 | + pagingRef.value?.reload() | |
| 213 | +} | |
| 214 | + | |
| 215 | +// 搜索处理 | |
| 216 | +const handleSearch = () => { | |
| 217 | + console.log('搜索关键词:', searchValue.value) | |
| 218 | + // 重置分页并刷新 | |
| 219 | + pagingRef.value?.reload() | |
| 220 | +} | |
| 221 | + | |
| 222 | +// 核心数据请求方法(适配z-paging的query回调) | |
| 223 | +const fetchData = async (pageNo, pageSize) => { | |
| 224 | + try { | |
| 225 | + let res = null | |
| 226 | + // 道路类型请求 | |
| 227 | + if (activeType.value === '道路') { | |
| 228 | + res = await roadPage({ | |
| 229 | + roadName: searchValue.value.trim(), | |
| 230 | + pageNo, | |
| 231 | + pageSize, | |
| 232 | + finishState: activeStatus.value | |
| 233 | + }) | |
| 234 | + } else { | |
| 235 | + // 其他养护类型请求 | |
| 236 | + // 找到当前类型对应的planTypeId | |
| 237 | + const currentType = typeTabs.value.find(item => item.name === activeType.value) | |
| 238 | + res = await planTypePage({ | |
| 239 | + planTypeId: currentType?.planTypeId || '', | |
| 240 | + planName: searchValue.value.trim(), | |
| 241 | + pageNo, | |
| 242 | + pageSize, | |
| 243 | + finishState: activeStatus.value | |
| 244 | + }) | |
| 245 | + } | |
| 246 | + | |
| 247 | + // 告诉z-paging数据加载完成 | |
| 248 | + // res.list为当前页数据,res.total为总条数(如果接口返回) | |
| 249 | + pagingRef.value?.complete(res?.list || [], res?.total) | |
| 250 | + } catch (error) { | |
| 251 | + console.error('请求失败:', error) | |
| 252 | + uni.showToast({ title: '网络异常,请重试', icon: 'none' }) | |
| 253 | + // 加载失败,告诉z-paging | |
| 254 | + pagingRef.value?.complete(false) | |
| 255 | + } | |
| 256 | +} | |
| 257 | + | |
| 258 | +// 跳转到计划明细页面 | |
| 259 | +const goToDetail = (item) => { | |
| 260 | + uni.navigateTo({ | |
| 261 | + url: `/pages-sub/daily/maintain-manage/road-detail-list?roadId=${item.roadId}&finish_state=${item.finishState || ''}` | |
| 262 | + }) | |
| 263 | +} | |
| 264 | + | |
| 265 | +// 提交记录 | |
| 266 | +const submitRecord = (item) => { | |
| 267 | + uni.navigateTo({ | |
| 268 | + url: `/pages/submitRecord/submitRecord?planId=${item.id || ''}&planName=${encodeURIComponent(item.planName || '')}` | |
| 269 | + }) | |
| 270 | + console.log('提交记录:', item) | |
| 271 | +} | |
| 272 | + | |
| 273 | +// 页面加载时初始化数据 | |
| 274 | +onLoad(() => { | |
| 275 | + // 先处理字典数据 | |
| 276 | + handleDictData() | |
| 277 | + // 初始化分页数据 | |
| 278 | + pagingRef.value?.reload() | |
| 279 | +}) | |
| 280 | +</script> | |
| 281 | + | |
| 282 | +<style scoped lang="scss"> | |
| 283 | +.main-container { | |
| 284 | + min-height: 100vh; | |
| 285 | + background-color: #f8f8f8; | |
| 286 | +} | |
| 287 | + | |
| 288 | +// 吸顶区域样式 | |
| 289 | +.sticky-wrap { | |
| 290 | + background-color: #fff; | |
| 291 | + padding-bottom: 10rpx; | |
| 292 | + border-bottom: 1px solid #eee; | |
| 293 | + | |
| 294 | + .first-tabs, .second-tabs { | |
| 295 | + margin: 10rpx 0; | |
| 296 | + } | |
| 297 | +} | |
| 298 | + | |
| 299 | +// 内容区域样式 | |
| 300 | +.content-wrap { | |
| 301 | + padding: 20rpx; | |
| 302 | + box-sizing: border-box; | |
| 303 | +} | |
| 304 | + | |
| 305 | +// 卡片列表样式 | |
| 306 | +.card-list { | |
| 307 | + display: flex; | |
| 308 | + flex-direction: column; | |
| 309 | + gap: 20rpx; | |
| 310 | +} | |
| 311 | + | |
| 312 | +// 卡片项样式 | |
| 313 | +.card-item { | |
| 314 | + background-color: #fff; | |
| 315 | + border-radius: 12rpx; | |
| 316 | + padding: 20rpx; | |
| 317 | + box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05); | |
| 318 | + | |
| 319 | + .card-content { | |
| 320 | + flex: 1; | |
| 321 | + display: flex; | |
| 322 | + flex-direction: column; | |
| 323 | + gap: 12rpx; | |
| 324 | + | |
| 325 | + .card-text { | |
| 326 | + font-size: 28rpx; | |
| 327 | + color: #333; | |
| 328 | + line-height: 1.4; | |
| 329 | + width: 100%; | |
| 330 | + display: flex; | |
| 331 | + align-items: center; | |
| 332 | + justify-content: space-between; // 让文本和按钮两端对齐 | |
| 333 | + | |
| 334 | + &.font-bold { | |
| 335 | + font-weight: 600; | |
| 336 | + font-size: 30rpx; | |
| 337 | + } | |
| 338 | + | |
| 339 | + .field-name { | |
| 340 | + color: #999; | |
| 341 | + display: inline-block; | |
| 342 | + margin-right: 15rpx; | |
| 343 | + flex-shrink: 0; | |
| 344 | + } | |
| 345 | + } | |
| 346 | + } | |
| 347 | +} | |
| 348 | + | |
| 349 | +// 行内操作按钮样式 | |
| 350 | +.inline-action { | |
| 351 | + font-size: 26rpx; | |
| 352 | + color: #1989fa; | |
| 353 | + padding: 4rpx 12rpx; | |
| 354 | + border-radius: 4rpx; | |
| 355 | + background-color: #f0f8ff; | |
| 356 | + white-space: nowrap; | |
| 357 | + float: right; | |
| 358 | + &.submit-btn { | |
| 359 | + background-color: #1989fa; | |
| 360 | + color: #fff; | |
| 361 | + } | |
| 362 | +} | |
| 363 | + | |
| 364 | +// 空数据提示 | |
| 365 | +.empty-tip { | |
| 366 | + display: flex; | |
| 367 | + justify-content: center; | |
| 368 | + align-items: center; | |
| 369 | + height: 300rpx; | |
| 370 | + font-size: 28rpx; | |
| 371 | + color: #999; | |
| 372 | +} | |
| 10 | 373 | |
| 374 | +// 加载中提示 | |
| 375 | +.loading-tip { | |
| 376 | + display: flex; | |
| 377 | + justify-content: center; | |
| 378 | + align-items: center; | |
| 379 | + height: 300rpx; | |
| 380 | +} | |
| 11 | 381 | </style> |
| 12 | 382 | \ No newline at end of file | ... | ... |
pages-sub/daily/maintain-manage/road-detail-list.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="page-container"> | |
| 3 | + <!-- 顶部吸顶区域 --> | |
| 4 | + <up-sticky> | |
| 5 | + <view class="sticky-header"> | |
| 6 | + <!-- 状态Tabs --> | |
| 7 | + <up-tabs | |
| 8 | + v-model="activeStatus" | |
| 9 | + :list="statusTabs" | |
| 10 | + line-width="40rpx" | |
| 11 | + active-color="#1989fa" | |
| 12 | + inactive-color="#666" | |
| 13 | + :scrollable="true" | |
| 14 | + class="status-tabs" | |
| 15 | + @click="handleStatusChange" | |
| 16 | + ></up-tabs> | |
| 17 | + | |
| 18 | + <!-- 搜索框 --> | |
| 19 | + <up-search | |
| 20 | + v-model="searchValue" | |
| 21 | + :placeholder="searchPlaceholder" | |
| 22 | + bg-color="#f5f5f5" | |
| 23 | + shape="round" | |
| 24 | + :show-action="true" | |
| 25 | + actionText="搜索" | |
| 26 | + :animation="true" | |
| 27 | + @search="handleSearch" | |
| 28 | + @custom="handleSearch" | |
| 29 | + :clearabled="false" | |
| 30 | + maxlength="50" | |
| 31 | + class="search-input" | |
| 32 | + ></up-search> | |
| 33 | + </view> | |
| 34 | + </up-sticky> | |
| 35 | + | |
| 36 | + <!-- 分页列表区域 --> | |
| 37 | + <z-paging | |
| 38 | + ref="pagingRef" | |
| 39 | + v-model="planList" | |
| 40 | + @query="queryList" | |
| 41 | + :top="140" | |
| 42 | + > | |
| 43 | + <!-- 空数据插槽 --> | |
| 44 | + <template #empty> | |
| 45 | + <view class="empty-container"> | |
| 46 | + <up-empty mode="list" text="暂无相关计划数据"></up-empty> | |
| 47 | + </view> | |
| 48 | + </template> | |
| 49 | + | |
| 50 | + <!-- 列表内容 --> | |
| 51 | + <view class="card-list"> | |
| 52 | + <view | |
| 53 | + class="plan-card" | |
| 54 | + v-for="(item, index) in planList" | |
| 55 | + :key="index" | |
| 56 | + > | |
| 57 | + <view class="card-header"> | |
| 58 | + <text class="plan-name">{{ item.planName || '未命名计划' }}</text> | |
| 59 | +<!-- <text class="plan-status" :class="getStatusClass(item.status)">{{ getStatusText(item.status) }}</text>--> | |
| 60 | + </view> | |
| 61 | + <view class="card-body"> | |
| 62 | + <view class="info-item"> | |
| 63 | + <text class="label">计划编码:</text> | |
| 64 | + <text class="value">{{ item.planNo || '-' }}</text> | |
| 65 | + </view> | |
| 66 | + <view class="info-item"> | |
| 67 | + <text class="label">养护周期:</text> | |
| 68 | + <text class="value">{{ item.rate || '-' }} {{ uni.$dict.getDictLabel('cycle_id_type', item.cycleId) }}</text> | |
| 69 | + </view> | |
| 70 | + <view class="info-item"> | |
| 71 | + <text class="label">计划完成次数:</text> | |
| 72 | + <text class="value">{{ item.planNum || 0 }}</text> | |
| 73 | + </view> | |
| 74 | + <view class="info-item"> | |
| 75 | + <text class="label">已完成比例:</text> | |
| 76 | + <text class="value">{{ item.finishPercent || 0 }}%</text> | |
| 77 | + </view> | |
| 78 | + <view class="info-item"> | |
| 79 | + <text class="label">计划有效期:</text> | |
| 80 | + <text class="value">{{ timeFormat(item.beginTime,'yyyy-mm-dd') || '-'}} 至 {{ timeFormat(item.endTime,'yyyy-mm-dd') || '-'}}</text> | |
| 81 | + </view> | |
| 82 | + </view> | |
| 83 | + <view class="card-footer"> | |
| 84 | + <up-button | |
| 85 | + type="primary" | |
| 86 | + size="mini" | |
| 87 | + @click="handleDetail(item)" | |
| 88 | + > | |
| 89 | + 查看详情 | |
| 90 | + </up-button> | |
| 91 | + </view> | |
| 92 | + </view> | |
| 93 | + </view> | |
| 94 | + </z-paging> | |
| 95 | + </view> | |
| 96 | +</template> | |
| 97 | + | |
| 98 | +<script setup> | |
| 99 | +import { ref, computed, onMounted } from 'vue' | |
| 100 | +import { onLoad, onShow } from '@dcloudio/uni-app' | |
| 101 | +import { timeFormat } from '@/uni_modules/uview-plus' | |
| 102 | +import { getRoadDetails } from "@/api/maintain-manage/maintain-manage"; | |
| 103 | + | |
| 104 | +// ========== 基础数据定义 ========== | |
| 105 | +// 状态Tabs数据 | |
| 106 | +const statusTabs = ref([ | |
| 107 | + { name: '待完成', id: '1' }, | |
| 108 | + { name: '已失效', id: '3' }, | |
| 109 | + { name: '已完成', id: '2' } | |
| 110 | +]) | |
| 111 | + | |
| 112 | +// 响应式数据 | |
| 113 | +const activeStatus = ref('1') // 当前选中的状态 | |
| 114 | +const searchValue = ref('') // 搜索框值 | |
| 115 | +const planList = ref([]) // 计划列表(绑定z-paging) | |
| 116 | +const pagingRef = ref(null) // z-paging实例 | |
| 117 | +const loading = ref(false) // 加载状态 | |
| 118 | + | |
| 119 | +// URL参数存储 | |
| 120 | +const roadId = ref('') // 从URL获取的roadId | |
| 121 | +const finishState = ref('') // 从URL获取的finish_state | |
| 122 | + | |
| 123 | +// 搜索占位符 | |
| 124 | +const searchPlaceholder = computed(() => { | |
| 125 | + return '请输入计划名称' | |
| 126 | +}) | |
| 127 | + | |
| 128 | +// ========== 方法定义 ========== | |
| 129 | +// 从URL获取参数 | |
| 130 | +const getUrlParams = (options) => { | |
| 131 | + // 1. 修复:URL中是roadId(驼峰),不是road_id | |
| 132 | + if (options?.roadId) { | |
| 133 | + roadId.value = options.roadId | |
| 134 | + console.log('从URL获取的roadId:', roadId.value) // 打印验证 | |
| 135 | + } | |
| 136 | + | |
| 137 | + if (options?.finish_state) { | |
| 138 | + finishState.value = options.finish_state | |
| 139 | + // 同步更新Tabs选中状态 | |
| 140 | + activeStatus.value = options.finish_state | |
| 141 | + console.log('从URL获取的finish_state:', finishState.value) | |
| 142 | + } | |
| 143 | +} | |
| 144 | + | |
| 145 | +// 状态切换 | |
| 146 | +const handleStatusChange = (item) => { | |
| 147 | + console.log('切换状态:', item) | |
| 148 | + activeStatus.value = item.id | |
| 149 | + // 更新finishState值 | |
| 150 | + finishState.value = item.id | |
| 151 | + // 重置分页并刷新 | |
| 152 | + pagingRef.value?.reload() | |
| 153 | +} | |
| 154 | + | |
| 155 | +// 搜索处理 | |
| 156 | +const handleSearch = () => { | |
| 157 | + console.log('搜索关键词:', searchValue.value) | |
| 158 | + // 重置分页并刷新 | |
| 159 | + pagingRef.value?.reload() | |
| 160 | +} | |
| 161 | + | |
| 162 | +// 获取状态文本 | |
| 163 | +const getStatusText = (status) => { | |
| 164 | + const statusMap = { | |
| 165 | + '1': '待完成', | |
| 166 | + '2': '已完成', | |
| 167 | + '3': '已失效' | |
| 168 | + } | |
| 169 | + return statusMap[status] || '未知状态' | |
| 170 | +} | |
| 171 | + | |
| 172 | +// 获取状态样式类 | |
| 173 | +const getStatusClass = (status) => { | |
| 174 | + const classMap = { | |
| 175 | + '1': 'status-pending', | |
| 176 | + '2': 'status-completed', | |
| 177 | + '3': 'status-invalid' | |
| 178 | + } | |
| 179 | + return classMap[status] || '' | |
| 180 | +} | |
| 181 | + | |
| 182 | +// 查看详情 | |
| 183 | +const handleDetail = (item) => { | |
| 184 | + uni.navigateTo({ | |
| 185 | + url: `/pages/planDetail/planDetail?planId=${item.id || ''}` | |
| 186 | + }) | |
| 187 | +} | |
| 188 | + | |
| 189 | +// 分页请求数据(z-paging回调) | |
| 190 | +const queryList = async (pageNo, pageSize) => { | |
| 191 | + try { | |
| 192 | + loading.value = true | |
| 193 | + | |
| 194 | + // 构造请求参数:优先使用URL参数 | |
| 195 | + const paramsData = { | |
| 196 | + pageNo: pageNo, | |
| 197 | + pageSize: pageSize, | |
| 198 | + road_id: roadId.value, // 现在能拿到正确的roadId了 | |
| 199 | + finish_state: finishState.value || activeStatus.value, | |
| 200 | + planName: searchValue.value.trim() | |
| 201 | + } | |
| 202 | + | |
| 203 | + console.log('请求参数:', paramsData) // 验证road_id是否有值 | |
| 204 | + const res = await getRoadDetails(paramsData) | |
| 205 | + console.log(res) | |
| 206 | + // 兼容不同的接口返回格式 | |
| 207 | + const listData = res?.list || res || [] | |
| 208 | + | |
| 209 | + // 告知z-paging数据加载完成 | |
| 210 | + pagingRef.value?.complete(listData) | |
| 211 | + loading.value = false | |
| 212 | + } catch (error) { | |
| 213 | + console.error('请求失败:', error) | |
| 214 | + uni.showToast({ title: '加载失败,请重试', icon: 'none' }) | |
| 215 | + pagingRef.value?.complete(false) | |
| 216 | + loading.value = false | |
| 217 | + } | |
| 218 | +} | |
| 219 | + | |
| 220 | +// ========== 生命周期修复 ========== | |
| 221 | +// 2. 修复:只有onLoad才会接收页面跳转的options参数 | |
| 222 | +onLoad((options) => { | |
| 223 | + // 页面首次加载时获取URL参数 | |
| 224 | + getUrlParams(options) | |
| 225 | + // 初始化数据 | |
| 226 | + pagingRef.value?.reload() | |
| 227 | +}) | |
| 228 | + | |
| 229 | +onShow(() => { | |
| 230 | + // 可选:页面再次显示时刷新(比如从详情页返回) | |
| 231 | + // if (roadId.value) { // 有roadId才刷新 | |
| 232 | + // pagingRef.value?.reload() | |
| 233 | + // } | |
| 234 | +}) | |
| 235 | + | |
| 236 | +onMounted(() => { | |
| 237 | + // 可选:初始化其他逻辑 | |
| 238 | +}) | |
| 239 | +</script> | |
| 240 | + | |
| 241 | +<style scoped lang="scss"> | |
| 242 | +.page-container { | |
| 243 | + min-height: 100vh; | |
| 244 | + background-color: #f8f8f8; | |
| 245 | +} | |
| 246 | + | |
| 247 | +// 顶部吸顶区域样式 | |
| 248 | +.sticky-header { | |
| 249 | + background-color: #ffffff; | |
| 250 | + padding-bottom: 10rpx; | |
| 251 | + border-bottom: 1px solid #eee; | |
| 252 | + | |
| 253 | + // 状态Tabs样式 | |
| 254 | + .status-tabs { | |
| 255 | + margin: 10rpx 0 0 0; | |
| 256 | + } | |
| 257 | + | |
| 258 | + // 搜索框样式 | |
| 259 | + .search-input { | |
| 260 | + margin: 20rpx 20rpx 10rpx !important; | |
| 261 | + } | |
| 262 | +} | |
| 263 | + | |
| 264 | +// 卡片列表样式 | |
| 265 | +.card-list { | |
| 266 | + padding: 0 20rpx; | |
| 267 | + display: flex; | |
| 268 | + flex-direction: column; | |
| 269 | + gap: 20rpx; | |
| 270 | +} | |
| 271 | + | |
| 272 | +// 计划卡片样式 | |
| 273 | +.plan-card { | |
| 274 | + background-color: #ffffff; | |
| 275 | + border-radius: 12rpx; | |
| 276 | + padding: 24rpx; | |
| 277 | + box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05); | |
| 278 | + | |
| 279 | + // 卡片头部 | |
| 280 | + .card-header { | |
| 281 | + display: flex; | |
| 282 | + justify-content: space-between; | |
| 283 | + align-items: center; | |
| 284 | + margin-bottom: 20rpx; | |
| 285 | + padding-bottom: 12rpx; | |
| 286 | + border-bottom: 1px solid #f5f5f5; | |
| 287 | + | |
| 288 | + .plan-name { | |
| 289 | + font-size: 30rpx; | |
| 290 | + font-weight: 600; | |
| 291 | + color: #333; | |
| 292 | + } | |
| 293 | + | |
| 294 | + .plan-status { | |
| 295 | + font-size: 24rpx; | |
| 296 | + padding: 4rpx 12rpx; | |
| 297 | + border-radius: 20rpx; | |
| 298 | + | |
| 299 | + // 状态样式 | |
| 300 | + &.status-pending { | |
| 301 | + background-color: #fff7e6; | |
| 302 | + color: #ff9f1c; | |
| 303 | + } | |
| 304 | + | |
| 305 | + &.status-completed { | |
| 306 | + background-color: #e8f8f5; | |
| 307 | + color: #00b42a; | |
| 308 | + } | |
| 309 | + | |
| 310 | + &.status-invalid { | |
| 311 | + background-color: #f5f5f5; | |
| 312 | + color: #999; | |
| 313 | + } | |
| 314 | + } | |
| 315 | + } | |
| 316 | + | |
| 317 | + // 卡片内容 | |
| 318 | + .card-body { | |
| 319 | + display: flex; | |
| 320 | + flex-direction: column; | |
| 321 | + gap: 16rpx; | |
| 322 | + margin-bottom: 20rpx; | |
| 323 | + | |
| 324 | + .info-item { | |
| 325 | + display: flex; | |
| 326 | + align-items: center; | |
| 327 | + font-size: 28rpx; | |
| 328 | + | |
| 329 | + .label { | |
| 330 | + color: #999; | |
| 331 | + flex-shrink: 0; | |
| 332 | + } | |
| 333 | + | |
| 334 | + .value { | |
| 335 | + color: #333; | |
| 336 | + flex: 1; | |
| 337 | + } | |
| 338 | + } | |
| 339 | + } | |
| 340 | + | |
| 341 | + // 卡片底部 | |
| 342 | + .card-footer { | |
| 343 | + display: flex; | |
| 344 | + justify-content: flex-end; | |
| 345 | + } | |
| 346 | +} | |
| 347 | + | |
| 348 | +// 空数据样式 | |
| 349 | +.empty-container { | |
| 350 | + display: flex; | |
| 351 | + justify-content: center; | |
| 352 | + align-items: center; | |
| 353 | + height: 400rpx; | |
| 354 | +} | |
| 355 | +</style> | |
| 0 | 356 | \ No newline at end of file | ... | ... |
pages-sub/daily/patrol-manage/index.vue deleted
pages.json
| ... | ... | @@ -83,14 +83,18 @@ |
| 83 | 83 | "path": "12345-order/index", |
| 84 | 84 | "style": { "navigationBarTitleText": "12345工单" } |
| 85 | 85 | }, |
| 86 | + | |
| 86 | 87 | { |
| 87 | - "path": "patrol-manage/index", | |
| 88 | - "style": { "navigationBarTitleText": "巡查管理" } | |
| 88 | + "path": "maintain-manage/index", | |
| 89 | + "style": { "navigationBarTitleText": "养护计划" } | |
| 89 | 90 | }, |
| 91 | + | |
| 90 | 92 | { |
| 91 | - "path": "maintain-manage/index", | |
| 92 | - "style": { "navigationBarTitleText": "养护管理" } | |
| 93 | + "path": "maintain-manage/road-detail-list", | |
| 94 | + "style": { "navigationBarTitleText": "道路明细列表" } | |
| 93 | 95 | } |
| 96 | + | |
| 97 | + | |
| 94 | 98 | ] |
| 95 | 99 | }, |
| 96 | 100 | { | ... | ... |