Commit dfa5aac5014397a310593d0d0da00296f83422de

Authored by 刘淇
1 parent 2b13ab68

验收加上 验收图片非必传

pages-sub/problem/work-order-manage/index.vue
... ... @@ -215,14 +215,14 @@
215 215 </view>
216 216 </up-modal>
217 217  
218   - <!-- 验收弹窗 up-modal -->
  218 + <!-- 验收弹窗 up-modal(含图片上传) -->
219 219 <up-modal
220 220 :show="acceptModalShow"
221 221 title="验收"
222 222 :closeOnClickOverlay="false"
223 223 :showConfirmButton="true"
224 224 :showCancelButton="true"
225   - @cancel="acceptModalShow=false"
  225 + @cancel="handleAcceptModalCancel"
226 226 @confirm="handleAcceptModalConfirm"
227 227 >
228 228 <view class="accept-modal-content">
... ... @@ -245,6 +245,22 @@
245 245 count
246 246 />
247 247 </view>
  248 +
  249 + <!-- 验收图片上传(选填,参考回退弹窗样式) -->
  250 + <view class="upload-wrap mt-20">
  251 + <view class="upload-title">上传验收图片(选填)</view>
  252 + <up-upload
  253 + :file-list="acceptImgs.imgList"
  254 + @after-read="acceptImgs.uploadImgs"
  255 + @delete="acceptImgs.deleteImg"
  256 + multiple
  257 + width="70"
  258 + height="70"
  259 + :max-count="acceptImgs.uploadConfig.maxCount"
  260 + :upload-text="acceptImgs.uploadConfig.uploadText"
  261 + :size-type="acceptImgs.uploadConfig.sizeType"
  262 + />
  263 + </view>
248 264 </view>
249 265 </up-modal>
250 266 </view>
... ... @@ -252,7 +268,7 @@
252 268  
253 269 <script setup>
254 270 import { ref, computed, watch } from 'vue';
255   -import { onReady, onShow } from '@dcloudio/uni-app';
  271 +import { onShow } from '@dcloudio/uni-app';
