feat:新增价格使用地接当前年份

main
LiaoYijun 2 months ago
parent ab8f133192
commit 134bd3ce79

@ -275,7 +275,7 @@ export const useProductsStore = create(
} }
}, },
newEmptyQuotation: () => ({ newEmptyQuotation: (useDates) => ({
id: null, id: null,
adult_cost: 0, adult_cost: 0,
child_cost: 0, child_cost: 0,
@ -283,10 +283,7 @@ export const useProductsStore = create(
unit_id: '0', unit_id: '0',
group_size_min: 1, group_size_min: 1,
group_size_max: 10, group_size_max: 10,
use_dates: [ use_dates: useDates,
dayjs().startOf('M'),
dayjs().endOf('M')
],
weekdayList: [], weekdayList: [],
fresh: true // 标识是否是新记录,新记录才用添加列表 fresh: true // 标识是否是新记录,新记录才用添加列表
}), }),

@ -133,12 +133,21 @@ const defaultDefinitionValue = {
'priceList': [defaultPriceValue] 'priceList': [defaultPriceValue]
} }
const getYearRange = (year) => [dayjs().year(year).startOf('y'), dayjs().year(year).endOf('y')]
const ProductInfoQuotation = ({ editable, ...props }) => { const ProductInfoQuotation = ({ editable, ...props }) => {
const { onChange } = props const { onChange } = props
const { t } = useTranslation() 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 [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)
@ -149,16 +158,11 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
const datePresets = useDatePresets() const datePresets = useDatePresets()
const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation, deleteQuotation, switchParams] =
useProductsStore((state) => [
state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation, state.deleteQuotation,
state.switchParams
])
useEffect(() => { useEffect(() => {
console.info('switchParams: ', switchParams) setDefaultUseDates(getYearRange(switchParams.use_year))
}, [switchParams]) }, [switchParams])
const triggerChange = (changedValue) => { const triggerChange = (changedValue) => {
onChange?.( onChange?.(
changedValue changedValue
@ -174,14 +178,13 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
} }
const onNewQuotation = () => { const onNewQuotation = () => {
const emptyQuotation = newEmptyQuotation() const emptyQuotation = newEmptyQuotation(defaultUseDates)
quotationForm.setFieldsValue(emptyQuotation) quotationForm.setFieldsValue(emptyQuotation)
setQuotationModalOpen(true) setQuotationModalOpen(true)
} }
const onQuotationFinish = (values) => { const onQuotationFinish = (values) => {
const newList = saveOrUpdateQuotation(values) const newList = saveOrUpdateQuotation(values)
console.info('newList', newList)
triggerChange(newList) triggerChange(newList)
setQuotationModalOpen(false) setQuotationModalOpen(false)
} }

Loading…
Cancel
Save