Commit 68d3fcfe8914d0998ba1cf0daf8d4189c6befe3e
1 parent
1d77d32a
详细
Showing
4 changed files
with
54 additions
and
165 deletions
pages-sub/daily/maintain-manage/finish-plan-detail.vue
| ... | ... | @@ -85,11 +85,7 @@ |
| 85 | 85 | </template> |
| 86 | 86 | </up-cell> --> |
| 87 | 87 | |
| 88 | - <up-cell | |
| 89 | - title="提交时间" | |
| 90 | - :value="i.createTime==null?'--':timeFormat(i.createTime,'yyyy-mm-dd hh:MM:ss')" | |
| 91 | - align="middle" | |
| 92 | - ></up-cell> | |
| 88 | + | |
| 93 | 89 | |
| 94 | 90 | <up-cell |
| 95 | 91 | title="提交人" |
| ... | ... | @@ -97,6 +93,12 @@ |
| 97 | 93 | align="middle" |
| 98 | 94 | |
| 99 | 95 | ></up-cell> |
| 96 | + | |
| 97 | + <up-cell | |
| 98 | + title="提交时间" | |
| 99 | + :value="i.createTime==null?'--':timeFormat(i.createTime,'yyyy-mm-dd hh:MM:ss')" | |
| 100 | + align="middle" | |
| 101 | + ></up-cell> | |
| 100 | 102 | </up-cell-group> |
| 101 | 103 | |
| 102 | 104 | <!-- 动态配置的养护字段填报值(garden_work_record/garden_work_field_value),未填报过则整段不显示 --> |
| ... | ... | @@ -108,6 +110,11 @@ |
| 108 | 110 | title="" |
| 109 | 111 | > |
| 110 | 112 | <up-cell v-for="(f, fi) in i.fieldRows" :key="fi" align="middle"> |
| 113 | + <!-- <up-cell | |
| 114 | + title="提交时间" | |
| 115 | + :value="i.createTime==null?'--':timeFormat(i.createTime,'yyyy-mm-dd hh:MM:ss')" | |
| 116 | + align="middle" | |
| 117 | + ></up-cell> --> | |
| 111 | 118 | <template #title> |
| 112 | 119 | <view class="field-cell-title-multi">{{f.name}}</view> |
| 113 | 120 | </template> |
| ... | ... | @@ -199,8 +206,8 @@ const previewImage = (currentUrl, allUrls) => { |
| 199 | 206 | /** |
| 200 | 207 | * 获取工单详情 |
| 201 | 208 | */ |
| 202 | -const getOrderDetail = async (planNo: string, commitId?: string, workRecordIndex: number = 0) => { | |
| 203 | - console.log('===传入的workRecordIndex===', workRecordIndex) | |
| 209 | +const getOrderDetail = async (planNo: string, commitId?: string) => { | |
| 210 | + console.log('getOrderDetail') | |
| 204 | 211 | try { |
| 205 | 212 | loading.value = true; |
| 206 | 213 | let queryData: any = { |
| ... | ... | @@ -216,21 +223,13 @@ const getOrderDetail = async (planNo: string, commitId?: string, workRecordIndex |
| 216 | 223 | const list = res.data?.list || res.list || []; |
| 217 | 224 | |
| 218 | 225 | orderDetail.value = list.map(item => { |
| 219 | - let useValues: any[] = [] | |
| 220 | - // 取 workRecords 指定下标的 values | |
| 221 | - if (Array.isArray(item.workRecords) && item.workRecords.length > 0) { | |
| 222 | - const targetRecord = item.workRecords[workRecordIndex]; | |
| 223 | - if (targetRecord && Array.isArray(targetRecord.values)) { | |
| 224 | - useValues = targetRecord.values | |
| 225 | - } | |
| 226 | - } | |
| 226 | + // ✅直接使用接口返回的 item.fields,不再读取 workRecords | |
| 227 | + const useValues = Array.isArray(item.fields) ? item.fields : [] | |
| 227 | 228 | return { |
| 228 | 229 | ...item, |
| 229 | - // ✅这里直接拿 workRecords[index].values,传给buildFieldRow渲染 | |
| 230 | 230 | fieldRows: useValues.map(buildFieldRow) |
| 231 | 231 | } |
| 232 | 232 | }) |
| 233 | - | |
| 234 | 233 | } catch (error) { |
| 235 | 234 | console.error('获取工单详情失败:', error); |
| 236 | 235 | uni.showToast({title: '加载失败,请重试', icon: 'none'}); |
| ... | ... | @@ -241,6 +240,7 @@ const getOrderDetail = async (planNo: string, commitId?: string, workRecordIndex |
| 241 | 240 | |
| 242 | 241 | |
| 243 | 242 | |
| 243 | + | |
| 244 | 244 | // ========== 动态配置字段(fieldValue)展示 ========== |
| 245 | 245 | // 解析口径与 PC 端 FieldValueCell.vue + WorkRecordTab.vue 保持一致: |
| 246 | 246 | // 后端 valueText 是「类型无关直拷、提交无校验」,历史格式与脏数据都可能出现,故所有解析一律降级、不抛异常。 |
| ... | ... | @@ -540,16 +540,15 @@ const openGeo = (geo) => { |
| 540 | 540 | // const workRecordIndex = ref(0) |
| 541 | 541 | // 页面加载 |
| 542 | 542 | onLoad((options) => { |
| 543 | - const {planNo, commitId ,index} = options; | |
| 544 | - console.log("load:"+index) | |
| 545 | - const workRecordIndex= Number(index) | |
| 543 | + const {planNo, commitId } = options; | |
| 546 | 544 | if (planNo) { |
| 547 | - getOrderDetail(planNo, commitId,workRecordIndex); | |
| 545 | + getOrderDetail(planNo, commitId); | |
| 548 | 546 | } else { |
| 549 | 547 | loading.value = false; |
| 550 | 548 | uni.showToast({title: '缺少工单ID', icon: 'none'}); |
| 551 | 549 | } |
| 552 | 550 | }); |
| 551 | + | |
| 553 | 552 | </script> |
| 554 | 553 | |
| 555 | 554 | <style scoped lang="scss"> | ... | ... |
pages-sub/daily/maintain-manage/index.vue
| ... | ... | @@ -81,7 +81,7 @@ |
| 81 | 81 | <!-- </up-button>--> |
| 82 | 82 | <!-- </view>--> |
| 83 | 83 | |
| 84 | - <view class="common-custom-btn" style="--btn-top: 18px;" @click="goToDetail(item)"> | |
| 84 | + <view class="common-custom-btn" style="--btn-top: 48px;" @click="goToDetail(item)"> | |
| 85 | 85 | 养护任务 |
| 86 | 86 | </view> |
| 87 | 87 | <!-- <view class="u-body-item u-flex">--> |
| ... | ... | @@ -104,6 +104,12 @@ |
| 104 | 104 | </view> |
| 105 | 105 | </view> --> |
| 106 | 106 | |
| 107 | + <view class="u-body-item u-flex"> | |
| 108 | + <view class="u-body-item-title">业务线:</view> | |
| 109 | + <view class="u-line-1 u-body-value">{{ uni.$dict.getDictLabel('business_line', item.busiLine) || item.busiLine || '-' }}</view> | |
| 110 | +</view> | |
| 111 | + | |
| 112 | + | |
| 107 | 113 | <view class="u-body-item u-flex common-item-center common-justify-between"> |
| 108 | 114 | <view class="u-body-item-title">养护级别: {{uni.$dict.getDictLabel('conserve_level', item.levelId) || '-'}}</view> |
| 109 | 115 | |
| ... | ... | @@ -302,14 +308,11 @@ const fetchData = async (pageNo, pageSize) => { |
| 302 | 308 | |
| 303 | 309 | // 跳转到计划明细页面 |
| 304 | 310 | const goToDetail = (item) => { |
| 305 | - // uni.navigateTo({ | |
| 306 | - // url: `/pages-sub/daily/maintain-manage/road-detail-list?roadId=${item.roadId}&finish_state=${item.finishState || ''} &businessType=${item.busiLine}` | |
| 307 | - // }) | |
| 308 | - | |
| 311 | + // 存入完整对象给下一页 | |
| 312 | + uni.setStorageSync('temp_maintain_item', item) | |
| 309 | 313 | uni.navigateTo({ |
| 310 | - url: `/pages-sub/daily/maintain-manage/type-list?roadName=${encodeURIComponent(item.roadName)}&planTypeId=${item.planTypeId}` | |
| 311 | -}) | |
| 312 | - | |
| 314 | + url: `/pages-sub/daily/maintain-manage/type-list` | |
| 315 | + }) | |
| 313 | 316 | } |
| 314 | 317 | |
| 315 | 318 | // 提交记录 | ... | ... |
pages-sub/daily/maintain-manage/type-list-page.vue
| ... | ... | @@ -48,14 +48,14 @@ |
| 48 | 48 | <up-modal :show="invalidModalShow" title="提示" :closeOnClickOverlay="false" :showConfirmButton="true" |
| 49 | 49 | :showCancelButton="true" @cancel="handleInvalidModalCancel" @confirm="confirmSetInvalid"> |
| 50 | 50 | <view class="invalid-modal-content"> |
| 51 | - <text>确定要置为失效该任务吗?</text> | |
| 51 | + <text>确定置为失效吗?</text> | |
| 52 | 52 | </view> |
| 53 | 53 | </up-modal> |
| 54 | 54 | <!-- ========== 结束任务二次确认弹窗 ========== --> |
| 55 | 55 | <up-modal :show="endTaskModalShow" title="提示" :closeOnClickOverlay="false" :showConfirmButton="true" |
| 56 | 56 | :showCancelButton="true" @cancel="handleEndTaskModalCancel" @confirm="confirmEndTask"> |
| 57 | 57 | <view class="end-task-modal-content"> |
| 58 | - <text>确定要结束该任务吗?结束后将不可再去作业。</text> | |
| 58 | + <text>确定要结束吗?</text> | |
| 59 | 59 | </view> |
| 60 | 60 | </up-modal> |
| 61 | 61 | </view> | ... | ... |
pages-sub/daily/maintain-manage/type-list.vue
| ... | ... | @@ -18,143 +18,41 @@ |
| 18 | 18 | </template> |
| 19 | 19 | <script setup lang="ts"> |
| 20 | 20 | import { ref } from 'vue' |
| 21 | -import { maintainPlan, maintainPlanNum } from "@/api/maintain-manage/maintain-manage"; | |
| 22 | -import { getDictLabel } from '@/common/utils/dict'; | |
| 23 | -import { useUserStore } from '@/pinia/user'; | |
| 24 | -// 新增维护仓库 | |
| 25 | -// import { useMaintainStore } from '@/pinia/maintain'; | |
| 26 | -import { onLoad, onShow } from '@dcloudio/uni-app'; | |
| 27 | -const userStore = useUserStore(); | |
| 28 | -// const maintainStore = useMaintainStore(); | |
| 29 | -// 标签列表,合并之后的数据结构 | |
| 30 | -// rawList:保存该分类下全部原始数据,用于点击跳转 | |
| 21 | +import { onLoad, onShow, onUnload } from '@dcloudio/uni-app'; | |
| 22 | + | |
| 31 | 23 | const tagList = ref<Array<{ |
| 32 | - label: string, | |
| 33 | - count: number, | |
| 34 | - rawList: any[], | |
| 35 | 24 | planTypeId: string | number |
| 25 | + planTypeName: string | |
| 26 | + batchNos: string[] | |
| 27 | + todayPendingCount: number | |
| 36 | 28 | }>>([]) |
| 37 | -const roadName = ref<string | null>(null) | |
| 38 | -const levelId = ref<string | null>(null) | |
| 39 | -onLoad((options) => { | |
| 40 | - roadName.value = decodeURIComponent(options.roadName) | |
| 41 | - // levelId.value = decodeURIComponent(options.levelId); | |
| 42 | -}); | |
| 29 | + | |
| 43 | 30 | onShow(() => { |
| 44 | - if (!roadName.value) { | |
| 31 | + // 从storage拿上一页传过来完整对象 | |
| 32 | + const item = uni.getStorageSync('temp_maintain_item') | |
| 33 | + if (!item) { | |
| 45 | 34 | uni.showToast({ |
| 46 | - title: '道路不存在', | |
| 35 | + title: '数据异常,请返回重试', | |
| 47 | 36 | icon: 'none' |
| 48 | 37 | }); |
| 49 | 38 | return; |
| 50 | 39 | } |
| 51 | - fetchData(); | |
| 40 | + // 直接取planTypes | |
| 41 | + tagList.value = item.planTypes || [] | |
| 52 | 42 | }); |
| 53 | -// 第一步:获取plan列表 | |
| 54 | -const fetchData = async () => { | |
| 55 | - try { | |
| 56 | - const res = await maintainPlan({ | |
| 57 | - roadName: roadName.value, | |
| 58 | - // roadName: '月坛南街', | |
| 59 | - pageNo:1, | |
| 60 | - pageSize:100, | |
| 61 | - finishState:1 | |
| 62 | - // levelId: levelId.value | |
| 63 | - }) | |
| 64 | - console.log('maintainPlan返回', res) | |
| 65 | - if (res.list.length == 0) { | |
| 66 | - tagList.value = [] | |
| 67 | - uni.showToast({ | |
| 68 | - title: '暂无养护类型', | |
| 69 | - icon: 'none' | |
| 70 | - }); | |
| 71 | - return | |
| 72 | - } | |
| 73 | - tagList.value = res.list[0].planTypes | |
| 74 | - // await requestBatchList(res.list) | |
| 75 | - } catch (error) { | |
| 76 | - console.error('请求失败:', error) | |
| 77 | - uni.showToast({ title: '网络异常,请重试', icon: 'none' }) | |
| 78 | - } | |
| 79 | -} | |
| 80 | -// 串行遍历所有batchNo,逐个调用第二个接口 | |
| 81 | -const requestBatchList = async (list: any[]) => { | |
| 82 | - const resultTags: any[] = [] | |
| 83 | - for (const item of list) { | |
| 84 | - try { | |
| 85 | - const numRes = await maintainPlanNum({ | |
| 86 | - pageNo: 1, | |
| 87 | - pageSize: 10, | |
| 88 | - planNo: '', | |
| 89 | - planAttr: item.planAttr ?? '', | |
| 90 | - finishState: 1, | |
| 91 | - batchNo: item.batchNo | |
| 92 | - }) | |
| 93 | - const total = numRes?.total || 0 | |
| 94 | - // 字典转换,把planTypeId转为养护类型名称 | |
| 95 | - const typeLabel = getDictLabel('maintain_type', item.planTypeId) | |
| 96 | - resultTags.push({ | |
| 97 | - label: typeLabel, | |
| 98 | - planTypeId: item.planTypeId, | |
| 99 | - count: total, | |
| 100 | - // 保留原始整条数据 | |
| 101 | - originItem: item | |
| 102 | - }) | |
| 103 | - } catch (err) { | |
| 104 | - console.error('batch请求异常', item.batchNo, err) | |
| 105 | - const typeLabel = getDictLabel('maintain_type', item.planTypeId) | |
| 106 | - resultTags.push({ | |
| 107 | - label: typeLabel, | |
| 108 | - planTypeId: item.planTypeId, | |
| 109 | - count: 0, | |
| 110 | - originItem: item | |
| 111 | - }) | |
| 112 | - } | |
| 113 | - } | |
| 114 | - console.log(resultTags) | |
| 115 | - // ========== 分组合并相同养护类型,count累加,保存原始数组 ========== | |
| 116 | - const groupMap = new Map<string, { | |
| 117 | - count: number, | |
| 118 | - rawList: any[], | |
| 119 | - planTypeId: string | number | |
| 120 | - }>() | |
| 121 | - for (const item of resultTags) { | |
| 122 | - console.log(item); | |
| 123 | - const name = item.label | |
| 124 | - if (!name) continue // 过滤字典为空的脏数据 | |
| 125 | - if (groupMap.has(name)) { | |
| 126 | - const groupData = groupMap.get(name)! | |
| 127 | - groupData.count += item.count | |
| 128 | - groupData.rawList.push(item.originItem) | |
| 129 | - } else { | |
| 130 | - groupMap.set(name, { | |
| 131 | - count: item.count, | |
| 132 | - rawList: [item.originItem], | |
| 133 | - planTypeId: item.planTypeId | |
| 134 | - }) | |
| 135 | - } | |
| 136 | - } | |
| 137 | - // map转为数组给页面渲染 | |
| 138 | - const groupList: any[] = [] | |
| 139 | - groupMap.forEach((group, label) => { | |
| 140 | - groupList.push({ | |
| 141 | - label, | |
| 142 | - count: group.count, | |
| 143 | - rawList: group.rawList, | |
| 144 | - planTypeId: group.planTypeId | |
| 145 | - }) | |
| 146 | - }) | |
| 147 | - tagList.value = groupList | |
| 148 | - console.log(tagList.value) | |
| 149 | -} | |
| 150 | -// 标签点击跳转,rawList存入storage,并且把planTypeId拼到url传给下一页 | |
| 43 | + | |
| 44 | +// 标签点击跳转,batchNos存入storage,并且把planTypeId拼到url传给下一页 | |
| 151 | 45 | const toNextPage = (item: any) => { |
| 152 | - // maintainStore.setRawList(item.rawList) | |
| 153 | 46 | uni.setStorageSync('temp_maintain_rawList', item.batchNos) |
| 154 | 47 | uni.navigateTo({ |
| 155 | 48 | url: `/pages-sub/daily/maintain-manage/type-list-page?planTypeId=${item.planTypeId}` |
| 156 | 49 | }) |
| 157 | 50 | } |
| 51 | + | |
| 52 | +// 页面卸载清理缓存,防止脏数据 | |
| 53 | +onUnload(()=>{ | |
| 54 | + uni.removeStorageSync('temp_maintain_item') | |
| 55 | +}) | |
| 158 | 56 | </script> |
| 159 | 57 | <style scoped lang="scss"> |
| 160 | 58 | .tag-wrap { |
| ... | ... | @@ -163,7 +61,6 @@ const toNextPage = (item: any) => { |
| 163 | 61 | gap: 24rpx; |
| 164 | 62 | padding: 30rpx; |
| 165 | 63 | } |
| 166 | - | |
| 167 | 64 | .tag-item { |
| 168 | 65 | display: inline-flex; |
| 169 | 66 | align-items: center; |
| ... | ... | @@ -171,39 +68,29 @@ const toNextPage = (item: any) => { |
| 171 | 68 | border: 1rpx solid #94c5ff; |
| 172 | 69 | border-radius: 8rpx; |
| 173 | 70 | padding: 16rpx 24rpx; |
| 174 | - max-width: 320rpx; // 限制标签最大宽度,超出自动省略 | |
| 71 | + max-width: 320rpx; | |
| 175 | 72 | transition: all 0.2s; |
| 176 | - | |
| 177 | 73 | &--hover { |
| 178 | 74 | background: #d8eaff; |
| 179 | 75 | } |
| 180 | 76 | } |
| 181 | - | |
| 182 | 77 | .tag-text { |
| 183 | 78 | display: flex; |
| 184 | 79 | align-items: center; |
| 185 | 80 | flex: 1; |
| 186 | 81 | overflow: hidden; |
| 187 | 82 | } |
| 188 | - | |
| 189 | 83 | .tag-name { |
| 190 | - // 核心:文字超长省略,只对名称生效 | |
| 191 | 84 | white-space: nowrap; |
| 192 | 85 | overflow: hidden; |
| 193 | 86 | text-overflow: ellipsis; |
| 194 | 87 | color: #1677ff; |
| 195 | 88 | font-size: 28rpx; |
| 196 | 89 | } |
| 197 | - | |
| 198 | 90 | .tag-count { |
| 199 | 91 | color: #1677ff; |
| 200 | 92 | font-size: 28rpx; |
| 201 | - flex-shrink: 0; // 重点!禁止压缩,保证(数字)永远显示 | |
| 202 | - margin-left: 4rpx; | |
| 203 | -} | |
| 204 | - | |
| 205 | -.tag-icon { | |
| 206 | 93 | flex-shrink: 0; |
| 207 | - margin-left: 12rpx; | |
| 94 | + margin-left: 4rpx; | |
| 208 | 95 | } |
| 209 | 96 | </style> | ... | ... |