|
|
|
|
@ -2,7 +2,7 @@ import { create } from 'zustand'
|
|
|
|
|
import { devtools } from 'zustand/middleware'
|
|
|
|
|
import { fetchJSON, postForm, postJSON } from '@/utils/request'
|
|
|
|
|
import { API_HOST, API_HOST_V3, EMAIL_HOST } from '@/config'
|
|
|
|
|
import { isNotEmpty, prepareUrl, uniqWith } from '@/utils/commons'
|
|
|
|
|
import { isEmpty, isNotEmpty, prepareUrl, uniqWith } from '@/utils/commons'
|
|
|
|
|
|
|
|
|
|
const initialState = {
|
|
|
|
|
orderList: [],
|
|
|
|
|
@ -11,6 +11,7 @@ const initialState = {
|
|
|
|
|
lastQuotation: {},
|
|
|
|
|
quotationList: [],
|
|
|
|
|
otherEmailList: [],
|
|
|
|
|
remindCheckList: [],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const useOrderStore = create(
|
|
|
|
|
@ -59,20 +60,19 @@ export const useOrderStore = create(
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
fetchOrderDetail: (colisn) => {
|
|
|
|
|
return fetchJSON(`${API_HOST}/getorderinfo`, { colisn }).then((json) => {
|
|
|
|
|
// return fetchJSON(`${API_HOST}/getorderinfo`, { colisn }).then((json) => {
|
|
|
|
|
return fetchJSON(`http://202.103.68.144:8888/v2/getorderinfo`, { colisn }).then((json) => {
|
|
|
|
|
if (json.errcode === 0 && json.result.length > 0) {
|
|
|
|
|
const orderResult = json.result[0]
|
|
|
|
|
|
|
|
|
|
set(() => ({
|
|
|
|
|
remindCheckList: transferRemind2Checklist(orderResult.remindstate),
|
|
|
|
|
orderDetail: { ...orderResult, coli_sn: colisn },
|
|
|
|
|
customerDetail: orderResult.contact.length > 0 ? orderResult.contact[0] : {},
|
|
|
|
|
// lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {},
|
|
|
|
|
// quotationList: orderResult.quotes,
|
|
|
|
|
}))
|
|
|
|
|
return {
|
|
|
|
|
orderDetail: { ...orderResult, coli_sn: colisn },
|
|
|
|
|
customerDetail: orderResult.contact.length > 0 ? orderResult.contact[0] : {},
|
|
|
|
|
// lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {},
|
|
|
|
|
// quotationList: orderResult.quotes,
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(json?.errmsg + ': ' + json.errcode)
|
|
|
|
|
@ -280,20 +280,52 @@ export const RemindStateDefaultOptions = [
|
|
|
|
|
* @useage 订单信息: 标记状态
|
|
|
|
|
*/
|
|
|
|
|
export const remindStatusOptions = [
|
|
|
|
|
{ value: 1, label: '已发一催' },
|
|
|
|
|
{ value: 2, label: '已发二催' },
|
|
|
|
|
{ value: 3, label: '已发三催' },
|
|
|
|
|
{ value: 'FirstRemind', label: '已发一催' },
|
|
|
|
|
{ value: 'SendFirstRemind', label: '已发二催' },
|
|
|
|
|
{ value: 'ThirdRemind', label: '已发三催' },
|
|
|
|
|
{ value: 'important', label: '重点团' },
|
|
|
|
|
{ value: 'sendsurvey', label: '已发 travel advisor survey' },
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export const remindStatusOptionsMapped = remindStatusOptions.reduce((acc, cur) => {
|
|
|
|
|
return { ...acc, [String(cur.value)]: cur }
|
|
|
|
|
}, {})
|
|
|
|
|
|
|
|
|
|
const transferRemind2Checklist = (remindstate) => {
|
|
|
|
|
const remindValueList = []
|
|
|
|
|
|
|
|
|
|
if (isEmpty(remindstate)) return remindValueList
|
|
|
|
|
|
|
|
|
|
if (remindstate.FirstRemind) {
|
|
|
|
|
remindValueList.push('FirstRemind')
|
|
|
|
|
}
|
|
|
|
|
if (remindstate.SendFirstRemind) {
|
|
|
|
|
remindValueList.push('SendFirstRemind')
|
|
|
|
|
}
|
|
|
|
|
if (remindstate.ThirdRemind) {
|
|
|
|
|
remindValueList.push('ThirdRemind')
|
|
|
|
|
}
|
|
|
|
|
if (remindstate.important) {
|
|
|
|
|
remindValueList.push('important')
|
|
|
|
|
}
|
|
|
|
|
if (remindstate.sendsurvey) {
|
|
|
|
|
remindValueList.push('sendsurvey')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return remindValueList
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {Object} params { coli_sn, remindstate }
|
|
|
|
|
* @param {Object} params { orderId, checkedValue }
|
|
|
|
|
*/
|
|
|
|
|
export const fetchSetRemindStateAction = async (params) => {
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/SetRemindState`, params)
|
|
|
|
|
export const setRemindStateAction = async (orderId, checkedValue) => {
|
|
|
|
|
const finalState = {
|
|
|
|
|
'FirstRemind': checkedValue.includes('FirstRemind') ? 1 : 0,
|
|
|
|
|
'SendFirstRemind': checkedValue.includes('SendFirstRemind') ? 1 : 0,
|
|
|
|
|
'ThirdRemind': checkedValue.includes('ThirdRemind') ? 1 : 0,
|
|
|
|
|
'important': checkedValue.includes('important') ? 1 : 0,
|
|
|
|
|
'sendsurvey': checkedValue.includes('sendsurvey') ? 1 : 0,
|
|
|
|
|
}
|
|
|
|
|
const { errcode, result } = await postJSON(`${API_HOST}/SetRemindState`, { coli_sn: orderId, remindstate: JSON.stringify(finalState)})
|
|
|
|
|
return errcode === 0 ? result : {}
|
|
|
|
|
}
|
|
|
|
|
|