feat: 增加价格变化对象存储

perf/export-docx
Jimmy Liow 11 months ago
parent 60be7b7457
commit 0f65540733

@ -43,7 +43,7 @@ async function fetchLastRequet() {
const initialState = {
tokenInterval: null,
tokenTimeout: false,// 开发时候用false正式环境true,
tokenTimeout: import.meta.env.PROD ? true : false,
loginStatus: 0,
defaltRoute: '',
currentUser: {

@ -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(() => ({

Loading…
Cancel
Save