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 };
}
/**
* 删除产品报价
*/
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 = {
loading: false,
searchValues: {}, // 客服首页: 搜索条件
@ -181,13 +189,16 @@ export const useProductsStore = create(
},
saveOrUpdateQuotation: (formValues) => {
const { quotationList } = get()
const prevList = quotationList.filter(q => q.id === formValues.id)
if (prevList.length > 0) {
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)
if (prevList.length > 0) {
const prevQuotation = prevList[0]
console.info('formValues: ', formValues)
console.info('prevQuotation: ', prevQuotation)
@ -201,8 +212,22 @@ export const useProductsStore = create(
}
}
set((state) => ({
quotationList: [...state.quotationList, ...[formValues]]
const mergedList = [...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': {
key: 'quotation',
transform: (value) => {
console.info(value)
return value.quotationList
},
transform: value => value
},
};
let dest = {};

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

Loading…
Cancel
Save