feat: 增加删除产品价格

perf/export-docx
Jimmy Liow 11 months ago
parent 2254a09c5f
commit 65e534bf3e

@ -108,6 +108,14 @@ export const postProductsSaveAction = async (products) => {
return { errcode, result, success: errcode === 0 }; return { errcode, result, success: errcode === 0 };
} }
/**
* 删除产品报价
*/
export const deleteQuotationAction = async (id) => {
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_quotation_delete`, {id});
return { errcode, result, success: errcode === 0 };
}
const initialState = { const initialState = {
loading: false, loading: false,
searchValues: {}, // 客服首页: 搜索条件 searchValues: {}, // 客服首页: 搜索条件
@ -181,13 +189,16 @@ export const useProductsStore = create(
}, },
saveOrUpdateQuotation: (formValues) => { saveOrUpdateQuotation: (formValues) => {
const { quotationList } = get() const { activeAgency, editingProduct, quotationList } = get()
formValues.WPI_SN = editingProduct.info.id
formValues.WPP_VEI_SN = activeAgency.travel_agency_id
formValues.use_dates_start = formValues.use_dates[0].format('YYYY-MM-DD')
formValues.use_dates_end = formValues.use_dates[1].format('YYYY-MM-DD')
const prevList = quotationList.filter(q => q.id === formValues.id) const prevList = quotationList.filter(q => q.id === formValues.id)
if (prevList.length > 0) { if (prevList.length > 0) {
formValues.use_dates_start = formValues.use_dates[0].format('YYYY-MM-DD')
formValues.use_dates_end = formValues.use_dates[1].format('YYYY-MM-DD')
const prevQuotation = prevList[0] const prevQuotation = prevList[0]
console.info('formValues: ', formValues) console.info('formValues: ', formValues)
console.info('prevQuotation: ', prevQuotation) console.info('prevQuotation: ', prevQuotation)
@ -201,8 +212,22 @@ export const useProductsStore = create(
} }
} }
set((state) => ({ const mergedList = [...quotationList,...[formValues]]
quotationList: [...state.quotationList, ...[formValues]] set(() => ({
quotationList: mergedList
}))
return mergedList
},
deleteQuotation: (quotaionId) => {
const { quotationList } = get()
const newList = quotationList.filter(q => {
return q.id != quotaionId
})
deleteQuotationAction(quotaionId)
set(() => ({
quotationList: newList
})) }))
}, },

@ -393,10 +393,7 @@ const formValuesMapper = (values) => {
], ],
'quotation_mapped': { 'quotation_mapped': {
key: 'quotation', key: 'quotation',
transform: (value) => { transform: value => value
console.info(value)
return value.quotationList
},
}, },
}; };
let dest = {}; let dest = {};

@ -236,8 +236,7 @@ const defaultDefinitionValue = {
const ProductInfoQuotation = ({ editable, ...props }) => { const ProductInfoQuotation = ({ editable, ...props }) => {
const { onChange } = props
const { id, value = {}, onChange } = props
const { t } = useTranslation() const { t } = useTranslation()
@ -246,17 +245,15 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
const [quotationForm] = Form.useForm() const [quotationForm] = Form.useForm()
const [batchSetupForm] = Form.useForm() const [batchSetupForm] = Form.useForm()
// console.info('value: ', value)
const datePresets = useDatePresets() const datePresets = useDatePresets()
const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation] = const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation, deleteQuotation] =
useProductsStore((state) => [state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation]) useProductsStore((state) => [state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation, state.deleteQuotation])
const triggerChange = (changedValue) => { const triggerChange = (changedValue) => {
onChange?.({ onChange?.(
quotationList changedValue
}) )
} }
const onQuotationSeleted = async (quotation) => { const onQuotationSeleted = async (quotation) => {
@ -273,20 +270,9 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
} }
const onQuotationFinish = (values) => { const onQuotationFinish = (values) => {
saveOrUpdateQuotation(values) const newList = saveOrUpdateQuotation(values)
triggerChange(quotationList) triggerChange(newList)
setQuotationModalOpen(false) setQuotationModalOpen(false)
// .then(() => {
// setQuotationModalOpen(false)
// })
// .catch(ex => {
// notification.error({
// message: 'Notification',
// description: ex.message,
// placement: 'top',
// duration: 4,
// })
// })
} }
const onBatchSetupFinish = () => { const onBatchSetupFinish = () => {
@ -356,7 +342,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
icon: <ExclamationCircleFilled />, icon: <ExclamationCircleFilled />,
content: '你要删除这条价格吗?', content: '你要删除这条价格吗?',
onOk() { onOk() {
console.log('OK'); deleteQuotation(quotation.id)
}, },
onCancel() { onCancel() {
console.log('Cancel'); console.log('Cancel');

Loading…
Cancel
Save