|
|
|
@ -210,13 +210,29 @@ export const useProductsStore = create(
|
|
|
|
|
formValues.use_dates_end = formValues.use_dates[1].format('YYYY-MM-DD')
|
|
|
|
|
|
|
|
|
|
if (isEmpty(formValues.id)) {
|
|
|
|
|
formValues.lastedit_changed = ''
|
|
|
|
|
formValues.audit_state_id = -1 // 新增
|
|
|
|
|
mergedList = [...quotationList,...[formValues]]
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
mergedList = quotationList.map(q => {
|
|
|
|
|
if (q.id === formValues.id) {
|
|
|
|
|
mergedList = quotationList.map(prevQuotation => {
|
|
|
|
|
if (prevQuotation.id === formValues.id) {
|
|
|
|
|
const changedList = []
|
|
|
|
|
for (const [key, value] of Object.entries(formValues)) {
|
|
|
|
|
if (key === 'use_dates' || key === 'id') continue
|
|
|
|
|
|
|
|
|
|
const preValue = prevQuotation[key]
|
|
|
|
|
const hasChanged = preValue !== value
|
|
|
|
|
|
|
|
|
|
if (hasChanged) {
|
|
|
|
|
changedList.push({
|
|
|
|
|
[key]: preValue,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
...q,
|
|
|
|
|
...prevQuotation,
|
|
|
|
|
adult_cost: formValues.adult_cost,
|
|
|
|
|
child_cost: formValues.child_cost,
|
|
|
|
|
currency: formValues.currency,
|
|
|
|
@ -225,28 +241,13 @@ export const useProductsStore = create(
|
|
|
|
|
group_size_max: formValues.group_size_max,
|
|
|
|
|
use_dates_start: formValues.use_dates_start,
|
|
|
|
|
use_dates_end: formValues.use_dates_end,
|
|
|
|
|
weekdays: formValues.weekdays
|
|
|
|
|
weekdays: formValues.weekdays,
|
|
|
|
|
lastedit_changed: JSON.stringify(changedList, null, 2)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return q
|
|
|
|
|
return prevQuotation
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const prevList = quotationList.filter(q => q.id === formValues.id)
|
|
|
|
|
|
|
|
|
|
if (prevList.length > 0) {
|
|
|
|
|
const prevQuotation = prevList[0]
|
|
|
|
|
console.info('formValues: ', formValues)
|
|
|
|
|
console.info('prevQuotation: ', prevQuotation)
|
|
|
|
|
// 对比报价前后是否有改动
|
|
|
|
|
for (const [key, value] of Object.entries(formValues)) {
|
|
|
|
|
if (key === 'use_dates' || key === 'id') continue
|
|
|
|
|
|
|
|
|
|
const prevValue = prevQuotation[key]
|
|
|
|
|
const hasChanged = prevValue === value
|
|
|
|
|
console.log(`${key}: ${prevValue} - ${value} (${hasChanged})`)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set(() => ({
|
|
|
|
|