Commit 5a91d0e7 by liimin

refactor(store): 重构全局状态管理以兼容旧项目

- 将原有的模块化 store 重构为 Vuex 风格的扁平化结构
- 实现与旧项目 gl_tape/store 兼容的 API(dispatch, commit, getters)
- 暂时注释 RecordService 中的 watch 监听以避免潜在冲突
- 新增状态持久化功能(如 customerInfo 的本地存储)
1 parent 102cd697
...@@ -86,40 +86,40 @@ class RecordService { ...@@ -86,40 +86,40 @@ class RecordService {
initWatchers() { initWatchers() {
// 监听 customerKey // 监听 customerKey
this.unwatchCustomer = watch( // this.unwatchCustomer = watch(
(): string => storeState.customerKey, // (): string => storeState.customerKey,
(val: string) => { // (val: string) => {
const customerInfo = storeState.customerInfo // const customerInfo = storeState.customerInfo
this.handler('updateCustomerInfo', customerInfo, (val: UTSJSONObject | null) => { this.updateCustomerInfo(val) }, 1000) // this.handler('updateCustomerInfo', customerInfo, (val: UTSJSONObject | null) => { this.updateCustomerInfo(val) }, 1000)
}, // },
{ immediate: true } // { immediate: true }
) // )
// 监听 receptionStatus // // 监听 receptionStatus
this.unwatchStatus = watch( // this.unwatchStatus = watch(
(): string => storeState.receptionStatus, // (): string => storeState.receptionStatus,
(val: string) => { // (val: string) => {
this.handler('updateReceptionStatus', val, (v: any) => { this.updateReceptionStatus(v as string) }, 200) // this.handler('updateReceptionStatus', val, (v: any) => { this.updateReceptionStatus(v as string) }, 200)
}, // },
{ immediate: true } // { immediate: true }
) // )
this.unwatchBookList = watch( // this.unwatchBookList = watch(
(): UTSJSONObject[] => storeState.booksList, // (): UTSJSONObject[] => storeState.booksList,
(val: UTSJSONObject[]) => { // (val: UTSJSONObject[]) => {
this.handler('updateBookList', val, (v: UTSJSONObject[]) => { this.updateBookList(v) }, 1500) // this.handler('updateBookList', val, (v: UTSJSONObject[]) => { this.updateBookList(v) }, 1500)
}, // },
{ immediate: true } // { immediate: true }
) // )
this.unwatchReceptionKey = watch( // this.unwatchReceptionKey = watch(
(): string => storeState.receptionKey, // (): string => storeState.receptionKey,
(val: string) => { // (val: string) => {
const receptionTrack = storeState.receptionTrack // const receptionTrack = storeState.receptionTrack
this.handler('updateMaterialPointList', receptionTrack, (v: UTSJSONObject[]) => { this.updateMaterialPointList(v) }, 1000) // this.handler('updateMaterialPointList', receptionTrack, (v: UTSJSONObject[]) => { this.updateMaterialPointList(v) }, 1000)
}, // },
{ immediate: true } // { immediate: true }
) // )
} }
// --- 业务逻辑 --- // --- 业务逻辑 ---
...@@ -404,12 +404,12 @@ class RecordService { ...@@ -404,12 +404,12 @@ class RecordService {
businessScene: sceneType businessScene: sceneType
} }
const newPointJson = JSON.parse(JSON.stringify(newPoint)) as UTSJSONObject const newPointJson = JSON.parse(JSON.stringify(newPoint)) as UTSJSONObject
const pMap = point.toMap() const pMap = point.toMap()
pMap.forEach((pv, pk) => { pMap.forEach((pv, pk) => {
newPointJson[pk] = pv newPointJson[pk] = pv
}) })
receptionCustomerMaterialPointList.push(newPointJson) receptionCustomerMaterialPointList.push(newPointJson)
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!