kz-ui-base 1.0.70 → 1.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/src/api/common/common.js +16 -9
- package/common/src/store/bdData.js +101 -9
- package/common/src/store/fdFactory.js +104 -12
- package/common/src/store/smSysSettings.js +84 -4
- package/common/src/store/tmTooling.js +64 -13
- package/package.json +1 -1
- package/views/bd/common/modal/EmployeeModal.vue +3 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Vue from "vue";
|
|
2
2
|
import request from "../../utils/request";
|
|
3
|
+
import localforage from 'localforage';
|
|
3
4
|
let that = new Vue();
|
|
4
5
|
|
|
5
6
|
//公共接口
|
|
@@ -257,17 +258,23 @@ export function getNameByDeptId(value) {
|
|
|
257
258
|
return value;
|
|
258
259
|
}
|
|
259
260
|
|
|
260
|
-
export function getNameByPostId(value) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
261
|
+
export async function getNameByPostId(value) {
|
|
262
|
+
try {
|
|
263
|
+
const cache = await localforage.getItem("post");
|
|
264
|
+
if (!cache) return value;
|
|
265
|
+
|
|
266
|
+
for (const item of cache) {
|
|
267
|
+
if (item.postId == value) {
|
|
268
|
+
return item.postName;
|
|
269
|
+
} else if (item.postCode == value) {
|
|
270
|
+
return item.postName;
|
|
271
|
+
}
|
|
268
272
|
}
|
|
273
|
+
return value;
|
|
274
|
+
} catch (err) {
|
|
275
|
+
console.error("Error retrieving post data:", err);
|
|
276
|
+
return value;
|
|
269
277
|
}
|
|
270
|
-
return value;
|
|
271
278
|
}
|
|
272
279
|
|
|
273
280
|
export function getLineNameByLineNo(value) {
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
// store/modules/bdData.js
|
|
2
2
|
import { getUrl } from '../api/common/common';
|
|
3
|
+
import localforage from 'localforage';
|
|
3
4
|
import Vue from 'vue'
|
|
4
5
|
|
|
6
|
+
// Configure localforage instances for each data type
|
|
7
|
+
const storage = {
|
|
8
|
+
itemClass: localforage.createInstance({ name: 'bdData', storeName: 'itemClass' }),
|
|
9
|
+
itemCategory: localforage.createInstance({ name: 'bdData', storeName: 'itemCategory' }),
|
|
10
|
+
productLine: localforage.createInstance({ name: 'bdData', storeName: 'productLine' }),
|
|
11
|
+
currency: localforage.createInstance({ name: 'bdData', storeName: 'currency' }),
|
|
12
|
+
scales: localforage.createInstance({ name: 'bdData', storeName: 'scales' })
|
|
13
|
+
};
|
|
14
|
+
|
|
5
15
|
const state = {
|
|
6
16
|
itemClass: null,
|
|
7
17
|
itemCategory: null,
|
|
@@ -29,7 +39,57 @@ const mutations = {
|
|
|
29
39
|
};
|
|
30
40
|
|
|
31
41
|
const actions = {
|
|
32
|
-
async initBdCache({ commit }) {
|
|
42
|
+
async initBdCache({ commit, dispatch }) {
|
|
43
|
+
try {
|
|
44
|
+
// First try to load from local storage
|
|
45
|
+
const loadedFromCache = await dispatch('loadFromLocalStorage');
|
|
46
|
+
|
|
47
|
+
if (loadedFromCache) {
|
|
48
|
+
// If we successfully loaded from cache, still refresh from server in background
|
|
49
|
+
dispatch('refreshFromServer');
|
|
50
|
+
return loadedFromCache;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// If no cache exists, load from server
|
|
54
|
+
return await dispatch('refreshFromServer');
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error("Failed to initialize BD data cache:", error);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
async loadFromLocalStorage({ commit }) {
|
|
62
|
+
try {
|
|
63
|
+
const [
|
|
64
|
+
itemClass,
|
|
65
|
+
itemCategory,
|
|
66
|
+
productLine,
|
|
67
|
+
currency,
|
|
68
|
+
scales
|
|
69
|
+
] = await Promise.all([
|
|
70
|
+
storage.itemClass.getItem('data'),
|
|
71
|
+
storage.itemCategory.getItem('data'),
|
|
72
|
+
storage.productLine.getItem('data'),
|
|
73
|
+
storage.currency.getItem('data'),
|
|
74
|
+
storage.scales.getItem('data')
|
|
75
|
+
]);
|
|
76
|
+
|
|
77
|
+
if (itemClass && itemCategory && productLine && currency && scales) {
|
|
78
|
+
commit('SET_ITEM_CLASS', itemClass);
|
|
79
|
+
commit('SET_ITEM_CATEGORY', itemCategory);
|
|
80
|
+
commit('SET_PRODUCT_LINE', productLine);
|
|
81
|
+
commit('SET_CURRENCY', currency);
|
|
82
|
+
commit('SET_SCALES', scales);
|
|
83
|
+
return [itemClass, itemCategory, productLine, currency, scales];
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error("Failed to load from local storage:", error);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
async refreshFromServer({ commit }) {
|
|
33
93
|
try {
|
|
34
94
|
const requests = [
|
|
35
95
|
getUrl("/bd/ItemClass/getItemClassAll"),
|
|
@@ -40,17 +100,49 @@ const actions = {
|
|
|
40
100
|
];
|
|
41
101
|
|
|
42
102
|
const responses = await Promise.all(requests);
|
|
103
|
+
const data = responses.map(r => r.data);
|
|
104
|
+
|
|
105
|
+
// Commit to state
|
|
106
|
+
commit('SET_ITEM_CLASS', data[0]);
|
|
107
|
+
commit('SET_ITEM_CATEGORY', data[1]);
|
|
108
|
+
commit('SET_PRODUCT_LINE', data[2]);
|
|
109
|
+
commit('SET_CURRENCY', data[3]);
|
|
110
|
+
Vue.prototype.$cache.local.setJSON("currency", data[3]);
|
|
111
|
+
commit('SET_SCALES', data[4]);
|
|
43
112
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
113
|
+
// Save to local storage
|
|
114
|
+
await Promise.all([
|
|
115
|
+
storage.itemClass.setItem('data', data[0]),
|
|
116
|
+
storage.itemCategory.setItem('data', data[1]),
|
|
117
|
+
storage.productLine.setItem('data', data[2]),
|
|
118
|
+
storage.currency.setItem('data', data[3]),
|
|
119
|
+
storage.scales.setItem('data', data[4])
|
|
120
|
+
]);
|
|
50
121
|
|
|
51
|
-
return
|
|
122
|
+
return data;
|
|
52
123
|
} catch (error) {
|
|
53
|
-
console.error("Failed to
|
|
124
|
+
console.error("Failed to refresh from server:", error);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
async clearLocalCache({ commit }) {
|
|
130
|
+
try {
|
|
131
|
+
await Promise.all([
|
|
132
|
+
storage.itemClass.removeItem('data'),
|
|
133
|
+
storage.itemCategory.removeItem('data'),
|
|
134
|
+
storage.productLine.removeItem('data'),
|
|
135
|
+
storage.currency.removeItem('data'),
|
|
136
|
+
storage.scales.removeItem('data')
|
|
137
|
+
]);
|
|
138
|
+
|
|
139
|
+
commit('SET_ITEM_CLASS', null);
|
|
140
|
+
commit('SET_ITEM_CATEGORY', null);
|
|
141
|
+
commit('SET_PRODUCT_LINE', null);
|
|
142
|
+
commit('SET_CURRENCY', null);
|
|
143
|
+
commit('SET_SCALES', null);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error("Failed to clear local cache:", error);
|
|
54
146
|
throw error;
|
|
55
147
|
}
|
|
56
148
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import { getUrl } from '../api/common/common';
|
|
2
|
+
import localforage from 'localforage';
|
|
3
3
|
import Vue from 'vue'
|
|
4
4
|
|
|
5
5
|
// 常量定义
|
|
@@ -8,6 +8,15 @@ const WA_TYPE_CODE_WORKSHOP = "2";
|
|
|
8
8
|
const WA_TYPE_CODE_PRODUCTION_LINE = "3";
|
|
9
9
|
const WA_TYPE_CODE_WORKSHOP_SECTION = "4";
|
|
10
10
|
|
|
11
|
+
const storage = {
|
|
12
|
+
sites: localforage.createInstance({ name: 'fdFactory', storeName: 'sites' }),
|
|
13
|
+
workAreas: localforage.createInstance({ name: 'fdFactory', storeName: 'workAreas' }),
|
|
14
|
+
workCenters: localforage.createInstance({ name: 'fdFactory', storeName: 'workCenters' }),
|
|
15
|
+
workUnits: localforage.createInstance({ name: 'fdFactory', storeName: 'workUnits' }),
|
|
16
|
+
storageZones: localforage.createInstance({ name: 'fdFactory', storeName: 'storageZones' }),
|
|
17
|
+
storageUnits: localforage.createInstance({ name: 'fdFactory', storeName: 'storageUnits' })
|
|
18
|
+
};
|
|
19
|
+
|
|
11
20
|
const state = {
|
|
12
21
|
sites: null,
|
|
13
22
|
workAreas: null,
|
|
@@ -39,7 +48,57 @@ const mutations = {
|
|
|
39
48
|
};
|
|
40
49
|
|
|
41
50
|
const actions = {
|
|
42
|
-
async initFdCache({ commit }) {
|
|
51
|
+
async initFdCache({ commit, dispatch }) {
|
|
52
|
+
try {
|
|
53
|
+
const loadedFromCache = await dispatch('loadFromLocalStorage');
|
|
54
|
+
|
|
55
|
+
if (loadedFromCache) {
|
|
56
|
+
dispatch('refreshFromServer');
|
|
57
|
+
return loadedFromCache;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return await dispatch('refreshFromServer');
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error("Failed to initialize FD factory cache:", error);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
async loadFromLocalStorage({ commit }) {
|
|
68
|
+
try {
|
|
69
|
+
const [
|
|
70
|
+
sites,
|
|
71
|
+
workAreas,
|
|
72
|
+
workCenters,
|
|
73
|
+
workUnits,
|
|
74
|
+
storageZones,
|
|
75
|
+
storageUnits
|
|
76
|
+
] = await Promise.all([
|
|
77
|
+
storage.sites.getItem('data'),
|
|
78
|
+
storage.workAreas.getItem('data'),
|
|
79
|
+
storage.workCenters.getItem('data'),
|
|
80
|
+
storage.workUnits.getItem('data'),
|
|
81
|
+
storage.storageZones.getItem('data'),
|
|
82
|
+
storage.storageUnits.getItem('data')
|
|
83
|
+
]);
|
|
84
|
+
|
|
85
|
+
if (sites && workAreas && workCenters && workUnits && storageZones && storageUnits) {
|
|
86
|
+
commit('SET_SITES', sites);
|
|
87
|
+
commit('SET_WORK_AREAS', workAreas);
|
|
88
|
+
commit('SET_WORK_CENTERS', workCenters);
|
|
89
|
+
commit('SET_WORK_UNITS', workUnits);
|
|
90
|
+
commit('SET_STORAGE_ZONES', storageZones);
|
|
91
|
+
commit('SET_STORAGE_UNITS', storageUnits);
|
|
92
|
+
return [sites, workAreas, workCenters, workUnits, storageZones, storageUnits];
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error("Failed to load from local storage:", error);
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
async refreshFromServer({ commit }) {
|
|
43
102
|
try {
|
|
44
103
|
const requests = [
|
|
45
104
|
getUrl("/fd/fd/getAllSites"),
|
|
@@ -51,18 +110,51 @@ const actions = {
|
|
|
51
110
|
];
|
|
52
111
|
|
|
53
112
|
const responses = await Promise.all(requests);
|
|
113
|
+
const data = responses.map(r => r.data);
|
|
114
|
+
|
|
115
|
+
commit('SET_SITES', data[0]);
|
|
116
|
+
Vue.prototype.$cache.local.setJSON("sites", data[0]);
|
|
117
|
+
commit('SET_WORK_AREAS', data[1]);
|
|
118
|
+
commit('SET_WORK_CENTERS', data[2]);
|
|
119
|
+
commit('SET_WORK_UNITS', data[3]);
|
|
120
|
+
commit('SET_STORAGE_ZONES', data[4]);
|
|
121
|
+
commit('SET_STORAGE_UNITS', data[5]);
|
|
54
122
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
123
|
+
await Promise.all([
|
|
124
|
+
storage.sites.setItem('data', data[0]),
|
|
125
|
+
storage.workAreas.setItem('data', data[1]),
|
|
126
|
+
storage.workCenters.setItem('data', data[2]),
|
|
127
|
+
storage.workUnits.setItem('data', data[3]),
|
|
128
|
+
storage.storageZones.setItem('data', data[4]),
|
|
129
|
+
storage.storageUnits.setItem('data', data[5])
|
|
130
|
+
]);
|
|
62
131
|
|
|
63
|
-
return
|
|
132
|
+
return data;
|
|
64
133
|
} catch (error) {
|
|
65
|
-
console.error("Failed to
|
|
134
|
+
console.error("Failed to refresh from server:", error);
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
async clearLocalCache({ commit }) {
|
|
140
|
+
try {
|
|
141
|
+
await Promise.all([
|
|
142
|
+
storage.sites.removeItem('data'),
|
|
143
|
+
storage.workAreas.removeItem('data'),
|
|
144
|
+
storage.workCenters.removeItem('data'),
|
|
145
|
+
storage.workUnits.removeItem('data'),
|
|
146
|
+
storage.storageZones.removeItem('data'),
|
|
147
|
+
storage.storageUnits.removeItem('data')
|
|
148
|
+
]);
|
|
149
|
+
|
|
150
|
+
commit('SET_SITES', null);
|
|
151
|
+
commit('SET_WORK_AREAS', null);
|
|
152
|
+
commit('SET_WORK_CENTERS', null);
|
|
153
|
+
commit('SET_WORK_UNITS', null);
|
|
154
|
+
commit('SET_STORAGE_ZONES', null);
|
|
155
|
+
commit('SET_STORAGE_UNITS', null);
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.error("Failed to clear local cache:", error);
|
|
66
158
|
throw error;
|
|
67
159
|
}
|
|
68
160
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
// store/modules/smSysSettings.js
|
|
2
1
|
import { getUrl } from '../api/common/common';
|
|
2
|
+
import localforage from 'localforage';
|
|
3
|
+
|
|
4
|
+
// 配置LocalForage实例
|
|
5
|
+
const settingsStorage = localforage.createInstance({
|
|
6
|
+
name: 'smSysSettings', // 数据库名称
|
|
7
|
+
storeName: 'settings' // 表名
|
|
8
|
+
});
|
|
3
9
|
|
|
4
10
|
const state = {
|
|
5
11
|
settings: null
|
|
@@ -12,12 +18,82 @@ const mutations = {
|
|
|
12
18
|
};
|
|
13
19
|
|
|
14
20
|
const actions = {
|
|
15
|
-
async initSmCache({ commit }) {
|
|
21
|
+
async initSmCache({ commit, dispatch }) {
|
|
22
|
+
try {
|
|
23
|
+
// 先尝试从本地加载
|
|
24
|
+
const cachedSettings = await dispatch('loadFromLocalStorage');
|
|
25
|
+
|
|
26
|
+
if (cachedSettings) {
|
|
27
|
+
// 如果有缓存,后台静默刷新
|
|
28
|
+
dispatch('refreshFromServer');
|
|
29
|
+
return cachedSettings;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 没有缓存则从服务器加载
|
|
33
|
+
return await dispatch('refreshFromServer');
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error("初始化系统设置失败:", error);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
// 从本地存储加载
|
|
41
|
+
async loadFromLocalStorage({ commit }) {
|
|
42
|
+
try {
|
|
43
|
+
const settings = await settingsStorage.getItem('data');
|
|
44
|
+
if (settings) {
|
|
45
|
+
commit('SET_SETTINGS', settings);
|
|
46
|
+
return settings;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error("从本地加载设置失败:", error);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
async refreshFromServer({ commit }) {
|
|
16
56
|
try {
|
|
17
57
|
const response = await getUrl("/sm/SmSysSetting/getSmSysSettingAll");
|
|
18
|
-
|
|
58
|
+
const settings = response.data;
|
|
59
|
+
|
|
60
|
+
commit('SET_SETTINGS', settings);
|
|
61
|
+
|
|
62
|
+
await settingsStorage.setItem('data', settings);
|
|
63
|
+
|
|
64
|
+
return settings;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error("从服务器刷新设置失败:", error);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
// 清除本地缓存
|
|
72
|
+
async clearLocalCache({ commit }) {
|
|
73
|
+
try {
|
|
74
|
+
await settingsStorage.removeItem('data');
|
|
75
|
+
commit('SET_SETTINGS', null);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error("清除本地缓存失败:", error);
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
// 更新单个设置项
|
|
83
|
+
async updateSetting({ commit, state }, { paramCode, paramValue }) {
|
|
84
|
+
try {
|
|
85
|
+
// 更新状态
|
|
86
|
+
const updatedSettings = state.settings.map(item =>
|
|
87
|
+
item.paramCode === paramCode ? { ...item, paramValue } : item
|
|
88
|
+
);
|
|
89
|
+
commit('SET_SETTINGS', updatedSettings);
|
|
90
|
+
|
|
91
|
+
// 更新本地存储
|
|
92
|
+
await settingsStorage.setItem('data', updatedSettings);
|
|
93
|
+
|
|
94
|
+
// 这里可以添加服务器更新逻辑
|
|
19
95
|
} catch (error) {
|
|
20
|
-
console.error("
|
|
96
|
+
console.error("更新设置失败:", error);
|
|
21
97
|
throw error;
|
|
22
98
|
}
|
|
23
99
|
}
|
|
@@ -28,6 +104,10 @@ const getters = {
|
|
|
28
104
|
if (!state.settings) return null;
|
|
29
105
|
const item = state.settings.find(item => item.paramCode === paramCode);
|
|
30
106
|
return item ? item.paramValue : null;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
allSettings: (state) => {
|
|
110
|
+
return state.settings || [];
|
|
31
111
|
}
|
|
32
112
|
};
|
|
33
113
|
|
|
@@ -1,42 +1,93 @@
|
|
|
1
|
-
// store/modules/tmTooling.js
|
|
2
1
|
import { getUrl } from '../api/common/common';
|
|
2
|
+
import localforage from 'localforage';
|
|
3
|
+
|
|
4
|
+
const toolingStorage = localforage.createInstance({
|
|
5
|
+
name: 'tooling-cache',
|
|
6
|
+
storeName: 'tooling_data'
|
|
7
|
+
});
|
|
3
8
|
|
|
4
9
|
const state = {
|
|
5
10
|
toolingList: null,
|
|
6
11
|
toolingIdMap: null,
|
|
7
|
-
toolingNoMap: null
|
|
12
|
+
toolingNoMap: null,
|
|
13
|
+
lastUpdated: null
|
|
8
14
|
};
|
|
9
15
|
|
|
10
16
|
const mutations = {
|
|
11
|
-
SET_TOOLING_LIST(state, list) {
|
|
12
|
-
state.toolingList = list;
|
|
13
|
-
// 预生成映射关系
|
|
17
|
+
SET_TOOLING_LIST(state, { list, lastUpdated }) {
|
|
18
|
+
state.toolingList = list || [];
|
|
14
19
|
state.toolingIdMap = {};
|
|
15
20
|
state.toolingNoMap = {};
|
|
16
|
-
|
|
21
|
+
state.lastUpdated = lastUpdated || new Date().toISOString();
|
|
22
|
+
|
|
23
|
+
(list || []).forEach(item => {
|
|
17
24
|
state.toolingIdMap[item.id] = item;
|
|
18
25
|
state.toolingNoMap[item.toolingNo] = item;
|
|
19
26
|
});
|
|
20
|
-
}
|
|
27
|
+
},
|
|
21
28
|
};
|
|
22
29
|
|
|
23
30
|
const actions = {
|
|
24
|
-
async initTmCache({ commit }) {
|
|
31
|
+
async initTmCache({ commit, state }) {
|
|
25
32
|
try {
|
|
33
|
+
|
|
34
|
+
const cachedData = await toolingStorage.getItem('toolingData');
|
|
35
|
+
const cacheTime = await toolingStorage.getItem('lastUpdated');
|
|
36
|
+
|
|
37
|
+
const oneHourAgo = new Date(Date.now() - 3600000).toISOString();
|
|
38
|
+
if (cachedData && cacheTime && cacheTime > oneHourAgo) {
|
|
39
|
+
commit('SET_TOOLING_LIST', {
|
|
40
|
+
list: cachedData,
|
|
41
|
+
lastUpdated: cacheTime
|
|
42
|
+
});
|
|
43
|
+
return cachedData;
|
|
44
|
+
}
|
|
45
|
+
|
|
26
46
|
const response = await getUrl("/tm/tooling/list");
|
|
27
|
-
|
|
47
|
+
if (!response.data) {
|
|
48
|
+
throw new Error("服务器返回空数据");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await toolingStorage.setItem('toolingData', response.data);
|
|
52
|
+
const newLastUpdated = new Date().toISOString();
|
|
53
|
+
await toolingStorage.setItem('lastUpdated', newLastUpdated);
|
|
54
|
+
|
|
55
|
+
commit('SET_TOOLING_LIST', {
|
|
56
|
+
list: response.data,
|
|
57
|
+
lastUpdated: newLastUpdated
|
|
58
|
+
});
|
|
28
59
|
return response.data;
|
|
29
60
|
} catch (error) {
|
|
30
|
-
console.error("
|
|
61
|
+
console.error("初始化刀具缓存失败:", error);
|
|
62
|
+
|
|
63
|
+
const cachedData = await toolingStorage.getItem('toolingData');
|
|
64
|
+
if (cachedData) {
|
|
65
|
+
commit('SET_TOOLING_LIST', {
|
|
66
|
+
list: cachedData,
|
|
67
|
+
lastUpdated: await toolingStorage.getItem('lastUpdated')
|
|
68
|
+
});
|
|
69
|
+
return cachedData;
|
|
70
|
+
}
|
|
71
|
+
|
|
31
72
|
throw error;
|
|
32
73
|
}
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
async clearToolingCache() {
|
|
77
|
+
await toolingStorage.clear();
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
async refreshToolingCache({ dispatch }) {
|
|
81
|
+
await toolingStorage.removeItem('lastUpdated');
|
|
82
|
+
return dispatch('initTmCache');
|
|
33
83
|
}
|
|
34
84
|
};
|
|
35
85
|
|
|
36
86
|
const getters = {
|
|
37
|
-
toolingList: state => state.toolingList,
|
|
38
|
-
toolingIdMap: state => state.toolingIdMap,
|
|
39
|
-
toolingNoMap: state => state.toolingNoMap
|
|
87
|
+
toolingList: state => state.toolingList || [],
|
|
88
|
+
toolingIdMap: state => state.toolingIdMap || {},
|
|
89
|
+
toolingNoMap: state => state.toolingNoMap || {},
|
|
90
|
+
lastUpdated: state => state.lastUpdated,
|
|
40
91
|
};
|
|
41
92
|
|
|
42
93
|
export default {
|
package/package.json
CHANGED
|
@@ -282,9 +282,10 @@ export default {
|
|
|
282
282
|
params.deptId = this.listQueryParams.deptId
|
|
283
283
|
}
|
|
284
284
|
selectPageByEmployeeSearchVo(params).then(response => {
|
|
285
|
-
response.rows.forEach(item => {
|
|
285
|
+
response.rows.forEach(async item => {
|
|
286
286
|
item.deptName = getNameByDeptId(item.deptId)
|
|
287
|
-
item.postName = getNameByPostId(item.postId)
|
|
287
|
+
// item.postName = await getNameByPostId(item.postId)
|
|
288
|
+
this.$set(item,'postName',await getNameByPostId(item.postId))
|
|
288
289
|
})
|
|
289
290
|
this.listQueryParams.total = Number(response.total);
|
|
290
291
|
this.listData = response.rows;
|