256 272 import { timeFormat } from '@/uni_modules/uview-plus';
257 273 import {
258 274 myBuzSimplePage,
... ... @@ -293,31 +309,45 @@ const isInspector = computed(() =&gt; {
293 309 // 增加可选链,避免用户信息不存在报错
294 310 return userStore.userInfo?.roles?.includes('yl_inspector') || false;
295 311 });
296   -// 回退弹窗相关(核心改造:使用useUploadImgs替代原始图片管理)
  312 +// 回退弹窗相关
297 313 const rejectModalShow = ref(false); // 回退modal显示开关
298 314 const rejectReason = ref(''); // 回退原因
299 315 const currentRejectItem = ref(null); // 当前回退工单
300 316  
301   -// ========== 核心改造:回退图片上传配置(与参考页面风格一致) ==========
  317 +// 回退图片上传配置(与参考页面风格一致)
302 318 const rejectImgs = useUploadImgs({
303   - maxCount: 3, // 最多上传3张,与原有逻辑一致
  319 + maxCount: 3, // 最多上传3张
304 320 uploadText: '选择回退图片', // 自定义上传提示文字
305   - sizeType: ['compressed'], // 仅上传压缩图,优化性能
306   - formRef: null, // 该弹窗无表单校验,传null即可
307   - fieldName: 'rejectImgs' // 自定义字段名,用于标识该上传实例
  321 + sizeType: ['compressed'], // 仅上传压缩图
  322 + formRef: null, // 该弹窗无表单校验
  323 + fieldName: 'rejectImgs' // 自定义字段名
308 324 })
309 325  
310   -// 监听上传实例响应式变化,解决u-upload不刷新问题(与参考页面一致)
  326 +// 监听上传实例响应式变化,解决u-upload不刷新问题
311 327 watch(() => rejectImgs.rawImgList.value, (newVal) => {
312 328 rejectImgs.imgList = newVal
313 329 }, { deep: true })
314 330  
315   -// ========== 新增:养护组长验收弹窗相关状态 ==========
  331 +// ========== 验收弹窗相关状态(含图片上传) ==========
316 332 const acceptModalShow = ref(false); // 验收弹窗显示开关
317 333 const acceptRadioValue = ref('0'); // 单选框值,默认0(通过)
318 334 const acceptReason = ref(''); // 验收原因
319 335 const currentAcceptItem = ref(null); // 当前验收的工单项
320 336  
  337 +// 验收图片上传配置(独立实例,参考回退弹窗)
  338 +const acceptImgs = useUploadImgs({
  339 + maxCount: 3, // 最多上传3张,与回退弹窗一致
  340 + uploadText: '选择验收图片', // 自定义上传提示文字
  341 + sizeType: ['compressed'], // 仅上传压缩图,优化性能
  342 + formRef: null, // 验收弹窗无表单校验
  343 + fieldName: 'acceptImgs' // 自定义字段名,区分回退图片
  344 +})
  345 +
  346 +// 监听验收图片上传实例响应式变化,解决u-upload不刷新问题
  347 +watch(() => acceptImgs.rawImgList.value, (newVal) => {
  348 + acceptImgs.imgList = newVal
  349 +}, { deep: true })
  350 +
321 351 // 分页查询列表
322 352 const queryList = async (pageNo, pageSize) => {
323 353 try {
... ... @@ -431,10 +461,6 @@ const handleProcess = async (item) =&gt; {
431 461 uni.navigateTo({
432 462 url: `/pages-sub/problem/work-order-manage/add-maintain-order?tempKey=${tempKey}`
433 463 })
434   -
435   - // uni.navigateTo({
436   - // url: `/pages-sub/problem/work-order-manage/add-maintain-order?taskId=${item.taskId}&id=${item.id}&orderNo=${item.orderNo}`
437   - // })
438 464 }
439 465 // 养护组长验收 - 打开弹窗
440 466 if (nextStepMap[item.taskKey]?.name == '养护组长验收') {
... ... @@ -556,8 +582,15 @@ const handleAddOrder = () =&gt; {
556 582 });
557 583 };
558 584  
559   -// ========== 验收弹窗事件 ==========
560   -// 验收弹窗 - 确定按钮(含表单校验)
  585 +// 验收弹窗 - 取消按钮(清空状态)
  586 +const handleAcceptModalCancel = () => {
  587 + acceptModalShow.value = false;
  588 + acceptReason.value = ''; // 清空验收原因
  589 + acceptRadioValue.value = '0'; // 重置单选框为“通过”
  590 + acceptImgs.clearImgs(); // 清空验收图片
  591 +};
  592 +
  593 +// 验收弹窗 - 确定按钮(含returnImgs传参)
561 594 const handleAcceptModalConfirm = async () => {
562 595 // 1. 校验验收原因是否为空
563 596 if (!acceptReason.value.trim()) {
... ... @@ -570,12 +603,13 @@ const handleAcceptModalConfirm = async () =&gt; {
570 603 return;
571 604 }
572 605 try {
573   - // 3. 调用验收接口
  606 + // 3. 构建请求参数(含returnImgs)
574 607 console.log(currentAcceptItem.value)
575 608 let postData = {}
576 609 if (currentAcceptItem.value?.taskKey == 'ylTeamLeaderConfirm') { // 养护组长验收
577 610 postData = {
578   - "taskKey": currentAcceptItem.value.taskKey, // ylTeamLeaderConfirm
  611 + "returnImgs": acceptImgs.getSuccessImgUrls(), // 验收图片URL数组
  612 + "taskKey": currentAcceptItem.value.taskKey,
579 613 "workerDataId": currentAcceptItem.value.id,
580 614 "taskId": currentAcceptItem.value.taskId,
581 615 "operateType": acceptRadioValue.value == 0 ? nextStepMap[currentAcceptItem.value.taskKey].operateTypePass : nextStepMap[currentAcceptItem.value.taskKey].operateTypeNoPass,
... ... @@ -584,7 +618,8 @@ const handleAcceptModalConfirm = async () =&gt; {
584 618 }
585 619 if (currentAcceptItem.value?.taskKey == 'ylInspector') { // 巡查员验收
586 620 postData = {
587   - "taskKey": currentAcceptItem.value.taskKey, //ylInspector
  621 + "returnImgs": acceptImgs.getSuccessImgUrls(), // 验收图片URL数组
  622 + "taskKey": currentAcceptItem.value.taskKey,
588 623 "taskId": currentAcceptItem.value.taskId,
589 624 "workerDataId": currentAcceptItem.value.id,
590 625 "operateType": acceptRadioValue.value == 0 ? nextStepMap[currentAcceptItem.value.taskKey].operateTypePass : nextStepMap[currentAcceptItem.value.taskKey].operateTypeNoPass,
... ... @@ -595,12 +630,11 @@ const handleAcceptModalConfirm = async () =&gt; {
595 630 const acceptRes = await universalApproval(postData);
596 631 // 4. 操作成功处理
597 632 uni.showToast({title: '提交成功', icon: 'success', duration: 1000});
598   - acceptModalShow.value = false;
599   - acceptReason.value = ''; // 清空验收原因
  633 + handleAcceptModalCancel(); // 清空状态
600 634 paging.value?.reload(); // 刷新工单列表
601 635 } catch (error) {
602 636 // 5. 操作失败处理
603   - console.error('养护组长验收失败:', error);
  637 + console.error('验收失败:', error);
604 638 uni.showToast({title: '验收提交失败,请重试', icon: 'none', duration: 1000});
605 639 }
606 640 };
... ... @@ -621,7 +655,6 @@ onShow(() =&gt; {
621 655 // 顶部固定区域
622 656 .header-wrap {
623 657 background-color: #fff;
624   - //box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
625 658 }
626 659  
627 660 // 搜索栏样式
... ... @@ -662,7 +695,6 @@ onShow(() =&gt; {
662 695  
663 696 }
664 697  
665   -
666 698 // 回退modal样式
667 699 .reject-modal-content {
668 700 width: 100%;
... ... @@ -681,7 +713,6 @@ onShow(() =&gt; {
681 713 }
682 714 }
683 715  
684   -
685 716 .upload-wrap {
686 717 margin-top: 20rpx;
687 718  
... ... @@ -696,6 +727,10 @@ onShow(() =&gt; {
696 727 margin-top: 20rpx;
697 728 }
698 729  
  730 +.mt-30 {
  731 + margin-top: 30rpx;
  732 +}
  733 +
699 734 // 养护组长验收弹窗样式
700 735 .accept-modal-content {
701 736 width: 100%;
... ...
pages-sub/problem/work-order-manage/order-detail.vue
... ... @@ -259,7 +259,7 @@
259 259 </view>
260 260 </view>
261 261  
262   - <!-- 回退原因弹窗 -->
  262 + <!-- 回退原因弹窗(新增图片上传) -->
263 263 <up-modal
264 264 :show="rejectModalShow"
265 265 title="回退原因"
... ... @@ -278,17 +278,32 @@
278 278 maxlength="200"
279 279 class="reject-textarea"
280 280 />
  281 + <!-- 新增:回退图片上传(选填) -->
  282 + <view class="upload-wrap mt-20">
  283 + <view class="upload-title">上传回退图片(选填)</view>
  284 + <up-upload
  285 + :file-list="rejectImgs.imgList"
  286 + @after-read="rejectImgs.uploadImgs"
  287 + @delete="rejectImgs.deleteImg"
  288 + multiple
  289 + width="70"
  290 + height="70"
  291 + :max-count="rejectImgs.uploadConfig.maxCount"
  292 + :upload-text="rejectImgs.uploadConfig.uploadText"
  293 + :size-type="rejectImgs.uploadConfig.sizeType"
  294 + />
  295 + </view>
281 296 </view>
282 297 </up-modal>
283 298  
284   - <!-- 验收弹窗 -->
  299 + <!-- 验收弹窗(新增图片上传) -->
285 300 <up-modal
286 301 :show="acceptModalShow"
287 302 title="验收"
288 303 :closeOnClickOverlay="false"
289 304 :showConfirmButton="true"
290 305 :showCancelButton="true"
291   - @cancel="acceptModalShow=false"
  306 + @cancel="handleAcceptModalCancel"
292 307 @confirm="handleAcceptModalConfirm"
293 308 >
294 309 <view class="accept-modal-content">
... ... @@ -311,6 +326,22 @@
311 326 count
312 327 />
313 328 </view>
  329 +
  330 + <!-- 新增:验收图片上传(选填) -->
  331 + <view class="upload-wrap mt-20">
  332 + <view class="upload-title">上传验收图片(选填)</view>
  333 + <up-upload
  334 + :file-list="acceptImgs.imgList"
  335 + @after-read="acceptImgs.uploadImgs"
  336 + @delete="acceptImgs.deleteImg"
  337 + multiple
  338 + width="70"
  339 + height="70"
  340 + :max-count="acceptImgs.uploadConfig.maxCount"
  341 + :upload-text="acceptImgs.uploadConfig.uploadText"
  342 + :size-type="acceptImgs.uploadConfig.sizeType"
  343 + />
  344 + </view>
314 345 </view>
315 346 </up-modal>
316 347  
... ... @@ -522,8 +553,7 @@ const activeTopTabClick = async (item: any) =&gt; {
522 553 }
523 554 }
524 555  
525   -
526   -// ========== 新增:回退弹窗相关状态 ==========
  556 +// ========== 回退弹窗相关状态(新增图片上传实例) ==========
527 557 const rejectModalShow = ref(false); // 回退modal显示开关
528 558 const rejectReason = ref(''); // 回退原因
529 559 const currentRejectItem = ref<any>(null); // 当前回退工单
... ... @@ -535,23 +565,35 @@ const rejectImgs = useUploadImgs({
535 565 formRef: null,
536 566 fieldName: 'rejectImgs'
537 567 })
538   -// 监听上传实例响应式变化
  568 +// 监听上传实例响应式变化,解决u-upload不刷新问题
539 569 watch(() => rejectImgs.rawImgList.value, (newVal) => {
540 570 rejectImgs.imgList = newVal
541 571 }, { deep: true })
542 572  
543   -// ========== 新增:验收弹窗相关状态 ==========
  573 +// ========== 验收弹窗相关状态(新增图片上传实例) ==========
544 574 const acceptModalShow = ref(false); // 验收弹窗显示开关
545 575 const acceptRadioValue = ref('0'); // 单选框值,默认0(通过)
546 576 const acceptReason = ref(''); // 验收原因
547 577 const currentAcceptItem = ref<any>(null); // 当前验收的工单项
  578 +// 验收图片上传配置
  579 +const acceptImgs = useUploadImgs({
  580 + maxCount: 3,
  581 + uploadText: '选择验收图片',
  582 + sizeType: ['compressed'],
  583 + formRef: null,
  584 + fieldName: 'acceptImgs'
  585 +})
  586 +// 监听验收图片上传实例响应式变化
  587 +watch(() => acceptImgs.rawImgList.value, (newVal) => {
  588 + acceptImgs.imgList = newVal
  589 +}, { deep: true })
548 590  
549   -// ========== 新增:生成临时key ==========
  591 +// ========== 生成临时key ==========
550 592 const generateTempKey = () => {
551 593 return 'renew_order_' + Date.now() + '_' + Math.floor(Math.random() * 10000);
552 594 };
553 595  
554   -// ========== 新增:handleRenew 重新提交工单 ==========
  596 +// ========== handleRenew 重新提交工单 ==========
555 597 const handleRenew = (item: any) => {
556 598 // 校验工单有效性
557 599 if (!item || !item.id) {
... ... @@ -577,7 +619,7 @@ const handleRenew = (item: any) =&gt; {
577 619 });
578 620 };
579 621  
580   -// ========== 新增:handleReject 打开回退弹窗 ==========
  622 +// ========== handleReject 打开回退弹窗 ==========
581 623 const handleReject = (item: any) => {
582 624 // 校验工单有效性
583 625 if (!item || !item.id) {
... ... @@ -590,14 +632,14 @@ const handleReject = (item: any) =&gt; {
590 632 rejectModalShow.value = true; // 显示回退modal
591 633 };
592 634  
593   -// ========== 新增:回退弹窗取消按钮 ==========
  635 +// ========== 回退弹窗取消按钮 ==========
594 636 const handleRejectModalCancel = () => {
595 637 rejectModalShow.value = false;
596 638 rejectReason.value = '';
597 639 rejectImgs.clearImgs(); // 清空上传图片
598 640 };
599 641  
600   -// ========== 新增:确认回退工单 ==========
  642 +// ========== 确认回退工单(新增returnImgs传参) ==========
601 643 const confirmReject = async () => {
602 644 // 严格校验回退原因(去除首尾空格)
603 645 const rejectReasonTrim = rejectReason.value.trim();
... ... @@ -615,9 +657,9 @@ const confirmReject = async () =&gt; {
615 657 // 显示加载中,防止重复提交
616 658 uni.showLoading({title: '提交中...', mask: true});
617 659  
618   - // 构建请求参数
  660 + // 构建请求参数(新增returnImgs)
619 661 const requestData = {
620   - "returnImgs": rejectImgs.getSuccessImgUrls(),
  662 + "returnImgs": rejectImgs.getSuccessImgUrls(), // 回退图片URL数组
621 663 "workerDataId": currentRejectItem.value.id,
622 664 "taskKey": currentRejectItem.value.taskKey,
623 665 "taskId": currentRejectItem.value.taskId,
... ... @@ -628,9 +670,13 @@ const confirmReject = async () =&gt; {
628 670 // 调用回退工单接口
629 671 const res = await universalApproval(requestData);
630 672 uni.showToast({title: '回退成功', icon: 'success', duration: 1000});
  673 +
631 674 rejectModalShow.value = false;
632 675 // 重新获取工单详情,刷新页面
633   - await DetailQuery(taskId.value);
  676 + // await DetailQuery(taskId.value);
  677 + uni.reLaunch({
  678 + url: `/pages-sub/problem/work-order-manage/index`
  679 + });
634 680 } catch (error) {
635 681 console.error('回退工单失败:', error);
636 682 uni.showToast({title: '网络异常,回退失败', icon: 'none', duration: 1000});
... ... @@ -640,7 +686,7 @@ const confirmReject = async () =&gt; {
640 686 }
641 687 };
642 688  
643   -// ========== 新增:handleProcess 处理工单 ==========
  689 +// ========== handleProcess 处理工单 ==========
644 690 const handleProcess = async (item: any) => {
645 691 console.log(nextStepMap[item.taskKey]?.name)
646 692 try {
... ... @@ -672,6 +718,7 @@ const handleProcess = async (item: any) =&gt; {
672 718 currentAcceptItem.value = item; // 存储当前工单信息
673 719 acceptReason.value = ''; // 清空上次的验收原因
674 720 acceptRadioValue.value = '0'; // 重置默认选中“通过”
  721 + acceptImgs.clearImgs(); // 清空验收图片
675 722 acceptModalShow.value = true; // 显示验收弹窗
676 723 }
677 724 // 巡查员验收 - 打开弹窗
... ... @@ -679,6 +726,7 @@ const handleProcess = async (item: any) =&gt; {
679 726 currentAcceptItem.value = item; // 存储当前工单信息
680 727 acceptReason.value = ''; // 清空上次的验收原因
681 728 acceptRadioValue.value = '0'; // 重置默认选中“通过”
  729 + acceptImgs.clearImgs(); // 清空验收图片
682 730 acceptModalShow.value = true; // 显示验收弹窗
683 731 }
684 732  
... ... @@ -690,7 +738,7 @@ const handleProcess = async (item: any) =&gt; {
690 738 content: "请确定是否结束工单?",
691 739 success: async function (res) {
692 740 if (res.confirm) {
693   - // 构建请求参数
  741 + // 构建请求参数(携带returnImgs)
694 742 const requestData = {
695 743 "returnImgs": rejectImgs.getSuccessImgUrls(),
696 744 "workerDataId": item.id,
... ... @@ -717,7 +765,15 @@ const handleProcess = async (item: any) =&gt; {
717 765 }
718 766 };
719 767  
720   -// ========== 新增:验收弹窗确认按钮 ==========
  768 +// ========== 验收弹窗取消按钮(新增清空图片) ==========
  769 +const handleAcceptModalCancel = () => {
  770 + acceptModalShow.value = false;
  771 + acceptReason.value = '';
  772 + acceptRadioValue.value = '0';
  773 + acceptImgs.clearImgs(); // 清空验收图片
  774 +};
  775 +
  776 +// ========== 验收弹窗确认按钮(新增returnImgs传参) ==========
721 777 const handleAcceptModalConfirm = async () => {
722 778 // 1. 校验验收原因是否为空
723 779 if (!acceptReason.value.trim()) {
... ... @@ -735,6 +791,7 @@ const handleAcceptModalConfirm = async () =&gt; {
735 791 let postData: any = {}
736 792 if (currentAcceptItem.value?.taskKey == 'ylTeamLeaderConfirm') { // 养护组长验收
737 793 postData = {
  794 + "returnImgs": acceptImgs.getSuccessImgUrls(), // 验收图片URL数组
738 795 "taskKey": currentAcceptItem.value.taskKey, // ylTeamLeaderConfirm
739 796 "workerDataId": currentAcceptItem.value.id,
740 797 "taskId": currentAcceptItem.value.taskId,
... ... @@ -744,6 +801,7 @@ const handleAcceptModalConfirm = async () =&gt; {
744 801 }
745 802 if (currentAcceptItem.value?.taskKey == 'ylInspector') { // 巡查员验收
746 803 postData = {
  804 + "returnImgs": acceptImgs.getSuccessImgUrls(), // 验收图片URL数组
747 805 "taskKey": currentAcceptItem.value.taskKey, //ylInspector
748 806 "taskId": currentAcceptItem.value.taskId,
749 807 "workerDataId": currentAcceptItem.value.id,
... ... @@ -755,10 +813,12 @@ const handleAcceptModalConfirm = async () =&gt; {
755 813 const acceptRes = await universalApproval(postData);
756 814 // 4. 操作成功处理
757 815 uni.showToast({title: '提交成功', icon: 'success', duration: 1000});
758   - acceptModalShow.value = false;
759   - acceptReason.value = ''; // 清空验收原因
  816 + handleAcceptModalCancel(); // 清空状态
760 817 // 重新获取工单详情,刷新页面
761   - await DetailQuery(taskId.value);
  818 + // await DetailQuery(taskId.value);
  819 + uni.reLaunch({
  820 + url: `/pages-sub/problem/work-order-manage/index`
  821 + });
762 822 } catch (error) {
763 823 // 5. 操作失败处理
764 824 console.error('验收失败:', error);
... ... @@ -926,7 +986,20 @@ onShow(() =&gt; {
926 986 }
927 987 }
928 988  
  989 +// 上传图片通用样式
  990 +.upload-wrap {
  991 + margin-top: 20rpx;
  992 +
  993 + .upload-title {
  994 + font-size: 28rpx;
  995 + color: #333;
  996 + margin-bottom: 10rpx;
  997 + }
  998 +}
929 999  
  1000 +.mt-20 {
  1001 + margin-top: 20rpx;
  1002 +}
930 1003  
931 1004 // 回退弹窗样式
932 1005 .reject-modal-content {
... ... @@ -935,6 +1008,9 @@ onShow(() =&gt; {
935 1008 padding: 10rpx 0;
936 1009 }
937 1010  
  1011 +.reject-textarea {
  1012 + width: 100%;
  1013 +}
938 1014  
939 1015 // 验收弹窗样式
940 1016 .accept-modal-content {
... ... @@ -955,7 +1031,6 @@ onShow(() =&gt; {
955 1031 margin-top: 30rpx;
956 1032 }
957 1033  
958   -
959 1034 .mt-30 {
960 1035 margin-top: 30rpx;
961 1036 }
... ...