This commit is contained in:
jl-zhoujl2
2022-08-04 10:45:22 +08:00
parent cde9e97e96
commit ce82c1552e
2 changed files with 155 additions and 95 deletions

View File

@ -1,12 +1,15 @@
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 } from 'antd';
import React, { useEffect, useState } from 'react';
import { Button, Card, Space, Tag } from 'antd';
import React, { ReactText, useEffect, useState } from 'react';
import { useRef } from 'react';
import MeetingReservation from './components/MeetingReservation';
const orange_bg = { background: '#f59a23', color: '#0000ff' };
const green_bg = { background: '#4b7902' };
const align_middle = { display: 'flex', alignItems: 'center' };
const tag_size = { height: '20px', width: '20px' };
const data = {
week: [
@ -290,70 +293,84 @@ const data = {
]
}
const columns: ProColumns<any>[] = [
const dataSource = [
{
title: '评标室名称',
dataIndex: 'name',
align: 'center',
render: (_, record, index) => {
return {
children: _,
props: {
rowSpan: index % 24 == 0 ? 24 : 0,
}
}
}
"id": "1",
"title": '集团第一评标室',
"rs": "10",
},
{
title: '可容纳人数(人)',
dataIndex: 'rs',
align: 'center',
render: (_, record, index) => {
return {
children: _,
props: {
rowSpan: index % 24 == 0 ? 24 : 0,
}
}
}
"id": "2",
"title": '集团第二评标室',
"rs": "18",
},
{
title: '场次',
align: 'center',
colSpan: 2,
render: (_, record, index) => {
return {
children: "00:00 ~ 24:00",
props: {
rowSpan: index % 24 == 0 ? 24 : 0,
}
}
}
},
{
dataIndex: "time",
align: 'right',
width: '60px',
colSpan: 0,
},
{
title: '预约时间',
dataIndex: "info_time",
valueType: 'date',
hideInTable: true,
},
];
"id": "3",
"title": '集团第三评标室',
"rs": "29",
}
]
export default () => {
const ScreenTable = (props: { tableData: any[], tabColumns: any[], record: any }) => {
const { tableData, tabColumns, record } = props;
const actionRef = useRef<ActionType>();
//表格列
const [tableColumns, setTableColumns] = useState<ProColumns<any>[]>([]);
//表格数据
const [tableData, setTableData] = useState<any[]>([]);
//预约弹窗
const [modalVisible, setModalVisible] = useState<boolean>(false);
const columns: ProColumns<any>[] = [
{
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: '60px',
colSpan: 0,
},
{
title: '预约时间',
dataIndex: "info_time",
valueType: 'date',
hideInTable: true,
},
];
useEffect(() => {
for (const ite of data.week) {
for (const ite of tabColumns) {
columns.push({
title: <span>{ite.week}<br />{ite.date}</span>,
dataIndex: ite.id,
@ -375,10 +392,17 @@ export default () => {
})
}
setTableColumns(columns);
setTableData(data.data);
}, []);
return (
<Card title="评标室预约情况" bodyStyle={{ padding: '1px 24px 24px', height: window.innerHeight - 120, overflowY: 'auto' }}>
<div>
<Space style={{ margin: '10px 0' }}>
<Button key="last-week" size='small' type="primary">
</Button>
<Button key="after-week" size='small' type="primary">
</Button>
</Space>
<ProTable<any>
columns={tableColumns}
actionRef={actionRef}
@ -390,31 +414,49 @@ export default () => {
pagination={false}
options={false}
dateFormatter="string"
toolbar={{
title: (
<Space>
<Button key="last-week" type="primary">
</Button>
<Button key="after-week" type="primary">
</Button>
<Button key="yuyue" type="primary" onClick={() => setModalVisible(true)}>
</Button>
</Space>
),
actions: [
<Button key="yuyueconfirm" type="primary">
</Button>,
<Button key="reserved" type="primary" style={{ background: '#f59a23', cursor: 'default', border: 'none' }}>
</Button>,
<Button key="no-appo" type="primary" style={{ background: '#4b7902', cursor: 'default', border: 'none' }}>
</Button>,
],
/>
</div>
)
}
export default () => {
//预约弹窗
const [modalVisible, setModalVisible] = useState<boolean>(false);
const [expandedRowKeys, setExpandedRowKeys] = useState<readonly ReactText[]>([]);
return (
<Card title="评标室预约情况" bodyStyle={{ padding: '16px 0px 24px', height: window.innerHeight - 120, overflowY: 'auto' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '0 24px 16px' }}>
<Space>
<Button key="yuyue" type="primary" onClick={() => setModalVisible(true)}>
</Button>
<Button key="yuyueconfirm">
</Button>
</Space>
<Space>
<div style={align_middle}><Tag color="#f59a23" style={tag_size}></Tag></div>
<div style={align_middle}><Tag color="#4b7902" style={tag_size}></Tag></div>
</Space>
</div>
<ProList<any>
rowKey="id"
expandable={{
expandedRowKeys, onExpandedRowsChange: setExpandedRowKeys,
}}
dataSource={dataSource}
toolBarRender={false}
metas={{
title: {
render: (_: any, record: any) => <span onClick={() => setExpandedRowKeys(keys => keys.includes(record.id) ? [] : [record.id])}>{record.title}</span>,
},
subTitle: {
render: (_: any, record: any) => `可容纳人数:${record.rs}`,
},
description: {
render: (_: any, record: any) => <ScreenTable tableData={data.data} tabColumns={data.week} record={record} />,
},
}}
/>
{modalVisible && <MeetingReservation modalVisible={modalVisible} onCancel={() => setModalVisible(false)} />}