feat: 价格使用 Form 管理

perf/export-docx
Jimmy Liow 11 months ago
parent b3faf7453e
commit a186142cc0

@ -180,9 +180,8 @@ export const useProductsStore = create(
saveOrUpdateQuotation: (formValues) => {
const { quotationList } = get()
console.info('formValues: ', formValues)
const prevList = quotationList.filter(q => q.id === formValues.id)
console.info(prevList)
if (prevList.length > 0) {
formValues.use_dates_start = formValues.use_dates[0].format('YYYY-MM-DD')
@ -199,6 +198,10 @@ export const useProductsStore = create(
console.log(`${key}: ${prevValue} - ${value} (${hasChanged})`)
}
}
set((state) => ({
quotationList: [...state.quotationList, ...[formValues]]
}))
},
// side effects

@ -134,8 +134,10 @@ const InfoForm = ({ onSubmit, onReset, onValuesChange, editable: _editable, show
</div>
</Form.Item>
)}
<Form.Item name='quotation_mapped'>
<ProductInfoQuotation editable={editable} />
</Form.Item>
</Form>
<ProductInfoQuotation editable={editable} />
</>
);
};
@ -380,6 +382,13 @@ const formValuesMapper = (values) => {
},
},
],
'quotation_mapped': {
key: 'quotation',
transform: (value) => {
console.info(value)
return value.quotationList
},
},
};
let dest = {};
const { city, ...omittedValue } = values;

@ -236,6 +236,9 @@ const defaultDefinitionValue = {
const ProductInfoQuotation = ({ editable, ...props }) => {
const { id, value = {}, onChange } = props
const { t } = useTranslation()
const [isQuotationModalOpen, setQuotationModalOpen] = useState(false)
@ -243,14 +246,18 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
const [quotationForm] = Form.useForm()
const [batchSetupForm] = Form.useForm()
// console.info('value: ', value)
const datePresets = useDatePresets()
const [newEmptyQuotation, appendQuotationList, quotationList, saveOrUpdateQuotation] =
useProductsStore((state) => [state.newEmptyQuotation, state.appendQuotationList, state.quotationList, state.saveOrUpdateQuotation])
const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation] =
useProductsStore((state) => [state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation])
useEffect(() => {
console.info('quotationList: ', quotationList)
}, [quotationList])
const triggerChange = (changedValue) => {
onChange?.({
quotationList
})
}
const onQuotationSeleted = async (quotation) => {
// start, end RangePicker
@ -267,6 +274,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
const onQuotationFinish = (values) => {
saveOrUpdateQuotation(values)
triggerChange(quotationList)
setQuotationModalOpen(false)
// .then(() => {
// setQuotationModalOpen(false)

Loading…
Cancel
Save