diff --git a/src/components/OrderProfile.jsx b/src/components/OrderProfile.jsx
index cd9f699..bc36fbd 100644
--- a/src/components/OrderProfile.jsx
+++ b/src/components/OrderProfile.jsx
@@ -14,7 +14,7 @@ import {
import { useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import { App, Flex, Select, Tooltip, Divider, Typography, Skeleton, Checkbox, Drawer, Button, Empty, Form, Input } from 'antd'
-import { useOrderStore, fetchSetRemindStateAction, OrderLabelDefaultOptions, OrderStatusDefaultOptions, remindStatusOptions } from '@/stores/OrderStore'
+import { useOrderStore, setRemindStateAction, OrderLabelDefaultOptions, OrderStatusDefaultOptions, remindStatusOptions } from '@/stores/OrderStore'
import { copy, isEmpty } from '@/utils/commons'
import { useShallow } from 'zustand/react/shallow'
import useConversationStore from '@/stores/ConversationStore'
@@ -35,7 +35,8 @@ const OrderProfile = ({ coliSN, ...props }) => {
orderLabelOptions.unshift({ value: 0, label: '未设置', disabled: true })
const orderStatusOptions = copy(OrderStatusDefaultOptions)
- const [orderDetail, customerDetail, fetchOrderDetail, setOrderPropValue, appendOrderComment, updateWhatsapp, updateExtraInfo] = useOrderStore((s) => [
+ const [orderDetail, customerDetail, fetchOrderDetail, setOrderPropValue,
+ appendOrderComment, updateWhatsapp, updateExtraInfo, remindCheckList] = useOrderStore((s) => [
s.orderDetail,
s.customerDetail,
s.fetchOrderDetail,
@@ -43,16 +44,13 @@ const OrderProfile = ({ coliSN, ...props }) => {
s.appendOrderComment,
s.updateWhatsapp,
s.updateExtraInfo,
+ s.remindCheckList
])
const loginUser = useAuthStore((state) => state.loginUser)
const currentOrder = useConversationStore(useShallow((state) => state.currentConversation?.coli_sn || ''))
const orderId = coliSN || currentOrder
- const [orderRemindState, setOrderRemindState] = useState(orderDetail.remindstate)
- useEffect(() => {
- setOrderRemindState(orderDetail.remindstate)
- }, [orderDetail.remindstate])
useEffect(() => {
if (orderId) {
setLoading(true)
@@ -71,20 +69,12 @@ const OrderProfile = ({ coliSN, ...props }) => {
}, [orderId])
const handleSetRemindState = async (checkedValue) => {
- const state = checkedValue.filter((v) => v !== orderRemindState)
- const oldState = orderRemindState
try {
- if (isEmpty(state)) {
- setOrderRemindState(null)
- } else {
- setOrderRemindState(state[0])
- }
- await fetchSetRemindStateAction({ coli_sn: coliSN, remindstate: state })
+ await setRemindStateAction(coliSN, checkedValue )
message.success('设置成功')
} catch (error) {
notification.warning({ message: '设置失败', description: error.message, placement: 'top', duration: 60 })
- setOrderRemindState(oldState)
}
}
@@ -206,7 +196,7 @@ const OrderProfile = ({ coliSN, ...props }) => {
催信
-
+
表单信息
diff --git a/src/stores/OrderStore.js b/src/stores/OrderStore.js
index 16270d9..7d7f3e9 100644
--- a/src/stores/OrderStore.js
+++ b/src/stores/OrderStore.js
@@ -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 : {}
}