import ProList from '@ant-design/pro-list'; import type { ActionType, ProColumns } from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table'; import { Button, Card, Space, Tag } from 'antd'; import React, { ReactText, useEffect, useState } from 'react'; import { useRef } from 'react'; import MeetingReservation from '@/components/ElecBidEvaluation/MeetingReservation'; import { getRecordData, getSiteList } from './service'; import { isEmpty } from '@/utils/CommonUtils'; const orange_bg = { background: '#f59a23', color: '#0000ff', cursor: 'pointer', width: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }; const green_bg = { background: '#4b7902' }; const align_middle = { display: 'flex', alignItems: 'center' }; const tag_size = { height: '20px', width: '20px' }; const ScreenTable = (props: { record: any, onCellClick: (id: any) => void, refresh: number }) => { const { record, onCellClick, refresh } = props; const actionRef = useRef(); //表格列 const [tableColumns, setTableColumns] = useState[]>([]); //表格数据 const [tableData, setTableData] = useState([]); //星期偏移量 const offset = useRef(0); //表格列拼接 const columnsSplice = (weeksData: any[]) => { const columns: ProColumns[] = [ { title: '评标室名称', dataIndex: 'name', align: 'center', render: (_, record, index) => { return { children: _, props: { rowSpan: index % 24 == 0 ? 24 : 0, } } } }, { title: '可容纳人数(人)', dataIndex: 'rs', align: 'center', render: (_, record, index) => { return { children: _, props: { rowSpan: index % 24 == 0 ? 24 : 0, } } } }, { title: '场次', align: 'center', colSpan: 2, render: (_, record, index) => { return { children: "07:00 ~ 18:00", props: { rowSpan: index % 24 == 0 ? 24 : 0, } } } }, { dataIndex: "time", align: 'right', width: '100px', colSpan: 0, }, { title: '预约时间', dataIndex: "info_time", valueType: 'date', hideInTable: true, }, ]; for (const ite of weeksData) { columns.push({ title: {ite.week}
{ite.date}
, dataIndex: ite.id, align: 'center', ellipsis: true, onCell: (record) => { return { style: record[ite.id]?.iskssj ? orange_bg : green_bg, onClick: record[ite.id]?.iskssj ? () => onCellClick(record[ite.id]?.id) : void 0, } }, render: (_: any, record: any) => { return { children: record[ite.id]?.hymc, props: { rowSpan: record[ite.id]?.iskssj ? record[ite.id]?.hour : record[ite.id]?.hour ? 0 : 1, } } } }) } setTableColumns(columns); } const getTableData = () => { getRecordData({ areaId: record?.id, offset: offset.current }).then(res => { if (res?.code == 200) { const data = res?.data; columnsSplice(data.week); setTableData(data.data); } }) } const weekChange = (param: string) => { if (param == "1") { offset.current += 1; } else if (param == "0") { offset.current -= 1; } getTableData(); } useEffect(() => { //获取预约记录 getTableData(); }, [refresh]); return (
{tableData.length > 0 && ( )} columns={tableColumns} actionRef={actionRef} bordered size='small' dataSource={tableData} rowKey="time" search={false} pagination={false} options={false} dateFormatter="string" />
) } export default () => { //预约弹窗 const [modalVisible, setModalVisible] = useState(false); //评标场所列表数据 const [siteListData, setSiteListData] = useState([]); //评标场所列表展开 const [expandedRowKeys, setExpandedRowKeys] = useState([]); //预约状态 const [meetStatus, setMeetStatus] = useState("2"); //预约id const [meetId, setMeetId] = useState(""); //刷新参数 const [refresh, setRefresh] = useState(0); //获取评标场所 const getSiteListData = (key: any) => { getSiteList().then(res => { if (res?.code == 200) { const data = res?.data; setSiteListData(data); if (key == "0" && data?.length > 0) { setExpandedRowKeys([data[0].id]); } } }) } //新建预约 const createMeet = () => { setMeetStatus("0"); setMeetId(""); setModalVisible(true); } //查看预约 const viewMeet = (id: any) => { setMeetStatus("2"); setMeetId(id); setModalVisible(true); } //查看预约详情跳转 const viewMeetContent = () => { window.open("/ElecEvalReserve"); } useEffect(() => { getSiteListData("0"); }, []) return (
已预约
未预约
rowKey="id" expandable={{ expandedRowKeys, onExpandedRowsChange: setExpandedRowKeys, }} dataSource={siteListData} toolBarRender={false} metas={{ title: { render: (_: any, record: any) => setExpandedRowKeys(keys => keys.includes(record.id) ? [] : [record.id])}>{record.areaName}, }, subTitle: { render: (_: any, record: any) => `可容纳人数:${isEmpty(record.areaNumber) ? '' : record.areaNumber}人`, }, description: { render: (_: any, record: any) => , }, }} /> {modalVisible && { setModalVisible(false); getSiteListData("1") }} roomList={siteListData} status={meetStatus} meetId={meetId} onSubmit={() => { setModalVisible(false); setRefresh(refresh => refresh + 1) }} />}
); };