diff --git a/src/stores/Auth.js b/src/stores/Auth.js index 0c48ce6..7fc81b8 100644 --- a/src/stores/Auth.js +++ b/src/stores/Auth.js @@ -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: { diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 9375042..ea0da01 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -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(() => ({