import React, { Fragment, useRef, useMemo,useEffect,useState } from 'react'; import { useSelector } from 'react-redux'; import BasicCrudModal from '../../../components/crud/BasicCrudModal'; import { Table, Card,Modal,Image,Input,Button,Row,Col,message } from 'antd'; import ToolBar from './toolbar'; import ModalForm from './form'; import RecordDetails from "./RecordForm" import apiurl from '../../../service/apiurl'; import usePageTable from '../../../components/crud/usePageTable2'; import { createCrudService } from '../../../components/crud/_'; import { CrudOpRender_text } from '../../../components/crud/CrudOpRender'; import { exportFile } from '../../../utils/tools.js'; import { httppost5 } from '../../../utils/request'; const Page = () => { const url = "http://223.75.53.141:9102/test.by-lyf.tmp" const role = useSelector(state => state.auth.role); const editBtn = role?.rule?.find(item => item.menuName == "编辑") || true; const viewBtn = role?.rule?.find(item => item.menuName == "查看") || true; const delBtn = role?.rule?.find(item => item.menuName == "删除") || true; const refModal = useRef(); const [searchVal, setSearchVal] = useState(false) const [pxRecordOpen, setPxRecordOpen] = useState(false) const columns = [ { title: '序号', key: 'inx', dataIndex: 'inx', width: 60, align:"center" }, { title: '培训班名称', key: 'teamName', dataIndex: 'teamName', width: 200, ellipsis: true }, { title: '计划培训周期', key: 'personCount', dataIndex: 'personCount', width: 200, }, { title: '主办单位', key: 'address', dataIndex: 'address', width: 200 }, { title: '培训内容', key: 'managementUnit', dataIndex: 'managementUnit', width: 200,ellipsis: true }, { title: '培训地点', key: 'teamLeader', dataIndex: 'teamLeader', width: 150, ellipsis: true }, { title: '填报人', key: 'phone', dataIndex: 'phone', width: 150, ellipsis: true }, { title: '操作', key: 'operation', width: 300, fixed: 'right',align: 'center', render: (value, row, index) => ( () => command(cmd)(row)} />) }, ]; const columns1 = [ { title: '序号', key: 'inx', dataIndex: 'inx', width: 60, align:"center" }, { title: '培训日期', key: 'teamName', dataIndex: 'teamName', width: 150, ellipsis: true }, { title: '培训时段', key: 'personCount', dataIndex: 'personCount', width: 150, }, { title: '参加人数', key: 'address', dataIndex: 'address', width: 100 }, { title: '参训人员', key: 'managementUnit', dataIndex: 'managementUnit', width: 200,ellipsis: true }, { title: '培训签到表', key: 'teamLeader', dataIndex: 'teamLeader', width: 150, render: (value) =>
{value ? reviewPic(value)}> {value} : ''}
}, { title: '操作', key: 'operation', width: 100, fixed: 'right',align: 'center', render: (value, row, index) => ( {setPxRecordOpen(true)}}>查看 ) }, ]; const width = useMemo(() => columns.reduce((total, cur) => total + (cur.width), 0), [columns]); const width1 = useMemo(() => columns1.reduce((total, cur) => total + (cur.width), 0), [columns1]); const [pxOpen, setPxOpen] = useState(false) const [imgVisible, setImgVisible] = useState(false) const [imgList, setImgList] = useState([]) const reviewPic = (arrPic) => { if (arrPic.length > 0) { setImgVisible(true) setImgList(arrPic) } } 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.fxzb.qsdw.zq.delete + `/${params.teamId}`); }else if (type === 'similarAdd') { refModal.current.showSimilarSave(params); } else { // 培训记录 setPxOpen(true); // setPxItem } } const { tableProps, search, refresh } = usePageTable(createCrudService(apiurl.fxzb.qsdw.zq.page).find_noCode); const { tableProps:tableProps1, search:search1 } = usePageTable(createCrudService(apiurl.fxzb.qsdw.zq.page).find_noCode); /** * @description 处理成功的回调 */ const successCallback = () => { refresh() } // 导出 const exportExcel = () => { let params = { ...searchVal, id:1 } httppost5(apiurl.gcaqjc.gcaqfx.jrx.export, params).then(res => { exportFile(`培训计划管理.xlsx`,res.data) }) } useEffect(()=>{ const params = { search: { ...searchVal, } }; search(params) }, [searchVal]) return ( <>
{refresh({addvcd:localStorage.getItem('ADCD6')})}} /> {/* 培训记录 */} { setPxOpen(false); }} >
{/* 培训记录查看 */} { setPxRecordOpen(false); }} >
setImgVisible(vis), }} > { imgList.length > 0 ? imgList.map(item => ( )) : null }
); } export default Page;