2024-09-20 15:02:50 +08:00
|
|
|
|
import React, { useEffect, useState } from 'react'
|
|
|
|
|
|
import {
|
|
|
|
|
|
Form,
|
|
|
|
|
|
Button,
|
|
|
|
|
|
Input,
|
|
|
|
|
|
message,
|
|
|
|
|
|
Row,
|
|
|
|
|
|
Col,
|
|
|
|
|
|
DatePicker,
|
|
|
|
|
|
Upload,
|
|
|
|
|
|
Image,
|
|
|
|
|
|
Modal
|
|
|
|
|
|
} from 'antd'
|
|
|
|
|
|
import {
|
|
|
|
|
|
DeleteOutlined,
|
|
|
|
|
|
FileWordOutlined,
|
|
|
|
|
|
FilePdfOutlined,
|
|
|
|
|
|
FileZipOutlined,
|
|
|
|
|
|
FileExcelOutlined,
|
|
|
|
|
|
FilePptOutlined
|
|
|
|
|
|
} from '@ant-design/icons'
|
|
|
|
|
|
import {
|
|
|
|
|
|
formItemLayout,
|
|
|
|
|
|
btnItemLayout
|
|
|
|
|
|
} from '../../../../components/crud/FormLayoutProps'
|
|
|
|
|
|
import { createCrudService } from '../../../../components/crud/_'
|
|
|
|
|
|
import apiurl from '../../../../service/apiurl'
|
|
|
|
|
|
import moment from 'moment'
|
|
|
|
|
|
import NormalSelect from '../../../../components/Form/NormalSelect'
|
|
|
|
|
|
import EditText from '../../../../components/EditText'
|
|
|
|
|
|
const { Dragger } = Upload
|
|
|
|
|
|
const { RangePicker } = DatePicker
|
|
|
|
|
|
const url = 'http://223.75.53.141:9102/test.by-lyf.tmp'
|
|
|
|
|
|
const ModalForm = ({ mode, record, onEdit, onSave, onCrudSuccess }) => {
|
|
|
|
|
|
if (record.startDate) {
|
|
|
|
|
|
record.startDate = moment(record.startDate)
|
|
|
|
|
|
}
|
|
|
|
|
|
console.log('record', record)
|
|
|
|
|
|
const meetingType = [
|
|
|
|
|
|
{
|
|
|
|
|
|
label: "视频会议",
|
|
|
|
|
|
value: "0"
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
label: '现场会议',
|
|
|
|
|
|
value: '1'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
label: '电话会议',
|
|
|
|
|
|
value: '2'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
label: '网络会议',
|
|
|
|
|
|
value: '3'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
const [form] = Form.useForm()
|
|
|
|
|
|
const [fileList, setFileList] = useState([]) //上传文件列表
|
|
|
|
|
|
const [fileIds, setFileIds] = useState([])
|
|
|
|
|
|
const [flag, setFlag] = useState(true)
|
|
|
|
|
|
const [iframeSrc, setIframeSrc] = useState('')
|
|
|
|
|
|
const [pdfViewOPen, setPdfViewOPen] = useState(false)
|
|
|
|
|
|
const [editorText, setEditorText] = useState('')
|
|
|
|
|
|
const [loading, setLoading] = useState(false)
|
|
|
|
|
|
const onFinish = async values => {
|
|
|
|
|
|
// if(values.startDate){values.startDate = moment(values.startDate).format('YYYY-MM-DD HH:mm:ss')}
|
|
|
|
|
|
values.adcd = record.adcd
|
|
|
|
|
|
values.year = record.year
|
|
|
|
|
|
values.hmId = record.hmId
|
|
|
|
|
|
values.startDate = moment(values.dateRange[0]).format('YYYY-MM-DD HH:mm')
|
|
|
|
|
|
values.endDate = moment(values.dateRange[1]).format('YYYY-MM-DD HH:mm')
|
|
|
|
|
|
delete values.dateRange
|
|
|
|
|
|
if (mode === 'edit') {
|
|
|
|
|
|
let oldFiles = fileList.map(item => item.response?.data?.fileId)
|
|
|
|
|
|
values.fileIds = oldFiles
|
|
|
|
|
|
values.content = editorText
|
|
|
|
|
|
onEdit(apiurl.fxzb.sxfd.fbzrh.edit, values)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (mode === 'save') {
|
|
|
|
|
|
values.fileIds = fileIds
|
|
|
|
|
|
values.content = editorText
|
|
|
|
|
|
onSave(apiurl.fxzb.sxfd.fbzrh.save,values)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
const onchange = html => {
|
|
|
|
|
|
setEditorText(html)
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @description 删除上传的图片
|
|
|
|
|
|
* @param {string} id 删除的id
|
|
|
|
|
|
*/
|
|
|
|
|
|
const deleteFile = fileId => {
|
|
|
|
|
|
let filterFile = fileList.filter(
|
|
|
|
|
|
item => item.response?.data?.fileId !== fileId
|
|
|
|
|
|
)
|
|
|
|
|
|
setFileList(filterFile)
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @description 上传图片
|
|
|
|
|
|
* @param {string} file 上传的文件
|
|
|
|
|
|
*/
|
|
|
|
|
|
const fileChange = info => {
|
|
|
|
|
|
if (info.file.status === "done") {
|
|
|
|
|
|
setLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (info.file.status === "uploading") {
|
|
|
|
|
|
setLoading(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (info.file.status === "error") {
|
|
|
|
|
|
message.error("文件上传失败")
|
|
|
|
|
|
setLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
let fileIds = info.fileList.map(file => {
|
|
|
|
|
|
return file.response?.data?.fileId
|
|
|
|
|
|
})
|
|
|
|
|
|
setFileIds(fileIds)
|
|
|
|
|
|
setFileList(info.fileList)
|
|
|
|
|
|
setFlag(false)
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @description 文件下载
|
|
|
|
|
|
* @param {String} params 文件fileId
|
|
|
|
|
|
*/
|
|
|
|
|
|
const download = params => {
|
|
|
|
|
|
let downloadLink = document.createElement('a')
|
2025-04-08 15:39:22 +08:00
|
|
|
|
downloadLink.href = `http://223.75.53.141:83/gunshiApp/xfflood/xfIdeoHmB/file/download/${params}`
|
2024-09-20 15:02:50 +08:00
|
|
|
|
downloadLink.download = `${params.fileName}`
|
|
|
|
|
|
downloadLink.style.display = 'none'
|
|
|
|
|
|
// 将链接添加到页面中
|
|
|
|
|
|
document.body.appendChild(downloadLink)
|
|
|
|
|
|
|
|
|
|
|
|
// 模拟点击事件,开始下载
|
|
|
|
|
|
downloadLink.click()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @description pdf文件预览
|
|
|
|
|
|
* @param {String} params 文件预览url
|
|
|
|
|
|
*/
|
|
|
|
|
|
const viewPdf = params => {
|
|
|
|
|
|
if (params) {
|
|
|
|
|
|
setIframeSrc(params)
|
|
|
|
|
|
setPdfViewOPen(true)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
console.log(record.fileList)
|
|
|
|
|
|
if (record.fileList) {
|
|
|
|
|
|
setFileList(record.fileList)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (mode == 'edit') {
|
|
|
|
|
|
form.setFieldsValue({
|
|
|
|
|
|
...record,
|
|
|
|
|
|
dateRange: [moment(record.startDate), moment(record.endDate)]
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [record])
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<Form form={form} {...formItemLayout} onFinish={onFinish}>
|
|
|
|
|
|
<Row>
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label='会议主题'
|
|
|
|
|
|
name='theme'
|
|
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Input
|
|
|
|
|
|
disabled={mode === 'view'}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
allowClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label='主办单位'
|
|
|
|
|
|
name='organiser'
|
|
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Input
|
|
|
|
|
|
disabled={mode === 'view'}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
allowClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label="会议类型"
|
|
|
|
|
|
name="meetType"
|
|
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
|
|
>
|
|
|
|
|
|
<NormalSelect style={{width:'100%'}} allowClear options={meetingType}/>
|
|
|
|
|
|
{/* <Input type='num' disabled={mode==='view'} style={{width:'100%'}} allowClear /> */}
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label='会议时间'
|
|
|
|
|
|
name='dateRange'
|
|
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
|
|
>
|
|
|
|
|
|
<RangePicker
|
|
|
|
|
|
showTime
|
|
|
|
|
|
format='YYYY-MM-DD HH:mm'
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<Form.Item label='会议地点' name='loc' rules={[{ required: true }]}>
|
|
|
|
|
|
<Input
|
|
|
|
|
|
type='num'
|
|
|
|
|
|
disabled={mode === 'view'}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
allowClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label='局内参加人员'
|
|
|
|
|
|
name='participant'
|
|
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Input
|
|
|
|
|
|
disabled={mode === 'view'}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
allowClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
<Row>
|
|
|
|
|
|
<Col span={24}>
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label='会议主要内容'
|
|
|
|
|
|
// name=""
|
|
|
|
|
|
labelCol={{ span: 3 }}
|
|
|
|
|
|
wrapperCol={{ span: 19 }}
|
|
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
|
|
>
|
|
|
|
|
|
<EditText
|
|
|
|
|
|
onChange={onchange}
|
|
|
|
|
|
htmlText={mode === 'edit' ? record.content : ''}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
<Row>
|
|
|
|
|
|
<Col span={24}>
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label={mode !== 'view' ? '附件' : ''}
|
|
|
|
|
|
name='fieldId'
|
|
|
|
|
|
labelCol={{ span: 3 }}
|
|
|
|
|
|
wrapperCol={{ span: 19 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
{mode !== 'view' && (
|
|
|
|
|
|
<Dragger
|
|
|
|
|
|
name='file'
|
|
|
|
|
|
// multiple
|
|
|
|
|
|
action='/gunshiApp/xfflood/xfIdeoHmB/file/upload/singleSimple'
|
|
|
|
|
|
onChange={fileChange}
|
|
|
|
|
|
onDrop={info => {
|
|
|
|
|
|
console.log(info.dataTransfer.files)
|
|
|
|
|
|
}}
|
|
|
|
|
|
fileList={fileList}
|
|
|
|
|
|
disabled={loading}
|
|
|
|
|
|
// onSuccess={handleSuccess}
|
|
|
|
|
|
>
|
|
|
|
|
|
<p className='ant-upload-text'>点击或拖拽文件到此区域上传</p>
|
|
|
|
|
|
<p className='ant-upload-hint'>
|
|
|
|
|
|
支持扩展名:.rar .zip .doc .docx .pdf .jpg .png .ppt
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</Dragger>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<Row gutter={[16]}>
|
|
|
|
|
|
{ loading ? <span>文件正在上传中,请等待</span> :
|
|
|
|
|
|
fileList.length > 0 &&
|
|
|
|
|
|
fileList.map(file => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<div
|
|
|
|
|
|
className={
|
|
|
|
|
|
mode == 'view' ? 'file-item view-file' : 'file-item'
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<div className='file-description'>
|
|
|
|
|
|
{file.name.indexOf('.docx') > -1 ? (
|
|
|
|
|
|
<div
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
download(file.response?.data?.fileId)
|
|
|
|
|
|
}}
|
|
|
|
|
|
style={{ cursor: 'pointer' }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<FileWordOutlined style={{ fontSize: 40 }} />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : file.name.indexOf('.pdf') > -1 ? (
|
|
|
|
|
|
<div
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
viewPdf(file.response?.data?.fileId)
|
|
|
|
|
|
}}
|
|
|
|
|
|
style={{ cursor: 'pointer' }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<FilePdfOutlined style={{ fontSize: 40 }} />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : file.name.indexOf('.zip') > -1 ? (
|
|
|
|
|
|
<div
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
download(file.response?.data?.fileId)
|
|
|
|
|
|
}}
|
|
|
|
|
|
style={{ cursor: 'pointer' }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<FileZipOutlined style={{ fontSize: 40 }} />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) :
|
|
|
|
|
|
file.name.indexOf('.ppt') > -1 ?
|
|
|
|
|
|
<div
|
|
|
|
|
|
onClick={() => { download(file.response?.data?.fileId) }}
|
|
|
|
|
|
style={{ cursor: 'pointer' }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<FilePptOutlined style={{ fontSize: 40 }} />
|
|
|
|
|
|
</div> :
|
|
|
|
|
|
file.name.indexOf('.xlsx') > -1 ? (
|
|
|
|
|
|
<div
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
download(file.response?.data?.fileId)
|
|
|
|
|
|
}}
|
|
|
|
|
|
style={{ cursor: 'pointer' }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<FileExcelOutlined style={{ fontSize: 40 }} />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Image
|
|
|
|
|
|
width={60}
|
|
|
|
|
|
src={url + file.response?.data?.filePath}
|
|
|
|
|
|
alt=''
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<span>{file.name}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
|
|
|
|
className={
|
|
|
|
|
|
mode == 'view'
|
|
|
|
|
|
? 'delete-icon disable-icon'
|
|
|
|
|
|
: 'delete-icon'
|
|
|
|
|
|
}
|
|
|
|
|
|
onClick={() =>
|
|
|
|
|
|
deleteFile(file.response?.data?.fileId)
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<DeleteOutlined />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
)
|
|
|
|
|
|
})}
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
|
|
|
|
{mode === 'view' ? null : (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<Form.Item {...btnItemLayout}>
|
|
|
|
|
|
<Button type='primary' htmlType='submit'>
|
|
|
|
|
|
{mode === 'save' ? '增加' : '修改'}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Form>
|
|
|
|
|
|
<Modal
|
|
|
|
|
|
open={pdfViewOPen}
|
|
|
|
|
|
width={1000}
|
|
|
|
|
|
title=''
|
|
|
|
|
|
footer={null}
|
|
|
|
|
|
style={{ marginTop: '-5%' }}
|
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
|
setPdfViewOPen(false)
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<iframe
|
|
|
|
|
|
style={{
|
|
|
|
|
|
height: '80vh',
|
|
|
|
|
|
width: '100%',
|
|
|
|
|
|
border: 0,
|
|
|
|
|
|
marginTop: 20
|
|
|
|
|
|
}}
|
|
|
|
|
|
src={`${
|
|
|
|
|
|
process.env.PUBLIC_URL
|
|
|
|
|
|
}/static/pdf/web/viewer.html?file=${encodeURIComponent(
|
|
|
|
|
|
`/gunshiApp/xfflood/xfIdeoFcB/file/download/${iframeSrc}`
|
|
|
|
|
|
)}`}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Modal>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default ModalForm
|