广州市综治平台前端
xusd
2 days ago e8071c7d6f7aa6ac0d5522c59a52ee5e187a4b16
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
import React, { useEffect, useState } from 'react';
import { Row, Col, Steps, Divider, Space, Spin } from 'antd';
import { Alert, Button, Select } from '@arco-design/web-react';
import { IconInfoCircle } from '@arco-design/web-react/icon';
import MyUpload from '../../components/MyUpload';
import NewPage from '../../components/NewPage';
import { useSearchParams, useNavigate } from 'react-router-dom';
import { ledger_1, ledger_2, ledger_3, ledger_4, ledger_5, ledger_6, ledger_7, ledger_10, ledger_11 } from '../../assets/images';
import { ax, info, infoSuccess, modalInfo, sleep, verifyEmpty } from '../../utils/utility';
import MyModal from '../../components/MyModal';
import * as $$ from '../../utils/utility';
 
const { Step } = Steps;
// 调解调度
function inCaseByExcelApi(submitData) {
  return ax.request({ url: 'caseBook/inputCaseByExcel', type: 'get', data: submitData, service: 'mediate' });
}
 
// 获取附件列表
function getAttachmentListApi(submitData) {
  return $$.ax.request({ url: 'fileInfo/listNewSysFile', type: 'get', data: submitData, service: 'sys' });
}
 
 
const CaseImportAdd = () => {
  let appUrl = $$.appUrl;
 
  let navigate = useNavigate();
 
  const [searchParams] = useSearchParams();
  // 模板
  const [mould, setMould] = useState(false)
 
  const attachmentId = searchParams.get('attachmentId');
 
  const [filesList, setFilesList] = useState([]);
 
  const [result, setResult] = useState({});
 
  const [stepsNum, setStepsNum] = useState(0);
 
  // 文件导入状态
  const [status, setStatus] = useState('');
 
  // 导入成功数据
  const [successData, setSuccessData] = useState({});
  const [downUrlId, setDownUrlId] = useState('');
 
 
 
  function onSubmit() {
    if (filesList?.length === 0) {
      return info({ type: 'warning', content: '至少上传一个文件' });
    }
    if (filesList?.length > 1) {
      return info({ type: 'warning', content: '每次只允许导入一个文件' });
    }
    if (filesList[0]?.name?.indexOf('xlsx') < 0 || filesList[0]?.name?.indexOf('xls') < 0) {
      return info({ type: 'warning', content: '上传文件格式不正确' });
    }
    console.log('filesList', filesList);
    let fileId = result.id;
    $$.arcoModalInfo({
      icon: <IconInfoCircle style={{ color: '#1A6FB8' }} />,
      title: '提醒',
      content: <span>确定进行导入操作吗?</span>,
      okText: '确定',
      cancelText: '我再想想',
      onOk: () => {
        inCaseByExcel({ fileId });
      },
    });
  }
 
  async function inCaseByExcel(inCaseData) {
    setStatus('loading');
    const res = await inCaseByExcelApi(inCaseData);
    console.log('res.type', res);
    if (res.type) {
      // 成功
      setSuccessData(res.data || {});
      setStatus('success');
    } else if (res.code === 105) {
      setStatus('');
      $$.modalInfo({
        title: '案件导入确认',
        content: <span>检测到您近期上传了相似的案件导入文件,{<span className='ledger-main-title'>请避免重复上传相同文件</span>},请核实本次导入文件名称</span>,
        okText: '继续导入',
        cancelText: '我再想想',
        onOk: () => {
          inCaseByExcel({ fileId: result.id, adopt: true });
        },
      })
    } else if (res.code === 409) {
      setStatus('error');
    } else {
      setStatus('error');
    }
  }
 
  function handleChangeFile(type, info, apiResult) {
    console.log('handleChangeFile', type, info, apiResult);
    let list = info.fileList ? info.fileList : [];
    // .map(item => ({ ...item, name: item.trueName }))
    setFilesList(list)
    setResult(apiResult)
    console.log('list', list);
    if (list.length >= 1) {
      setStepsNum(1)
    } else {
      setStepsNum(0)
    }
  }
 
  async function getAttachmentList(params) {
    global.setSpinning(true);
    const res = await getAttachmentListApi({ ownerType: '22_00018-605', ownerId: '10001', size: '3' });
    global.setSpinning(false);
    if (res.type) {
      let list = res?.data || [];
      setDownUrlId(list?.length > 0 ? list[0].id : '')
    }
  }
 
  // 初始化
  useEffect(() => {
    getAttachmentList();
  }, []);
 
 
 
  return (
    <NewPage pageHead={{ breadcrumbData: [{ title: '工作台' }, { title: '案件导入' }], title: '案件导入' }}>
      <div className="comprehensive" >
        <div style={{ backgroundColor: '#ffffff', padding: '16px 24px', marginBottom: '16px', height: '100%', position: 'relative' }}>
          <Row>
            <Col span={24} style={{ padding: '20px', display: 'flex', justifyContent: 'center' }}>
              <div style={{ minWidth: '824px' }}>
                <Steps className="ledgerEdit-main-steps" current={stepsNum}>
                  <Step title="上传导入文件" description={<span style={{ color: stepsNum == '2' && 'rgba(0,0,0,0.45)' }}>上传包含案件信息的导入文件</span>} />
                  <Step title="解析导入文件" description={<span style={{ color: stepsNum == '1' && 'rgba(0,0,0,0.45)' }}>解析上传文件并批量导入案件信息</span>} />
                </Steps>
              </div>
            </Col>
            <Divider style={{ margin: '24px 0 12px' }} />
            <Col span={24}>
              <div style={{ margin: '12px 0' }}>
                <Alert
                  type='info'
                  content={<span>请使用系统提供的文件模板进行导入<span style={{ color: '#F53F3F' }}>已结案的矛盾纠纷数据</span><span>,且每次只允许上传一个导入文件&nbsp;&nbsp;</span><span className='public-color public-a' onClick={() => window.open(`${$$.appUrl.fileUrl}${$$.appUrl.fileDownUrl}${downUrlId}`)}>下载模板</span></span>}
                />
              </div>
            </Col>
            {
              !status &&
              <Col span={24}>
                <h5><div style={{ display: 'flex' }}>导入文件<div className="must">必填</div></div></h5>
                <MyUpload
                  ledgerType={true}
                  styleHeight={'158px'}
                  fileIcon={true}
                  mainId={'10001'}
                  ownerId={'10001'}
                  ownerType={'22_00018-504'}
                  handleChangeFile={(type, info, apiResult) => {
                    handleChangeFile(type, info, apiResult);
                  }}
                  accept=".xls, .xlsx"
                  formatType='支持xls、xlsx格式的文件上传,每次上传大小不超过10M'
                  fileType="22_00018-504"
                  fileList={filesList}
                />
              </Col>
            }
 
            {
              status && status == 'loading' &&
              <div style={{ width: '100%', paddingTop: '150px', display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center' }}>
                <div>
                  <Spin className='ledgerEdit-main-spin' size={'large'} spinning={status} />
                </div>
                <div style={{ fontSize: '20px', lineHeight: '28px', color: 'rgba(0,0,0,0.85)', margin: '20px 0 12px' }}>文件导入中</div>
                <div style={{ marginBottom: '12px', }}>
                  <span style={{ lineHeight: '22px', color: 'rgba(0,0,0,0.45)' }}>这个过程可能需要几分钟的时间,请耐心等待...<br />
                    导入后,为确保最终导入系统的案件质量<br />
                    请在<span className='public-color' >导入草稿</span>列表中进行二次确认</span>
                </div>
              </div>
            }
 
            {
              status && status == 'error' &&
              <div style={{ width: '100%', paddingTop: '150px', display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center' }}>
                <div>
                  <img className='ledgerEdit-main-spin-img' src={ledger_6} alt="" />
                </div>
                <div style={{ fontSize: '20px', lineHeight: '28px', color: 'rgba(0,0,0,0.85)', margin: '20px 0 12px' }}>文件导入失败</div>
                <div style={{ marginBottom: '12px', }}>
                  <span style={{ lineHeight: '22px', color: 'rgba(0,0,0,0.45)' }}>原因:<span className='ledger-main-title' >导入文件模板不正确(未使用系统模板)</span></span>
                </div>
                <Space size="large">
                  <Button onClick={() => setStatus('')} type="primary">
                    重新上传
                  </Button>
                  <Button onClick={() => navigate(-1)}>返回列表</Button>
                </Space>
              </div>
            }
 
 
            {
              status && status == 'success' &&
              <div style={{ width: '100%', display: 'flex', gap: "16px", flexDirection: 'column', justifyContent: 'center' }}>
                <div style={{ display: 'flex', justifyContent: 'center', backgroundColor: '#F8FAFB', padding: '16px', borderRadius: '10px' }}>
                  <div style={{ display: 'flex', width: '824px', justifyContent: 'space-between' }}>
                    <div>
                      <div style={{ fontSize: '16px', paddingBottom: '4px', color: '#86909C' }}>数据总数</div>
                      <div><span style={{ fontSize: '24px', lineHeight: '32px' }}>{(successData.countSuccess || 0) + (successData.countFalse || 0)}</span><span style={{ fontSize: '14px', color: '#86909C' }}>&nbsp;&nbsp;条</span></div>
                    </div>
                    <div style={{ width: '1px', backgroundColor: '#E5E6EB', height: '100%', margin: '0 12px' }} />
 
                    <div>
                      <div style={{ fontSize: '16px', paddingBottom: '4px', color: '#86909C' }}>导入成功</div>
                      <div><span style={{ color: '#00B42A', fontSize: '24px', lineHeight: '32px' }}>{(successData.countSuccess || 0)}</span><span style={{ fontSize: '14px', color: '#86909C' }}>&nbsp;&nbsp;条</span></div>
                    </div>
                    <div style={{ width: '1px', backgroundColor: '#E5E6EB', height: '100%', margin: '0 12px' }} />
                    <div>
                      <div style={{ fontSize: '16px', paddingBottom: '4px', color: '#86909C' }}>导入失败</div>
                      <div><span style={{ color: '#F53F3F', fontSize: '24px', lineHeight: '32px' }}>{(successData.countFalse || 0)}</span><span style={{ fontSize: '14px', color: '#86909C' }}>&nbsp;&nbsp;条</span></div>
                    </div>
                  </div>
 
                </div>
                {
                  successData.countFalse > 0 &&
                  <Alert type='warning' title="导入失败原因" content={
                    <div>
                      {
                        successData.countFalseContent?.map((item, index) => (
                          <div key={`Alert${index}`}>{item}</div>
                        ))
                      }
                    </div>
                  } banner />
                }
                <Space size="large" className='ledgerEdit-main-submit'>
                  <Button style={{ marginLeft: '12px' }} type="primary" onClick={() => navigate(-1)}>返回列表</Button>
                </Space>
              </div>
            }
 
          </Row>
          {
            !status &&
            <Space size="large" className='ledgerEdit-main-submit'>
              <Button onClick={() => onSubmit()} type="primary" className="dialogPrimary">
                导入
              </Button>
              <Button type='secondary' onClick={() => navigate(-1)}>返回上级页面</Button>
            </Space>
          }
        </div>
      </div>
      <MyModal
        width={'80%'}
        visible={mould}
        okText="关闭页面"
        onOk={() => setMould(false)}
        bodyStyle={{ padding: '0 16px 16px' }}
        closable={false}
      >
        <div className="myMessage-modal-header">
          <h4>导入说明</h4>
        </div>
        <div>
          <pre>
            <div className='ledger-main-mould'>
              <div className='ledger-main-mould-img'>
                <img src={ledger_2} alt="" />
              </div>
              <span style={{ lineHeight: '22px' }}>案件首次导入后,将进入<span className='ledger-main-title'>导入草稿</span>列表,操作人需要在该列表内对案件数据进行核实后,批量勾选并点击<span className='ledger-main-title'>确定导入</span>按钮,以实现将案件正式导入多元化解平台操作案件正式导入平台后将自动归档,调解员可在<span className='ledger-main-title'>我的调解/我负责的(协助调解员为我参与的)/调解结束、调解总览(一本账)</span>功能中看到案件信息</span>
            </div>
            <div className='ledger-main-mould' style={{ margin: '12px 0' }}>
              <div className='ledger-main-mould-img'>
                <img src={ledger_1} alt="" />
              </div>
              <span style={{ lineHeight: '22px' }}>模板案件填写样例</span>
            </div>
            <img style={{ height: '300px', width: '100%' }} src={ledger_4} alt="" />
            <img style={{ height: '300px', width: "100%" }} src={ledger_3} alt="" />
          </pre>
        </div>
      </MyModal>
    </NewPage >
  )
};
 
export default CaseImportAdd;