广州矛调粤政易端
xusd
7 days ago d27794814b69d18aeb8ee96a46cae91d5613570c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
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
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
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
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
/*
 * @Author: zhouxt
 * @Date: 2025-04-10 09:28:00
 * @LastEditTime: 2025-05-23 16:12:10
 * @LastEditors: lwh
 * @Description: 粤政易首页
 */
import React, { useState, useEffect, useRef } from 'react';
import { useHistory } from 'react-router-dom';
import { Swiper, Toast, Drawer, Button, Popguide, TextareaItem, InputItem } from 'dingtalk-design-mobile';
import { Scrollbars } from 'react-custom-scrollbars';
import * as $$ from '../../utils/utility';
import NavBarPage from '../../components/NavBarPage';
import MyList from '../../components/MyList';
import { home_1, home_2, home_3, home_4, home_5, home_6, home_7, home_8, home_9, home_11, caseQuery_2 } from '../../assets/img';
import DingUpload from '../../components/DingUpload';
import './index.less';
import { getNewTimeCaseId } from '../../api/caseApi';
 
// 获取任务数量接口
function getCountListApi() {
    return $$.ax.request({
        url: 'caseTask/getCountList',
        type: 'get',
        service: 'mediate',
    });
}
 
// 全部待办接口
function pageMyTaskAllApi(data) {
    return $$.ax.request({
        url: 'caseTask/pageMyTaskAll',
        type: 'get',
        data,
        service: 'mediate',
    });
}
 
// 待合并接口
function pageMyTaskHbApi(data) {
    return $$.ax.request({
        url: 'caseRepeatInfo/pageCaseRepeatHb',
        type: 'get',
        data,
        service: 'mediate',
    });
}
 
// 待分派接口
function pageMyTaskFpApi(data) {
    return $$.ax.request({
        url: 'caseTask/pageMyTaskFp',
        type: 'get',
        data,
        service: 'mediate',
    });
}
 
// 待受理接口
function pageMyTaskSlApi(data) {
    return $$.ax.request({
        url: 'caseTask/pageMyTaskSl',
        type: 'get',
        data,
        service: 'mediate',
    });
}
 
// 办理中接口
function pageMyTaskBlzApi(data) {
    return $$.ax.request({
        url: 'caseTask/pageMyTaskBlz',
        type: 'get',
        data,
        service: 'mediate',
    });
}
 
// 待审核接口
function pageMyTaskShApi(data) {
    return $$.ax.request({
        url: 'caseTask/pageMyTaskSh',
        type: 'get',
        data,
        service: 'mediate',
    });
}
 
// 督办接口
function pageMyTaskDbApi(data) {
    return $$.ax.request({
        url: 'caseTask/pageMyTaskDb',
        type: 'get',
        data,
        service: 'mediate',
    });
}
 
// 获取督办详情API
function getSuperviseDetailApi(id) {
    return $$.ax.request({
        url: `caseSupervise/getById?id=${id}`,
        type: 'get',
        service: 'mediate',
    });
}
 
// 回复督办API
function replyCaseSuperviseApi(data) {
    return $$.ax.request({
        url: 'caseSupervise/replyCaseSupervise',
        type: 'post',
        data,
        service: 'mediate',
    });
}
 
// 获取标签API
function getLabelApi(caseId) {
    return $$.ax.request({
        url: `caseTask/getLabel?caseId=${caseId}`,
        type: 'get',
        service: 'mediate',
    });
}
 
