You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Global-sales/src/stores/OrderStore.js

38 lines
1.1 KiB
JavaScript

import { create } from 'zustand'
import { devtools } from 'zustand/middleware'
import { fetchJSON, postJSON } from '@/utils/request'
const API_HOST = 'https://p9axztuwd7x8a7.mycht.cn/whatsapp_server';
const useOrderStore = create((set, get) => ({
orderDetail: {},
customerDetail: {},
lastQuotation: {},
quotationList: [],
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]
set(() => ({
orderDetail: orderResult,
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)
},
}))
export default useOrderStore