广州市综治平台前端
liuwh
4 days ago ebc701d2374ddef3fb985be85c49c5cdcd5425a7
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
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-03-23 14:34:29
 * @LastEditTime: 2023-05-12 17:12:17
 * @LastEditors: lwh
 * @Version: 1.0.0
 * @Description: 其他功能
 */
import React, { useState, useEffect } from 'react';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { Row, Col, Input, Button, Tooltip, Space } from 'antd';
import {
  UsergroupAddOutlined,
} from '@ant-design/icons';
import { ax, infoSuccess, modalInfo, sleep } from '../../../utils/utility';
import MyUpload from '../../../components/MyUpload';
import SelectObjModal from '../../../components/SelectObjModal';
import WantUserTag from '../../../components/WantUserTag';
 
const { TextArea } = Input;
 
// 退回上一处理人接口
function returnTaskApi(submitData) {
  return ax.request({ url: 'caseTask/backTask', type: 'post', data: submitData, service: 'mediate' });
}
 
// 回显
function listByCaseIdApi(submitData) {
  return ax.request({ url: 'caseAssist/listByCaseId', type: 'get', data: submitData, service: 'mediate' });
}
 
// 新增
function setUpAssistApi(caseId, submitData) {
  return ax.request({ url: 'caseAssist/setUpAssist?caseId=' + caseId, type: 'post', data: submitData, service: 'mediate' });
}
 
// 删除
function removeAssistApi(submitData) {
  return ax.request({ url: 'caseAssist/removeAssist', type: 'post', data: submitData, service: 'mediate' });
}
 
 
 
const MediateSetting = ({ tabActive, caseId, taskId, disputeData }) => {
  const [searchParams] = useSearchParams();
 
  const navigate = useNavigate();
 
  const back = searchParams.get('back');
 
  const [handleContent, setHandleContent] = useState();
 
  const [otherMediatorList, setOtherMediatorList] = useState([]);
 
  // 选择协助调解员modal显隐
  const [selectHelpObjModal, setSelectHelpObjModal] = useState({ visible: false, type: 'person', isCheckbox: true });
 
 
  async function handleChangeInput(key, value) {
    console.log(key, value);
    // 选择后被保存
    global.setSpinning(true);
    const res = await setUpAssistApi(caseId, value.map(item => item.value));
    global.setSpinning(false);
    if (res.type) {
      infoSuccess({ content: '保存成功' });
      setSelectHelpObjModal({ visible: false });
      setOtherMediatorList(value)
    }
  }
 
  // 退回上一环节
  function handleReturn() {
    modalInfo({
      title: '调解任务退回确认',
      content: '确定将调解任务退回给上一级处理人吗?',
      okText: '确定退回',
      onOk: async () => {
        global.setSpinning(true);
        const res = await returnTaskApi({ id: taskId, handleContent });
        global.setSpinning(false);
        if (res.type) {
          infoSuccess({ content: '退回成功,即将为您跳转「我的调解」页面' });
          await sleep();
          navigate(`${back}?isBack=true`);
        }
      },
    });
  }
 
  useEffect(() => {
    listByCaseIdData()
  }, []);
 
 
  async function listByCaseIdData() {
    global.setSpinning(true);
    const res = await listByCaseIdApi({ caseId });
    global.setSpinning(false);
    if (res.type) {
      let list = res.data || [];
      setOtherMediatorList(list.map(item => ({ checkable: true, value: item.assUserId, name: item.assUserName })));
      // infoSuccess({ content: '退回成功,即将为您跳转「我的调解」页面' });
      // await sleep();
      // navigate(`${back}?isBack=true`);
    }
  }
 
  const oneDom = (
    <>
      <div className="mediationWindow-modal-main">
        <Row gutter={[16, 16]}>
          <Col span={24}>
            <h5>退回理由</h5>
            <TextArea
              rows={2}
              value={handleContent}
              onChange={(e) => setHandleContent(e.target.value)}
              placeholder="输入退回调解任务给上一级处理人的理由"
            />
          </Col>
          <Col span={24}>
            <h5>上传附件</h5>
            <MyUpload fileId={taskId} fileType="22_00018-501" />
          </Col>
        </Row>
      </div>
      <div className="mediationWindow-modal-footer">
        <Tooltip title={disputeData.process === '22_00006-3' ? '司法确认中不可退回' : null}>
          <Button disabled={disputeData.process === '22_00006-3'} onClick={handleReturn} danger>
            退回上一环节
          </Button>
        </Tooltip>
      </div>
    </>
  );
 
  console.log('otherMediatorList', otherMediatorList);
 
  const twoDom = (
    <>
      <div className="mediationWindow-modal-main">
        <Row gutter={[16, 16]}>
          <Col span={24}>
            <h5>协助调解参与人</h5>
            <div className="caseHandle-subtitle">设置完成后,协助调解员可在<span className="public-color">我的调解/我参与的</span>列表中查看和跟进调解案件</div>
            <Space size="small" wrap>
              {otherMediatorList?.map((item, index) => {
                return <WantUserTag color='orange' key={`assistIdList${index}`} value={item.value} name={item.name} onClose={(e) => handleChangeInput('assistIdList', otherMediatorList.filter(item => item.value !== e))} />
              })}
              <Button type="dashed" icon={<UsergroupAddOutlined />} onClick={() => setSelectHelpObjModal({ visible: true })}>
                选择协助调解员
              </Button>
            </Space>
          </Col>
          {/* <Col span={24}>
            <h5>协助调解员名单</h5>
            <Space size="small" wrap>
              {otherMediatorList?.map((item, index) => {
                return <WantUserTag color='orange' key={`assistIdList${index}`} value={item.value} name={item.name} onClose={(e) => handleChangeInput('assistIdList', otherMediatorList.filter(item => item.value !== e))} />
              })}
            </Space>
          </Col> */}
        </Row>
      </div>
      {/* <div className="mediationWindow-modal-footer">
        <Tooltip title={disputeData.process === '22_00006-3' ? '司法确认中不可退回' : null}>
          <Button type="primary" onClick={handleReturn}>
            保存修改
          </Button>
        </Tooltip>
      </div> */}
    </>
  );
 
  return (
    <>
      {
        tabActive === '1' ? oneDom : twoDom
      }
      <SelectObjModal
        visible={selectHelpObjModal.visible}
        type={selectHelpObjModal.type}
        isCheckbox={true}
        checkKeys={otherMediatorList ? otherMediatorList.map(item => ({ value: item.value, label: item.name })) : []}
        onClose={() => setSelectHelpObjModal({ visible: false })}
        onOk={(value) => {
 
          handleChangeInput('assistIdList', value.items);
        }}
      />
    </>
  );
};
 
export default MediateSetting;