广州市综治平台前端
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
import React, { useState, useRef } from 'react';
import { Form, Input, Button, Modal, Select, Tooltip } from '@arco-design/web-react';
import { Col, Row } from 'antd';
import ArcoUpload from '@/components/ArcoUpload';
import * as $$ from '@/utils/utility';
import { question1, } from '@/assets/images';
import SelectObjModal from '@/components/SelectObjModal/selectPerson';
 
const FormItem = Form.Item;
const appUrl = $$.appUrl;
 
function delFile(id) {
  return $$.ax.request({ url: `fileInfo/deleteFileById`, type: 'get', service: 'sys', data: { id } });
}
 
function postAssistApply(data) {
  return $$.ax.request({ url: `caseAssistApply/addCaseAssistApply`, type: 'post', service: 'mediate', data });
}
 
 
const UniteHandle = ({ id, visible, handleOnCancel, caseId, caseTaskId }) => {
  const formRef = useRef();
  const [isModalVisible, setIsModalVisible] = useState(false);
  const [wantUser, setWantUser] = useState([]);
  const [selectOptions, setSelectOptions] = useState([]);//部门选择的options
 
  //删除文件
  const handleDelFile = async (id) => {
    const res = await delFile(id)
    if (res.type) {
      $$.infoSuccess({ content: '删除成功!' });
    }
  }
 
  const handleSupervising = () => {
    formRef.current.validate(undefined, (errors, values) => {
      if (!errors) {
        handleJoint({
          id,
          caseId,
          applyContent: values.applyContent,
          applyAssistUnitId: wantUser?.map(item => item.value).join(',') || '',
          applyAssistUnitName: wantUser?.map(item => item.name).join(',') || '',
        })
      }
    })
  }
 
  //form数据同步要提交的数据
  const handleSync = (value) => {
    let newList = wantUser.filter(item => value.indexOf(item.value) != -1)
    setWantUser(newList);
  }
 
  //联合处置请求
  const handleJoint = async (data) => {
    const res = await postAssistApply(data)
    if (res.type) {
      $$.infoSuccess({ content: '提交申请成功!' });
      handleOnCancel();
    }
  }
 
  return (
    <Modal
      visible={visible}
      onCancel={handleOnCancel}
      title='联合处置申请'
      centered
      footer={null}
      unmountOnExit={true}
      maskClosable={false}
      autoFocus={false}
      focusLock={false}
    >
      <Form
        ref={formRef}
        layout='vertical'
        requiredSymbol={false}
        scrollToFirstError={true}
        initialValues={{
          applyContent: '在事项办理过程中:\n因[......业务]涉及[......部门名称]\n因[......业务]涉及[......部门名称]\n特申请将上述部门列为配合部门,请审批'
        }}//默认值
      >
        <Row>
          <Col span={24}>
            <FormItem
              label={<div style={{ display: 'flex' }}><div>添加配合部门</div><div style={{ color: '#86909C' }}>(可多选)</div></div>}
              field='unit'
            >
              <Select
                mode='multiple'
                placeholder='请选择配合部门'
                allowClear
                onFocus={(e) => {
                  e.stopPropagation()
                  setIsModalVisible(true)
                }}
                options={selectOptions}
                onChange={handleSync}
              >
              </Select>
            </FormItem>
          </Col>
          <Col span={24}>
            <FormItem
              field='applyContent'
              label={(<div style={{ display: 'flex' }}>添加理由<div className="must">必填</div></div>)}
              rules={[{ required: true, message: '请输入添加理由' }]}
            >
              <Input.TextArea
                rows={5}
              />
            </FormItem>
          </Col>
          <Col span={24}>
            <ArcoUpload
              params={{
                action: `${appUrl.fileUrl}/${appUrl.sys}/api/web/fileInfo/upload?mainId=${caseId}&&ownerId=${id}&ownerType=22_00018-508`,
              }}
              field='file'
              label={
                <div>
                  附件材料
                  <Tooltip>
                    <img src={question1} alt="" style={{ width: '13px', height: '13px', margin: '-3px 4px 0px 4px' }} />
                  </Tooltip>
                </div>
              }
              handleDelFile={handleDelFile}
            />
          </Col>
          <div className='dialogFooter'>
            <Button type='primary' style={{ marginTop: '-16px' }} onClick={handleSupervising}>提交申请</Button>
          </div>
        </Row>
      </Form>
      <SelectObjModal
        visible={isModalVisible}
        checkKeys={wantUser}
        onOk={(value) => {
          setWantUser(value.items)
          setSelectOptions(value.items.map(item => ({
            label: item.name,
            value: item.value
          })))
          formRef.current.setFieldValue('unit', value.items.map(item => item.value))
          setIsModalVisible(false)
        }}
        onClose={() => setIsModalVisible(false)}
        type='dept_union'
        isCheckbox={true}
      />
    </Modal>
  )
}
 
export default UniteHandle;