haiwei-module-admin 1.1.7 → 1.1.9
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.9",
|
|
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.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@vue/cli-plugin-babel": "^4.4.4",
|
|
@@ -6,10 +6,15 @@
|
|
|
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
|
+
data() {
|
|
14
|
+
return {
|
|
15
|
+
action: this.query
|
|
16
|
+
}
|
|
17
|
+
},
|
|
13
18
|
props: {
|
|
14
19
|
/** 枚举值 */
|
|
15
20
|
value: {
|
|
@@ -54,24 +59,25 @@ export default {
|
|
|
54
59
|
default: 'small'
|
|
55
60
|
}
|
|
56
61
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
methods: {
|
|
63
|
+
query() {
|
|
64
|
+
const { moduleCode, enumName, libName } = this
|
|
65
|
+
// 使用缓存方法获取枚举数据
|
|
66
|
+
return this.getEnumData(moduleCode, enumName, libName)
|
|
61
67
|
}
|
|
62
68
|
},
|
|
63
69
|
computed: {
|
|
64
70
|
displayText() {
|
|
65
|
-
if (this.
|
|
71
|
+
if (this.value_ === null || this.value_ === undefined || this.value_ === '') {
|
|
66
72
|
return this.emptyText
|
|
67
73
|
}
|
|
68
74
|
|
|
69
|
-
const enumItem = this.
|
|
70
|
-
return enumItem ? enumItem.label : this.
|
|
75
|
+
const enumItem = this.options.find(item => item.value == this.value_)
|
|
76
|
+
return enumItem ? enumItem.label : this.value_
|
|
71
77
|
},
|
|
72
78
|
|
|
73
79
|
showTag() {
|
|
74
|
-
return this.useTag && this.
|
|
80
|
+
return this.useTag && this.value_ !== null && this.value_ !== undefined && this.value_ !== ''
|
|
75
81
|
},
|
|
76
82
|
|
|
77
83
|
// 计算tag颜色类型
|
|
@@ -86,12 +92,12 @@ export default {
|
|
|
86
92
|
// 如果是对象,根据枚举值查找对应的颜色
|
|
87
93
|
if (typeof this.tagType === 'object' && this.tagType !== null) {
|
|
88
94
|
// 首先尝试精确匹配
|
|
89
|
-
if (this.tagType[this.
|
|
90
|
-
return this.tagType[this.
|
|
95
|
+
if (this.tagType[this.value_] !== undefined) {
|
|
96
|
+
return this.tagType[this.value_]
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
// 尝试数字匹配
|
|
94
|
-
const numValue = Number(this.
|
|
100
|
+
const numValue = Number(this.value_)
|
|
95
101
|
if (this.tagType[numValue] !== undefined) {
|
|
96
102
|
return this.tagType[numValue]
|
|
97
103
|
}
|
|
@@ -99,12 +105,12 @@ export default {
|
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
// 如果没有指定或未找到匹配,根据枚举值自动计算
|
|
102
|
-
if (this.
|
|
108
|
+
if (this.value_ === null || this.value_ === undefined || this.value_ === '') {
|
|
103
109
|
return 'info'
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
// 将值转换为数字
|
|
107
|
-
const numValue = Number(this.
|
|
113
|
+
const numValue = Number(this.value_)
|
|
108
114
|
|
|
109
115
|
// 简单的颜色映射
|
|
110
116
|
if (numValue === 0) return 'primary' // 默认/初始状态
|
|
@@ -120,62 +126,19 @@ export default {
|
|
|
120
126
|
watch: {
|
|
121
127
|
moduleCode: {
|
|
122
128
|
immediate: true,
|
|
123
|
-
handler: '
|
|
129
|
+
handler: 'refresh'
|
|
124
130
|
},
|
|
125
131
|
enumName: {
|
|
126
132
|
immediate: true,
|
|
127
|
-
handler: '
|
|
133
|
+
handler: 'refresh'
|
|
128
134
|
},
|
|
129
135
|
libName: {
|
|
130
136
|
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
|
-
}
|
|
137
|
+
handler: 'refresh'
|
|
138
|
+
},
|
|
139
|
+
value(val) {
|
|
140
|
+
if (val !== this.value_) this.value_ = val
|
|
175
141
|
}
|
|
176
|
-
},
|
|
177
|
-
mounted() {
|
|
178
|
-
// 移除mounted中的调用,由watch的immediate处理
|
|
179
142
|
}
|
|
180
143
|
}
|
|
181
144
|
</script>
|