Commit 194ce9b3e52c30af7c3b745a16c147686e38b8e5
Merge remote-tracking branch 'origin/dev' into dev
Showing
4 changed files
with
70 additions
and
42 deletions
common/config/env.js
| ... | ... | @@ -2,12 +2,12 @@ |
| 2 | 2 | const env = { |
| 3 | 3 | // 开发环境 |
| 4 | 4 | development: { |
| 5 | - baseUrl: 'http://192.168.1.55:48081', | |
| 5 | + baseUrl: 'https://test.jichengshanshui.com.cn:28302', | |
| 6 | 6 | // https://test.jichengshanshui.com.cn:28302 |
| 7 | 7 | |
| 8 | 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 | 11 | // baseApi:'admin-api', |
| 12 | 12 | // appApi:'app-api' |
| 13 | 13 | }, | ... | ... |
pages-sub/daily/maintain-manage/finish-plan-detail.vue
| ... | ... | @@ -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 | 204 | try { |
| 204 | 205 | loading.value = true; |
| 205 | - // 后端 page 接口支持 commitId 精确过滤:从上报记录列表点「查看」时只展示这一条 | |
| 206 | 206 | let queryData: any = { |
| 207 | 207 | planNo: planNo, |
| 208 | 208 | pageSize: commitId ? 1 : 100, |
| ... | ... | @@ -213,17 +213,24 @@ const getOrderDetail = async (planNo: string, commitId?: string) => { |
| 213 | 213 | } |
| 214 | 214 | const res = await detailList(queryData); |
| 215 | 215 | console.log('接口返回:', res); |
| 216 | - | |
| 217 | - // 修复2:正确解析接口数据(res.data.list 而非 res.list) | |
| 218 | 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 | 234 | } catch (error) { |
| 228 | 235 | console.error('获取工单详情失败:', error); |
| 229 | 236 | uni.showToast({title: '加载失败,请重试', icon: 'none'}); |
| ... | ... | @@ -232,6 +239,8 @@ const getOrderDetail = async (planNo: string, commitId?: string) => { |
| 232 | 239 | } |
| 233 | 240 | }; |
| 234 | 241 | |
| 242 | + | |
| 243 | + | |
| 235 | 244 | // ========== 动态配置字段(fieldValue)展示 ========== |
| 236 | 245 | // 解析口径与 PC 端 FieldValueCell.vue + WorkRecordTab.vue 保持一致: |
| 237 | 246 | // 后端 valueText 是「类型无关直拷、提交无校验」,历史格式与脏数据都可能出现,故所有解析一律降级、不抛异常。 |
| ... | ... | @@ -528,12 +537,14 @@ const openGeo = (geo) => { |
| 528 | 537 | fail: () => uni.showToast({title: '地图打开失败', icon: 'none'}) |
| 529 | 538 | }); |
| 530 | 539 | }; |
| 531 | - | |
| 540 | + // const workRecordIndex = ref(0) | |
| 532 | 541 | // 页面加载 |
| 533 | 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 | 546 | if (planNo) { |
| 536 | - getOrderDetail(planNo, commitId); | |
| 547 | + getOrderDetail(planNo, commitId,workRecordIndex); | |
| 537 | 548 | } else { |
| 538 | 549 | loading.value = false; |
| 539 | 550 | uni.showToast({title: '缺少工单ID', icon: 'none'}); | ... | ... |
pages-sub/daily/maintain-manage/now-list-page.vue
| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | <view class="item-title">【第{{ item.sortNum || (index + 1) }}次上报】{{ planName }}</view> |
| 11 | 11 | <view class="item-row item-row-bottom"> |
| 12 | 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 | 14 | </view> |
| 15 | 15 | </view> |
| 16 | 16 | </view> |
| ... | ... | @@ -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 | 96 | console.log('查看详情', item) |
| 97 | + console.log('查看详情', index) | |
| 97 | 98 | uni.navigateTo({ |
| 98 | 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 | 103 | // 新增上报记录,把planNo + currentCommitId带到新增页面 | ... | ... |
pages-sub/daily/maintain-manage/type-list-page.vue
| ... | ... | @@ -23,9 +23,9 @@ |
| 23 | 23 | </view> |
| 24 | 24 | <!-- 第二行:任务次数 + 去作业按钮 --> |
| 25 | 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 | 27 | <view class="info-text" v-else>任务次数:第{{ item.planFinishNum +1 }}次</view> |
| 28 | - | |
| 28 | + | |
| 29 | 29 | <!-- 待完成:去作业;已完成:去查看 --> |
| 30 | 30 | <view v-if="activeStatus === '1'" class="mini-btn" @click.stop="handleGoWork(item)">去作业</view> |
| 31 | 31 | <view v-else-if="activeStatus === '2'" class="mini-btn" @click.stop="handleGoWorkLook(item)">去查看</view> |
| ... | ... | @@ -37,8 +37,8 @@ |
| 37 | 37 | <view class="info-text u-line-1">有效期:{{ timeFormat(item.beginTime, 'yyyy-mm-dd') }}—{{ |
| 38 | 38 | timeFormat(item.endTime, 'yyyy-mm-dd') }} |
| 39 | 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 | 42 | @click.stop="handleEndTask(item)">结束任务</view> |
| 43 | 43 | </view> |
| 44 | 44 | </view> |
| ... | ... | @@ -66,7 +66,6 @@ import { onShow, onUnload, onLoad } from '@dcloudio/uni-app' |
| 66 | 66 | import { useUserStore } from '@/pinia/user'; |
| 67 | 67 | import { maintainPlanNum, finishPlan, invalidatePlan, maintainCreate } from "@/api/maintain-manage/maintain-manage"; |
| 68 | 68 | import { timeFormat } from '@/uni_modules/uview-plus'; |
| 69 | - | |
| 70 | 69 | /** 获取当天日期 yyyy-MM-dd */ |
| 71 | 70 | const getTodayStr = () => { |
| 72 | 71 | const d = new Date() |
| ... | ... | @@ -101,7 +100,6 @@ const currentInvalidItem = ref(null) |
| 101 | 100 | // ===================== 结束任务确认弹窗 ===================== |
| 102 | 101 | const endTaskModalShow = ref(false) |
| 103 | 102 | const currentEndTaskItem = ref<any>(null) |
| 104 | - | |
| 105 | 103 | // 加载数据,根据当前activeStatus动态调用接口 |
| 106 | 104 | const loadData = async () => { |
| 107 | 105 | console.log('123123') |
| ... | ... | @@ -150,7 +148,7 @@ const loadData = async () => { |
| 150 | 148 | allTotalData.value = tempResult |
| 151 | 149 | } catch (err) { |
| 152 | 150 | console.error('批量请求接口异常', err) |
| 153 | - uni.showToast({ title: '数据加载失败', icon: 'none' }) | |
| 151 | + uni.showToast({ title: err.msg || '数据加载失败', icon: 'none', duration:2000 }) | |
| 154 | 152 | } finally { |
| 155 | 153 | uni.hideLoading() |
| 156 | 154 | pagingRef.value?.reload() |
| ... | ... | @@ -193,7 +191,7 @@ const confirmSetInvalid = async () => { |
| 193 | 191 | const item = currentInvalidItem.value |
| 194 | 192 | console.log(currentInvalidItem.value) |
| 195 | 193 | if (!item) { |
| 196 | - uni.showToast({ title: '数据异常', icon: 'none' }) | |
| 194 | + uni.showToast({ title: '数据异常', icon: 'none', duration:2000 }) | |
| 197 | 195 | return |
| 198 | 196 | } |
| 199 | 197 | uni.showLoading({ title: '提交中...', mask: true }) |
| ... | ... | @@ -213,25 +211,25 @@ const confirmSetInvalid = async () => { |
| 213 | 211 | targetCommitId = createRes && typeof createRes === 'object' ? createRes.id : createRes |
| 214 | 212 | if (!targetCommitId) { |
| 215 | 213 | uni.hideLoading() |
| 216 | - uni.showToast({ title: '创建养护草稿失败,无法置为失效', icon: 'none' }) | |
| 214 | + uni.showToast({ title: '创建养护草稿失败,无法置为失效', icon: 'none', duration:2000 }) | |
| 217 | 215 | return |
| 218 | 216 | } |
| 219 | 217 | } |
| 220 | - | |
| 221 | 218 | const params = { |
| 222 | 219 | commitId: targetCommitId, |
| 220 | + invalidReason: '管理员手动置为失效', | |
| 221 | + invalidFiles: '' | |
| 223 | 222 | } |
| 224 | 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 | 226 | handleInvalidModalCancel() |
| 229 | 227 | // 重新加载数据刷新列表 |
| 230 | 228 | await loadData() |
| 231 | 229 | pagingRef.value?.reload() |
| 232 | 230 | } catch (err) { |
| 233 | 231 | console.error(err) |
| 234 | - uni.showToast({ title: '提交失败,请重试', icon: 'none' }) | |
| 232 | + uni.showToast({ title: err?.msg || '提交失败,请重试', icon: 'none', duration:2000 }) | |
| 235 | 233 | } finally { |
| 236 | 234 | uni.hideLoading() |
| 237 | 235 | } |
| ... | ... | @@ -248,8 +246,6 @@ const handleGoWorkLook = (item) => { |
| 248 | 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 | 249 | const handleEndTask = async (item) => { |
| 254 | 250 | currentEndTaskItem.value = item |
| 255 | 251 | endTaskModalShow.value = true |
| ... | ... | @@ -259,23 +255,43 @@ const handleEndTaskModalCancel = () => { |
| 259 | 255 | endTaskModalShow.value = false |
| 260 | 256 | currentEndTaskItem.value = null |
| 261 | 257 | } |
| 262 | -// 确认结束任务,真正调用接口 | |
| 258 | +// ✅改造confirmEndTask:没有commitId先maintainCreate,和置为失效逻辑保持一致 | |
| 263 | 259 | const confirmEndTask = async () => { |
| 264 | 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 | 265 | endTaskModalShow.value = false |
| 267 | 266 | uni.showLoading({ title: '提交中...', mask: true }) |
| 268 | 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 | 287 | uni.hideLoading() |
| 271 | - uni.showToast({ title: '结束任务成功', icon: 'success' }) | |
| 288 | + uni.showToast({ title: '结束任务成功', icon: 'success', duration:2000 }) | |
| 272 | 289 | await loadData() |
| 273 | 290 | pagingRef.value?.reload() |
| 274 | 291 | } catch (err) { |
| 275 | 292 | console.error('结束任务失败', err) |
| 276 | 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 | 295 | } finally { |
| 280 | 296 | currentEndTaskItem.value = null |
| 281 | 297 | } | ... | ... |