haiwei-module-admin 1.1.7 → 1.1.8
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.1.
|
|
5
|
+
"version": "1.1.8",
|
|
6
6
|
"description": "haiwei前端Admin模块组件",
|
|
7
7
|
"author": "Eric",
|
|
8
8
|
"license": "ISC",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"haiwei-skins-classics": "^1.0.7",
|
|
22
|
-
"haiwei-ui": "^1.
|
|
22
|
+
"haiwei-ui": "^1.4.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@vue/cli-plugin-babel": "^4.4.4",
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script>
|
|
9
|
-
|
|
10
|
-
const enumCache = new Map()
|
|
9
|
+
import { mixins } from 'haiwei-ui'
|
|
11
10
|
|
|
12
11
|
export default {
|
|
12
|
+
mixins: [mixins.text],
|
|
13
13
|
props: {
|
|
14
14
|
/** 枚举值 */
|
|
15
15
|
value: {
|
|
@@ -54,24 +54,18 @@ export default {
|
|
|
54
54
|
default: 'small'
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
-
data() {
|
|
58
|
-
return {
|
|
59
|
-
enumList: [],
|
|
60
|
-
loading: false
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
57
|
computed: {
|
|
64
58
|
displayText() {
|
|
65
|
-
if (this.
|
|
59
|
+
if (this.value_ === null || this.value_ === undefined || this.value_ === '') {
|
|
66
60
|
return this.emptyText
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
const enumItem = this.
|
|
70
|
-
return enumItem ? enumItem.label : this.
|
|
63
|
+
const enumItem = this.options.find(item => item.value == this.value_)
|
|
64
|
+
return enumItem ? enumItem.label : this.value_
|
|
71
65
|
},
|
|
72
66
|
|
|
73
67
|
showTag() {
|
|
74
|
-
return this.useTag && this.
|
|
68
|
+
return this.useTag && this.value_ !== null && this.value_ !== undefined && this.value_ !== ''
|
|
75
69
|
},
|
|
76
70
|
|
|
77
71
|
// 计算tag颜色类型
|
|
@@ -86,12 +80,12 @@ export default {
|
|
|
86
80
|
// 如果是对象,根据枚举值查找对应的颜色
|
|
87
81
|
if (typeof this.tagType === 'object' && this.tagType !== null) {
|
|
88
82
|
// 首先尝试精确匹配
|
|
89
|
-
if (this.tagType[this.
|
|
90
|
-
return this.tagType[this.
|
|
83
|
+
if (this.tagType[this.value_] !== undefined) {
|
|
84
|
+
return this.tagType[this.value_]
|
|
91
85
|
}
|
|
92
86
|
|
|
93
87
|
// 尝试数字匹配
|
|
94
|
-
const numValue = Number(this.
|
|
88
|
+
const numValue = Number(this.value_)
|
|
95
89
|
if (this.tagType[numValue] !== undefined) {
|
|
96
90
|
return this.tagType[numValue]
|
|
97
91
|
}
|
|
@@ -99,12 +93,12 @@ export default {
|
|
|
99
93
|
}
|
|
100
94
|
|
|
101
95
|
// 如果没有指定或未找到匹配,根据枚举值自动计算
|
|
102
|
-
if (this.
|
|
96
|
+
if (this.value_ === null || this.value_ === undefined || this.value_ === '') {
|
|
103
97
|
return 'info'
|
|
104
98
|
}
|
|
105
99
|
|
|
106
100
|
// 将值转换为数字
|
|
107
|
-
const numValue = Number(this.
|
|
101
|
+
const numValue = Number(this.value_)
|
|
108
102
|
|
|
109
103
|
// 简单的颜色映射
|
|
110
104
|
if (numValue === 0) return 'primary' // 默认/初始状态
|
|
@@ -120,62 +114,19 @@ export default {
|
|
|
120
114
|
watch: {
|
|
121
115
|
moduleCode: {
|
|
122
116
|
immediate: true,
|
|
123
|
-
handler: '
|
|
117
|
+
handler: 'refresh'
|
|
124
118
|
},
|
|
125
119
|
enumName: {
|
|
126
120
|
immediate: true,
|
|
127
|
-
handler: '
|
|
121
|
+
handler: 'refresh'
|
|
128
122
|
},
|
|
129
123
|
libName: {
|
|
130
124
|
immediate: true,
|
|
131
|
-
handler: '
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
async loadEnumList() {
|
|
136
|
-
if (!this.moduleCode || !this.enumName) {
|
|
137
|
-
this.enumList = []
|
|
138
|
-
return
|
|
139
|
-
}
|
|
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
|
-
|
|
157
|
-
try {
|
|
158
|
-
const { moduleCode, enumName, libName } = this
|
|
159
|
-
const result = await $api.admin.tool.enumSelect({ moduleCode, enumName, libName })
|
|
160
|
-
|
|
161
|
-
// API返回的是数组格式:[{label: '出仓', value: 0}, {label: '入仓', value: 1}]
|
|
162
|
-
if (result && Array.isArray(result)) {
|
|
163
|
-
this.enumList = result
|
|
164
|
-
// 缓存结果
|
|
165
|
-
enumCache.set(cacheKey, result)
|
|
166
|
-
} else {
|
|
167
|
-
this.enumList = []
|
|
168
|
-
}
|
|
169
|
-
} catch (error) {
|
|
170
|
-
console.error('加载枚举列表失败:', error)
|
|
171
|
-
this.enumList = []
|
|
172
|
-
} finally {
|
|
173
|
-
this.loading = false
|
|
174
|
-
}
|
|
125
|
+
handler: 'refresh'
|
|
126
|
+
},
|
|
127
|
+
value(val) {
|
|
128
|
+
if (val !== this.value_) this.value_ = val
|
|
175
129
|
}
|
|
176
|
-
},
|
|
177
|
-
mounted() {
|
|
178
|
-
// 移除mounted中的调用,由watch的immediate处理
|
|
179
130
|
}
|
|
180
131
|
}
|
|
181
132
|
</script>
|