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';
|
2024-09-27 14:38:23 +08:00
|
|
|
import { FileWordOutlined, FilePdfOutlined, FileZipOutlined, PaperClipOutlined } from '@ant-design/icons';
|
2024-09-23 15:52:06 +08:00
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
import ToolBar from './toolbar';
|
|
|
|
|
import ModalForm from './form';
|
|
|
|
|
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-27 14:38:23 +08:00
|
|
|
import { httpgetExport } from '../../../utils/request';
|
|
|
|
|
import { exportFile } from '../../../utils/tools';
|
2024-10-18 13:29:56 +08:00
|
|
|
import dayjs from 'dayjs';
|
2024-09-23 15:52:06 +08:00
|
|
|
|
|
|
|
|
const url = "http://223.75.53.141:9102/test.by-lyf.tmp"
|
2024-09-26 17:59:26 +08:00
|
|
|
const obj={0:"党支部工作制度",1:"行政工作制度",2:"部门工作制度",3:"安全管理制度",4:"工程管理制度",5:"技术规程",6:"岗位责任制"}
|
2024-09-23 15:52:06 +08:00
|
|
|
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 [iframeSrc, setIframeSrc] = useState('')
|
|
|
|
|
const [pdfViewOPen, setPdfViewOPen] = useState(false)
|
|
|
|
|
const [isFetch, setIsFetch] = useState(false)
|
|
|
|
|
const columns = [
|
|
|
|
|
{ title: '序号', key: 'inx', dataIndex: 'inx', width: 60, align: "center" },
|
2024-09-27 14:38:23 +08:00
|
|
|
{ title: '标题', key: 'name', dataIndex: 'name', ellipsis: true },
|
2024-09-23 15:52:06 +08:00
|
|
|
{
|
2024-09-27 14:38:23 +08:00
|
|
|
title: '制度类型', key: 'type', dataIndex: 'type',render:(v)=><>{obj[v]}</>
|
2024-09-23 15:52:06 +08:00
|
|
|
},
|
|
|
|
|
{
|
2024-10-18 13:29:56 +08:00
|
|
|
title: '发布日期', key: 'releaseDate', dataIndex: 'releaseDate',
|
|
|
|
|
render: (value) => <span>{dayjs(value).format('YYYY-MM-DD')}</span>,
|
2024-09-23 15:52:06 +08:00
|
|
|
},
|
|
|
|
|
{
|
2024-09-27 14:38:23 +08:00
|
|
|
title: '发布单位', key: 'fillUnit', dataIndex: 'fillUnit'
|
2024-09-23 15:52:06 +08:00
|
|
|
},
|
|
|
|
|
{
|
2024-09-27 14:38:23 +08:00
|
|
|
title: '上传时间', key: 'uploadDate', dataIndex: 'uploadDate'
|
2024-09-23 15:52:06 +08:00
|
|
|
},
|
|
|
|
|
{
|
2024-09-27 14:38:23 +08:00
|
|
|
title: '附件', key: 'files', dataIndex: 'files', render:(v,r)=><a onClick={()=>download(v[0].fileId,v[0]?.fileName)}><PaperClipOutlined />{v[0]?.fileName}</a>
|
2024-09-23 15:52:06 +08:00
|
|
|
},
|
|
|
|
|
{
|
2024-09-27 14:38:23 +08:00
|
|
|
title: '操作', key: 'operation', fixed: 'right', align: 'center',
|
2024-09-23 15:52:06 +08:00
|
|
|
render: (value, row, index) => (
|
|
|
|
|
<CrudOpRender_text
|
|
|
|
|
edit={true}
|
|
|
|
|
del={true}
|
2024-09-26 17:59:26 +08:00
|
|
|
// view={true}
|
2024-09-23 15:52:06 +08:00
|
|
|
command={(cmd) => () => command(cmd)(row)} />)
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const width = useMemo(() => columns.reduce((total, cur) => total + (cur.width), 0), [columns]);
|
|
|
|
|
|
|
|
|
|
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') {
|
2024-09-26 17:59:26 +08:00
|
|
|
refModal.current.onDeleteGet(apiurl.zdgl.del + `/${params.id}`);
|
2024-09-23 15:52:06 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-09-26 17:59:26 +08:00
|
|
|
const { tableProps, search, refresh } = usePageTable(createCrudService(apiurl.zdgl.list).find_noCode);
|
2024-09-23 15:52:06 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description 处理成功的回调
|
|
|
|
|
*/
|
|
|
|
|
const successCallback = () => {
|
|
|
|
|
refresh()
|
|
|
|
|
setIsFetch(!isFetch)
|
|
|
|
|
}
|
2024-09-27 14:38:23 +08:00
|
|
|
/**
|
|
|
|
|
* @description 文件下载
|
|
|
|
|
* @param {String} params 文件fileId
|
|
|
|
|
*/
|
|
|
|
|
const download = async(id, name) => {
|
|
|
|
|
var extension = name?.split('.').pop().toLowerCase();
|
|
|
|
|
httpgetExport(apiurl.zdgl.download+id).then(res => {
|
|
|
|
|
exportFile(name,res.data)
|
|
|
|
|
})
|
|
|
|
|
}
|
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" }}>
|
2024-09-27 14:38:23 +08:00
|
|
|
<Table columns={columns} rowKey="inx" {...tableProps} />
|
2024-09-23 15:52:06 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<BasicCrudModal
|
|
|
|
|
width={1000}
|
|
|
|
|
ref={refModal}
|
|
|
|
|
title=""
|
|
|
|
|
component={ModalForm}
|
|
|
|
|
onCrudSuccess={successCallback}
|
|
|
|
|
// onCrudSuccess={()=>{refresh({addvcd:localStorage.getItem('ADCD6')})}}
|
|
|
|
|
/>
|
|
|
|
|
</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,
|
|
|
|
|
}}
|
2024-09-26 17:59:26 +08:00
|
|
|
src={`${process.env.PUBLIC_URL}/static/pdf/web/viewer.html?file=${encodeURIComponent(`/gunshiApp/tsg/projectEvents/file/download/${iframeSrc}`)}`}
|
2024-09-23 15:52:06 +08:00
|
|
|
/>
|
|
|
|
|
</Modal>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Page;
|