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

198 lines
7.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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';
import './index.less'
import { httppost5 } from '../../../../utils/request';
import { exportFile } from '../../../../utils/tools';
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 [iframeSrc, setIframeSrc] = useState('')
const [pdfViewOPen, setPdfViewOPen] = 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/tsg/projectEvents/file/download/${params}`;
downloadLink.download = `${params.fileName}`;
downloadLink.style.display = "none";
// 将链接添加到页面中
document.body.appendChild(downloadLink);
// 模拟点击事件,开始下载
downloadLink.click();
}
const { tableProps, search, refresh } = usePageTable(createCrudService(apiurl.gcdsj.qzqda.list).find_noCode);
console.log(tableProps);
/**
* @description pdf文件预览
* @param {String} params 文件预览url
*/
const viewPdf = (params) => {
setIframeSrc(params)
setPdfViewOPen(true)
}
const onExport = () => {
let params = {
...searchVal,
pageSo:{
pageNum:1,pageSize:9999
}
}
httppost5(apiurl.gcdsj.qzqda.export, params).then(res => {
exportFile(`全周期档案.xlsx`,res.data)
})
}
useEffect(()=>{
const params = {
search: {
...searchVal,
},
pageSize:9999
};
search(params)
}, [searchVal])
return (
<>
<div className='content-root clearFloat xybm' style={{paddingRight:"0",paddingBottom:"0"}}>
<div className='lf CrudAdcdTreeTableBox' style={{width:"100%",overflow:'hidden'}}>
<Card className='nonebox'>
<ToolBar
setSearchVal={setSearchVal}
onExport={onExport}
role={role}
/>
</Card>
<div className="ant-card-body" style={{ padding: "20px 0 0 0",overflowY:"auto",height: 'calc(100vh - 68px)'}}>
<div className='time-line' style={{width:'calc(100% - 140px)'}}>
<Timeline >
{tableProps.dataSource?.map((item, index) => (
<Timeline.Item key={index}>
<div className='time-line-item'>
<div style={{width:100}}>
<span>{item.eventsDate}</span>
<div className='dsj'>{item.typeName}</div>
</div>
<div className='item-right'>
<span>{item.eventsDesc}</span>
<div style={{ display: "flex"}}>
<span>附件</span>
<Row gutter={[16]} style={{flex:1}}>
{
item.files?.length > 0 && item.files?.map(file => {
return (
<Col span={12}>
<div className="file-item" style={{width:"100%"}}>
<div className='file-description'>
{file.fileName?.indexOf('.docx') > -1 ?
<div
onClick={() => { download(file.fileId) }}
style={{ cursor: 'pointer' }}
>
<FileWordOutlined
style={{ fontSize: 40 }}
/>
</div>
:
file.fileName?.indexOf('.pdf') > -1 ?
<div
onClick={() => { viewPdf(file?.fileId) }}
style={{ cursor: 'pointer' }}
>
<FilePdfOutlined style={{ fontSize: 40 }} />
</div>
:
file.fileName?.indexOf('.zip') > -1 ?
<div
onClick={() => { download(file?.fileId) }}
style={{ cursor: 'pointer' }}
>
<FileZipOutlined style={{ fontSize: 40 }} />
</div>
:
file.fileName?.indexOf('.xlsx') > -1 ?
<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>
<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/tsg/projectEvents/file/download/${iframeSrc}`)}`}
/>
</Modal>
</>
);
}
export default Page;