|
|
@ -1,7 +1,7 @@
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import { useState } from 'react'
|
|
|
|
import { Table, Form, Modal, Button, Radio, Input, Flex, Card, Select, Typography, InputNumber, Checkbox, DatePicker, Space } from 'antd'
|
|
|
|
import { Table, Form, Modal, Button, Radio, Input, Flex, Card, Select, InputNumber, Checkbox, DatePicker, Space, App } from 'antd'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { CloseOutlined, StarTwoTone, PlusOutlined, ExclamationCircleFilled } from '@ant-design/icons';
|
|
|
|
import { CloseOutlined, StarTwoTone, PlusOutlined, ExclamationCircleFilled } from '@ant-design/icons'
|
|
|
|
import { useDatePresets } from '@/hooks/useDatePresets'
|
|
|
|
import { useDatePresets } from '@/hooks/useDatePresets'
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import useProductsStore from '@/stores/Products/Index'
|
|
|
|
import useProductsStore from '@/stores/Products/Index'
|
|
|
@ -30,7 +30,7 @@ const PriceInput = (props) => {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!('numberStart' in value)) {
|
|
|
|
if (!('numberStart' in value)) {
|
|
|
|
setNumberStart(newNumber);
|
|
|
|
setNumberStart(newNumber)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
triggerChange({
|
|
|
|
triggerChange({
|
|
|
|
numberStart: newNumber,
|
|
|
|
numberStart: newNumber,
|
|
|
@ -46,8 +46,8 @@ const PriceInput = (props) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
triggerChange({
|
|
|
|
triggerChange({
|
|
|
|
numberEnd: newNumber,
|
|
|
|
numberEnd: newNumber,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
};
|
|
|
|
}
|
|
|
|
const onAudultPriceChange = (e) => {
|
|
|
|
const onAudultPriceChange = (e) => {
|
|
|
|
const newNumber = parseInt(e.target.value || '0', 10)
|
|
|
|
const newNumber = parseInt(e.target.value || '0', 10)
|
|
|
|
if (Number.isNaN(audultPrice)) {
|
|
|
|
if (Number.isNaN(audultPrice)) {
|
|
|
@ -71,7 +71,7 @@ const PriceInput = (props) => {
|
|
|
|
triggerChange({
|
|
|
|
triggerChange({
|
|
|
|
childrenPrice: newNumber,
|
|
|
|
childrenPrice: newNumber,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Space.Compact id={id}>
|
|
|
|
<Space.Compact id={id}>
|
|
|
|
<Input
|
|
|
|
<Input
|
|
|
@ -121,7 +121,7 @@ const batchSetupInitialValues = {
|
|
|
|
dayjs().add(1, 'year').startOf('y'), dayjs().add(1, 'year').endOf('y')
|
|
|
|
dayjs().add(1, 'year').startOf('y'), dayjs().add(1, 'year').endOf('y')
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'unitId': '0',
|
|
|
|
'unitId': '0',
|
|
|
|
'currency': 'CNY',
|
|
|
|
'currency': 'RMB',
|
|
|
|
'weekend': [
|
|
|
|
'weekend': [
|
|
|
|
'5',
|
|
|
|
'5',
|
|
|
|
'6'
|
|
|
|
'6'
|
|
|
@ -167,7 +167,7 @@ const batchSetupInitialValues = {
|
|
|
|
dayjs().add(1, 'year').subtract(2, 'M').startOf('M'), dayjs().add(1, 'year').endOf('M')
|
|
|
|
dayjs().add(1, 'year').subtract(2, 'M').startOf('M'), dayjs().add(1, 'year').endOf('M')
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'unitId': '0',
|
|
|
|
'unitId': '0',
|
|
|
|
'currency': 'CNY',
|
|
|
|
'currency': 'RMB',
|
|
|
|
'weekend': [
|
|
|
|
'weekend': [
|
|
|
|
'5',
|
|
|
|
'5',
|
|
|
|
'6'
|
|
|
|
'6'
|
|
|
@ -224,7 +224,7 @@ const defaultDefinitionValue = {
|
|
|
|
dayjs().add(1, 'year').subtract(2, 'M').startOf('M'), dayjs().add(1, 'year').endOf('M')
|
|
|
|
dayjs().add(1, 'year').subtract(2, 'M').startOf('M'), dayjs().add(1, 'year').endOf('M')
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'unitId': '0',
|
|
|
|
'unitId': '0',
|
|
|
|
'currency': 'CNY',
|
|
|
|
'currency': 'RMB',
|
|
|
|
'weekend': [
|
|
|
|
'weekend': [
|
|
|
|
'5',
|
|
|
|
'5',
|
|
|
|
'6'
|
|
|
|
'6'
|
|
|
@ -242,6 +242,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
|
|
|
|
|
|
|
|
const [isQuotationModalOpen, setQuotationModalOpen] = useState(false)
|
|
|
|
const [isQuotationModalOpen, setQuotationModalOpen] = useState(false)
|
|
|
|
const [isBatchSetupModalOpen, setBatchSetupModalOpen] = useState(false)
|
|
|
|
const [isBatchSetupModalOpen, setBatchSetupModalOpen] = useState(false)
|
|
|
|
|
|
|
|
const { modal } = App.useApp();
|
|
|
|
const [quotationForm] = Form.useForm()
|
|
|
|
const [quotationForm] = Form.useForm()
|
|
|
|
const [batchSetupForm] = Form.useForm()
|
|
|
|
const [batchSetupForm] = Form.useForm()
|
|
|
|
|
|
|
|
|
|
|
@ -259,6 +260,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
const onQuotationSeleted = async (quotation) => {
|
|
|
|
const onQuotationSeleted = async (quotation) => {
|
|
|
|
// 把 start, end 转换为 RangePicker 数组格式
|
|
|
|
// 把 start, end 转换为 RangePicker 数组格式
|
|
|
|
quotation.use_dates = [dayjs(quotation.use_dates_start), dayjs(quotation.use_dates_end)]
|
|
|
|
quotation.use_dates = [dayjs(quotation.use_dates_start), dayjs(quotation.use_dates_end)]
|
|
|
|
|
|
|
|
quotation.weekdayList = quotation.weekdays.split(',')
|
|
|
|
quotationForm.setFieldsValue(quotation)
|
|
|
|
quotationForm.setFieldsValue(quotation)
|
|
|
|
setQuotationModalOpen(true)
|
|
|
|
setQuotationModalOpen(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -276,30 +278,9 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const onBatchSetupFinish = () => {
|
|
|
|
const onBatchSetupFinish = () => {
|
|
|
|
let priceList = []
|
|
|
|
|
|
|
|
const defList = batchSetupForm.getFieldsValue().defList
|
|
|
|
const defList = batchSetupForm.getFieldsValue().defList
|
|
|
|
|
|
|
|
const newList = appendQuotationList(defList)
|
|
|
|
defList.forEach(definition => {
|
|
|
|
triggerChange(newList)
|
|
|
|
const mappedPriceList = definition?.priceList.map(price => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
id: null,
|
|
|
|
|
|
|
|
adult_cost: price.priceInput.audultPrice,
|
|
|
|
|
|
|
|
child_cost: price.priceInput.childrenPrice,
|
|
|
|
|
|
|
|
group_size_min: price.priceInput.numberStart,
|
|
|
|
|
|
|
|
group_size_max: price.priceInput.numberEnd,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currency: definition.currency,
|
|
|
|
|
|
|
|
unit_id: definition.unitId,
|
|
|
|
|
|
|
|
// 保持和 API 返回格式一致,日期要转换为字符串
|
|
|
|
|
|
|
|
use_dates_start: definition.useDate[0].format('YYYY-MM-DD'),
|
|
|
|
|
|
|
|
use_dates_end: definition.useDate[1].format('YYYY-MM-DD'),
|
|
|
|
|
|
|
|
weekdays: definition.weekend.join(','),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
priceList.push(...mappedPriceList)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appendQuotationList(priceList)
|
|
|
|
|
|
|
|
setBatchSetupModalOpen(false)
|
|
|
|
setBatchSetupModalOpen(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -337,16 +318,13 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
<Space>
|
|
|
|
<Space>
|
|
|
|
<Button type='link' onClick={() => onQuotationSeleted(quotation)}>{t('Edit')}</Button>
|
|
|
|
<Button type='link' onClick={() => onQuotationSeleted(quotation)}>{t('Edit')}</Button>
|
|
|
|
<Button type='link' danger onClick={() => {
|
|
|
|
<Button type='link' danger onClick={() => {
|
|
|
|
Modal.confirm({
|
|
|
|
modal.confirm({
|
|
|
|
title: '请确认',
|
|
|
|
title: '请确认',
|
|
|
|
icon: <ExclamationCircleFilled />,
|
|
|
|
icon: <ExclamationCircleFilled />,
|
|
|
|
content: '你要删除这条价格吗?',
|
|
|
|
content: '你要删除这条价格吗?',
|
|
|
|
onOk() {
|
|
|
|
onOk() {
|
|
|
|
deleteQuotation(quotation.id)
|
|
|
|
deleteQuotation(quotation.id)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onCancel() {
|
|
|
|
|
|
|
|
console.log('Cancel');
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}}>{t('Delete')}</Button>
|
|
|
|
}}>{t('Delete')}</Button>
|
|
|
|
</Space>
|
|
|
|
</Space>
|
|
|
@ -359,7 +337,6 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<h2>{t('products:EditComponents.Quotation')}</h2>
|
|
|
|
<h2>{t('products:EditComponents.Quotation')}</h2>
|
|
|
|
<Table
|
|
|
|
<Table
|
|
|
|
// rowKey={'id'}
|
|
|
|
|
|
|
|
bordered
|
|
|
|
bordered
|
|
|
|
dataSource={quotationList}
|
|
|
|
dataSource={quotationList}
|
|
|
|
columns={quotationColumns}
|
|
|
|
columns={quotationColumns}
|
|
|
@ -408,7 +385,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<Form.Item label='币种' name={[field.name, 'currency']}>
|
|
|
|
<Form.Item label='币种' name={[field.name, 'currency']}>
|
|
|
|
<Select placeholder='选择币种'>
|
|
|
|
<Select placeholder='选择币种'>
|
|
|
|
<Select.Option value='CNY'>CNY</Select.Option>
|
|
|
|
<Select.Option value='RMB'>RMB</Select.Option>
|
|
|
|
<Select.Option value='USD'>USD</Select.Option>
|
|
|
|
<Select.Option value='USD'>USD</Select.Option>
|
|
|
|
</Select>
|
|
|
|
</Select>
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
@ -453,13 +430,6 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
</Flex>
|
|
|
|
</Flex>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
</Form.List>
|
|
|
|
</Form.List>
|
|
|
|
<Form.Item noStyle shouldUpdate>
|
|
|
|
|
|
|
|
{() => (
|
|
|
|
|
|
|
|
<Typography className='hidden'>
|
|
|
|
|
|
|
|
<pre>{JSON.stringify(batchSetupForm.getFieldsValue(), null, 2)}</pre>
|
|
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
</Form>
|
|
|
|
</Form>
|
|
|
|
</Modal>
|
|
|
|
</Modal>
|
|
|
|
|
|
|
|
|
|
|
@ -488,6 +458,8 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<Form.Item name='id' className='hidden' ><Input /></Form.Item>
|
|
|
|
<Form.Item name='id' className='hidden' ><Input /></Form.Item>
|
|
|
|
|
|
|
|
<Form.Item name='key' className='hidden' ><Input /></Form.Item>
|
|
|
|
|
|
|
|
<Form.Item name='fresh' className='hidden' ><Input /></Form.Item>
|
|
|
|
<Form.Item
|
|
|
|
<Form.Item
|
|
|
|
label={t('products:adultPrice')}
|
|
|
|
label={t('products:adultPrice')}
|
|
|
|
name='adult_cost'
|
|
|
|
name='adult_cost'
|
|
|
@ -580,7 +552,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item
|
|
|
|
<Form.Item
|
|
|
|
label={t('products:Weekdays')}
|
|
|
|
label={t('products:Weekdays')}
|
|
|
|
name='weekdays'
|
|
|
|
name='weekdayList'
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<Checkbox.Group options={['5', '6', '7']} />
|
|
|
|
<Checkbox.Group options={['5', '6', '7']} />
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|