tsg-web/src/views/sq/qzq/qzqda/index.js

154 lines
6.0 KiB
JavaScript
Raw Normal View History

2024-09-23 15:52:06 +08:00
import React, { Fragment, useRef, useMemo,useEffect,useState } from 'react';
import BasicCrudModal from '../../../../components/crud/BasicCrudModal';
import { Table, Card, Modal, Form, Input, Button, Row,Col, Timeline, message, Tabs,Image } from 'antd';
import {FileWordOutlined,FilePdfOutlined,FileZipOutlined,FileExcelOutlined } from '@ant-design/icons';
import { useSelector } from 'react-redux';
import ToolBar from './toolbar';
import apiurl from '../../../../service/apiurl';
import usePageTable from '../../../../components/crud/usePageTable2';
import { createCrudService } from '../../../../components/crud/_';
import {CrudOpRender_text} from '../../../../components/crud/CrudOpRender';
2024-09-24 16:52:00 +08:00
import './index.less'
2024-09-23 15:52:06 +08:00
const url = "http://223.75.53.141:9102/test.by-lyf.tmp"
const Page = () => {
const role = useSelector(state => state.auth.role);
const editBtn = role?.rule?.find(item => item.menuName == "编辑");
const viewBtn = role?.rule?.find(item => item.menuName == "查看");
const delBtn = role?.rule?.find(item => item.menuName == "删除");
const refModal = useRef();
const [searchVal, setSearchVal] = useState(false)
const [isFetch, setIsFetch] = useState(false)
const command = (type) => (params) => {
if (type === 'save') {
refModal.current.showSave();
} else if (type === 'edit') {
refModal.current.showEdit({ ...params });
} else if (type === 'view') {
refModal.current.showView(params);
} else if (type === 'del') {
refModal.current.onDeleteGet(apiurl.rcgl.gcdsj.delete + `/${params.id}`);
}
}
const download = (params) => {
let downloadLink = document.createElement("a");
downloadLink.href = `http://local.gunshiiot.com:18083/gunshiApp/xyt/projectEvents/file/download/${params}`;
downloadLink.download = `${params.fileName}`;
downloadLink.style.display = "none";
// 将链接添加到页面中
document.body.appendChild(downloadLink);
// 模拟点击事件,开始下载
downloadLink.click();
}
2024-09-24 16:52:00 +08:00
const { tableProps, search, refresh } = usePageTable(createCrudService(apiurl.gcdsj.qzqda.list).find_noCode);
2024-09-23 15:52:06 +08:00
const viewPdf = (params) => {
// setIframeSrc(params)
// setPdfViewOPen(true)
}
useEffect(()=>{
const params = {
search: {
...searchVal,
}
};
search(params)
}, [searchVal])
return (
<>
<div className='content-root clearFloat xybm' style={{paddingRight:"0",paddingBottom:"0"}}>
<div className='lf CrudAdcdTreeTableBox' style={{width:"100%",overflowY:"auto"}}>
<Card className='nonebox'>
<ToolBar
setSearchVal={setSearchVal}
onSave={command('save')}
role={role}
/>
</Card>
<div className="ant-card-body" style={{ padding: "20px 0 0 0" }}>
<div className='time-line'>
<Timeline>
2024-09-24 16:52:00 +08:00
{tableProps.dataSource?.map((item, index) => (
2024-09-23 15:52:06 +08:00
<Timeline.Item key={index}>
<div className='time-line-item'>
<span style={{width:100}}>{item.eventsDate}</span>
<div className='item-right'>
<span>{item.eventsDesc}</span>
<div style={{ display: "flex"}}>
<span>附件</span>
<Row gutter={[16]} style={{flex:1}}>
{
2024-09-24 16:52:00 +08:00
item.files?.length > 0 && item.files?.map(file => {
2024-09-23 15:52:06 +08:00
return (
<Col span={12}>
<div className="file-item" style={{width:"100%"}}>
<div className='file-description'>
2024-09-24 16:52:00 +08:00
{file.fileName?.indexOf('.docx') > -1 ?
2024-09-23 15:52:06 +08:00
<div
onClick={() => { download(file.fileId) }}
style={{ cursor: 'pointer' }}
>
<FileWordOutlined
style={{ fontSize: 40 }}
/>
</div>
:
2024-09-24 16:52:00 +08:00
file.fileName?.indexOf('.pdf') > -1 ?
2024-09-23 15:52:06 +08:00
<div
onClick={() => { viewPdf(file?.fileId) }}
style={{ cursor: 'pointer' }}
>
<FilePdfOutlined style={{ fontSize: 40 }} />
</div>
:
2024-09-24 16:52:00 +08:00
file.fileName?.indexOf('.zip') > -1 ?
2024-09-23 15:52:06 +08:00
<div
onClick={() => { download(file?.fileId) }}
style={{ cursor: 'pointer' }}
>
<FileZipOutlined style={{ fontSize: 40 }} />
</div>
:
2024-09-24 16:52:00 +08:00
file.fileName?.indexOf('.xlsx') > -1 ?
2024-09-23 15:52:06 +08:00
<div
onClick={() => { download(file?.fileId) }}
style={{ cursor: 'pointer' }}
>
<FileExcelOutlined style={{ fontSize: 40 }} />
</div>
:
<Image width={60} src={url +file?.filePath} alt='' />
}
<span>{file.fileName}</span>
</div>
</div>
</Col>
)
})
}
</Row>
</div>
</div>
</div>
</Timeline.Item>
))}
</Timeline>
</div>
</div>
</div>
</div>
</>
);
}
export default Page;