ecbfbe06
刘淇
树巡检记录
|
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
|
import { nextStepMap, calculateFormatTimeDiff } from '@/common/utils/common'
import { useUploadImgs } from '@/common/utils/useUploadImgs'
import { useUserStore } from '@/pinia/user'
// 全局实例
const userStore = useUserStore()
const USER_ROLES = userStore.userInfo?.roles || []
const eventChannel = ref<any>(null)
// 通用方法
const showToast = (title: string, icon: 'none' | 'success' | 'loading' = 'none', duration = 2000) => {
uni.showToast({ title, icon, duration })
}
const generateTempKey = (prefix = 'order') => {
return `${prefix}_${Date.now()}_${Math.floor(Math.random() * 10000)}`
}
const setOrderStorage = (item: any, prefix: string) => {
if (!item?.id) return null
const tempKey = generateTempKey(prefix)
try {
uni.setStorageSync(tempKey, item)
return tempKey
} catch (err) {
console.error('存储失败:', err)
showToast('数据存储异常')
return null
}
}
const callApprovalApi = async (params: any, taskKey: string) => {
if (taskKey === 'aiRegionManager') return await aiUniversalApproval(params)
if (taskKey === 'shRegionManager') return await dcyUniversalApproval(params)
if (taskKey === 'regionManager') return await qyUniversalApproval(params)
if (USER_ROLES.includes('regional_manager')) return await daquUniversalApproval(params)
if (USER_ROLES.includes('Inspector_global')) return await dcyUniversalApproval(params)
if (USER_ROLES.includes('patrol_global')) return await qyUniversalApproval(params)
if (USER_ROLES.includes('AI_dispatcher')) return await aiUniversalApproval(params)
throw new Error('未匹配对应接口')
}
const navToOrderPage = (path: string, query = {}) => {
const queryStr = Object.keys(query)
.map(k => `${k}=${encodeURIComponent(query[k])}`)
.join('&')
const url = queryStr ? `${path}?${queryStr}` : path
uni.navigateTo({ url })
}
// 页面状态
const loading = ref(true)
const activeTopTab = ref(0)
const activeImgTab = ref(0)
const topTabList = ref([
{ name: '工单详情' },
{ name: '流程节点' }
])
const imgTabList = ref([
{ name: '开始', badge: { isDot: true } },
{ name: '进行中' },
{ name: '结束', badge: { isDot: true } },
{ name: '人员' },
{ name: '材料' }
])
const processData = ref<any>({
status: 2,
activityNodes: [],
formFieldsPermission: null,
todoTask: null
})
// 工单详情数据
const orderDetail = ref<any>({
id: 0,
busiLine: '',
orderNo: '',
orderName: '',
sourceId: 0,
sourceName: '',
roadId: 0,
roadName: '',
streetId: '',
streetName: '',
curingLevelId: 0,
curingLevelName: '',
commitDate: 0,
finishDate: 0,
expectedFinishDate: 0,
pressingType: 0,
userId: 0,
userName: '',
companyId: 0,
latLonType: 0,
lat: 0,
lon: 0,
lonLatAddress: '',
thirdWorkNo: '',
thirdPushState: 0,
buzStatus: null,
status: 0,
processInstanceId: '',
remark: '',
handleResult: '',
createTime: 0,
fileNames: null,
coHandlers: null,
coHandlersName: null,
companyName: null,
userMobile: null,
taskId: '',
taskName: '',
taskKey: '',
processDefinitionName: '',
startTime: 0,
endTime: 0,
key_: '',
problemsImgs: [],
startImgs: [],
processingImgs: [],
endImgs: [],
personImgs: [],
materialImgs: []
})
const currentImgList = ref<any[]>([])
const tabKeyMap = ['startImgs', 'processingImgs', 'endImgs', 'personImgs', 'materialImgs']
const imgTabChange = ({ index }: { index: number }) => {
currentImgList.value = orderDetail.value[tabKeyMap[index]]
}
// 路由参数
const taskId = ref('')
const activeTab = ref('')
const processInstanceId = ref('')
const orderId = ref('')
// 文本截取
const getLimitReason = (reason: string | null | undefined) => {
if (!reason) return '无处理说明'
return reason.length > 200 ? reason.substring(0, 200) + '...' : reason
}
// 步骤索引
const getCurrentStepIndex = () => {
const { activityNodes } = processData.value
if (!activityNodes || !activityNodes.length) return 0
return activityNodes.length
}
|
ecbfbe06
刘淇
树巡检记录
|
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
|
processData.value = { ...res, activityNodes: formatNodes }
} else {
processData.value = res
}
}
}
// 回退弹窗
const rejectModalShow = ref(false)
const rejectReason = ref('')
const currentRejectItem = ref<any>(null)
const rejectImgs = useUploadImgs({
maxCount: 3,
uploadText: '选择回退图片',
sizeType: ['compressed'],
formRef: null,
fieldName: 'rejectImgs'
})
// 验收弹窗
const acceptModalShow = ref(false)
const acceptRadioValue = ref('0')
const acceptReason = ref('')
const currentAcceptItem = ref<any>(null)
const acceptImgs = useUploadImgs({
maxCount: 3,
uploadText: '选择验收图片',
sizeType: ['compressed'],
formRef: null,
fieldName: 'acceptImgs'
})
// 重新提交工单
const handleRenew = (item: any) => {
if (!item?.id) return showToast('工单信息异常')
const tempKey = setOrderStorage(item, 'renew_order')
if (!tempKey) return
const url = USER_ROLES.includes('patrol_global')
? '/pages-sub/problem/regional-order-manage/add-patrol-order'
: '/pages-sub/problem/regional-order-manage/add-order'
navToOrderPage(url, { isRenew: 1, tempKey })
}
// 打开回退弹窗
const handleReject = (item: any) => {
if (!item?.id) return showToast('工单信息异常')
currentRejectItem.value = item
rejectReason.value = ''
rejectImgs.clearImgs()
rejectModalShow.value = true
}
// 关闭回退弹窗
const handleRejectModalCancel = () => {
rejectModalShow.value = false
rejectReason.value = ''
rejectImgs.clearImgs()
}
// 确认回退
const confirmReject = async () => {
const reason = rejectReason.value.trim()
if (!reason) return showToast('请填写回退原因')
const item = currentRejectItem.value
if (!item?.id) return showToast('工单信息异常')
uni.showLoading({ title: '提交中...', mask: true })
try {
const params = {
returnImgs: rejectImgs.getSuccessImgUrls(),
workerDataId: item.id,
taskKey: item.taskKey,
taskId: item.taskId,
operateType: nextStepMap[item.taskKey].operateTypeNoPass,
agree: 1,
reason
}
await callApprovalApi(params, item.taskKey)
showToast('回退成功', 'success')
handleRejectModalCancel()
eventChannel.value.emit('needRefresh')
uni.navigateBack()
} catch (err: any) {
console.error('回退失败:', err)
showToast(err.msg || '回退失败,请重试')
} finally {
uni.hideLoading()
}
}
// 处理工单操作
const handleProcess = async (item: any) => {
if (!item) return showToast('工单信息异常')
const stepName = nextStepMap[item.taskKey]?.name
if (!stepName) return showToast('暂无操作权限')
uni.showLoading({ title: '处理中...', mask: true })
try {
if (stepName === '大区经理分配') {
const tempKey = setOrderStorage(item, 'distribute_order')
tempKey && navToOrderPage('/pages-sub/problem/regional-order-manage/distribution-order', { tempKey })
} else if (stepName === '养护员待实施') {
const tempKey = setOrderStorage(item, 'maintain_order')
tempKey && navToOrderPage('/pages-sub/problem/regional-order-manage/add-maintain-order', { tempKey })
} else if (stepName === '督察员单子大区经理分配') {
uni.showModal({
title: '分配工单',
content: '确定分配该工单?',
success: async (res) => {
if (res.confirm) {
const params = {
taskKey: item.taskKey,
taskId: item.taskId,
operateType: 60,
workerDataId: item.id,
agree: 0,
reason: item.remark,
roadId: item.roadId,
roadName: item.roadName,
pressingType: item.pressingType,
orderName: item.orderName,
expectedFinishDate: item.expectedFinishDate,
busiLine: item.busiLine
}
await dcyUniversalApproval(params)
showToast('分配成功', 'success')
eventChannel.value.emit('needRefresh')
uni.navigateBack()
}
}
})
} else if (stepName === 'ai单子大区经理分配') {
uni.showModal({
title: '分配工单',
content: '确定分配该工单?',
success: async (res) => {
if (res.confirm) {
const params = {
taskKey: item.taskKey,
taskId: item.taskId,
operateType: 40,
workerDataId: item.id,
agree: 0,
reason: item.remark,
roadId: item.roadId,
roadName: item.roadName,
pressingType: item.pressingType,
orderName: item.orderName,
expectedFinishDate: item.expectedFinishDate,
busiLine: item.busiLine
}
await aiUniversalApproval(params)
showToast('分配成功', 'success')
eventChannel.value.emit('needRefresh')
uni.navigateBack()
}
}
})
} else if (['养护组长验收', '巡查员验收'].includes(stepName)) {
currentAcceptItem.value = item
acceptReason.value = ''
acceptRadioValue.value = '0'
acceptModalShow.value = true
} else if (stepName === '发起人确认') {
uni.hideLoading()
uni.showModal({
title: '结束工单',
content: '确定结束该工单?',
success: async (res) => {
if (res.confirm) {
const params = {
workerDataId: item.id,
taskKey: 'ylInspectorStart',
taskId: item.taskId,
operateType: 200,
agree: 1,
reason: '结束工单'
}
await callApprovalApi(params, item.taskKey)
showToast('结束成功', 'success')
eventChannel.value.emit('needRefresh')
uni.navigateBack()
}
}
})
} else if (stepName === 'AI工单派发人员') {
uni.showModal({
title: '结束工单',
content: '确定结束该工单?',
success: async (res) => {
if (res.confirm) {
const params = {
workerDataId: item.id,
taskKey: 'ylInspectorStart',
taskId: item.taskId,
operateType: 200,
agree: 1,
reason: 'AI工单派发人员结束工单'
}
await callApprovalApi(params, item.taskKey)
showToast('结束成功', 'success')
eventChannel.value.emit('needRefresh')
uni.navigateBack()
}
}
})
}
} catch (err: any) {
console.error('操作失败:', err)
showToast(err.msg || '操作失败,请重试')
} finally {
uni.hideLoading()
}
}
// 关闭验收弹窗
const handleAcceptModalCancel = () => {
acceptModalShow.value = false
acceptReason.value = ''
acceptRadioValue.value = '0'
acceptImgs.clearImgs()
}
// 确认验收(已修复 value 拼写错误)
const handleAcceptModalConfirm = async () => {
const reason = acceptReason.value.trim()
if (!reason) return showToast('请填写验收原因')
if (reason.length > 200) return showToast('验收原因最多200字')
const item = currentAcceptItem.value
if (!item?.id) return showToast('工单信息异常')
uni.showLoading({ title: '提交中...', mask: true })
try {
let params: any = {}
if (item.taskKey === 'ylTeamLeaderConfirm') {
params = {
returnImgs: acceptImgs.getSuccessImgUrls(),
taskKey: item.taskKey,
workerDataId: item.id,
taskId: item.taskId,
operateType: acceptRadioValue.value === '0'
? nextStepMap[item.taskKey].operateTypePass
: nextStepMap[item.taskKey].operateTypeNoPass,
reason
}
}
if (item.taskKey === 'ylInspector') {
params = {
returnImgs: acceptImgs.getSuccessImgUrls(),
taskKey: item.taskKey,
taskId: item.taskId,
workerDataId: item.id,
operateType: acceptRadioValue.value === '0'
? nextStepMap[item.taskKey].operateTypePass
: nextStepMap[item.taskKey].operateTypeNoPass,
reason,
agree: acceptRadioValue.value
}
}
await callApprovalApi(params, item.taskKey)
showToast('提交成功', 'success')
handleAcceptModalCancel()
eventChannel.value.emit('needRefresh')
uni.navigateBack()
} catch (err: any) {
console.error('验收失败:', err)
showToast(err.msg || '验收失败,请重试')
} finally {
uni.hideLoading()
}
}
// 页面加载:接收上一页路由参数 id
onLoad((options: any) => {
console.log('路由参数:', options)
const { taskId: taskIdOpt, activeTab: activeTabOpt, processInstanceId: processInstanceIdOpt, id: orderIdOpt } = options
taskId.value = taskIdOpt || ''
activeTab.value = activeTabOpt || '0'
processInstanceId.value = processInstanceIdOpt || ''
orderId.value = orderIdOpt || ''
// 监听页面返回刷新
eventChannel.value = getCurrentPages()[getCurrentPages().length - 1].getOpenerEventChannel()
// 有工单ID则请求详情接口
if (orderId.value) {
DetailQuery(orderId.value)
} else {
showToast('缺少工单ID')
}
})
</script>
<style scoped lang="scss">
.page-container {
min-height: 100vh;
background-color: #f5f5f5;
}
.main-content {
padding-bottom: 80rpx;
}
.detail-content {
.detail-cell-group {
background-color: #fff;
margin-bottom: 20rpx;
}
.empty-text {
color: #999;
font-size: 26rpx;
}
}
.img-tabs-block {
background-color: #fff;
.img-tab-content {
padding: 20rpx 15px;
text-align: center;
.empty-img-text {
height: 75px;
line-height: 75px;
color: #999;
font-size: 28rpx;
}
}
}
.process-content {
.empty-process {
margin-top: 100rpx;
}
.vertical-steps {
background-color: #fff;
padding: 20rpx;
border-radius: 12rpx;
display: flex;
flex-direction: column;
gap: 20rpx;
}
.step-content-wrap {
width: 100%;
box-sizing: border-box;
.step-title {
font-size: 30rpx;
font-weight: 600;
color: #333;
margin-bottom: 12rpx;
}
.step-desc {
font-size: 24rpx;
color: #666;
line-height: 1.6;
.processing-tag {
color: #f59c26;
margin-left: 10rpx;
}
}
}
}
.fixed-bottom-btn-wrap {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
padding: 15rpx 20rpx;
background-color: #fff;
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
box-sizing: border-box;
}
.upload-title {
font-size: 26rpx;
color: #666;
margin-bottom: 10rpx;
}
.mt-20 {
margin-top: 20rpx;
}
.mt-30 {
margin-top: 30rpx;
}
.radio-group-wrap {
display: flex;
align-items: center;
gap: 40rpx;
font-size: 28rpx;
}
:deep .u-album__row__wrapper image {
width: 70px !important;
height: 70px !important;
}
</style>
|