feat: 批量设置价格根据选择年份

main
LiaoYijun 2 months ago
parent 134bd3ce79
commit 9fc8057b03

@ -11,21 +11,45 @@ import { formatGroupSize } from '@/hooks/useProductsSets'
const { RangePicker } = DatePicker const { RangePicker } = DatePicker
const batchSetupInitialValues = { const defaultPriceValue = {
'priceInput': {
'numberStart': 1,
'numberEnd': 2,
'audultPrice': 0,
'childrenPrice': 0
}
}
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
const { t } = useTranslation()
const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation, deleteQuotation, switchParams] =
useProductsStore((state) => [
state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation, state.deleteQuotation,
state.switchParams
])
const batchSetupInitialValues = {
'defList': [ 'defList': [
// //
{ {
'useDateList': [ 'useDateList': [{'useDate': getYearRange(switchParams.use_year)}],
{
'useDate': [
dayjs().add(1, 'year').startOf('y'), dayjs().add(1, 'year').endOf('y')
]
}
],
'unitId': '0', 'unitId': '0',
'currency': 'RMB', 'currency': 'RMB',
'weekend': [ 'weekend': [],
],
'priceList': [ 'priceList': [
{ {
'priceInput': { 'priceInput': {
@ -66,14 +90,13 @@ const batchSetupInitialValues = {
'useDateList': [ 'useDateList': [
{ {
'useDate': [ 'useDate': [
dayjs().add(1, 'year').subtract(2, 'M').startOf('M'), dayjs().add(1, 'year').endOf('M') dayjs().year(switchParams.use_year).subtract(2, 'M').startOf('M'), dayjs().year(switchParams.use_year).endOf('M')
] ]
} }
], ],
'unitId': '0', 'unitId': '0',
'currency': 'RMB', 'currency': 'RMB',
'weekend': [ 'weekend': [],
],
'priceList': [ 'priceList': [
{ {
'priceInput': { 'priceInput': {
@ -110,44 +133,10 @@ const batchSetupInitialValues = {
] ]
} }
] ]
}
const defaultPriceValue = {
'priceInput': {
'numberStart': 1,
'numberEnd': 2,
'audultPrice': 0,
'childrenPrice': 0
} }
}
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 ProductInfoQuotation = ({ editable, ...props }) => {
const { onChange } = props
const { t } = useTranslation()
const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation, deleteQuotation, switchParams] =
useProductsStore((state) => [
state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation, state.deleteQuotation,
state.switchParams
])
const [defaultUseDates, setDefaultUseDates] = useState(getYearRange(switchParams.use_year)) const [defaultUseDates, setDefaultUseDates] = useState(getYearRange(switchParams.use_year))
const [defaultDefinitionValue, setDefaultDefinitionValue] = useState(generateDefinitionValue(switchParams.use_year))
const [isQuotationModalOpen, setQuotationModalOpen] = useState(false) const [isQuotationModalOpen, setQuotationModalOpen] = useState(false)
const [isBatchSetupModalOpen, setBatchSetupModalOpen] = useState(false) const [isBatchSetupModalOpen, setBatchSetupModalOpen] = useState(false)
const [groupSizeUnlimit, setGroupSizeUnlimit] = useState(false) const [groupSizeUnlimit, setGroupSizeUnlimit] = useState(false)
@ -160,6 +149,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
useEffect(() => { useEffect(() => {
setDefaultUseDates(getYearRange(switchParams.use_year)) setDefaultUseDates(getYearRange(switchParams.use_year))
setDefaultDefinitionValue(generateDefinitionValue(switchParams.use_year))
}, [switchParams]) }, [switchParams])
@ -340,7 +330,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
{index == 0 ? <StarTwoTone twoToneColor='#eb2f96' /> : <CloseOutlined onClick={() => useDateOptList.remove(useDateField.name)} />} {index == 0 ? <StarTwoTone twoToneColor='#eb2f96' /> : <CloseOutlined onClick={() => useDateOptList.remove(useDateField.name)} />}
</Space> </Space>
))} ))}
<Button type='dashed' icon={<PlusOutlined />} onClick={() => useDateOptList.add(defaultUseDate)} block> <Button type='dashed' icon={<PlusOutlined />} onClick={() => useDateOptList.add({'useDate': defaultUseDates})} block>
新增有效期 新增有效期
</Button> </Button>
</Flex> </Flex>

Loading…
Cancel
Save