广州矛调粤政易端
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
/*
 * @Company: hugeInfo
 * @Author: lwh
 * @Date: 2025-04-10 10:15:06
 * @LastEditTime: 2025-05-13 10:42:23
 * @LastEditors: lwh
 * @Version: 1.0.0
 * @Description: 添加办理记录
 */
import React, { useEffect, useState } from 'react';
import { TextareaItem, Button } from 'dingtalk-design-mobile';
import { useHistory } from 'react-router-dom';
import * as $$ from '../../../utils/utility';
import NavBarPage from '../../../components/NavBarPage';
import DingUpload from '../../../components/DingUpload';
 
import './index.less';
 
// 获取id
function getNewTimeIdApi(id) {
    return $$.ax.request({ url: `caseUtils/getNewTimeId`, type: 'get', service: 'utils' });
}
 
function updateFeedbackApi(data) {
    return $$.ax.request({ url: `caseFeedback/updateFeedback`, type: 'post', service: 'mediate', data });
}
 
function saveFeedbackApi(data) {
    return $$.ax.request({ url: `caseFeedback/saveFeedback`, type: 'post', service: 'mediate', data });
}
 
const AddRecord = () => {
    const history = useHistory();
    const mainId = $$.getQueryString('mainId');
    const caseId = $$.getQueryString('caseId');
    const caseTaskId = $$.getQueryString('caseTaskId');
    const [handleContent, setHandleContent] = useState('');
    const [fileList, setFileList] = useState([]);
    const [newId, setNewId] = useState('');
 
    // 处理提交
    const handleSubmit = async () => {
        if (!handleContent) {
            $$.showToast({ content: '办理意见不能为空' });
            return;
        }
        if (handleContent.length > 500) {
            $$.showToast({ content: '办理意见不能超过500个字符' });
            return;
        }
 
        // 新增
        if (!mainId) {
            global.setSpinning(true);
            const res = await saveFeedbackApi({
                handleContent,
                caseId,
                caseTaskId,
                id: newId,
            });
            global.setSpinning(false);
            if (res.type) {
                $$.showToast({ type: 'success', content: '提交成功' });
                $$.setLocal('bljl', true);
                history.goBack();
            }
        } else {
            global.setSpinning(true);
            const res = await updateFeedbackApi({
                handleContent,
                caseId,
                caseTaskId,
                id: mainId,
            });
            global.setSpinning(false);
            if (res.type) {
                $$.showToast({ type: 'success', content: '提交成功' });
                $$.setLocal('bljl', true);
                history.goBack();
            }
        }
    };
 
    // 查看说明材料
    const handleViewInstructions = () => {
        console.log('查看说明材料');
    };
 
    //获取id
    const getNewTimeId = async (type) => {
        const res = await getNewTimeIdApi();
        if (res.type) {
            setNewId(res.data);
        }
    };
 
    useEffect(() => {
        if (!mainId) {
            getNewTimeId();
        } else {
            // 记录在缓存中
            // sxbl_currentRecord,要做到回显内容
            const currentRecord = $$.getSessionStorage('sxbl_currentRecord');
            if (currentRecord) {
                setHandleContent(currentRecord.handleContent || '');
                setNewId(mainId);
            }
            // 文件列表
            if (currentRecord.fileInfoList && currentRecord.fileInfoList.length > 0) {
                setFileList(currentRecord.fileInfoList);
            }
        }
    }, []);
 
    return (
        <NavBarPage
            title="添加办理记录"
            rightContent={
                <span className="public-color" onClick={handleViewInstructions}>
                    说明材料
                </span>
            }
        >
            <div className="add-record">
                <div className="add-record-content">
                    <div className="add-record-input">
                        <div className="add-record-label">
                            <span className="required-mark">*</span>
                            办理意见
                        </div>
                        <TextareaItem
                            value={handleContent}
                            onChange={(value) => setHandleContent(value)}
                            showCount
                            maxLength={500}
                            placeholder="办理意见应该填写完整,办理意见应具备5要素:调解时间+调解参与部门/人+调解地点+调解过程+调解结果"
                            autoHeight
                            rows={16}
                        />
                    </div>
                    <div className="add-record-file">
                        <DingUpload
                            title="办理附件"
                            subtitle="可添加办理相关附件"
                            fileList={fileList}
                            mainId={caseId}
                            ownerId={newId}
                            ownerType="22_00018-501"
                            multiple={true}
                            maxCount={9}
                        />
                    </div>
                </div>
 
                <div className="add-record-footer">
                    <Button type="primary" onClick={handleSubmit}>
                        提交
                    </Button>
                </div>
            </div>
        </NavBarPage>
    );
};
 
export default AddRecord;