|
|
|
@ -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)
|
|
|
|
|
}
|
|
|
|
|