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

main
LiaoYijun 2 months ago
parent ab8f133192
commit 134bd3ce79

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

@ -133,12 +133,21 @@ const defaultDefinitionValue = {
'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 [isQuotationModalOpen, setQuotationModalOpen] = useState(false)
const [isBatchSetupModalOpen, setBatchSetupModalOpen] = useState(false)
const [groupSizeUnlimit, setGroupSizeUnlimit] = useState(false)
@ -149,16 +158,11 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
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(() => {
console.info('switchParams: ', switchParams)
setDefaultUseDates(getYearRange(switchParams.use_year))
}, [switchParams])
const triggerChange = (changedValue) => {
onChange?.(
changedValue
@ -174,14 +178,13 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
}
const onNewQuotation = () => {
const emptyQuotation = newEmptyQuotation()
const emptyQuotation = newEmptyQuotation(defaultUseDates)
quotationForm.setFieldsValue(emptyQuotation)
setQuotationModalOpen(true)
}
const onQuotationFinish = (values) => {
const newList = saveOrUpdateQuotation(values)
console.info('newList', newList)
triggerChange(newList)
setQuotationModalOpen(false)
}

Loading…
Cancel
Save