fix: 删除价格导致产品只剩一项

perf/export-docx
Jimmy Liow 11 months ago
parent 20bd547fd6
commit 910c6c02af

@ -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, generateId, isEmpty } from '@/utils/commons';
import { groupBy, generateId, isNotEmpty } from '@/utils/commons';
export const searchAgencyAction = async (param) => {
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param);
@ -291,31 +291,39 @@ export const useProductsStore = create(
const { editingProduct, quotationList, agencyProducts } = get()
const productTypeId = editingProduct.info.product_type_id;
const quotationId = quotation.id
const newList = quotationList.filter(q => {
const newQuotationList = quotationList.filter(q => {
return q.key != quotation.key
})
const newProductList = agencyProducts[productTypeId].map(p => {
if (p.info.id == editingProduct.info.id) {
return {
...editingProduct,
quotation: newQuotationList
}
} else {
return p
}
})
set({
agencyProducts: {
...agencyProducts,
[productTypeId]: [{
...editingProduct,
quotation: newList
}]
[productTypeId]: newProductList
},
quotationList: newList
quotationList: newQuotationList
})
if (isEmpty(quotationId)) {
return Promise.resolve(newList)
} else {
const { result, success } = await deleteQuotationAction(quotationId)
if (success) {
return Promise.resolve(result)
} else {
return Promise.reject(result)
let promiseDelete = Promise.resolve(newQuotationList)
if (isNotEmpty(quotationId)) {
const { result, success } = await deleteQuotationAction('quotationId')
if (!success) {
promiseDelete = Promise.reject(result)
}
}
return promiseDelete
},
// side effects

Loading…
Cancel
Save