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;
|