const Home = () => {
    const history = useHistory();
 
    // Tab 状态
    const [activeTab, setActiveTab] = useState('all'); // 'all','merge','dispatch','accept','processing','review','supervise'
 
    // 任务数量
    const [countData, setCountData] = useState({
        allTask: 0,
        waitDisp: 0,
        waitAccept: 0,
        Processing: 0,
        waitReview: 0,
        supervise: 0,
    });
 
    // 列表数据
    const [listData, setListData] = useState([]);
    const [loading, setLoading] = useState(false);
    const [refreshing, setRefreshing] = useState(false);
    const [hasMore, setHasMore] = useState(true);
    const [page, setPage] = useState(1);
    const [totalCount, setTotalCount] = useState(0);
    const [totalPages, setTotalPages] = useState(1);
    const [searchParams, setSearchParams] = useState({
        caseTaskType: '1',
        caseTaskTypeName: '我承办的',
        mediatorType: '0',
        mediatorTypeName: '本部门办理',
    });
 
    // 请求参数
    const [queryParams, setQueryParams] = useState({
        page: 1,
        size: 10,
        status: 1,
        sortType: 2,
        sortColmn: 1,
        type: 1,
        caseTaskType: 1,
    });
 
    // 添加按钮选中状态
    const [activeButton, setActiveButton] = useState(1); // 1: 我承办的, 2: 我配合的
    const [activeReviewButton, setActiveReviewButton] = useState(1); // 1: 回退审核, 2: 上报审核, 3: 结案审核, 4: 联合处置审核
 
    // 滑动图片
    const carouselItems = [
        { id: 1, src: home_1, alt: '轮播图1' },
        { id: 2, src: home_1, alt: '轮播图2' },
        { id: 3, src: home_1, alt: '轮播图3' },
    ];
 
    // 底部导航项
    const bottomNavItems = [
        { id: 'home', icon: home_6, text: '首页', path: '/gzdyh/home' },
        { id: 'message', icon: home_7, text: '消息', path: '/gzdyh/message' },
        { id: 'count', icon: home_8, text: '统计', path: '/gzdyh/workStatistics' },
        { id: 'personCenter', icon: home_9, text: '我的', path: '/gzdyh/personCenter' },
    ];
 
    // 功能按钮项
    const functionItems = [
        { id: 'register', icon: home_2, text: '登记', path: '/gzdyh/Naturepersonnone' },
        { id: 'done', icon: home_3, text: '已办事项', path: '/gzdyh/caseYb' },
        { id: 'query', icon: home_4, text: '综合查询', path: '/gzdyh/caseQuery' },
        { id: 'draft', icon: home_5, text: '草稿箱', path: '/gzdyh/draftBox' },
    ];
 
    // Tab 列表项
    const tabItems = [
        { id: 'all', text: '全部', countKey: 'allTask', apiFunc: pageMyTaskAllApi },
        { id: 'merge', text: '待合并', countKey: null, apiFunc: pageMyTaskHbApi },
        { id: 'dispatch', text: '待分派', countKey: 'waitDisp', apiFunc: pageMyTaskFpApi },
        { id: 'accept', text: '待受理', countKey: 'waitAccept', apiFunc: pageMyTaskSlApi },
        { id: 'processing', text: '办理中', countKey: 'processing', apiFunc: pageMyTaskBlzApi },
        { id: 'review', text: '待审核', countKey: 'waitReview', apiFunc: pageMyTaskShApi },
        { id: 'supervise', text: '督办', countKey: 'supervise', apiFunc: pageMyTaskDbApi },
    ];
 
    // 督办回复相关状态
    const [superviseReplyVisible, setSuperviseReplyVisible] = useState(false);
    const [currentSupervise, setCurrentSupervise] = useState(null);
    const [replyContent, setReplyContent] = useState('');
    const [attachments, setAttachments] = useState([]);
    const [superviseLoading, setSuperviseLoading] = useState(false);
 
    // 风险标签相关状态
    const [labelVisible, setLabelVisible] = useState(false);
    const [labelInfo, setLabelInfo] = useState({
        personLabel: '',
        caseLabel: '',
    });
    const [currentCaseId, setCurrentCaseId] = useState(null);
 
    // 筛选弹窗相关状态
    const [filterVisible, setFilterVisible] = useState(false);
    const [filterRole, setFilterRole] = useState(1); // 1:我承办的 2:我配合的
    const [filterScope, setFilterScope] = useState(1); // 1:本部门办理 2:本人办理 3:未指派经办人
 
    // 初始化加载数据
    // useEffect(() => {
    //     fetchCountData();
    //     fetchListData(1, activeTab, queryParams);
    // }, []);
 
    useEffect(() => {
        if ($$.getSessionStorage('visitWorkBench')) {
            const { tabId, params } = $$.getSessionStorage('visitWorkBench');
            fetchCountData();
            fetchListData(1, tabId, params);
            $$.clearSessionStorage('visitWorkBench');
        } else {
            fetchCountData();
            fetchListData(1, activeTab, queryParams);
        }
    }, []);
 
    // 获取任务数量数据
    const fetchCountData = async () => {
        try {
            const res = await getCountListApi();
            if (res.type) {
                setCountData(res.data || {});
            }
        } catch (error) {
            console.error('获取任务数量失败', error);
        }
    };
 
    // 获取列表数据
    const fetchListData = async (currentPage, tabId, listParams) => {
        // 根据当前选中的tab,获取对应的api函数
        const currentTab = tabItems.find((tab) => tab.id === tabId);
        if (!currentTab || !currentTab.apiFunc) return;
 
        setLoading(true);
 
        try {
            const params = { ...listParams, page: currentPage };
 
            // 当tab为supervise时,设置status=0
            if (tabId === 'supervise' || tabId === 'review') {
                params.status = 0;
            } else {
                params.status = 1;
            }
 
            const res = await currentTab.apiFunc(params);
 
            if (res.type) {
                const { content, totalElements, totalPages, last } = res.data;
 
                // 确保返回的数据不为空
                const dataList = content || [];
 
                if (currentPage === 1) {
                    // 第一页数据,直接设置
                    setListData(dataList);
                } else {
                    // 加载更多数据
                    setListData((prev) => [...prev, ...dataList]);
                }
                setActiveTab(tabId);
                setTotalCount(totalElements);
                setTotalPages(totalPages);
                setHasMore(!last);
                setPage(currentPage);
                setQueryParams(listParams);
            }
        } catch (error) {
            console.error('获取列表数据失败', error);
            Toast.show({
                content: '获取数据失败,请稍后重试',
                position: 'bottom',
            });
        } finally {
            setLoading(false);
            setRefreshing(false);
        }
    };
 
    // 下拉刷新
    const handleRefresh = () => {
        setRefreshing(true);
        fetchCountData();
        fetchListData(1, activeTab, queryParams);
        setTimeout(() => {
            setRefreshing(false);
        }, 1000);
    };
 
    // 加载更多
    const loadMoreData = (callback) => {
        if (loading || !hasMore) {
            if (callback) callback();
            return;
        }
 
        setLoading(true);
        fetchListData(page + 1, activeTab, queryParams)
            .then(() => {
                if (callback) callback();
            })
            .catch(() => {
                if (callback) callback();
            });
    };
 
    // 跳转到详情页
    const handleGoToDetail = async (item) => {
        if (!item) return;
 
        // 督办标签处理
        if (activeTab === 'supervise') {
            try {
                setSuperviseLoading(true);
                const res = await getSuperviseDetailApi(item.ownerId);
                if (res.type) {
                    setCurrentSupervise(res.data);
                    setSuperviseReplyVisible(true);
                } else {
                    Toast.show({
                        content: '获取督办详情失败',
                        position: 'bottom',
                    });
                }
            } catch (error) {
                console.error('获取督办详情失败', error);
                Toast.show({
                    content: '获取督办详情失败,请稍后重试',
                    position: 'bottom',
                });
            } finally {
                setSuperviseLoading(false);
            }
            return;
        }
 
        // 全部标签处理
        if (activeTab === 'all') {
            if (item.taskTypeName === '督办') {
                try {
                    setSuperviseLoading(true);
                    const res = await getSuperviseDetailApi(item.ownerId);
                    if (res.type) {
                        setCurrentSupervise(res.data);
                        setSuperviseReplyVisible(true);
                    } else {
                        Toast.show({
                            content: '获取督办详情失败',
                            position: 'bottom',
                        });
                    }
                } catch (error) {
                    console.error('获取督办详情失败', error);
                    Toast.show({
                        content: '获取督办详情失败,请稍后重试',
                        position: 'bottom',
                    });
                } finally {
                    setSuperviseLoading(false);
                }
                return;
            }
 
            // 其他类型的跳转
            let path = `/gzdyh/flow?caseTaskId=${item.ownerId}&caseId=${item.caseId}&editShow=true`;
            if (item.taskType) {
                path += `&moutedTab=${item.taskType}`;
            }
            history.push(path);
            return;
        }
 
        // 其他标签的处理
        let path = '';
        switch (activeTab) {
            case 'merge':
                path = `/gzdyh/flow?caseTaskId=${item.ownerId}&caseId=${item.caseId}&editShow=true&moutedTab=hbcl`;
                break;
            case 'dispatch':
                path = `/gzdyh/flow?caseTaskId=${item.ownerId}&caseId=${item.caseId}&editShow=true&moutedTab=dslxq`;
                break;
            case 'accept':
                path = `/gzdyh/flow?caseTaskId=${item.ownerId}&caseId=${item.caseId}&editShow=true&slTitle=true`;
                break;
            case 'processing':
                path = `/gzdyh/flow?caseTaskId=${item.ownerId}&caseId=${item.caseId}&editShow=true&moutedTab=sxbl`;
                break;
            case 'review':
                let reviewTab = '';
                switch (activeReviewButton) {
                    case 1:
                        reviewTab = 'htsh';
                        break;
                    case 2:
                        reviewTab = 'sbsh';
                        break;
                    case 3:
                        reviewTab = 'jash';
                        break;
                    case 4:
                        reviewTab = 'lhczsh';
                        break;
                    default:
                        reviewTab = 'htsh';
                }
                path = `/gzdyh/flow?caseTaskId=${item.ownerId}&caseId=${item.caseId}&editShow=true&moutedTab=${reviewTab}`;
                break;
            default:
                path = `/gzdyh/detail?caseId=${item.caseId}`;
        }
        $$.setSessionStorage('visitWorkBench', {
            tabId: activeTab,
            params: queryParams,
        });
        history.push(path);
    };
 
    // 关闭督办回复弹窗
    const handleCloseSuperviseReply = () => {
        setSuperviseReplyVisible(false);
        setCurrentSupervise(null);
        setReplyContent('');
        setAttachments([]);
    };
 
    // 处理按钮点击
    const handleButtonClick = (type) => {
        if (type === 3) {
            setFilterVisible(true);
            return;
        } else {
            setActiveButton(type);
            fetchListData(1, activeTab, { ...queryParams, caseTaskType: type });
        }
    };
 
    // 处理审核按钮点击
    const handleReviewButtonClick = (type) => {
        setActiveReviewButton(type);
        fetchListData(1, activeTab, { ...queryParams, type: type });
    };
 
    // 关闭标签气泡
    const handleCloseLabelPopguide = () => {
        setLabelVisible(false);
        setCurrentCaseId(null);
    };
 
    // 处理风险标签点击
    const handleRiskLabelClick = async (caseId) => {
        try {
            // 如果是同一个标签再次点击,直接关闭气泡
            if (currentCaseId === caseId && labelVisible) {
                setLabelVisible(false);
                setCurrentCaseId(null);
                return;
            }
 
            setCurrentCaseId(caseId);
 
            const res = await getLabelApi(caseId);
            if (res.type) {
                setLabelInfo({
                    personLabel: res.data.personLabel || '',
                    caseLabel: res.data.caseLabel || '',
                });
                // 等数据加载完毕后再显示气泡
                setTimeout(() => {
                    setLabelVisible(true);
                }, 10);
            } else {
                Toast.show({
                    content: '获取标签信息失败',
                    position: 'bottom',
                });
            }
        } catch (error) {
            console.error('获取标签信息失败', error);
            Toast.show({
                content: '获取标签信息失败,请稍后重试',
                position: 'bottom',
            });
        }
    };
 
    // 提交督办回复
    const handleSubmitSuperviseReply = async () => {
        if (!replyContent.trim()) {
            Toast.show({
                content: '请输入回复内容',
                position: 'bottom',
            });
            return;
        }
 
        if (!currentSupervise) return;
 
        const requestData = {
            replyContent: replyContent,
            id: currentSupervise.id,
        };
 
        try {
            global.setSpinning(true);
            const res = await replyCaseSuperviseApi(requestData);
            global.setSpinning(false);
 
            if (res.type) {
                Toast.show({
                    content: '回复成功',
                    position: 'bottom',
                });
                handleCloseSuperviseReply();
                fetchListData(1, activeTab, queryParams); // 刷新列表
            } else {
                Toast.show({
                    content: res.message || '回复失败',
                    position: 'bottom',
                });
            }
        } catch (error) {
            global.setSpinning(false);
            console.error('提交督办回复失败', error);
            Toast.show({
                content: '网络异常,请稍后再试',
                position: 'bottom',
            });
        }
    };
 
    // 使用回复模板
    const handleUseTemplate = () => {
        setReplyContent('双方当事人于xx时间xx地址已达成xx协议,纠纷已化解。');
    };
 
    // OCR识别材料
    const handleOcrRecognize = () => {
        Toast.show({
            content: '正在识别材料...',
            position: 'bottom',
        });
 
        // 模拟识别结果
        setTimeout(() => {
            setReplyContent(replyContent + (replyContent ? '\n\n' : '') + '通过识别,确认双方当事人已达成和解协议,纠纷已妥善处理。');
            Toast.show({
                content: '识别完成',
                position: 'bottom',
            });
        }, 1000);
    };
 
    // 渲染顶部轮播图
    const renderCarousel = () => {
        return (
            <div className="home-carousel">
                <Swiper autoplay={true} loop={true}>
                    {carouselItems.map((item) => (
                        <Swiper.Item key={item.id}>
                            <div className="home-carousel-item">
                                <img src={item.src} alt={item.alt} />
                            </div>
                        </Swiper.Item>
                    ))}
                </Swiper>
            </div>
        );
    };
 
    // 渲染功能按钮
    const renderFunctionButtons = () => {
        return (
            <div className="home-function-buttons">
                {functionItems.map((item) => (
                    <div key={item.id} className="home-function-button-wrapper">
                        <div className="home-function-button" onClick={() => history.push(item.path)}>
                            <div className="home-function-button-icon">
                                <img src={item.icon} alt={item.text} />
                            </div>
                        </div>
                        <div className="home-function-button-text">{item.text}</div>
                    </div>
                ))}
            </div>
        );
    };
 
    // 渲染Tab栏
    const renderTabs = () => {
        return (
            <div className="home-tabs">
                {tabItems.map((tab) => {
                    const count = tab.countKey ? countData[tab.countKey] || 0 : 0;
                    const isActive = activeTab === tab.id;
 
                    return (
                        <div
                            key={tab.id}
                            className={`home-tab ${isActive ? 'home-tab-active' : ''}`}
                            onClick={() => {
                                fetchListData(1, tab.id, queryParams);
                            }}
                        >
                            <div className="home-tab-text">{tab.text}</div>
                            {isActive && count > 0 && <div className="home-tab-count">({count})</div>}
                        </div>
                    );
                })}
            </div>
        );
    };
 
    // 渲染列表项
    const renderListItem = (item, index) => {
        // 转换事项等级
        const getGradeText = (grade) => {
            switch (grade) {
                case 1:
                    return '一级';
                case 2:
                    return '二级';
                case 3:
                    return '三级';
                case 4:
                    return '四级';
                case 5:
                    return '五级';
                default:
                    return grade;
            }
        };
 
        // 格式化时间
        const formatTime = (time) => {
            if (!time) return '';
            const date = new Date(time);
            const year = date.getFullYear();
            const month = String(date.getMonth() + 1).padStart(2, '0');
            const day = String(date.getDate()).padStart(2, '0');
            const hours = String(date.getHours()).padStart(2, '0');
            const minutes = String(date.getMinutes()).padStart(2, '0');
            return `${year}-${month}-${day} ${hours}:${minutes}`;
        };
 
        // 判断时间状态
        const getTimeStatus = () => {
            if (!item.timeLimit) return null;
 
            const now = new Date().getTime();
            const limitTime = new Date(item.timeLimit).getTime();
 
            if (now > limitTime) {
                return 'timeout'; // 已超时
            } else if (limitTime - now < 3600000) {
                // 小于一小时(3600000毫秒)
                return 'soon'; // 即将超时
            }
            return null;
        };
 
        // 获取标签列表
        const getTagList = () => {
            const tags = [];
 
            // 时间状态标签 - 即将超时
            if (getTimeStatus() === 'soon') {
                tags.push({
                    text: '即将超时',
                    type: 'soon',
                });
            }
 
            // 时间状态标签 - 已超时
            if (getTimeStatus() === 'timeout') {
                tags.push({
                    text: '已超时',
                    type: 'timeout',
                });
            }
 
            // 督办标签
            if (item.superviseCount > 0) {
                tags.push({
                    text: '督办',
                    type: 'supervise',
                });
            }
 
            return tags;
        };
 
        return (
            <div className="home-list-item">
                <div className="home-list-item-parties">
                    <div className="home-list-item-plaintiffs">{item.plaintiffs}</div>
                    {item.defendants && (
                        <>
                            <div className="home-list-item-parties-separator">、</div>
                            <div className="home-list-item-defendants">{item.defendants}</div>
                        </>
                    )}
                </div>
                <div className="home-list-item-time">{formatTime(item.turnaroundTime)}</div>
                <div className="home-list-item-tags">
                    {activeTab === 'all' && item.taskTypeName && <div className="home-list-item-tag-type">{item.taskTypeName}</div>}
                    <div className="home-list-item-tag">{item.caseType}</div>
                    {activeTab === 'all' && item.isRisk === '1' && (
                        <Popguide
                            visible={labelVisible && currentCaseId === item.caseId}
                            onClose={handleCloseLabelPopguide}
                            title={
                                <div className="risk-label-content">
                                    <div className="risk-label-item">
                                        <span className="risk-label-title">人员标签:</span>
                                        <span className="risk-label-value">({labelInfo.personLabel})</span>
                                    </div>
                                    <div className="risk-label-item">
                                        <span className="risk-label-title">事项标签:</span>
                                        <span className="risk-label-value">({labelInfo.caseLabel})</span>
                                    </div>
                                </div>
                            }
                            placement="top"
                            getPopupContainer={() => document.querySelector('.home-container')}
                        >
                            <div className="home-list-item-tag-timeout" id={`risk-tag-${item.caseId}`} onClick={() => handleRiskLabelClick(item.caseId)}>
                                风险
                            </div>
                        </Popguide>
                    )}
                </div>
                <div className="home-list-item-info">
                    <div className="home-list-item-address">
                        {item.caseSource} | {getGradeText(item.caseGrade)}
                    </div>
                    <div className="home-list-item-action">
                        <div className="home-list-item-action-btn" onClick={() => handleGoToDetail(item)}>
                            处理
                        </div>
                    </div>
                </div>
            </div>
        );
    };
 
    // 渲染列表内容
    const renderListContent = () => {
        return (
            <div className="home-list">
                {activeTab === 'processing' && (
                    <div className="home-list-processing">
                        <div className="home-list-buttons">
                            <div className={`home-list-button ${activeButton === 1 ? 'active' : ''}`} onClick={() => handleButtonClick(1)}>
                                办理中
                            </div>
                            <div className={`home-list-button ${activeButton === 2 ? 'active' : ''}`} onClick={() => handleButtonClick(2)}>
                                结案申请
                            </div>
                        </div>
                        {/* 筛选条件 */}
                        <div className="home-list-processing-filter" onClick={() => handleButtonClick(3)}>
                            <div className="home-list-processing-filter-item">
                                <div className="home-list-processing-filter-item-img">
                                    <img src={home_11} alt="办理中" />
                                </div>
                                <div className="home-list-processing-filter-item-value">
                                    {searchParams.caseTaskTypeName}+{searchParams.mediatorTypeName}
                                </div>
                            </div>
                        </div>
                    </div>
                )}
 
                {activeTab === 'review' && (
                    <div className="home-list-buttons">
                        <div className={`home-list-button ${activeReviewButton === 1 ? 'active' : ''}`} onClick={() => handleReviewButtonClick(1)}>
                            回退审核
                        </div>
                        <div className={`home-list-button ${activeReviewButton === 2 ? 'active' : ''}`} onClick={() => handleReviewButtonClick(2)}>
                            上报审核
                        </div>
                        <div className={`home-list-button ${activeReviewButton === 3 ? 'active' : ''}`} onClick={() => handleReviewButtonClick(3)}>
                            结案审核
                        </div>
                        <div className={`home-list-button ${activeReviewButton === 4 ? 'active' : ''}`} onClick={() => handleReviewButtonClick(4)}>
                            联合处置审核
                        </div>
                    </div>
                )}
 
                {loading && listData.length === 0 ? (
                    <div className="home-loading">
                        <div className="home-loading-text">加载中...</div>
                    </div>
                ) : !loading && listData.length === 0 ? (
                    <div className="home-empty">
                        <img src={caseQuery_2} alt="暂无数据" className="home-empty-image" />
                        <div className="home-empty-text">暂无数据</div>
                    </div>
                ) : (
                    <Scrollbars style={{ height: `calc(100vh - ${activeTab === 'review' || activeTab === 'processing' ? 435 : 386}px)` }}>
                        <MyList
                            data={listData}
                            dataTotal={totalCount}
                            hasMore={hasMore}
                            loadMore={loadMoreData}
                            getScrollTopKey={`home-${activeTab}`}
                            itemDom={renderListItem}
                            threshold={100}
                            showBottomText={true}
                        />
                    </Scrollbars>
                )}
            </div>
        );
    };
 
    // 渲染底部导航
    const renderBottomNav = () => {
        return (
            <div className="home-bottom-nav">
                {bottomNavItems.map((item) => (
                    <div
                        key={item.id}
                        className={`home-bottom-nav-item ${item.id === 'home' ? 'home-bottom-nav-item-active' : ''}`}
                        onClick={() => history.push(item.path)}
                    >
                        <div className="home-bottom-nav-item-icon">
                            <img src={item.icon} alt={item.text} />
                        </div>
                        <div className="home-bottom-nav-item-text">{item.text}</div>
                    </div>
                ))}
            </div>
        );
    };
 
    // 渲染督办回复弹窗
    const renderSuperviseReplyModal = () => {
        if (!currentSupervise) return null;
 
        return (
            <Drawer visible={superviseReplyVisible} onClose={handleCloseSuperviseReply} position="bottom">
                <div className="dbcb-reply-home-wrapper">
                    <div className="dbcb-reply-home-header">
                        <div className="audit-drawer-title">督办回复</div>
                        <div className="audit-drawer-close" onClick={handleCloseSuperviseReply}>
                            <i className="audit-drawer-close-icon"></i>
                        </div>
                    </div>
                    <Scrollbars style={{ height: '55vh' }}>
                        <div className="dbcb-reply-home-content">
                            {/* 督办详情信息 */}
                            <div className="dbcb-reply-home-detail">
                                <div className="dbcb-reply-home-section">
                                    <div className="dbcb-reply-home-label">督办时间</div>
                                    <div className="dbcb-reply-home-value">{currentSupervise.supTime}</div>
                                </div>
 
                                <div className="dbcb-reply-home-section">
                                    <div className="dbcb-reply-home-label">督办人</div>
                                    <div className="dbcb-reply-home-value">{`${currentSupervise.supUserName} (${currentSupervise.supUnitName})`}</div>
                                </div>
 
                                <div className="dbcb-reply-home-section">
                                    <div className="dbcb-reply-home-label">督办内容</div>
                                    <div className="dbcb-reply-home-value">{currentSupervise.supContent}</div>
                                </div>
 
                                {currentSupervise.fileInfoList && currentSupervise.fileInfoList.length > 0 && (
                                    <div className="dbcb-reply-home-section">
                                        <div className="dbcb-reply-home-label">督办附件</div>
                                        <DingUpload
                                            fileList={(currentSupervise.fileInfoList || []).map((file) => ({
                                                id: file.id || Date.now().toString(),
                                                name: file.name || '附件',
                                                size: file.size || '12.3K',
                                                showUrl: file.url || '',
                                            }))}
                                            viewOnly={true}
                                            title=""
                                        />
                                    </div>
                                )}
                            </div>
                            {/* 分割线 */}
                            <div className="dbcb-reply-home-divider"></div>
 
                            {/* 回复内容区域 */}
                            <div className="dbcb-reply-home-section">
                                <div className="dbcb-reply-home-label">
                                    <span className="dbcb-reply-home-label-text">回复内容</span>
                                    <div className="dbcb-reply-home-btn-group">
                                        {/* <div className="dbcb-reply-home-ocr-btn" onClick={handleOcrRecognize}>
                                            <svg viewBox="0 0 1024 1024" width="20" height="20">
                                                <path
                                                    d="M832 128H192c-35.2 0-64 28.8-64 64v640c0 35.2 28.8 64 64 64h640c35.2 0 64-28.8 64-64V192c0-35.2-28.8-64-64-64z m0 704H192V192h640v640z"
                                                    fill="#1A6FB8"
                                                ></path>
                                                <path
                                                    d="M696.9 298.1H584.1c-12.3 0-22.3 10-22.3 22.3s10 22.3 22.3 22.3h69l-155.8 155.8c-8.7 8.7-8.7 22.8 0 31.5 4.4 4.4 10.1 6.5 15.7 6.5s11.4-2.2 15.7-6.5l155.8-155.8v69c0 12.3 10 22.3 22.3 22.3s22.3-10 22.3-22.3V320.4c0.1-12.3-9.9-22.3-22.2-22.3z"
                                                    fill="#1A6FB8"
                                                ></path>
                                                <path
                                                    d="M428.5 685.5c4.4 4.4 10.1 6.5 15.7 6.5s11.4-2.2 15.7-6.5c8.7-8.7 8.7-22.8 0-31.5L303.2 497.3v-69c0-12.3-10-22.3-22.3-22.3s-22.3 10-22.3 22.3v112.8c0 12.3 10 22.3 22.3 22.3h112.8c12.3 0 22.3-10 22.3-22.3s-10-22.3-22.3-22.3h-69L428.5 654c8.6 8.7 8.6 22.8 0 31.5z"
                                                    fill="#1A6FB8"
                                                ></path>
                                            </svg>
                                            识别材料
                                        </div> */}
                                        <div className="dbcb-reply-home-template-btn" onClick={handleUseTemplate}>
                                            <svg viewBox="0 0 1024 1024" width="20" height="20">
                                                <path
                                                    d="M832 64H192C121.6 64 64 121.6 64 192v640c0 70.4 57.6 128 128 128h640c70.4 0 128-57.6 128-128V192c0-70.4-57.6-128-128-128zM192 128h640c35.2 0 64 28.8 64 64v256h-768V192c0-35.2 28.8-64 64-64z m640 768H192c-35.2 0-64-28.8-64-64V512h768v320c0 35.2-28.8 64-64 64z"
                                                    fill="#1A6FB8"
                                                ></path>
                                                <path d="M672 320H544V192h128v128zM672 832H544V704h128v128z" fill="#1A6FB8"></path>
                                            </svg>
                                            选择模板
                                        </div>
                                    </div>
                                </div>
                                <TextareaItem placeholder={`请填写`} value={replyContent} onChange={(value) => setReplyContent(value)} rows={4} />
                            </div>
 
                            {/* 附件区域 */}
                            <div className="dbcb-reply-home-section">
                                <DingUpload
                                    fileList={attachments}
                                    onChange={(info) => {
                                        if (info.fileList) {
                                            setAttachments(info.fileList);
                                        }
                                    }}
                                    ownerId={currentSupervise.id}
                                    ownerType="22_00018-507"
                                    disabled={false}
                                    viewOnly={false}
                                    accept="image/*, .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .txt"
                                    tipText="支持扩展名:.doc .docx .pdf .jpg 等,30M以内"
                                    btnText="添加附件"
                                    subtitle="请上传与内容相关的附件材料"
                                    title="附件材料"
                                />
                            </div>
                        </div>
                    </Scrollbars>
                    {/* 底部按钮 */}
                    <div className="dbcb-reply-home-footer">
                        <Button type="primary" className="dbcb-reply-home-submit-btn" onClick={handleSubmitSuperviseReply}>
                            提交
                        </Button>
                    </div>
                </div>
            </Drawer>
        );
    };
 
    return (
        <NavBarPage title="首页">
            <div className="home-container">
                {/* 顶部轮播图 */}
                {renderCarousel()}
 
                {/* 功能按钮 */}
                {renderFunctionButtons()}
 
                {/* Tab栏 */}
                {renderTabs()}
 
                {/* 搜索框 */}
                <div className="home-search-box">
                    <div className="home-search-box-input">
                        <InputItem placeholder="申请人/被申请人/事项编号" value={searchParams.partyName} onChange={(value) => setSearchParams({ ...searchParams, partyName: value })} className="custom-search-input" />
                        <button onClick={() => fetchListData(1, activeTab, { ...queryParams, partyName: searchParams.partyName })} className="custom-search-btn">查询</button>
                    </div>
                </div>
 
                {/* 内容区域 */}
                <div className="home-content">{renderListContent()}</div>
 
                {/* 底部导航 */}
                {renderBottomNav()}
 
                {/* 督办回复弹窗 */}
                {renderSuperviseReplyModal()}
            </div>
            {filterVisible && (
                <div className="filter-modal-mask" onClick={() => setFilterVisible(false)}>
                    <div className="filter-modal" onClick={(e) => e.stopPropagation()}>
                        <div className="filter-modal-header">
                            <span>筛选</span>
                            <span className="filter-modal-close" onClick={() => setFilterVisible(false)}>
                                ×
                            </span>
                        </div>
                        <div className="filter-modal-section">
                            <div className="filter-modal-label">办理角色</div>
                            <div className="filter-modal-options">
                                <div
                                    className={`filter-modal-option${searchParams.caseTaskType === '1' ? ' selected' : ''}`}
                                    onClick={() => setSearchParams({ ...searchParams, caseTaskTypeName: '我承办的', caseTaskType: '1' })}
                                >
                                    我承办的
                                </div>
                            <div
                                    className={`filter-modal-option${searchParams.caseTaskType === '2' ? ' selected' : ''}`}
                                    onClick={() => setSearchParams({ ...searchParams, caseTaskTypeName: '我配合的', caseTaskType: '2' })}
                                >
                                    我配合的
                                </div>
                            </div>
                        </div>
                        <div className="filter-modal-section">
                            <div className="filter-modal-label">查询范围</div>
                            <div className="filter-modal-options">
                                <div
                                    className={`filter-modal-option${searchParams.mediatorType === '0' ? ' selected' : ''}`}
                                    onClick={() => setSearchParams({ ...searchParams, mediatorTypeName: '本部门办理', mediatorType: '0' })}
                                >
                                    本部门办理
                                </div>
                                <div
                                    className={`filter-modal-option${searchParams.mediatorType === '1' ? ' selected' : ''}`}
                                    onClick={() => setSearchParams({ ...searchParams, mediatorTypeName: '本人办理', mediatorType: '1' })}
                                >
                                    本人办理
                                </div>
                                <div
                                    className={`filter-modal-option${searchParams.mediatorType === '2' ? ' selected' : ''}`}
                                    onClick={() => setSearchParams({ ...searchParams, mediatorTypeName: '未指派经办人', mediatorType: '2' })}
                                >
                                    未指派经办人
                                </div>
                            </div>
                        </div>
                        <button
                            className="filter-modal-confirm"
                            onClick={() => {
                                setFilterVisible(false);
                                fetchListData(1, activeTab, {
                                    ...queryParams,
                                    caseTaskType: searchParams.caseTaskType,
                                    mediatorType: searchParams.mediatorType,
                                });
                            }}
                        >
                            确定
                        </button>
                    </div>
                </div>
            )}
        </NavBarPage>
    );
};
 
export default Home;