Commit db80a7cd376c3ea4a3e681321a078f93a4e6fd7c
1 parent
e8f5dac4
业务线 小程序不用写死,从后端接口获取
Showing
3 changed files
with
33 additions
and
6 deletions
pages-sub/daily/maintain-manage/add-record.vue
| ... | ... | @@ -229,8 +229,16 @@ export default { |
| 229 | 229 | }, |
| 230 | 230 | onLoad(option) { |
| 231 | 231 | console.log('页面参数:', option) |
| 232 | - this.paramsOptins = option | |
| 233 | - const { businessType, planTypeId } = option | |
| 232 | + // 入口 URL 里出现过 `planNo=${planNo} &businessType=` 这种多一个空格的历史写法, | |
| 233 | + // 会让 planNo 带上尾空格 → 后端按 planNo 查不到计划(提交报「养护计划不存在」)。 | |
| 234 | + // 这里统一 trim,不依赖每个入口都写对 | |
| 235 | + const params = {} | |
| 236 | + Object.keys(option || {}).forEach(key => { | |
| 237 | + const val = option[key] | |
| 238 | + params[key] = typeof val === 'string' ? val.trim() : val | |
| 239 | + }) | |
| 240 | + this.paramsOptins = params | |
| 241 | + const { businessType, planTypeId } = params | |
| 234 | 242 | this.loadDynamicFields(businessType, planTypeId) |
| 235 | 243 | }, |
| 236 | 244 | onReady() { |
| ... | ... | @@ -558,6 +566,22 @@ export default { |
| 558 | 566 | getImgUrlList(imgList) { |
| 559 | 567 | return imgList.filter(item => item.status === 'success').map(item => item.url) |
| 560 | 568 | }, |
| 569 | + /** | |
| 570 | + * 开始照片:把所有「图片」(fieldType=7) 动态字段里上传成功的 URL 拍平成一个数组。 | |
| 571 | + * 不写死字段 code —— 配置里叫 tu_pian 还是别的名字都能取到; | |
| 572 | + * 判空口径与校验规则 buildRequiredRule 一致(看 fileListMap 的 status,而不是 inspectForm) | |
| 573 | + */ | |
| 574 | + collectBeginImgs() { | |
| 575 | + const fields = this.dynamicFields || [] | |
| 576 | + const urls = [] | |
| 577 | + fields.forEach(field => { | |
| 578 | + if (field.fieldType !== 7) return | |
| 579 | + this.getImgUrlList(this.fileListMap[field.fieldCode] || []).forEach(url => { | |
| 580 | + if (url) urls.push(url) | |
| 581 | + }) | |
| 582 | + }) | |
| 583 | + return urls | |
| 584 | + }, | |
| 561 | 585 | // ========== 动态字段:渲染与取值辅助 ========== |
| 562 | 586 | /** |
| 563 | 587 | * 类型6 多选是否要求每项填「使用数量」(ext_config.needQuantity) |
| ... | ... | @@ -918,7 +942,10 @@ uploadFieldFiles(item: any, event: any) { |
| 918 | 942 | const submitData = { |
| 919 | 943 | planNo: this.paramsOptins.planNo, |
| 920 | 944 | imgHost: "1", |
| 921 | - beginImg: this.getImgUrlList(this.imagesList), | |
| 945 | + // 开始照片 = 动态「图片」(fieldType=7) 字段里已上传成功的 URL。 | |
| 946 | + // 页面上已没有固定的「上传图片」行(图片/附件都是配置出来的动态字段), | |
| 947 | + // 没配图片字段或没传图时是空数组 —— 后端 beginImg 已改为选填 | |
| 948 | + beginImg: this.collectBeginImgs(), | |
| 922 | 949 | commonUserList: [], |
| 923 | 950 | remark: this.inspectForm.remark.trim(), |
| 924 | 951 | } | ... | ... |
pages-sub/daily/maintain-manage/index.vue
| ... | ... | @@ -318,11 +318,11 @@ const submitRecord = (item) => { |
| 318 | 318 | console.log('提交记录:', item) |
| 319 | 319 | if (item.planFinishNum == 0) { // 去新增 |
| 320 | 320 | uni.navigateTo({ |
| 321 | - url: `/pages-sub/daily/maintain-manage/add-record?finishState=${item.finishState}&planNo=${item.planNo} &businessType=${item.busiLine}` | |
| 321 | + url: `/pages-sub/daily/maintain-manage/add-record?finishState=${item.finishState}&planNo=${item.planNo}&planTypeId=${item.planTypeId}&businessType=${item.busiLine}` | |
| 322 | 322 | }) |
| 323 | 323 | } else { |
| 324 | 324 | uni.navigateTo({ |
| 325 | - url: `/pages-sub/daily/maintain-manage/pending-plan-detail?finishState=${item.finishState}&planNo=${item.planNo}&planTypeId=${item.planTypeId} &businessType=${item.busiLine}` | |
| 325 | + url: `/pages-sub/daily/maintain-manage/pending-plan-detail?finishState=${item.finishState}&planNo=${item.planNo}&planTypeId=${item.planTypeId}&businessType=${item.busiLine}` | |
| 326 | 326 | }) |
| 327 | 327 | } |
| 328 | 328 | ... | ... |
pages-sub/daily/maintain-manage/road-detail-list.vue
| ... | ... | @@ -179,7 +179,7 @@ const submitRecord = (item) => { |
| 179 | 179 | console.log('提交记录:', item.planFinishNum) |
| 180 | 180 | if (item.planFinishNum == 0) { |
| 181 | 181 | uni.navigateTo({ |
| 182 | - url: `/pages-sub/daily/maintain-manage/add-record?finishState=${item.finishState}&planNo=${item.planNo}&businessType=${item.busiLine}` | |
| 182 | + url: `/pages-sub/daily/maintain-manage/add-record?finishState=${item.finishState}&planNo=${item.planNo}&planTypeId=${item.planTypeId}&businessType=${item.busiLine}` | |
| 183 | 183 | }) |
| 184 | 184 | } else { |
| 185 | 185 | uni.navigateTo({ | ... | ... |