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 ChartToolBar from './chartToolbar'; import ModalForm from './form'; import apiurl from '../../../service/apiurl'; import options from "./options"; import ReactEcharts from 'echarts-for-react'; import usePageTable from '../../../components/crud/usePageTable2'; import { createCrudService } from '../../../components/crud/_'; import { CrudOpRender_text } from '../../../components/crud/CrudOpRender'; import "./index.less" import { httpget2 } from '../../../utils/request'; import moment from 'moment'; const Page = () => { const types = [ { label: "水利", value:1 }, { label: "岗前培训", value:2 },{ label: "在岗培训", value:3 },{ label: "政治学习教育", value:4 }, { label: "其他", value:5 }, ] 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 [searchChartVal, setSearchChartVal] = useState() const columns = [ { title: '序号', key: 'inx', dataIndex: 'inx', width: 60, align:"center" }, { title: '培训日期', key: 'planDate', dataIndex: 'planDate', width: 200, ellipsis: true }, { title: '标题', key: 'name', dataIndex: 'name', width: 200,ellipsis: true }, { title: '主办单位', key: 'unit', dataIndex: 'unit', width: 150 }, { title: '培训分类', key: 'type', dataIndex: 'type', width: 150, render: (v) => {types[v - 1]?.label} }, { title: '培训内容', key: 'content', dataIndex: 'content', width: 200,ellipsis: true }, { title: '参训人员', key: 'trainees', dataIndex: 'trainees', width: 200, ellipsis: true }, { title: '培训地点', key: 'addr', dataIndex: 'addr', width: 150, ellipsis: true }, { title: '填报人', key: 'applicant', dataIndex: 'applicant', width: 150, ellipsis: true }, { title: '登记日期', key: 'regDate', dataIndex: 'regDate', width: 150, ellipsis: true }, { title: '操作', key: 'operation', width: 200, fixed: 'right',align: 'center', render: (value, row, index) => ( () => 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') { refModal.current.onDeleteGet(apiurl.pxjl.delete + `/${params.id}`); } } const { tableProps, search, refresh } = usePageTable(createCrudService(apiurl.pxjl.page).find_noCode); /** * @description 处理成功的回调 */ const successCallback = () => { refresh() getStaData(searchChartVal) } // 获取统计数据 const [staData, setStaData] = useState({}) const pxOptions = useMemo(() => { if (staData) { return options(staData) } else { return options({}) } }, [staData]) const getStaData = async (params) => { try { const res = await httpget2(apiurl.pxjl.sta + `/${params.year}`) if (res.code == 200) { setStaData({...res.data}) // if (params.teamName == 1) { // setStaData({...res.data,list:res.data.list1}) // } else { // setStaData({...res.data,list:res.data.list2}) // } }else{ message.error(res.description) setStaData([]) } } catch (error) { console.log(error); } } useEffect(()=>{ const params = { search: { ...searchVal, } }; search(params) }, [searchVal]) useEffect(() => { if (searchChartVal) { getStaData(searchChartVal) } }, [searchChartVal]) return ( <>
本年培训期数 计划/实际 { staData?.numberOfPeriods2 ?? "--"} 期/ { staData?.numberOfPeriods1 ?? "--"} 期
本年培训人次 计划/实际 { staData?.personNum2 ?? "--"} 人次/ { staData?.personNum1 ?? "--"} 人次
{refresh({addvcd:localStorage.getItem('ADCD6')})}} /> ); } export default Page;