Commit 3c3d6799509365fbc5f83062f8f2ee4cb48c732f
1 parent
50176780
重点巡检区域
Showing
4 changed files
with
106 additions
and
90 deletions
common/utils/upload.js
| @@ -6,6 +6,7 @@ import { fileUpload } from '@/api/common'; | @@ -6,6 +6,7 @@ import { fileUpload } from '@/api/common'; | ||
| 6 | 6 | ||
| 7 | // 统一的多文件上传方法(单/多图都走这个) | 7 | // 统一的多文件上传方法(单/多图都走这个) |
| 8 | export const uploadImages = async (options) => { | 8 | export const uploadImages = async (options) => { |
| 9 | + console.log(options) | ||
| 9 | const { | 10 | const { |
| 10 | filePaths, | 11 | filePaths, |
| 11 | fileKey = 'file', | 12 | fileKey = 'file', |
| @@ -28,6 +29,7 @@ export const uploadImages = async (options) => { | @@ -28,6 +29,7 @@ export const uploadImages = async (options) => { | ||
| 28 | 29 | ||
| 29 | // 遍历上传(单/多图统一遍历逻辑) | 30 | // 遍历上传(单/多图统一遍历逻辑) |
| 30 | for (let i = 0; i < filePaths.length; i++) { | 31 | for (let i = 0; i < filePaths.length; i++) { |
| 32 | + console.log(filePaths[i]) | ||
| 31 | try { | 33 | try { |
| 32 | const url = await new Promise((resolve, reject) => { | 34 | const url = await new Promise((resolve, reject) => { |
| 33 | uni.uploadFile({ | 35 | uni.uploadFile({ |
manifest.json
pages-sub/daily/maintain-manage/add-record.vue
| @@ -229,16 +229,8 @@ export default { | @@ -229,16 +229,8 @@ export default { | ||
| 229 | }, | 229 | }, |
| 230 | onLoad(option) { | 230 | onLoad(option) { |
| 231 | console.log('页面参数:', option) | 231 | console.log('页面参数:', 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 | 232 | + this.paramsOptins = option |
| 233 | + const { businessType, planTypeId } = option | ||
| 242 | this.loadDynamicFields(businessType, planTypeId) | 234 | this.loadDynamicFields(businessType, planTypeId) |
| 243 | }, | 235 | }, |
| 244 | onReady() { | 236 | onReady() { |
| @@ -566,22 +558,6 @@ export default { | @@ -566,22 +558,6 @@ export default { | ||
| 566 | getImgUrlList(imgList) { | 558 | getImgUrlList(imgList) { |
| 567 | return imgList.filter(item => item.status === 'success').map(item => item.url) | 559 | return imgList.filter(item => item.status === 'success').map(item => item.url) |
| 568 | }, | 560 | }, |
| 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 | - }, | ||
| 585 | // ========== 动态字段:渲染与取值辅助 ========== | 561 | // ========== 动态字段:渲染与取值辅助 ========== |
| 586 | /** | 562 | /** |
| 587 | * 类型6 多选是否要求每项填「使用数量」(ext_config.needQuantity) | 563 | * 类型6 多选是否要求每项填「使用数量」(ext_config.needQuantity) |
| @@ -726,13 +702,13 @@ uploadFieldFiles(item: any, event: any) { | @@ -726,13 +702,13 @@ uploadFieldFiles(item: any, event: any) { | ||
| 726 | const fileList = Array.isArray(rawFile) ? rawFile : [rawFile] | 702 | const fileList = Array.isArray(rawFile) ? rawFile : [rawFile] |
| 727 | const targetImgList = this.fileListMap[item.fieldCode] || (this.fileListMap[item.fieldCode] = []) | 703 | const targetImgList = this.fileListMap[item.fieldCode] || (this.fileListMap[item.fieldCode] = []) |
| 728 | const filePaths = fileList.map(file => file.url) | 704 | const filePaths = fileList.map(file => file.url) |
| 729 | - const tempItems = fileList.map(item => ({ | ||
| 730 | - ...item, | ||
| 731 | - status: 'uploading', | ||
| 732 | - message: '上传中' | ||
| 733 | - })) | ||
| 734 | - const startIndex = targetImgList.length | ||
| 735 | - targetImgList.push(...tempItems) | 705 | + // const tempItems = fileList.map(item => ({ |
| 706 | + // ...item, | ||
| 707 | + // status: 'uploading', | ||
| 708 | + // message: '上传中' | ||
| 709 | + // })) | ||
| 710 | + // const startIndex = targetImgList.length | ||
| 711 | + // targetImgList.push(...tempItems) | ||
| 736 | 712 | ||
| 737 | this.uploadToField(item, fileList.filter(file => file && file.url).map(file => ({ | 713 | this.uploadToField(item, fileList.filter(file => file && file.url).map(file => ({ |
| 738 | url: file.url, | 714 | url: file.url, |
| @@ -776,62 +752,66 @@ uploadFieldFiles(item: any, event: any) { | @@ -776,62 +752,66 @@ uploadFieldFiles(item: any, event: any) { | ||
| 776 | * 把选中的本地文件逐个上传并把 http 地址回填到 fileListMap / inspectForm。 | 752 | * 把选中的本地文件逐个上传并把 http 地址回填到 fileListMap / inspectForm。 |
| 777 | * 7图片与8附件共用(uploadImages 是通用 uni.uploadFile,不限图片类型) | 753 | * 7图片与8附件共用(uploadImages 是通用 uni.uploadFile,不限图片类型) |
| 778 | */ | 754 | */ |
| 779 | - async uploadToField(item: any, files: any[]) { | ||
| 780 | - const code = item.fieldCode | ||
| 781 | - const maxCount = this.maxCountOf(item, 5) | ||
| 782 | - const maxSizeMb = this.maxSizeMbOf(item, 5) | ||
| 783 | - const validFiles = (files || []).filter(file => file && file.url && !this.isOversize(file, maxSizeMb)) | ||
| 784 | - if (!validFiles.length) { | ||
| 785 | - return | ||
| 786 | - } | ||
| 787 | - const targetList = this.fileListMap[code] || (this.fileListMap[code] = []) | ||
| 788 | - if (targetList.length + validFiles.length > maxCount) { | ||
| 789 | - uni.showToast({ title: `最多只能上传${maxCount}个`, icon: 'none' }) | ||
| 790 | - return | ||
| 791 | - } | ||
| 792 | - const startIndex = targetList.length | ||
| 793 | - targetList.push(...validFiles.map(file => ({ | ||
| 794 | - url: file.url, status: 'uploading', message: '上传中', name: file.name || '' | ||
| 795 | - }))) | ||
| 796 | - try { | ||
| 797 | - const uploadResultUrls = await uploadImages({ | ||
| 798 | - filePaths: validFiles.map(file => file.url), | ||
| 799 | - ignoreError: true | 755 | + async uploadToField(item: any, files: any[]) { |
| 756 | +const code = item.fieldCode | ||
| 757 | +const maxCount = this.maxCountOf(item, 5) | ||
| 758 | +const maxSizeMb = this.maxSizeMbOf(item, 5) | ||
| 759 | +const validFiles = (files || []).filter(file => file && file.url && !this.isOversize(file, maxSizeMb)) | ||
| 760 | +if (!validFiles.length) { | ||
| 761 | +return | ||
| 762 | +} | ||
| 763 | +const targetList = this.fileListMap[code] || (this.fileListMap[code] = []) | ||
| 764 | +if (targetList.length + validFiles.length > maxCount) { | ||
| 765 | +uni.showToast({ title: `最多只能上传${maxCount}个`, icon: 'none' }) | ||
| 766 | +return | ||
| 767 | +} | ||
| 768 | +// 保存起始下标 | ||
| 769 | +const startIndex = targetList.length | ||
| 770 | +// 只在这里push一次 | ||
| 771 | +targetList.push(...validFiles.map(file => ({ | ||
| 772 | +url: file.url, status: 'uploading', message: '上传中', name: file.name || '' | ||
| 773 | +}))) | ||
| 774 | +try { | ||
| 775 | +const uploadResultUrls = await uploadImages({ | ||
| 776 | +filePaths: validFiles.map(file => file.url), | ||
| 777 | +ignoreError: true | ||
| 800 | }) | 778 | }) |
| 801 | - uploadResultUrls.forEach((url, index) => { | ||
| 802 | - if (targetList[startIndex + index]) { | ||
| 803 | - targetList.splice(startIndex + index, 1, { | ||
| 804 | - url, status: 'success', message: '', name: validFiles[index].name || '' | 779 | +uploadResultUrls.forEach((url, index) => { |
| 780 | +// 用startIndex + index 替换对应条目 | ||
| 781 | +if (targetList[startIndex + index]) { | ||
| 782 | +targetList.splice(startIndex + index, 1, { | ||
| 783 | +url, status: 'success', message: '', name: validFiles[index].name || '' | ||
| 805 | }) | 784 | }) |
| 806 | } | 785 | } |
| 807 | }) | 786 | }) |
| 808 | - for (let i = uploadResultUrls.length; i < validFiles.length; i++) { | ||
| 809 | - if (targetList[startIndex + i]) { | ||
| 810 | - targetList.splice(startIndex + i, 1, { | ||
| 811 | - url: validFiles[i].url, status: 'failed', message: '上传失败', name: validFiles[i].name || '' | 787 | +for (let i = uploadResultUrls.length; i < validFiles.length; i++) { |
| 788 | +if (targetList[startIndex + i]) { | ||
| 789 | +targetList.splice(startIndex + i, 1, { | ||
| 790 | +url: validFiles[i].url, status: 'failed', message: '上传失败', name: validFiles[i].name || '' | ||
| 812 | }) | 791 | }) |
| 813 | } | 792 | } |
| 814 | } | 793 | } |
| 815 | - if (uploadResultUrls.length < validFiles.length) { | ||
| 816 | - uni.showToast({ | ||
| 817 | - title: `成功${uploadResultUrls.length}个,失败${validFiles.length - uploadResultUrls.length}个`, | ||
| 818 | - icon: 'none' | 794 | +if (uploadResultUrls.length < validFiles.length) { |
| 795 | +uni.showToast({ | ||
| 796 | +title: `成功${uploadResultUrls.length}个,失败${validFiles.length - uploadResultUrls.length}个`, | ||
| 797 | +icon: 'none' | ||
| 819 | }) | 798 | }) |
| 820 | } | 799 | } |
| 821 | } catch (err) { | 800 | } catch (err) { |
| 822 | - console.error(`【${code}】文件上传失败:`, err) | ||
| 823 | - for (let i = 0; i < validFiles.length; i++) { | ||
| 824 | - if (targetList[startIndex + i]) { | ||
| 825 | - targetList.splice(startIndex + i, 1, { | ||
| 826 | - url: validFiles[i].url, status: 'failed', message: '上传失败', name: validFiles[i].name || '' | 801 | +console.error(`【${code}】文件上传失败:`, err) |
| 802 | +for (let i = 0; i < validFiles.length; i++) { | ||
| 803 | +if (targetList[startIndex + i]) { | ||
| 804 | +targetList.splice(startIndex + i, 1, { | ||
| 805 | +url: validFiles[i].url, status: 'failed', message: '上传失败', name: validFiles[i].name || '' | ||
| 827 | }) | 806 | }) |
| 828 | } | 807 | } |
| 829 | } | 808 | } |
| 830 | - uni.showToast({ title: '上传失败,请重试', icon: 'none' }) | 809 | +uni.showToast({ title: '上传失败,请重试', icon: 'none' }) |
| 831 | } | 810 | } |
| 832 | - this.syncFileValue(item) | ||
| 833 | - this.$refs.inspectFormRef.validateField(code) | ||
| 834 | - }, | 811 | +this.syncFileValue(item) |
| 812 | +this.$refs.inspectFormRef.validateField(code) | ||
| 813 | +}, | ||
| 814 | + | ||
| 835 | /** | 815 | /** |
| 836 | * 删除 7图片/8附件 的某一个已选文件 | 816 | * 删除 7图片/8附件 的某一个已选文件 |
| 837 | */ | 817 | */ |
| @@ -942,10 +922,7 @@ uploadFieldFiles(item: any, event: any) { | @@ -942,10 +922,7 @@ uploadFieldFiles(item: any, event: any) { | ||
| 942 | const submitData = { | 922 | const submitData = { |
| 943 | planNo: this.paramsOptins.planNo, | 923 | planNo: this.paramsOptins.planNo, |
| 944 | imgHost: "1", | 924 | imgHost: "1", |
| 945 | - // 开始照片 = 动态「图片」(fieldType=7) 字段里已上传成功的 URL。 | ||
| 946 | - // 页面上已没有固定的「上传图片」行(图片/附件都是配置出来的动态字段), | ||
| 947 | - // 没配图片字段或没传图时是空数组 —— 后端 beginImg 已改为选填 | ||
| 948 | - beginImg: this.collectBeginImgs(), | 925 | + beginImg: this.getImgUrlList(this.imagesList), |
| 949 | commonUserList: [], | 926 | commonUserList: [], |
| 950 | remark: this.inspectForm.remark.trim(), | 927 | remark: this.inspectForm.remark.trim(), |
| 951 | } | 928 | } |
| @@ -1011,15 +988,7 @@ uploadFieldFiles(item: any, event: any) { | @@ -1011,15 +988,7 @@ uploadFieldFiles(item: any, event: any) { | ||
| 1011 | .date-input-wrap { | 988 | .date-input-wrap { |
| 1012 | width: 100%; | 989 | width: 100%; |
| 1013 | } | 990 | } |
| 1014 | -.fixed-bottom-btn-wrap { | ||
| 1015 | - position: fixed; | ||
| 1016 | - bottom: 0; | ||
| 1017 | - left: 0; | ||
| 1018 | - width: 100%; | ||
| 1019 | - padding: 20rpx; | ||
| 1020 | - box-sizing: border-box; | ||
| 1021 | - background-color: #fff; | ||
| 1022 | -} | 991 | + |
| 1023 | // 放大u-number-box输入框 | 992 | // 放大u-number-box输入框 |
| 1024 | .large-number-box { | 993 | .large-number-box { |
| 1025 | :deep(.u-number-box__input) { | 994 | :deep(.u-number-box__input) { |
pages-sub/problem/work-order-manage/add-order.vue
| @@ -72,6 +72,22 @@ | @@ -72,6 +72,22 @@ | ||
| 72 | <up-icon name="arrow-right" size="16" v-else></up-icon> | 72 | <up-icon name="arrow-right" size="16" v-else></up-icon> |
| 73 | </template> | 73 | </template> |
| 74 | </up-form-item> | 74 | </up-form-item> |
| 75 | + | ||
| 76 | +<!-- 修改后 --> | ||
| 77 | +<up-form-item label="重点巡检区域" prop="keyInspection" border-bottom required> | ||
| 78 | + <up-radio-group v-model="workOrderForm.keyInspection" @change="groupChange"> | ||
| 79 | + <up-radio | ||
| 80 | + :customStyle="{marginBottom: '8px'}" | ||
| 81 | + v-for="(item, index) in keyInspectionOptions" | ||
| 82 | + :key="index" | ||
| 83 | + :label="item.name" | ||
| 84 | + :name="item.name" | ||
| 85 | + > | ||
| 86 | + </up-radio> | ||
| 87 | + </up-radio-group> | ||
| 88 | +</up-form-item> | ||
| 89 | + | ||
| 90 | + | ||
| 75 | </up-form> | 91 | </up-form> |
| 76 | </view> | 92 | </view> |
| 77 | 93 | ||
| @@ -128,6 +144,30 @@ const formatBusiLineOptions = () => { | @@ -128,6 +144,30 @@ const formatBusiLineOptions = () => { | ||
| 128 | console.log(busiLineOptions.value) | 144 | console.log(busiLineOptions.value) |
| 129 | }; | 145 | }; |
| 130 | 146 | ||
| 147 | + | ||
| 148 | +const keyInspectionOptions = reactive([ | ||
| 149 | + { | ||
| 150 | + name: '否', | ||
| 151 | + disabled: false, | ||
| 152 | + }, | ||
| 153 | + { | ||
| 154 | + name: '是', | ||
| 155 | + disabled: false, | ||
| 156 | + }, | ||
| 157 | + | ||
| 158 | +]); | ||
| 159 | + | ||
| 160 | +// up-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中 | ||
| 161 | +const radiovalue1 = ref('否'); | ||
| 162 | + | ||
| 163 | +const groupChange = (n) => { | ||
| 164 | + console.log('groupChange', n); | ||
| 165 | +}; | ||
| 166 | + | ||
| 167 | +const radioChange = (n) => { | ||
| 168 | + console.log('radioChange', n); | ||
| 169 | +}; | ||
| 170 | + | ||
| 131 | // ========== 工具方法 ========== | 171 | // ========== 工具方法 ========== |
| 132 | // 编码 → 中文名称。字典未拉到时(登录时字典请求是容错的)兜底显示原始编码, | 172 | // 编码 → 中文名称。字典未拉到时(登录时字典请求是容错的)兜底显示原始编码, |
| 133 | // 保证选项不为空、页面仍可用 | 173 | // 保证选项不为空、页面仍可用 |
| @@ -198,6 +238,7 @@ const workOrderForm = reactive({ | @@ -198,6 +238,7 @@ const workOrderForm = reactive({ | ||
| 198 | lat: 0, // 原有字段 | 238 | lat: 0, // 原有字段 |
| 199 | lon: 0, // 原有字段 | 239 | lon: 0, // 原有字段 |
| 200 | expectedFinishDate: '', // 原有字段 | 240 | expectedFinishDate: '', // 原有字段 |
| 241 | + keyInspection: '否' | ||
| 201 | }) | 242 | }) |
| 202 | 243 | ||
| 203 | // ========== 表单校验规则(核心调整:新增busiLineCn校验规则) ========== | 244 | // ========== 表单校验规则(核心调整:新增busiLineCn校验规则) ========== |
| @@ -307,7 +348,9 @@ const echoOrderData = (orderItem) => { | @@ -307,7 +348,9 @@ const echoOrderData = (orderItem) => { | ||
| 307 | workOrderForm.lat = orderItem.lat || 0; | 348 | workOrderForm.lat = orderItem.lat || 0; |
| 308 | workOrderForm.lon = orderItem.lon || 0; | 349 | workOrderForm.lon = orderItem.lon || 0; |
| 309 | workOrderForm.expectedFinishDate = orderItem.expectedFinishDate ? timeFormat(orderItem.expectedFinishDate, 'yyyy-mm-dd hh:MM:ss') : ''; | 350 | workOrderForm.expectedFinishDate = orderItem.expectedFinishDate ? timeFormat(orderItem.expectedFinishDate, 'yyyy-mm-dd hh:MM:ss') : ''; |
| 310 | - | 351 | +if (orderItem.keyInspection !== undefined) { |
| 352 | + workOrderForm.keyInspection = orderItem.keyInspection === 1 ? '是' : '否' | ||
| 353 | +} | ||
| 311 | // 3. 上传图片回显(兼容useUploadImgs格式) | 354 | // 3. 上传图片回显(兼容useUploadImgs格式) |
| 312 | if (orderItem.problemsImgs && Array.isArray(orderItem.problemsImgs) && orderItem.problemsImgs.length > 0) { | 355 | if (orderItem.problemsImgs && Array.isArray(orderItem.problemsImgs) && orderItem.problemsImgs.length > 0) { |
| 313 | const imgList = orderItem.problemsImgs.map((imgUrl, index) => ({ | 356 | const imgList = orderItem.problemsImgs.map((imgUrl, index) => ({ |
| @@ -531,6 +574,7 @@ const submitWorkOrder = async () => { | @@ -531,6 +574,7 @@ const submitWorkOrder = async () => { | ||
| 531 | return; | 574 | return; |
| 532 | } | 575 | } |
| 533 | console.log('完成时间:' + workOrderForm.expectedFinishDate) | 576 | console.log('完成时间:' + workOrderForm.expectedFinishDate) |
| 577 | + const keyInspectionVal = workOrderForm.keyInspection === '是' ? 1 : 0 | ||
| 534 | // 构建公共提交数据 | 578 | // 构建公共提交数据 |
| 535 | const commonSubmitData = { | 579 | const commonSubmitData = { |
| 536 | roadId: workOrderForm.roadId, | 580 | roadId: workOrderForm.roadId, |
| @@ -543,6 +587,7 @@ const submitWorkOrder = async () => { | @@ -543,6 +587,7 @@ const submitWorkOrder = async () => { | ||
| 543 | lonLatAddress: workOrderForm.workLocation, | 587 | lonLatAddress: workOrderForm.workLocation, |
| 544 | pressingType: workOrderForm.pressingType, | 588 | pressingType: workOrderForm.pressingType, |
| 545 | orderName: workOrderForm.orderName, | 589 | orderName: workOrderForm.orderName, |
| 590 | + keyInspection: keyInspectionVal, | ||
| 546 | expectedFinishDate: workOrderForm.expectedFinishDate == "" ? "" : new Date(workOrderForm.expectedFinishDate).getTime(), | 591 | expectedFinishDate: workOrderForm.expectedFinishDate == "" ? "" : new Date(workOrderForm.expectedFinishDate).getTime(), |
| 547 | sourceId: 1, | 592 | sourceId: 1, |
| 548 | sourceName: workOrderForm.busiLineCn, // 从form字段获取业务线中文名称 | 593 | sourceName: workOrderForm.busiLineCn, // 从form字段获取业务线中文名称 |