fix: 删除价格后,同时更新 State 数据

perf/export-docx
Jimmy Liow 11 months ago
parent b1ddfc9bda
commit 8dbedbcf38

@ -3,7 +3,7 @@ import { devtools } from 'zustand/middleware';
import dayjs from 'dayjs'
import { fetchJSON, postForm, postJSON } from '@/utils/request';
import { HT_HOST } from '@/config';
import { groupBy, isEmpty, generateId } from '@/utils/commons';
import { groupBy, generateId } from '@/utils/commons';
export const searchAgencyAction = async (param) => {
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param);
@ -287,15 +287,23 @@ export const useProductsStore = create(
},
deleteQuotation: (quotaionId) => {
const { quotationList } = get()
const { editingProduct, quotationList, agencyProducts } = get()
const productTypeId = editingProduct.info.product_type_id;
const newList = quotationList.filter(q => {
return q.id != quotaionId
})
deleteQuotationAction(quotaionId)
set(() => ({
// 还要设置回 product.quotaion 对象
set({
agencyProducts: {
...agencyProducts,
[productTypeId]: [{
...editingProduct,
quotation: newList
}]
},
quotationList: newList
}))
})
},
// side effects

@ -5,7 +5,6 @@ import { CloseOutlined, StarTwoTone, PlusOutlined, ExclamationCircleFilled } fro
import { useDatePresets } from '@/hooks/useDatePresets'
import dayjs from 'dayjs'
import useProductsStore from '@/stores/Products/Index'
import { generateId } from '@/utils/commons'
const { RangePicker } = DatePicker

Loading…
Cancel
Save