diff --git a/src/views/products/Detail/ProductInfoQuotation.jsx b/src/views/products/Detail/ProductInfoQuotation.jsx index 5fe6a89..ceb0054 100644 --- a/src/views/products/Detail/ProductInfoQuotation.jsx +++ b/src/views/products/Detail/ProductInfoQuotation.jsx @@ -11,107 +11,6 @@ import { formatGroupSize } from '@/hooks/useProductsSets' const { RangePicker } = DatePicker -const batchSetupInitialValues = { - 'defList': [ - // 旺季 - { - 'useDateList': [ - { - 'useDate': [ - dayjs().add(1, 'year').startOf('y'), dayjs().add(1, 'year').endOf('y') - ] - } - ], - 'unitId': '0', - 'currency': 'RMB', - 'weekend': [ - ], - '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 - } - } - ] - }, - // 淡季 - { - 'useDateList': [ - { - 'useDate': [ - dayjs().add(1, 'year').subtract(2, 'M').startOf('M'), dayjs().add(1, 'year').endOf('M') - ] - } - ], - 'unitId': '0', - 'currency': 'RMB', - 'weekend': [ - ], - '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 - } - } - ] - } - ] -} - const defaultPriceValue = { 'priceInput': { 'numberStart': 1, @@ -121,20 +20,16 @@ const defaultPriceValue = { } } -const defaultUseDate = { - 'useDate': [dayjs().add(1, 'year').startOf('y'), dayjs().add(1, 'year').endOf('y')] -} - -const defaultDefinitionValue = { - 'useDateList': [defaultUseDate], - 'unitId': '0', - 'currency': 'RMB', - 'weekend': [], - 'priceList': [defaultPriceValue] -} - const getYearRange = (year) => [dayjs().year(year).startOf('y'), dayjs().year(year).endOf('y')] +const generateDefinitionValue = (year) => ({ + 'useDateList': [{'useDate': getYearRange(year)}], + 'unitId': '0', + 'currency': 'RMB', + 'weekend': [], + 'priceList': [defaultPriceValue] + }) + const ProductInfoQuotation = ({ editable, ...props }) => { const { onChange } = props @@ -147,7 +42,101 @@ const ProductInfoQuotation = ({ editable, ...props }) => { state.switchParams ]) + const batchSetupInitialValues = { + 'defList': [ + // 旺季 + { + 'useDateList': [{'useDate': getYearRange(switchParams.use_year)}], + 'unitId': '0', + 'currency': 'RMB', + 'weekend': [], + '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 + } + } + ] + }, + // 淡季 + { + 'useDateList': [ + { + 'useDate': [ + dayjs().year(switchParams.use_year).subtract(2, 'M').startOf('M'), dayjs().year(switchParams.use_year).endOf('M') + ] + } + ], + 'unitId': '0', + 'currency': 'RMB', + 'weekend': [], + '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 + } + } + ] + } + ] + } + const [defaultUseDates, setDefaultUseDates] = useState(getYearRange(switchParams.use_year)) + const [defaultDefinitionValue, setDefaultDefinitionValue] = useState(generateDefinitionValue(switchParams.use_year)) const [isQuotationModalOpen, setQuotationModalOpen] = useState(false) const [isBatchSetupModalOpen, setBatchSetupModalOpen] = useState(false) const [groupSizeUnlimit, setGroupSizeUnlimit] = useState(false) @@ -160,6 +149,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => { useEffect(() => { setDefaultUseDates(getYearRange(switchParams.use_year)) + setDefaultDefinitionValue(generateDefinitionValue(switchParams.use_year)) }, [switchParams]) @@ -340,7 +330,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => { {index == 0 ? : useDateOptList.remove(useDateField.name)} />} ))} -