|
|
@ -1,371 +1,366 @@
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
import { useState } from 'react';
|
|
|
|
import { Button, Card, Checkbox, Col, DatePicker, Form, Input, Row, Select, Space, Tag, Table, InputNumber } from 'antd';
|
|
|
|
import { Button, Card, Checkbox, Table, Col, Flex, DatePicker, Typography, Form, Input, Row, Select, Space } from 'antd';
|
|
|
|
import { CloseOutlined } from '@ant-design/icons';
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import { CloseOutlined, StarOutlined } from '@ant-design/icons';
|
|
|
|
import { useDatePresets } from '@/hooks/useDatePresets';
|
|
|
|
import { useDatePresets } from '@/hooks/useDatePresets';
|
|
|
|
const { Option } = Select;
|
|
|
|
const { Option } = Select;
|
|
|
|
const { RangePicker } = DatePicker;
|
|
|
|
const { RangePicker } = DatePicker;
|
|
|
|
|
|
|
|
|
|
|
|
const BatchImportPrice = ({ onBatchImportData }) => {
|
|
|
|
const BatchImportPrice = ({ onBatchImportData }) => {
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const [tags, setTags] = useState([]);
|
|
|
|
|
|
|
|
const [minPeople, setMinPeople] = useState('');
|
|
|
|
|
|
|
|
const [maxPeople, setMaxPeople] = useState('');
|
|
|
|
|
|
|
|
const [checkedDays, setCheckedDays] = useState([]);
|
|
|
|
|
|
|
|
const [tableData, setTableData] = useState([]);
|
|
|
|
|
|
|
|
const [sendData, setSendData] = useState(null);
|
|
|
|
|
|
|
|
const presets = useDatePresets();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleTagClose = (removedTag) => {
|
|
|
|
const previewTableColumns = [
|
|
|
|
setTags(tags.filter(tag => tag !== removedTag));
|
|
|
|
{ title: t('products:adultPrice'), dataIndex: 'adult_cost', width: '10%' },
|
|
|
|
};
|
|
|
|
{ title: t('products:childrenPrice'), dataIndex: 'child_cost', width: '10%' },
|
|
|
|
|
|
|
|
{ title: t('products:currency'), dataIndex: 'currency', width: '10%' },
|
|
|
|
const handleInputConfirm = () => {
|
|
|
|
{
|
|
|
|
if (minPeople && maxPeople) {
|
|
|
|
title: t('products:Types'),
|
|
|
|
const tag = `${minPeople}-${maxPeople}`;
|
|
|
|
dataIndex: 'unit',
|
|
|
|
if (tags.indexOf(tag) === -1) {
|
|
|
|
width: '10%',
|
|
|
|
setTags([...tags, tag]);
|
|
|
|
editable: true,
|
|
|
|
}
|
|
|
|
render: (text) => (text === '0' ? '每人' : text === '1' ? '每团' : text),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setMinPeople('');
|
|
|
|
{
|
|
|
|
setMaxPeople('');
|
|
|
|
title: t('products:number'),
|
|
|
|
};
|
|
|
|
dataIndex: 'group_size',
|
|
|
|
|
|
|
|
width: '10%',
|
|
|
|
const handleCheckboxChange = (checkedValues) => {
|
|
|
|
editable: true,
|
|
|
|
setCheckedDays(checkedValues);
|
|
|
|
render: (_, record) => `${record.group_size_min}-${record.group_size_max}`
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
const generateTableData = () => {
|
|
|
|
title: t('products:validityPeriod'),
|
|
|
|
const values = form.getFieldsValue();
|
|
|
|
dataIndex: 'validityPeriod',
|
|
|
|
const weekdays = checkedDays.join(',');
|
|
|
|
width: '20%',
|
|
|
|
let tempSendData = [];
|
|
|
|
editable: true,
|
|
|
|
console.log("values",values)
|
|
|
|
render: (_, record) => dayjs(record.use_dates_start).format('YYYY-MM-DD') + '~' + dayjs(record.use_dates_end).format('YYYY-MM-DD')
|
|
|
|
// 遍历 items
|
|
|
|
},
|
|
|
|
values.items.forEach((item, index) => {
|
|
|
|
{ title: t('products:Weekdays'), dataIndex: 'weekdays', width: '10%' },
|
|
|
|
// 遍历 validPeriods
|
|
|
|
]
|
|
|
|
let tempValidPeriods = []
|
|
|
|
|
|
|
|
item.validPeriods?.forEach((period) => {
|
|
|
|
|
|
|
|
console.log("period",period)
|
|
|
|
|
|
|
|
const validPeriod = period.validPeriod.map(date => date.format('YYYY-MM-DD')).join('~');
|
|
|
|
|
|
|
|
tempValidPeriods.push(validPeriod)
|
|
|
|
|
|
|
|
// 更新 tempSendData 中每一个 tag 的值
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const priceType = `批量设置价格 ${index + 1} ${item.currency}/${item.type}`
|
|
|
|
|
|
|
|
let tempData = []
|
|
|
|
|
|
|
|
const unit_name = item.type
|
|
|
|
|
|
|
|
const currency = item.currency
|
|
|
|
|
|
|
|
tags.forEach((tag) => {
|
|
|
|
|
|
|
|
tempValidPeriods.forEach(validPeriod => {
|
|
|
|
|
|
|
|
const group_size_min = tag.split('-')[0]
|
|
|
|
|
|
|
|
const group_size_max = tag.split('-')[1]
|
|
|
|
|
|
|
|
let unit_id = null
|
|
|
|
|
|
|
|
const use_dates_start = validPeriod.split('~')[0]
|
|
|
|
|
|
|
|
const use_dates_end = validPeriod.split('~')[1]
|
|
|
|
|
|
|
|
if (unit_name === "每人") {
|
|
|
|
|
|
|
|
unit_id = 0
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
unit_id = 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tempData.push({ group_size_min, group_size_max, validPeriod, unit_id, unit_name, use_dates_start, use_dates_end, currency, weekdays, tag, priceType })
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log("tempData", tempData)
|
|
|
|
|
|
|
|
tempSendData.push(...tempData)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
const [priceForm] = Form.useForm()
|
|
|
|
|
|
|
|
const [previewData, setPreviewData] = useState([])
|
|
|
|
// 设置最终的发送数据
|
|
|
|
const presets = useDatePresets()
|
|
|
|
setSendData([...tempSendData]); // 使用展开操作符确保传递给 setSendData 的是一个新对象
|
|
|
|
|
|
|
|
const data = [];
|
|
|
|
|
|
|
|
values.items.forEach((item, index) => {
|
|
|
|
|
|
|
|
item.validPeriods?.forEach((period, idx) => {
|
|
|
|
|
|
|
|
const row = {
|
|
|
|
|
|
|
|
key: `${index}-${idx}`,
|
|
|
|
|
|
|
|
priceType: `批量设置价格 ${index + 1} ${item.currency}/${item.type}`,
|
|
|
|
|
|
|
|
validPeriod: period.validPeriod.map(date => date.format('YYYY-MM-DD')).join('~'),
|
|
|
|
|
|
|
|
currency: item.currency,
|
|
|
|
|
|
|
|
type: item.type,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
tags.forEach((tag, tagIndex) => {
|
|
|
|
|
|
|
|
row[`adultPrice${tagIndex + 1}`] = 0; // Initialize with 0
|
|
|
|
|
|
|
|
row[`childrenPrice${tagIndex + 1}`] = 0; // Initialize with 0
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
data.push(row);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// setSendData([...tempSendData,data]);
|
|
|
|
|
|
|
|
setTableData(data);
|
|
|
|
|
|
|
|
// onBatchImportData(data); // 将生成的初始表格数据传递回父组件
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const previewSetupPrice = () => {
|
|
|
|
|
|
|
|
let previewList = []
|
|
|
|
|
|
|
|
const defList = priceForm.getFieldsValue().defList
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defList.forEach(definition => {
|
|
|
|
|
|
|
|
const previewPrice = definition?.priceList.map(price => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
adult_cost: price.priceInput.audultPrice,
|
|
|
|
|
|
|
|
child_cost: price.priceInput.childrenPrice,
|
|
|
|
|
|
|
|
group_size_min: price.priceInput.numberStart,
|
|
|
|
|
|
|
|
group_size_max: price.priceInput.numberEnd,
|
|
|
|
|
|
|
|
|
|
|
|
const handleTableChange = (age_type, value, tag, priceType) => {
|
|
|
|
currency: definition.currency,
|
|
|
|
if (age_type === 'adult_cost') {
|
|
|
|
unit: definition.unitName,
|
|
|
|
console.log("sendData", sendData)
|
|
|
|
use_dates_start: definition.useDate[0],
|
|
|
|
const updatedSendData = sendData.map((item) => {
|
|
|
|
use_dates_end: definition.useDate[1],
|
|
|
|
console.log("item.priceType === priceType", item.priceType === priceType)
|
|
|
|
weekdays: definition.weekend.join(','),
|
|
|
|
console.log("item.priceType", item.priceType)
|
|
|
|
|
|
|
|
console.log("priceType", priceType)
|
|
|
|
|
|
|
|
if (item.priceType === priceType && item.tag === tag) {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...item,
|
|
|
|
|
|
|
|
adult_cost: value, // 更新对应的 adult_cost 属性
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return item; // 对于不匹配的项,保持不变
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 更新 sendData
|
|
|
|
|
|
|
|
console.log("updatedSendData", updatedSendData)
|
|
|
|
|
|
|
|
onBatchImportData(updatedSendData);
|
|
|
|
|
|
|
|
setSendData(updatedSendData);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const updatedSendData = sendData.map((item) => {
|
|
|
|
|
|
|
|
if (item.priceType === priceType && item.tag === tag) {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...item,
|
|
|
|
|
|
|
|
child_cost: value, // 更新对应的 child_cost 属性
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return item; // 对于不匹配的项,保持不变
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 更新 sendData
|
|
|
|
|
|
|
|
onBatchImportData(updatedSendData);
|
|
|
|
|
|
|
|
setSendData(updatedSendData);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
|
|
|
previewList.push(...previewPrice)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
setPreviewData(previewList)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const generatePeopleColumns = () => {
|
|
|
|
const PriceInput = (props) => {
|
|
|
|
const columns = [];
|
|
|
|
const { id, value = {}, onChange } = props
|
|
|
|
tags.forEach((tag, index) => {
|
|
|
|
const [numberStart, setNumberStart] = useState(0)
|
|
|
|
columns.push({
|
|
|
|
const [numberEnd, setNumberEnd] = useState(0)
|
|
|
|
title: tag,
|
|
|
|
const [audultPrice, setAudultPrice] = useState(0)
|
|
|
|
children: [
|
|
|
|
const [childrenPrice, setChildrenPrice] = useState(0)
|
|
|
|
{
|
|
|
|
const triggerChange = (changedValue) => {
|
|
|
|
title: '成人价',
|
|
|
|
onChange?.({
|
|
|
|
dataIndex: `adultPrice${index + 1}`,
|
|
|
|
numberStart,
|
|
|
|
key: `adultPrice${index + 1}`,
|
|
|
|
numberEnd,
|
|
|
|
render: (text, record, rowIndex) => {
|
|
|
|
audultPrice,
|
|
|
|
const sameTagRecords = tableData.filter(item => item.priceType === record.priceType);
|
|
|
|
childrenPrice,
|
|
|
|
const firstTagIndex = tableData.findIndex(item => item.priceType === record.priceType && item.validPeriod === sameTagRecords[0].validPeriod);
|
|
|
|
...value,
|
|
|
|
|
|
|
|
...changedValue,
|
|
|
|
if (rowIndex === firstTagIndex) {
|
|
|
|
})
|
|
|
|
return {
|
|
|
|
}
|
|
|
|
children: (
|
|
|
|
const onNumberStartChange = (e) => {
|
|
|
|
<InputNumber
|
|
|
|
const newNumber = parseInt(e.target.value || '0', 10)
|
|
|
|
formatter={value => `${value}`}
|
|
|
|
if (Number.isNaN(numberStart)) {
|
|
|
|
parser={value => value.replace(/[^\d]/g, '')}
|
|
|
|
return
|
|
|
|
onChange={(value) => handleTableChange('adult_cost', value, tag, record.priceType)}
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
if (!('numberStart' in value)) {
|
|
|
|
),
|
|
|
|
setNumberStart(newNumber);
|
|
|
|
props: {
|
|
|
|
}
|
|
|
|
rowSpan: sameTagRecords.length,
|
|
|
|
triggerChange({
|
|
|
|
},
|
|
|
|
numberStart: newNumber,
|
|
|
|
};
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
const onNumberEndChange = (e) => {
|
|
|
|
props: {
|
|
|
|
const newNumber = parseInt(e.target.value || '0', 10)
|
|
|
|
rowSpan: 0,
|
|
|
|
if (Number.isNaN(numberEnd)) {
|
|
|
|
},
|
|
|
|
return
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!('numberEnd' in value)) {
|
|
|
|
},
|
|
|
|
setNumberEnd(newNumber)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
{
|
|
|
|
triggerChange({
|
|
|
|
title: '儿童价',
|
|
|
|
numberEnd: newNumber,
|
|
|
|
dataIndex: `childrenPrice${index + 1}`,
|
|
|
|
});
|
|
|
|
key: `childrenPrice${index + 1}`,
|
|
|
|
};
|
|
|
|
render: (text, record, rowIndex) => {
|
|
|
|
const onAudultPriceChange = (e) => {
|
|
|
|
const sameTagRecords = tableData.filter(item => item.priceType === record.priceType);
|
|
|
|
const newNumber = parseInt(e.target.value || '0', 10)
|
|
|
|
const firstTagIndex = tableData.findIndex(item => item.priceType === record.priceType && item.validPeriod === sameTagRecords[0].validPeriod);
|
|
|
|
if (Number.isNaN(audultPrice)) {
|
|
|
|
|
|
|
|
return
|
|
|
|
if (rowIndex === firstTagIndex) {
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
if (!('audultPrice' in value)) {
|
|
|
|
children: (
|
|
|
|
setAudultPrice(newNumber)
|
|
|
|
<InputNumber
|
|
|
|
}
|
|
|
|
formatter={value => `${value}`}
|
|
|
|
triggerChange({
|
|
|
|
parser={value => value.replace(/[^\d]/g, '')}
|
|
|
|
audultPrice: newNumber,
|
|
|
|
onChange={(value) => handleTableChange('child_cost', value, tag, record.priceType)}
|
|
|
|
})
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
),
|
|
|
|
const onChildrenPriceChange = (e) => {
|
|
|
|
props: {
|
|
|
|
const newNumber = parseInt(e.target.value || '0', 10)
|
|
|
|
rowSpan: sameTagRecords.length,
|
|
|
|
if (Number.isNaN(childrenPrice)) {
|
|
|
|
},
|
|
|
|
return
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!('childrenPrice' in value)) {
|
|
|
|
return {
|
|
|
|
setChildrenPrice(newNumber)
|
|
|
|
props: {
|
|
|
|
}
|
|
|
|
rowSpan: 0,
|
|
|
|
triggerChange({
|
|
|
|
},
|
|
|
|
childrenPrice: newNumber,
|
|
|
|
};
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return columns;
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
title: ' ',
|
|
|
|
|
|
|
|
dataIndex: 'priceType',
|
|
|
|
|
|
|
|
key: 'priceType',
|
|
|
|
|
|
|
|
width: "10%",
|
|
|
|
|
|
|
|
render: (text, record, index) => {
|
|
|
|
|
|
|
|
const obj = {
|
|
|
|
|
|
|
|
children: text,
|
|
|
|
|
|
|
|
props: {},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if (index > 0 && text === tableData[index - 1].priceType) {
|
|
|
|
|
|
|
|
obj.props.rowSpan = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
obj.props.rowSpan = tableData.filter(item => item.priceType === text).length;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
title: '有效期\\人等',
|
|
|
|
|
|
|
|
dataIndex: 'validPeriod',
|
|
|
|
|
|
|
|
key: 'validPeriod',
|
|
|
|
|
|
|
|
width: "15%"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
...generatePeopleColumns(),
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Space.Compact id={id}>
|
|
|
|
<Card
|
|
|
|
<Input
|
|
|
|
size="small"
|
|
|
|
type="text"
|
|
|
|
title="选择人等、周末"
|
|
|
|
value={value.numberStart || numberStart}
|
|
|
|
style={{ marginBottom: 16 }}
|
|
|
|
onChange={onNumberStartChange}
|
|
|
|
>
|
|
|
|
style={{
|
|
|
|
<Row>
|
|
|
|
width: '20%',
|
|
|
|
<Col>
|
|
|
|
}}
|
|
|
|
<Input.Group compact style={{ marginTop: 10 }}>
|
|
|
|
/>
|
|
|
|
<Input
|
|
|
|
<Input
|
|
|
|
style={{ width: 100, textAlign: 'center' }}
|
|
|
|
type="text"
|
|
|
|
placeholder="Start"
|
|
|
|
value={value.numberEnd || numberEnd}
|
|
|
|
value={minPeople}
|
|
|
|
onChange={onNumberEndChange}
|
|
|
|
onChange={(e) => setMinPeople(e.target.value)}
|
|
|
|
style={{
|
|
|
|
/>
|
|
|
|
width: '40%',
|
|
|
|
<Input
|
|
|
|
}}
|
|
|
|
style={{ width: 30, borderLeft: 0, pointerEvents: 'none', backgroundColor: '#fff' }}
|
|
|
|
addonBefore="~"
|
|
|
|
placeholder="~"
|
|
|
|
/>
|
|
|
|
disabled
|
|
|
|
<Input
|
|
|
|
/>
|
|
|
|
type="text"
|
|
|
|
<Input
|
|
|
|
value={value.audultPrice || audultPrice}
|
|
|
|
style={{ width: 100, textAlign: 'center', borderLeft: 0 }}
|
|
|
|
onChange={onAudultPriceChange}
|
|
|
|
placeholder="End"
|
|
|
|
style={{
|
|
|
|
value={maxPeople}
|
|
|
|
width: '70%',
|
|
|
|
onChange={(e) => setMaxPeople(e.target.value)}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
addonBefore="成人价"
|
|
|
|
</Input.Group>
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
<Input
|
|
|
|
|
|
|
|
type="text"
|
|
|
|
<Col>
|
|
|
|
value={value.childrenPrice || childrenPrice}
|
|
|
|
<Button size="small" type="primary" onClick={handleInputConfirm} style={{ marginLeft: 12, marginTop: 12 }}>
|
|
|
|
onChange={onChildrenPriceChange}
|
|
|
|
添加人等
|
|
|
|
style={{
|
|
|
|
</Button>
|
|
|
|
width: '70%',
|
|
|
|
</Col>
|
|
|
|
}}
|
|
|
|
</Row>
|
|
|
|
addonBefore="儿童价"
|
|
|
|
<div style={{ marginTop: 16 }}>
|
|
|
|
/>
|
|
|
|
{tags.map((tag) => (
|
|
|
|
</Space.Compact>
|
|
|
|
<Tag key={tag} closable onClose={() => handleTagClose(tag)}>
|
|
|
|
)
|
|
|
|
{tag}
|
|
|
|
}
|
|
|
|
</Tag>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Checkbox.Group
|
|
|
|
|
|
|
|
style={{ marginTop: 16 }}
|
|
|
|
|
|
|
|
options={['5', '6', '7']}
|
|
|
|
|
|
|
|
onChange={handleCheckboxChange}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Form
|
|
|
|
const priceInitialValues = {
|
|
|
|
labelCol={{ span: 6 }}
|
|
|
|
"defList": [
|
|
|
|
wrapperCol={{ span: 18 }}
|
|
|
|
// 旺季
|
|
|
|
form={form}
|
|
|
|
{
|
|
|
|
name="dynamic_form_complex"
|
|
|
|
"useDate": [
|
|
|
|
style={{ maxWidth: 600 }}
|
|
|
|
dayjs().add(1, 'year').startOf("y"), dayjs().add(1, 'year').endOf("y")
|
|
|
|
autoComplete="off"
|
|
|
|
],
|
|
|
|
initialValues={{ items: [{}] }}
|
|
|
|
"unitName": "每人",
|
|
|
|
>
|
|
|
|
"currency": "CNY",
|
|
|
|
<Form.List name="items">
|
|
|
|
"weekend": [
|
|
|
|
{(fields, { add, remove }) => (
|
|
|
|
"5",
|
|
|
|
<div style={{ display: 'flex', rowGap: 16, flexDirection: 'column' }}>
|
|
|
|
"6"
|
|
|
|
{fields.map((field, index) => (
|
|
|
|
],
|
|
|
|
<Card
|
|
|
|
"priceList": [
|
|
|
|
size="small"
|
|
|
|
{
|
|
|
|
title={`批量设置价格 ${index + 1}`}
|
|
|
|
"priceInput": {
|
|
|
|
key={field.key}
|
|
|
|
"numberStart": 1,
|
|
|
|
extra={<CloseOutlined onClick={() => remove(field.name)} />}
|
|
|
|
"numberEnd": 2,
|
|
|
|
>
|
|
|
|
"audultPrice": 0,
|
|
|
|
<Form.Item label="类型" name={[field.name, 'type']}>
|
|
|
|
"childrenPrice": 0
|
|
|
|
<Select placeholder="选择类型">
|
|
|
|
}
|
|
|
|
<Option value="每人">每人</Option>
|
|
|
|
},
|
|
|
|
<Option value="每团">每团</Option>
|
|
|
|
{
|
|
|
|
</Select>
|
|
|
|
"priceInput": {
|
|
|
|
</Form.Item>
|
|
|
|
"numberStart": 3,
|
|
|
|
|
|
|
|
"numberEnd": 4,
|
|
|
|
|
|
|
|
"audultPrice": 0,
|
|
|
|
|
|
|
|
"childrenPrice": 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"priceInput": {
|
|
|
|
|
|
|
|
"numberStart": 5,
|
|
|
|
|
|
|
|
"numberEnd": 6,
|
|
|
|
|
|
|
|
"audultPrice": 0,
|
|
|
|
|
|
|
|
"childrenPrice": 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"priceInput": {
|
|
|
|
|
|
|
|
"numberStart": 7,
|
|
|
|
|
|
|
|
"numberEnd": 9,
|
|
|
|
|
|
|
|
"audultPrice": 0,
|
|
|
|
|
|
|
|
"childrenPrice": 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// 淡季
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"useDate": [
|
|
|
|
|
|
|
|
dayjs().add(1, 'year').subtract(2, "M").startOf("M"), dayjs().add(1, 'year').endOf("M")
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
"unitName": "每人",
|
|
|
|
|
|
|
|
"currency": "CNY",
|
|
|
|
|
|
|
|
"weekend": [
|
|
|
|
|
|
|
|
"5",
|
|
|
|
|
|
|
|
"6"
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
"priceList": [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"priceInput": {
|
|
|
|
|
|
|
|
"numberStart": 1,
|
|
|
|
|
|
|
|
"numberEnd": 2,
|
|
|
|
|
|
|
|
"audultPrice": 0,
|
|
|
|
|
|
|
|
"childrenPrice": 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"priceInput": {
|
|
|
|
|
|
|
|
"numberStart": 3,
|
|
|
|
|
|
|
|
"numberEnd": 4,
|
|
|
|
|
|
|
|
"audultPrice": 0,
|
|
|
|
|
|
|
|
"childrenPrice": 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"priceInput": {
|
|
|
|
|
|
|
|
"numberStart": 5,
|
|
|
|
|
|
|
|
"numberEnd": 6,
|
|
|
|
|
|
|
|
"audultPrice": 0,
|
|
|
|
|
|
|
|
"childrenPrice": 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"priceInput": {
|
|
|
|
|
|
|
|
"numberStart": 7,
|
|
|
|
|
|
|
|
"numberEnd": 9,
|
|
|
|
|
|
|
|
"audultPrice": 0,
|
|
|
|
|
|
|
|
"childrenPrice": 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item label="币种" name={[field.name, 'currency']}>
|
|
|
|
return (
|
|
|
|
<Select placeholder="选择币种">
|
|
|
|
<Row gutter={16} justify="center">
|
|
|
|
<Option value="CNY">CNY</Option>
|
|
|
|
<Col span={12}>
|
|
|
|
<Option value="USD">USD</Option>
|
|
|
|
<Form
|
|
|
|
</Select>
|
|
|
|
labelCol={{ span: 3 }}
|
|
|
|
</Form.Item>
|
|
|
|
wrapperCol={{ span: 20 }}
|
|
|
|
|
|
|
|
form={priceForm}
|
|
|
|
|
|
|
|
name="priceForm"
|
|
|
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
|
|
|
initialValues={priceInitialValues}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Form.List name="defList">
|
|
|
|
|
|
|
|
{(fields, { add, remove }) => (
|
|
|
|
|
|
|
|
<Flex gap="middle" vertical>
|
|
|
|
|
|
|
|
{fields.map((field, index) => (
|
|
|
|
|
|
|
|
<Card
|
|
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
|
|
title={index==0?'旺季':index==1?'淡季':'其他'}
|
|
|
|
|
|
|
|
key={field.key}
|
|
|
|
|
|
|
|
extra={index==0?null:<CloseOutlined onClick={() => {
|
|
|
|
|
|
|
|
remove(field.name)
|
|
|
|
|
|
|
|
}} />}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Form.Item label="类型" name={[field.name, 'unitName']}>
|
|
|
|
|
|
|
|
<Select placeholder="选择类型">
|
|
|
|
|
|
|
|
<Option value="每人">每人</Option>
|
|
|
|
|
|
|
|
<Option value="每团">每团</Option>
|
|
|
|
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Item label="有效期">
|
|
|
|
<Form.Item label="币种" name={[field.name, 'currency']}>
|
|
|
|
<Form.List name={[field.name, 'validPeriods']}>
|
|
|
|
<Select placeholder="选择币种">
|
|
|
|
{(periodFields, periodOpt) => (
|
|
|
|
<Option value="CNY">CNY</Option>
|
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', rowGap: 16 }}>
|
|
|
|
<Option value="USD">USD</Option>
|
|
|
|
{periodFields.map((periodField, idx) => (
|
|
|
|
</Select>
|
|
|
|
<Space key={periodField.key}>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item noStyle name={[periodField.name, 'validPeriod']}>
|
|
|
|
<Form.Item label="有效期" name={[field.name, 'useDate']}>
|
|
|
|
<RangePicker allowClear={true} inputReadOnly={true} presets={presets} placeholder={['From', 'Thru']}/>
|
|
|
|
<RangePicker style={{width: '100%'}} allowClear={true} inputReadOnly={true} presets={presets} placeholder={['From', 'Thru']} />
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|
<CloseOutlined onClick={() => periodOpt.remove(periodField.name)} />
|
|
|
|
<Form.Item label="周末" name={[field.name, 'weekend']}>
|
|
|
|
</Space>
|
|
|
|
<Checkbox.Group
|
|
|
|
))}
|
|
|
|
options={['5', '6', '7']}
|
|
|
|
<Button type="dashed" onClick={() => periodOpt.add()} block>
|
|
|
|
/>
|
|
|
|
+ 新增有效期
|
|
|
|
</Form.Item>
|
|
|
|
</Button>
|
|
|
|
<Form.Item label="人等">
|
|
|
|
</div>
|
|
|
|
<Form.List name={[field.name, 'priceList']}>
|
|
|
|
)}
|
|
|
|
{(priceFieldList, priceOptList) => (
|
|
|
|
</Form.List>
|
|
|
|
<Flex gap="middle" vertical>
|
|
|
|
</Form.Item>
|
|
|
|
{priceFieldList.map((priceField, index) => (
|
|
|
|
</Card>
|
|
|
|
<Space key={priceField.key}>
|
|
|
|
|
|
|
|
<Form.Item noStyle name={[priceField.name, 'priceInput']}>
|
|
|
|
|
|
|
|
<PriceInput />
|
|
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
{index==0?<StarOutlined />:<CloseOutlined onClick={() => priceOptList.remove(priceField.name)} />}
|
|
|
|
|
|
|
|
</Space>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
<Button type="dashed" onClick={() => add()} block>
|
|
|
|
<Button type="dashed" onClick={() => priceOptList.add()} block>
|
|
|
|
+ 新增价格设置
|
|
|
|
+ 新增人等
|
|
|
|
</Button>
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</Flex>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
</Form.List>
|
|
|
|
</Form.List>
|
|
|
|
</Form>
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
</Card>
|
|
|
|
<Button type="primary" onClick={generateTableData} style={{ marginTop: 20 }}>
|
|
|
|
))}
|
|
|
|
生成表格
|
|
|
|
<Button type="dashed" onClick={() => add()} block>
|
|
|
|
</Button>
|
|
|
|
+ 新增价格设置
|
|
|
|
|
|
|
|
</Button>
|
|
|
|
{tableData.length > 0 && (
|
|
|
|
</Flex>
|
|
|
|
<div style={{ overflowX: 'auto' }}>
|
|
|
|
)}
|
|
|
|
<Table
|
|
|
|
</Form.List>
|
|
|
|
style={{ marginTop: 20 }}
|
|
|
|
<Form.Item noStyle shouldUpdate>
|
|
|
|
columns={columns}
|
|
|
|
{() => (
|
|
|
|
dataSource={tableData}
|
|
|
|
<Typography className='hidden'>
|
|
|
|
pagination={false}
|
|
|
|
<pre>{JSON.stringify(priceForm.getFieldsValue(), null, 2)}</pre>
|
|
|
|
/>
|
|
|
|
</Typography>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</Form.Item>
|
|
|
|
);
|
|
|
|
</Form>
|
|
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
|
|
<Button type="dashed" onClick={() => previewSetupPrice()} block>
|
|
|
|
|
|
|
|
预览
|
|
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<Table
|
|
|
|
|
|
|
|
bordered
|
|
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
|
|
dataSource={previewData}
|
|
|
|
|
|
|
|
columns={previewTableColumns}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default BatchImportPrice;
|
|
|
|
export default BatchImportPrice;
|
|
|
|