广州市综治平台前端
xusd
7 days ago 544148eddae96db824423cd059ebecb9d13c392e
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
import React, { useEffect, useRef, useState } from 'react'
import { Row, Col } from 'antd';
import { Form, Input, Button } from '@arco-design/web-react';
import ArcoUpload from '@/components/ArcoUpload';
import { Scrollbars } from "react-custom-scrollbars";
import { escalation } from '@/assets/images/icon';
import * as $$ from '@/utils/utility';
import { useNavigate } from 'react-router-dom';
 
const FormItem = Form.Item;
const TextArea = Input.TextArea;
const appUrl = $$.appUrl;
 
function getId() {
  return $$.ax.request({ url: `caseUtils/getNewTimeId`, type: 'get', service: 'utils' });
}
 
function delFile(id) {
  return $$.ax.request({ url: `fileInfo/deleteFileById`, type: 'get', service: 'sys', data: { id } });
}
 
function appearApply(data) {
  return $$.ax.request({ url: `caseTask/appearApply`, type: 'post', service: 'mediate', data });
}
 
function getAppearToUnit() {
  return $$.ax.request({ url: `ctUnit/getAppearToUnit`, type: 'get', service: 'cust' });
}
 
export default function BackModel(props) {
  const navigate = useNavigate();
  const formRef = useRef();
  const [id, setId] = useState();
  const [unitData, setUnitData] = useState({});
 
  useEffect(() => {
    getAppId()
    getAppearToUnitData()
  }, [])
 
  //获取上报部门
  const getAppearToUnitData = async () => {
    const res = await getAppearToUnit()
    if (res.type) {
      setUnitData({
        auditUnitId: res.data.auditUnitId,
        auditUnitName: res.data.auditUnitName
      })
    }
  }
 
  //获取id
  const getAppId = async () => {
    const res = await getId()
    if (res.type) {
      setId(res.data)
    }
  }
 
  const handleSubmit = () => {
    if (formRef.current) {
      formRef.current.validate(undefined, (errors, values) => {
        if (!errors) {
          handleEscala({
            id,
            caseId: props.caseId,
            caseTaskId: props.caseTaskId,
            appearContent: values.appearContent,
            ...unitData
          })
        }
      })
    }
  }
 
  const handleTemplate = (type) => {
    if (type === 1) {
      formRef.current.setFieldValue('appearContent', '经我部门核查,该矛盾纠纷涉及XX业务,化解事权应由XX部门牵头,特请求上级协调交办XX部门牵头办理。')
    } else {
      formRef.current.setFieldValue('appearContent', '经综合研判,该纠纷事权在XX区/镇街,特请移交XX区/镇街牵头办理。')
    }
  }
 
  //上报请求
  const handleEscala = async (data) => {
    const res = await appearApply(data)
    if (res.type) {
      $$.infoSuccess({ content: '提交申请成功!' });
      props.onCancel()
      navigate('/mediate/visit/visitWorkBench')
    }
  }
 
  //删除文件
  const handleDelFile = async (id) => {
    const res = await delFile(id)
    if (res.type) {
      $$.infoSuccess({ content: '删除成功!' });
    }
  }
 
  return (
    <div>
      <Scrollbars style={{ height: '550px' }} autoHide>
        <Form
          ref={formRef}
          layout='vertical'
          requiredSymbol={false}
          initialValues={{
          }}//默认值
          scrollToFirstError
        >
          <Row>
            <Col span={24}>
              <FormItem
                label='上报至'
                field='name'
              >
                <div className='myTag' >
                  <img src={escalation} alt="" className="title-file" />{unitData.auditUnitName}
                </div>
              </FormItem>
            </Col>
            <Col span={24} style={{ position: 'relative' }}>
              <div style={{ position: 'absolute', display: 'flex ', top: '28px', zIndex: 1 }}>
                <div className='myTag' style={{ marginRight: '22px' }} onClick={() => { handleTemplate(1) }}>公共模板1:申请移交上级职能部门范本</div>
                <div className='myTag' style={{ marginRight: '22px' }} onClick={() => { handleTemplate(2) }}>公共模板2:跨区域纠纷移交上报范本</div>
              </div>
              <FormItem
                label={(<div style={{ display: 'flex' }}>上报意见<div className="must">必填</div></div>)}
                field='appearContent'
                rules={[{ required: true, message: '请选择上报理由' }]}
              >
                <TextArea
                  autoSize={{ minRows: 4, maxRows: 8 }}
                  placeholder='请填写上报的具体理由'
                  style={{ marginTop: '40px' }}
                />
              </FormItem>
            </Col>
            <Col span={24} className="doubleFile">
              <ArcoUpload
                params={{
                  action: `${appUrl.fileUrl}/${appUrl.sys}/api/web/fileInfo/upload?mainId=${props.caseId}&ownerId=${id}&ownerType=22_00018-512`,
                }}
                field='file'
                label='附件材料'
                handleDelFile={handleDelFile}
              />
            </Col>
          </Row>
        </Form>
      </Scrollbars>
      <div className='dialogFooter'>
        <Button
          type="primary"
          className="dialogPrimary"
          onClick={handleSubmit}
        >
          提交
        </Button>
      </div>
    </div>
  )
}