|
|
|
@ -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 } from '@/utils/commons';
|
|
|
|
|
import { groupBy, generateId, isEmpty } from '@/utils/commons';
|
|
|
|
|
|
|
|
|
|
export const searchAgencyAction = async (param) => {
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param);
|
|
|
|
@ -287,16 +287,14 @@ export const useProductsStore = create(
|
|
|
|
|
return mergedList
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
deleteQuotationById: async(quotaionId) => {
|
|
|
|
|
deleteQuotation: async(quotation) => {
|
|
|
|
|
const { editingProduct, quotationList, agencyProducts } = get()
|
|
|
|
|
const productTypeId = editingProduct.info.product_type_id;
|
|
|
|
|
const quotationId = quotation.id
|
|
|
|
|
const newList = quotationList.filter(q => {
|
|
|
|
|
return q.id != quotaionId
|
|
|
|
|
return q.key != quotation.key
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const { result, success } = await deleteQuotationAction(quotaionId)
|
|
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
|
set({
|
|
|
|
|
agencyProducts: {
|
|
|
|
|
...agencyProducts,
|
|
|
|
@ -307,10 +305,17 @@ export const useProductsStore = create(
|
|
|
|
|
},
|
|
|
|
|
quotationList: newList
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// side effects
|
|
|
|
|