|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
import { useState, useEffect } from 'react'
|
|
|
|
|
import { useParams, useNavigate } from 'react-router-dom'
|
|
|
|
|
import { Row, Col, Modal, Space, Form, Typography, DatePicker, Input, Button, App } from 'antd'
|
|
|
|
|
import { Row, Col, Modal, InputNumber, Form, Typography, DatePicker, Input, Button, App } from 'antd'
|
|
|
|
|
import useHotelStore from '@/stores/Hotel'
|
|
|
|
|
import { HotelList, RoomList } from "./HotelComponents";
|
|
|
|
|
import { ExclamationCircleFilled } from '@ant-design/icons'
|
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
import { isEmpty } from '@/utils/commons'
|
|
|
|
|
const { Title } = Typography
|
|
|
|
|
|
|
|
|
|
function Detail() {
|
|
|
|
@ -18,6 +20,7 @@ function Detail() {
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
const [searchForm] = Form.useForm()
|
|
|
|
|
const { notification, modal } = App.useApp()
|
|
|
|
|
const [selectedHotel, getRoomListByHotel, roomList] =
|
|
|
|
|
useHotelStore(state =>
|
|
|
|
@ -25,12 +28,35 @@ function Detail() {
|
|
|
|
|
|
|
|
|
|
useEffect (() => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// http://localhost:5175/hotel/416980/2024-09-10/2024-09-11
|
|
|
|
|
if (isEmpty(hotelId) || isEmpty(checkin) || isEmpty(checkout)) {
|
|
|
|
|
console.info('criteria is null')
|
|
|
|
|
} else {
|
|
|
|
|
searchForm.setFieldsValue({
|
|
|
|
|
dataRange: [dayjs(checkin), dayjs(checkout)],
|
|
|
|
|
adultCount: 2,
|
|
|
|
|
roomCount: 1
|
|
|
|
|
})
|
|
|
|
|
setLoading(true)
|
|
|
|
|
getRoomListByHotel(hotelId, checkin, checkout)
|
|
|
|
|
.finally(() => setLoading(false))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
const handelFormFinish = () => {
|
|
|
|
|
const formValue = searchForm.getFieldValue()
|
|
|
|
|
// setSearchParams({
|
|
|
|
|
// hotel: formValue.hotelName,
|
|
|
|
|
// checkin: formValue.dataRange[0].format('YYYY-MM-DD'),
|
|
|
|
|
// checkout: formValue.dataRange[1].format('YYYY-MM-DD')
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
setLoading(true)
|
|
|
|
|
getRoomListByHotel(hotelId, checkin, checkout, formValue.adultCount, formValue.roomCount)
|
|
|
|
|
.finally(() => setLoading(false))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleRoomChange = (room, plan) => {
|
|
|
|
|
console.info('room: ', room)
|
|
|
|
|
console.info('plan: ', plan)
|
|
|
|
@ -60,26 +86,62 @@ function Detail() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div className='min-w-[1152px]'>
|
|
|
|
|
<input type='hidden' id='forHtJson' />
|
|
|
|
|
<Modal title='你选择了' open={isModalOpen} onOk={handleOk} onCancel={handleCancel}>
|
|
|
|
|
<p>酒店:{hotelQuotation.hotelName}</p>
|
|
|
|
|
<p>房型:{hotelQuotation.roomName}</p>
|
|
|
|
|
<p>价格:{hotelQuotation.price}</p>
|
|
|
|
|
</Modal>
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
<Col span={20}>
|
|
|
|
|
|
|
|
|
|
<Typography.Title level={4}>
|
|
|
|
|
{selectedHotel.hotel_name}
|
|
|
|
|
</Typography.Title>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={4}>
|
|
|
|
|
<Button onClick={() => navigate(-1)}>Back</Button>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
<div className='p-2'>
|
|
|
|
|
<Form
|
|
|
|
|
name='searchForm'
|
|
|
|
|
form={searchForm}
|
|
|
|
|
layout='inline'
|
|
|
|
|
onFinish={handelFormFinish}
|
|
|
|
|
onFinishFailed={() => console.info('onFinishFailed')}
|
|
|
|
|
autoComplete='off'
|
|
|
|
|
>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={'入住时间'}
|
|
|
|
|
name='dataRange'
|
|
|
|
|
allowClear={false}
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '必填',
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<DatePicker.RangePicker placeholder={['入住日期', '退房日期']} />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={'房间数'}
|
|
|
|
|
name='roomCount'
|
|
|
|
|
>
|
|
|
|
|
<InputNumber min={1} max={100} />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
label={'人数'}
|
|
|
|
|
name='adultCount'
|
|
|
|
|
>
|
|
|
|
|
<InputNumber min={1} max={100} />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item>
|
|
|
|
|
<Button type='primary' htmlType='submit'>搜索</Button>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item>
|
|
|
|
|
<Button onClick={() => navigate(-1)}>返回</Button>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
</div>
|
|
|
|
|
<RoomList loading={loading} onChange={({room, plan}) => {handleRoomChange(room, plan)}} dataSource={roomList}></RoomList>
|
|
|
|
|
</>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Detail;
|
|
|
|
|
export default Detail
|
|
|
|
|