Commit 00d835da6dd518491d0f8036d252d7c3ad55db54
1 parent
62ffd5df
查看详情
Showing
4 changed files
with
70 additions
and
42 deletions
common/config/env.js
| @@ -2,12 +2,12 @@ | @@ -2,12 +2,12 @@ | ||
| 2 | const env = { | 2 | const env = { |
| 3 | // 开发环境 | 3 | // 开发环境 |
| 4 | development: { | 4 | development: { |
| 5 | - baseUrl: 'http://192.168.1.55:48081', | 5 | + baseUrl: 'https://test.jichengshanshui.com.cn:28302', |
| 6 | // https://test.jichengshanshui.com.cn:28302 | 6 | // https://test.jichengshanshui.com.cn:28302 |
| 7 | 7 | ||
| 8 | // baseUrl: 'http://192.168.1.111:48081', | 8 | // baseUrl: 'http://192.168.1.111:48081', |
| 9 | 9 | ||
| 10 | - uploadUrl: 'http://192.168.1.55:48081', | 10 | + uploadUrl: 'https://test.jichengshanshui.com.cn:28302', |
| 11 | // baseApi:'admin-api', | 11 | // baseApi:'admin-api', |
| 12 | // appApi:'app-api' | 12 | // appApi:'app-api' |
| 13 | }, | 13 | }, |
pages-sub/daily/maintain-manage/finish-plan-detail.vue
| @@ -199,10 +199,10 @@ const previewImage = (currentUrl, allUrls) => { | @@ -199,10 +199,10 @@ const previewImage = (currentUrl, allUrls) => { | ||
| 199 | /** | 199 | /** |
| 200 | * 获取工单详情 | 200 | * 获取工单详情 |
| 201 | */ | 201 | */ |
| 202 | -const getOrderDetail = async (planNo: string, commitId?: string) => { | 202 | +const getOrderDetail = async (planNo: string, commitId?: string, workRecordIndex: number = 0) => { |
| 203 | + console.log('===传入的workRecordIndex===', workRecordIndex) | ||
| 203 | try { | 204 | try { |
| 204 | loading.value = true; | 205 | loading.value = true; |
| 205 | - // 后端 page 接口支持 commitId 精确过滤:从上报记录列表点「查看」时只展示这一条 | ||
| 206 | let queryData: any = { | 206 | let queryData: any = { |
| 207 | planNo: planNo, | 207 | planNo: planNo, |
| 208 | pageSize: commitId ? 1 : 100, | 208 | pageSize: commitId ? 1 : 100, |
| @@ -213,17 +213,24 @@ const getOrderDetail = async (planNo: string, commitId?: string) => { | @@ -213,17 +213,24 @@ const getOrderDetail = async (planNo: string, commitId?: string) => { | ||
| 213 | } | 213 | } |
| 214 | const res = await detailList(queryData); | 214 | const res = await detailList(queryData); |
| 215 | console.log('接口返回:', res); | 215 | console.log('接口返回:', res); |
| 216 | - | ||
| 217 | - // 修复2:正确解析接口数据(res.data.list 而非 res.list) | ||
| 218 | const list = res.data?.list || res.list || []; | 216 | const list = res.data?.list || res.list || []; |
| 219 | - // 预解析动态字段,避免模板里重复 JSON.parse | ||
| 220 | - orderDetail.value = list.map(item => ({ | ||
| 221 | - ...item, | ||
| 222 | - fieldRows: (item.fields || []).map(buildFieldRow) | ||
| 223 | - })); | ||
| 224 | - | ||
| 225 | - // 调试:打印格式化后的图片URL | ||
| 226 | - console.log('格式化后图片URL:', formatImageUrls(orderDetail.value[0]?.beginImgList || [])); | 217 | + |
| 218 | + 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 | + } | ||
| 227 | + return { | ||
| 228 | + ...item, | ||
| 229 | + // ✅这里直接拿 workRecords[index].values,传给buildFieldRow渲染 | ||
| 230 | + fieldRows: useValues.map(buildFieldRow) | ||
| 231 | + } | ||
| 232 | + }) | ||
| 233 | + | ||
| 227 | } catch (error) { | 234 | } catch (error) { |
| 228 | console.error('获取工单详情失败:', error); | 235 | console.error('获取工单详情失败:', error); |
| 229 | uni.showToast({title: '加载失败,请重试', icon: 'none'}); | 236 | uni.showToast({title: '加载失败,请重试', icon: 'none'}); |
| @@ -232,6 +239,8 @@ const getOrderDetail = async (planNo: string, commitId?: string) => { | @@ -232,6 +239,8 @@ const getOrderDetail = async (planNo: string, commitId?: string) => { | ||
| 232 | } | 239 | } |
| 233 | }; | 240 | }; |
| 234 | 241 | ||
| 242 | + | ||
| 243 | + | ||
| 235 | // ========== 动态配置字段(fieldValue)展示 ========== | 244 | // ========== 动态配置字段(fieldValue)展示 ========== |
| 236 | // 解析口径与 PC 端 FieldValueCell.vue + WorkRecordTab.vue 保持一致: | 245 | // 解析口径与 PC 端 FieldValueCell.vue + WorkRecordTab.vue 保持一致: |
| 237 | // 后端 valueText 是「类型无关直拷、提交无校验」,历史格式与脏数据都可能出现,故所有解析一律降级、不抛异常。 | 246 | // 后端 valueText 是「类型无关直拷、提交无校验」,历史格式与脏数据都可能出现,故所有解析一律降级、不抛异常。 |
| @@ -528,12 +537,14 @@ const openGeo = (geo) => { | @@ -528,12 +537,14 @@ const openGeo = (geo) => { | ||
| 528 | fail: () => uni.showToast({title: '地图打开失败', icon: 'none'}) | 537 | fail: () => uni.showToast({title: '地图打开失败', icon: 'none'}) |
| 529 | }); | 538 | }); |
| 530 | }; | 539 | }; |
| 531 | - | 540 | + // const workRecordIndex = ref(0) |
| 532 | // 页面加载 | 541 | // 页面加载 |
| 533 | onLoad((options) => { | 542 | onLoad((options) => { |
| 534 | - const {planNo, commitId} = options; | 543 | + const {planNo, commitId ,index} = options; |
| 544 | + console.log("load:"+index) | ||
| 545 | + const workRecordIndex= Number(index) | ||
| 535 | if (planNo) { | 546 | if (planNo) { |
| 536 | - getOrderDetail(planNo, commitId); | 547 | + getOrderDetail(planNo, commitId,workRecordIndex); |
| 537 | } else { | 548 | } else { |
| 538 | loading.value = false; | 549 | loading.value = false; |
| 539 | uni.showToast({title: '缺少工单ID', icon: 'none'}); | 550 | uni.showToast({title: '缺少工单ID', icon: 'none'}); |
pages-sub/daily/maintain-manage/now-list-page.vue
| @@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
| 10 | <view class="item-title">【第{{ item.sortNum || (index + 1) }}次上报】{{ planName }}</view> | 10 | <view class="item-title">【第{{ item.sortNum || (index + 1) }}次上报】{{ planName }}</view> |
| 11 | <view class="item-row item-row-bottom"> | 11 | <view class="item-row item-row-bottom"> |
| 12 | <view class="item-time">提交时间:{{ timeFormat(item.createTime,'yyyy-mm-dd hh:MM:ss')}}</view> | 12 | <view class="item-time">提交时间:{{ timeFormat(item.createTime,'yyyy-mm-dd hh:MM:ss')}}</view> |
| 13 | - <view class="look-btn" @click="handleView(item,reportList[0])">查看</view> | 13 | + <view class="look-btn" @click="handleView(index,item,reportList[0])">查看</view> |
| 14 | </view> | 14 | </view> |
| 15 | </view> | 15 | </view> |
| 16 | </view> | 16 | </view> |
| @@ -92,11 +92,12 @@ const getReportList = async () => { | @@ -92,11 +92,12 @@ const getReportList = async () => { | ||
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | // 查看上报详情 | 94 | // 查看上报详情 |
| 95 | -const handleView = (item,i) => { | 95 | +const handleView = (index,item,i) => { |
| 96 | console.log('查看详情', item) | 96 | console.log('查看详情', item) |
| 97 | + console.log('查看详情', index) | ||
| 97 | uni.navigateTo({ | 98 | uni.navigateTo({ |
| 98 | // 后端 page 接口支持 commitId 精确过滤,必须带上,否则会把该计划全部上报都展示出来 | 99 | // 后端 page 接口支持 commitId 精确过滤,必须带上,否则会把该计划全部上报都展示出来 |
| 99 | - url: `/pages-sub/daily/maintain-manage/finish-plan-detail?planNo=${i.planNo}&commitId=${i.commitId}` | 100 | + url: `/pages-sub/daily/maintain-manage/finish-plan-detail?planNo=${i.planNo}&commitId=${i.commitId}&index=${index}` |
| 100 | }) | 101 | }) |
| 101 | } | 102 | } |
| 102 | // 新增上报记录,把planNo + currentCommitId带到新增页面 | 103 | // 新增上报记录,把planNo + currentCommitId带到新增页面 |
pages-sub/daily/maintain-manage/type-list-page.vue
| @@ -23,9 +23,9 @@ | @@ -23,9 +23,9 @@ | ||
| 23 | </view> | 23 | </view> |
| 24 | <!-- 第二行:任务次数 + 去作业按钮 --> | 24 | <!-- 第二行:任务次数 + 去作业按钮 --> |
| 25 | <view class="row row-2"> | 25 | <view class="row row-2"> |
| 26 | - <view class="info-text" v-if="activeStatus === '2'">完成次数:{{ item.planFinishNum }}次</view> | 26 | + <view class="info-text" v-if="activeStatus === '2'">完成次数:{{ item.planFinishNum }}次</view> |
| 27 | <view class="info-text" v-else>任务次数:第{{ item.planFinishNum +1 }}次</view> | 27 | <view class="info-text" v-else>任务次数:第{{ item.planFinishNum +1 }}次</view> |
| 28 | - | 28 | + |
| 29 | <!-- 待完成:去作业;已完成:去查看 --> | 29 | <!-- 待完成:去作业;已完成:去查看 --> |
| 30 | <view v-if="activeStatus === '1'" class="mini-btn" @click.stop="handleGoWork(item)">去作业</view> | 30 | <view v-if="activeStatus === '1'" class="mini-btn" @click.stop="handleGoWork(item)">去作业</view> |
| 31 | <view v-else-if="activeStatus === '2'" class="mini-btn" @click.stop="handleGoWorkLook(item)">去查看</view> | 31 | <view v-else-if="activeStatus === '2'" class="mini-btn" @click.stop="handleGoWorkLook(item)">去查看</view> |
| @@ -37,8 +37,8 @@ | @@ -37,8 +37,8 @@ | ||
| 37 | <view class="info-text u-line-1">有效期:{{ timeFormat(item.beginTime, 'yyyy-mm-dd') }}—{{ | 37 | <view class="info-text u-line-1">有效期:{{ timeFormat(item.beginTime, 'yyyy-mm-dd') }}—{{ |
| 38 | timeFormat(item.endTime, 'yyyy-mm-dd') }} | 38 | timeFormat(item.endTime, 'yyyy-mm-dd') }} |
| 39 | </view> | 39 | </view> |
| 40 | - <!-- 仅待完成且存在进行中的本次养护时才显示结束任务(commitId 由后端按 commit_state=1 回填) --> | ||
| 41 | - <view v-if="activeStatus === '1' && item.commitId" class="mini-btn" | 40 | + <!-- ✅ 修改:去掉item.commitId判断,待完成tab就一直展示结束任务 --> |
| 41 | + <view v-if="activeStatus === '1'" class="mini-btn" | ||
| 42 | @click.stop="handleEndTask(item)">结束任务</view> | 42 | @click.stop="handleEndTask(item)">结束任务</view> |
| 43 | </view> | 43 | </view> |
| 44 | </view> | 44 | </view> |
| @@ -66,7 +66,6 @@ import { onShow, onUnload, onLoad } from '@dcloudio/uni-app' | @@ -66,7 +66,6 @@ import { onShow, onUnload, onLoad } from '@dcloudio/uni-app' | ||
| 66 | import { useUserStore } from '@/pinia/user'; | 66 | import { useUserStore } from '@/pinia/user'; |
| 67 | import { maintainPlanNum, finishPlan, invalidatePlan, maintainCreate } from "@/api/maintain-manage/maintain-manage"; | 67 | import { maintainPlanNum, finishPlan, invalidatePlan, maintainCreate } from "@/api/maintain-manage/maintain-manage"; |
| 68 | import { timeFormat } from '@/uni_modules/uview-plus'; | 68 | import { timeFormat } from '@/uni_modules/uview-plus'; |
| 69 | - | ||
| 70 | /** 获取当天日期 yyyy-MM-dd */ | 69 | /** 获取当天日期 yyyy-MM-dd */ |
| 71 | const getTodayStr = () => { | 70 | const getTodayStr = () => { |
| 72 | const d = new Date() | 71 | const d = new Date() |
| @@ -101,7 +100,6 @@ const currentInvalidItem = ref(null) | @@ -101,7 +100,6 @@ const currentInvalidItem = ref(null) | ||
| 101 | // ===================== 结束任务确认弹窗 ===================== | 100 | // ===================== 结束任务确认弹窗 ===================== |
| 102 | const endTaskModalShow = ref(false) | 101 | const endTaskModalShow = ref(false) |
| 103 | const currentEndTaskItem = ref<any>(null) | 102 | const currentEndTaskItem = ref<any>(null) |
| 104 | - | ||
| 105 | // 加载数据,根据当前activeStatus动态调用接口 | 103 | // 加载数据,根据当前activeStatus动态调用接口 |
| 106 | const loadData = async () => { | 104 | const loadData = async () => { |
| 107 | console.log('123123') | 105 | console.log('123123') |
| @@ -150,7 +148,7 @@ const loadData = async () => { | @@ -150,7 +148,7 @@ const loadData = async () => { | ||
| 150 | allTotalData.value = tempResult | 148 | allTotalData.value = tempResult |
| 151 | } catch (err) { | 149 | } catch (err) { |
| 152 | console.error('批量请求接口异常', err) | 150 | console.error('批量请求接口异常', err) |
| 153 | - uni.showToast({ title: '数据加载失败', icon: 'none' }) | 151 | + uni.showToast({ title: err.msg || '数据加载失败', icon: 'none', duration:2000 }) |
| 154 | } finally { | 152 | } finally { |
| 155 | uni.hideLoading() | 153 | uni.hideLoading() |
| 156 | pagingRef.value?.reload() | 154 | pagingRef.value?.reload() |
| @@ -193,7 +191,7 @@ const confirmSetInvalid = async () => { | @@ -193,7 +191,7 @@ const confirmSetInvalid = async () => { | ||
| 193 | const item = currentInvalidItem.value | 191 | const item = currentInvalidItem.value |
| 194 | console.log(currentInvalidItem.value) | 192 | console.log(currentInvalidItem.value) |
| 195 | if (!item) { | 193 | if (!item) { |
| 196 | - uni.showToast({ title: '数据异常', icon: 'none' }) | 194 | + uni.showToast({ title: '数据异常', icon: 'none', duration:2000 }) |
| 197 | return | 195 | return |
| 198 | } | 196 | } |
| 199 | uni.showLoading({ title: '提交中...', mask: true }) | 197 | uni.showLoading({ title: '提交中...', mask: true }) |
| @@ -213,25 +211,25 @@ const confirmSetInvalid = async () => { | @@ -213,25 +211,25 @@ const confirmSetInvalid = async () => { | ||
| 213 | targetCommitId = createRes && typeof createRes === 'object' ? createRes.id : createRes | 211 | targetCommitId = createRes && typeof createRes === 'object' ? createRes.id : createRes |
| 214 | if (!targetCommitId) { | 212 | if (!targetCommitId) { |
| 215 | uni.hideLoading() | 213 | uni.hideLoading() |
| 216 | - uni.showToast({ title: '创建养护草稿失败,无法置为失效', icon: 'none' }) | 214 | + uni.showToast({ title: '创建养护草稿失败,无法置为失效', icon: 'none', duration:2000 }) |
| 217 | return | 215 | return |
| 218 | } | 216 | } |
| 219 | } | 217 | } |
| 220 | - | ||
| 221 | const params = { | 218 | const params = { |
| 222 | commitId: targetCommitId, | 219 | commitId: targetCommitId, |
| 220 | + invalidReason: '管理员手动置为失效', | ||
| 221 | + invalidFiles: '' | ||
| 223 | } | 222 | } |
| 224 | console.log('置为失效提交参数:', params) | 223 | console.log('置为失效提交参数:', params) |
| 225 | - console.log(params.commitId) | ||
| 226 | - await invalidatePlan({ commitId: params.commitId }) | ||
| 227 | - uni.showToast({ title: '操作成功', icon: 'success' }) | 224 | + await invalidatePlan(params) |
| 225 | + uni.showToast({ title: '操作成功', icon: 'success', duration:2000 }) | ||
| 228 | handleInvalidModalCancel() | 226 | handleInvalidModalCancel() |
| 229 | // 重新加载数据刷新列表 | 227 | // 重新加载数据刷新列表 |
| 230 | await loadData() | 228 | await loadData() |
| 231 | pagingRef.value?.reload() | 229 | pagingRef.value?.reload() |
| 232 | } catch (err) { | 230 | } catch (err) { |
| 233 | console.error(err) | 231 | console.error(err) |
| 234 | - uni.showToast({ title: '提交失败,请重试', icon: 'none' }) | 232 | + uni.showToast({ title: err?.msg || '提交失败,请重试', icon: 'none', duration:2000 }) |
| 235 | } finally { | 233 | } finally { |
| 236 | uni.hideLoading() | 234 | uni.hideLoading() |
| 237 | } | 235 | } |
| @@ -248,8 +246,6 @@ const handleGoWorkLook = (item) => { | @@ -248,8 +246,6 @@ const handleGoWorkLook = (item) => { | ||
| 248 | url: `/pages-sub/daily/maintain-manage/finish-plan-detail?planNo=${item.planNo}&planTypeId=${planTypeId.value}&businessType=${item.busiLine}&isView=${isView}` | 246 | url: `/pages-sub/daily/maintain-manage/finish-plan-detail?planNo=${item.planNo}&planTypeId=${planTypeId.value}&businessType=${item.busiLine}&isView=${isView}` |
| 249 | }) | 247 | }) |
| 250 | } | 248 | } |
| 251 | - | ||
| 252 | - | ||
| 253 | const handleEndTask = async (item) => { | 249 | const handleEndTask = async (item) => { |
| 254 | currentEndTaskItem.value = item | 250 | currentEndTaskItem.value = item |
| 255 | endTaskModalShow.value = true | 251 | endTaskModalShow.value = true |
| @@ -259,23 +255,43 @@ const handleEndTaskModalCancel = () => { | @@ -259,23 +255,43 @@ const handleEndTaskModalCancel = () => { | ||
| 259 | endTaskModalShow.value = false | 255 | endTaskModalShow.value = false |
| 260 | currentEndTaskItem.value = null | 256 | currentEndTaskItem.value = null |
| 261 | } | 257 | } |
| 262 | -// 确认结束任务,真正调用接口 | 258 | +// ✅改造confirmEndTask:没有commitId先maintainCreate,和置为失效逻辑保持一致 |
| 263 | const confirmEndTask = async () => { | 259 | const confirmEndTask = async () => { |
| 264 | const item = currentEndTaskItem.value | 260 | const item = currentEndTaskItem.value |
| 265 | - if (!item || !item.commitId) return | 261 | + if (!item) { |
| 262 | + uni.showToast({ title: '数据异常', icon: 'none', duration:2000 }) | ||
| 263 | + return | ||
| 264 | + } | ||
| 266 | endTaskModalShow.value = false | 265 | endTaskModalShow.value = false |
| 267 | uni.showLoading({ title: '提交中...', mask: true }) | 266 | uni.showLoading({ title: '提交中...', mask: true }) |
| 268 | try { | 267 | try { |
| 269 | - await finishPlan({ commitId: item.commitId }) | 268 | + let targetCommitId = item.commitId |
| 269 | + // 不存在commitId,先创建草稿 | ||
| 270 | + if (!targetCommitId) { | ||
| 271 | + const submitData = { | ||
| 272 | + planNo: item.planNo, | ||
| 273 | + imgHost: '1', | ||
| 274 | + beginImg: [], | ||
| 275 | + commonUserList: [], | ||
| 276 | + remark: '' | ||
| 277 | + } | ||
| 278 | + const createRes: any = await maintainCreate(submitData) | ||
| 279 | + targetCommitId = createRes && typeof createRes === 'object' ? createRes.id : createRes | ||
| 280 | + if (!targetCommitId) { | ||
| 281 | + uni.hideLoading() | ||
| 282 | + uni.showToast({ title: '创建养护草稿失败,无法结束任务', icon: 'none', duration:2000 }) | ||
| 283 | + return | ||
| 284 | + } | ||
| 285 | + } | ||
| 286 | + await finishPlan({ commitId: targetCommitId }) | ||
| 270 | uni.hideLoading() | 287 | uni.hideLoading() |
| 271 | - uni.showToast({ title: '结束任务成功', icon: 'success' }) | 288 | + uni.showToast({ title: '结束任务成功', icon: 'success', duration:2000 }) |
| 272 | await loadData() | 289 | await loadData() |
| 273 | pagingRef.value?.reload() | 290 | pagingRef.value?.reload() |
| 274 | } catch (err) { | 291 | } catch (err) { |
| 275 | console.error('结束任务失败', err) | 292 | console.error('结束任务失败', err) |
| 276 | uni.hideLoading() | 293 | uni.hideLoading() |
| 277 | - if (err && err.msg) return | ||
| 278 | - uni.showToast({ title: '结束任务失败,请重试', icon: 'none' }) | 294 | + uni.showToast({ title: err?.msg || '结束任务失败,请重试', icon: 'none', duration:2000 }) |
| 279 | } finally { | 295 | } finally { |
| 280 | currentEndTaskItem.value = null | 296 | currentEndTaskItem.value = null |
| 281 | } | 297 | } |