|
|
@ -3,7 +3,7 @@ import { devtools } from 'zustand/middleware';
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import { fetchJSON, postForm, postJSON } from '@/utils/request';
|
|
|
|
import { fetchJSON, postForm, postJSON } from '@/utils/request';
|
|
|
|
import { HT_HOST } from '@/config';
|
|
|
|
import { HT_HOST } from '@/config';
|
|
|
|
import { groupBy } from '@/utils/commons';
|
|
|
|
import { groupBy, isEmpty } from '@/utils/commons';
|
|
|
|
|
|
|
|
|
|
|
|
export const searchAgencyAction = async (param) => {
|
|
|
|
export const searchAgencyAction = async (param) => {
|
|
|
|
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param);
|
|
|
|
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param);
|
|
|
@ -181,38 +181,74 @@ export const useProductsStore = create(
|
|
|
|
weekdays: '5, 6'
|
|
|
|
weekdays: '5, 6'
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
|
|
// TODO:添加价格后,重新读取列表
|
|
|
|
|
|
|
|
appendQuotationList: (newList) => {
|
|
|
|
appendQuotationList: (newList) => {
|
|
|
|
set((state) => ({
|
|
|
|
const { activeAgency, editingProduct, quotationList } = get()
|
|
|
|
quotationList: [...state.quotationList, ...newList]
|
|
|
|
|
|
|
|
|
|
|
|
const mapList = newList.map(q => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...q,
|
|
|
|
|
|
|
|
WPI_SN: editingProduct.info.id,
|
|
|
|
|
|
|
|
WPP_VEI_SN: activeAgency.travel_agency_id
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const mergedList = [...quotationList,...mapList]
|
|
|
|
|
|
|
|
set(() => ({
|
|
|
|
|
|
|
|
quotationList: mergedList
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return mergedList
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
saveOrUpdateQuotation: (formValues) => {
|
|
|
|
saveOrUpdateQuotation: (formValues) => {
|
|
|
|
const { activeAgency, editingProduct, quotationList } = get()
|
|
|
|
const { activeAgency, editingProduct, quotationList } = get()
|
|
|
|
|
|
|
|
let mergedList = []
|
|
|
|
|
|
|
|
|
|
|
|
formValues.WPI_SN = editingProduct.info.id
|
|
|
|
formValues.WPI_SN = editingProduct.info.id
|
|
|
|
formValues.WPP_VEI_SN = activeAgency.travel_agency_id
|
|
|
|
formValues.WPP_VEI_SN = activeAgency.travel_agency_id
|
|
|
|
formValues.use_dates_start = formValues.use_dates[0].format('YYYY-MM-DD')
|
|
|
|
formValues.use_dates_start = formValues.use_dates[0].format('YYYY-MM-DD')
|
|
|
|
formValues.use_dates_end = formValues.use_dates[1].format('YYYY-MM-DD')
|
|
|
|
formValues.use_dates_end = formValues.use_dates[1].format('YYYY-MM-DD')
|
|
|
|
|
|
|
|
|
|
|
|
const prevList = quotationList.filter(q => q.id === formValues.id)
|
|
|
|
if (isEmpty(formValues.id)) {
|
|
|
|
|
|
|
|
mergedList = [...quotationList,...[formValues]]
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mergedList = quotationList.map(q => {
|
|
|
|
|
|
|
|
if (q.id === formValues.id) {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
...q,
|
|
|
|
|
|
|
|
adult_cost: formValues.adult_cost,
|
|
|
|
|
|
|
|
child_cost: formValues.child_cost,
|
|
|
|
|
|
|
|
currency: formValues.currency,
|
|
|
|
|
|
|
|
unit_id: formValues.unit_id,
|
|
|
|
|
|
|
|
group_size_min: formValues.group_size_min,
|
|
|
|
|
|
|
|
group_size_max: formValues.group_size_max,
|
|
|
|
|
|
|
|
use_dates_start: formValues.use_dates_start,
|
|
|
|
|
|
|
|
use_dates_end: formValues.use_dates_end,
|
|
|
|
|
|
|
|
weekdays: formValues.weekdays
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return q
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const prevList = quotationList.filter(q => q.id === formValues.id)
|
|
|
|
|
|
|
|
|
|
|
|
if (prevList.length > 0) {
|
|
|
|
if (prevList.length > 0) {
|
|
|
|
const prevQuotation = prevList[0]
|
|
|
|
const prevQuotation = prevList[0]
|
|
|
|
console.info('formValues: ', formValues)
|
|
|
|
console.info('formValues: ', formValues)
|
|
|
|
console.info('prevQuotation: ', prevQuotation)
|
|
|
|
console.info('prevQuotation: ', prevQuotation)
|
|
|
|
// 对比报价前后是否有改动
|
|
|
|
// 对比报价前后是否有改动
|
|
|
|
for (const [key, value] of Object.entries(formValues)) {
|
|
|
|
for (const [key, value] of Object.entries(formValues)) {
|
|
|
|
if (key === 'use_dates') continue
|
|
|
|
if (key === 'use_dates' || key === 'id') continue
|
|
|
|
|
|
|
|
|
|
|
|
const prevValue = prevQuotation[key]
|
|
|
|
const prevValue = prevQuotation[key]
|
|
|
|
const hasChanged = prevValue === value
|
|
|
|
const hasChanged = prevValue === value
|
|
|
|
console.log(`${key}: ${prevValue} - ${value} (${hasChanged})`)
|
|
|
|
console.log(`${key}: ${prevValue} - ${value} (${hasChanged})`)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const mergedList = [...quotationList,...[formValues]]
|
|
|
|
|
|
|
|
set(() => ({
|
|
|
|
set(() => ({
|
|
|
|
quotationList: mergedList
|
|
|
|
quotationList: mergedList
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|