|
|
|
@ -4,7 +4,7 @@ import { API_HOST } from '@/config'
|
|
|
|
|
|
|
|
|
|
const useOrderStore = create((set, get) => ({
|
|
|
|
|
|
|
|
|
|
orderData: [],
|
|
|
|
|
orderList: [],
|
|
|
|
|
orderDetail: {},
|
|
|
|
|
customerDetail: {},
|
|
|
|
|
lastQuotation: {},
|
|
|
|
@ -51,21 +51,16 @@ const useOrderStore = create((set, get) => ({
|
|
|
|
|
.then(json => {
|
|
|
|
|
if (json.errcode === 0) {
|
|
|
|
|
set(() => ({
|
|
|
|
|
orderData: json.result.map((order) => { return { ...order, key: order.COLI_ID } }),
|
|
|
|
|
orderList: json.result.map((order) => { return { ...order, key: order.COLI_ID } }),
|
|
|
|
|
}))
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(json?.errmsg + ': ' + json.errcode)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// .finally(() => setLoading(false))
|
|
|
|
|
.catch(reason => {
|
|
|
|
|
throw new Error(reason.message)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
fetchOrderDetail: async (colisn) => {
|
|
|
|
|
const { orderDetail, updateQuotation } = get()
|
|
|
|
|
const json = await fetchJSON(`${API_HOST}/getorderinfo`, { colisn })
|
|
|
|
|
if (json.errcode === 0 && json.result.length > 0) {
|
|
|
|
|
const orderResult = json.result[0]
|
|
|
|
@ -74,13 +69,29 @@ const useOrderStore = create((set, get) => ({
|
|
|
|
|
customerDetail: orderResult.contact.length > 0 ? orderResult.contact[0] : {},
|
|
|
|
|
lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {},
|
|
|
|
|
quotationList: orderResult.quotes,
|
|
|
|
|
}))
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setOrderPropValue: async (colisn, propName, value) => {
|
|
|
|
|
const json = await fetchJSON(`${API_HOST}/setorderstatus`, { colisn, stype: propName, svalue: value })
|
|
|
|
|
console.info(json)
|
|
|
|
|
if (propName === 'orderlabel') {
|
|
|
|
|
set((state) => ({
|
|
|
|
|
orderDetail: {
|
|
|
|
|
...state.orderDetail,
|
|
|
|
|
tags: value
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (propName === 'orderstatus') {
|
|
|
|
|
set((state) => ({
|
|
|
|
|
orderDetail: {
|
|
|
|
|
...state.orderDetail,
|
|
|
|
|
states: value
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
}))
|
|
|
|
|