haiwei-module-admin 1.0.8 → 1.0.82

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": 0,
3
3
  "name": "haiwei-module-admin",
4
4
  "code": "admin",
5
- "version": "1.0.8",
5
+ "version": "1.0.82",
6
6
  "description": "haiwei前端Admin模块组件",
7
7
  "author": "Eric",
8
8
  "license": "ISC",
@@ -6,6 +6,9 @@
6
6
  </template>
7
7
 
8
8
  <script>
9
+ // 全局缓存,避免重复请求相同的枚举
10
+ const enumCache = new Map()
11
+
9
12
  export default {
10
13
  props: {
11
14
  /** 枚举值 */
@@ -24,7 +27,6 @@ export default {
24
27
  required: true
25
28
  },
26
29
  /** 所在库 */
27
- /**所在库 */
28
30
  libName: String,
29
31
  /** 空值显示文本 */
30
32
  emptyText: {
@@ -54,7 +56,8 @@ export default {
54
56
  },
55
57
  data() {
56
58
  return {
57
- enumList: []
59
+ enumList: [],
60
+ loading: false
58
61
  }
59
62
  },
60
63
  computed: {
@@ -135,23 +138,44 @@ export default {
135
138
  return
136
139
  }
137
140
 
141
+ // 生成缓存键
142
+ const cacheKey = `${this.moduleCode}_${this.enumName}_${this.libName || ''}`
143
+
144
+ // 检查缓存
145
+ if (enumCache.has(cacheKey)) {
146
+ this.enumList = enumCache.get(cacheKey)
147
+ return
148
+ }
149
+
150
+ // 防止重复请求
151
+ if (this.loading) {
152
+ return
153
+ }
154
+
155
+ this.loading = true
156
+
138
157
  try {
139
158
  const { moduleCode, enumName, libName } = this
140
159
  const result = await $api.admin.tool.enumSelect({ moduleCode, enumName, libName })
141
160
 
142
- if (result && result.data) {
143
- this.enumList = result.data
161
+ // API返回的是数组格式:[{label: '出仓', value: 0}, {label: '入仓', value: 1}]
162
+ if (result && Array.isArray(result)) {
163
+ this.enumList = result
164
+ // 缓存结果
165
+ enumCache.set(cacheKey, result)
144
166
  } else {
145
167
  this.enumList = []
146
168
  }
147
169
  } catch (error) {
148
170
  console.error('加载枚举列表失败:', error)
149
171
  this.enumList = []
172
+ } finally {
173
+ this.loading = false
150
174
  }
151
175
  }
152
176
  },
153
177
  mounted() {
154
- this.loadEnumList()
178
+ // 移除mounted中的调用,由watch的immediate处理
155
179
  }
156
180
  }
157
181
  </script>