@infly/ui 1.0.18 → 1.0.20
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/README.md +53 -43
- package/index.js +47 -33
- package/package.json +60 -29
- package/scripts/install-comp.js +13 -0
- package/src/Base/InflyCheckBox/InflyCheckBox.test.js +154 -0
- package/src/Base/InflyCheckBox/InflyCheckBox.vue +227 -0
- package/src/Base/InflyCheckBox/index.js +6 -0
- package/src/Base/InflyDialog/InflyDialog.test.js +122 -0
- package/src/Base/InflyDialog/InflyDialog.vue +111 -0
- package/src/Base/InflyDialog/index.js +6 -0
- package/src/Base/InflyForm/InflyForm.test.js +239 -0
- package/src/Base/InflyForm/InflyForm.vue +974 -0
- package/src/Base/InflyForm/index.js +6 -0
- package/src/Base/InflyInput/InflyInput.test.js +105 -0
- package/src/Base/InflyInput/InflyInput.vue +167 -0
- package/src/Base/InflyInput/index.js +6 -0
- package/src/Base/InflyList/InflyList.test.js +229 -0
- package/src/Base/InflyList/InflyList.vue +926 -0
- package/src/Base/InflyList/index.js +6 -0
- package/src/Business/BusinessSwitch/BusinessSwitch.test.js +250 -0
- package/src/Business/BusinessSwitch/BusinessSwitch.vue +115 -0
- package/src/Business/BusinessSwitch/index.js +6 -0
- package/src/Business/BusinessTag/BusinessTag.test.js +70 -0
- package/src/Business/BusinessTag/BusinessTag.vue +58 -0
- package/src/Business/BusinessTag/index.js +6 -0
- package/src/Business/InstitutionSelect/InstitutionSelect.test.js +281 -0
- package/src/Business/InstitutionSelect/InstitutionSelect.vue +768 -0
- package/src/Business/InstitutionSelect/index.js +6 -0
- package/src/utils/Uts.js +3 -0
- package/src/utils/ts-libs.test.js +31 -0
- package/styles/base.scss +755 -0
- package/styles/index.scss +202 -0
- package/styles/mixin.scss +19 -0
- package/styles/variables.scss +24 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BusinessSwitch 组件测试
|
|
3
|
+
*
|
|
4
|
+
* 验证业务开关组件的 props、按钮显隐逻辑和事件。
|
|
5
|
+
* 注:与项目现有测试一致,不依赖 Element UI 的全局注册。
|
|
6
|
+
*/
|
|
7
|
+
const { mount } = require("../../../test/helper");
|
|
8
|
+
const BusinessSwitch = require("./BusinessSwitch.vue");
|
|
9
|
+
|
|
10
|
+
describe("BusinessSwitch", () => {
|
|
11
|
+
describe("渲染", () => {
|
|
12
|
+
it("渲染 comp-BusinessSwitch 容器", () => {
|
|
13
|
+
const wrapper = mount(BusinessSwitch, {
|
|
14
|
+
propsData: { value: 1 },
|
|
15
|
+
});
|
|
16
|
+
assert.ok(wrapper.find(".comp-BusinessSwitch").exists());
|
|
17
|
+
wrapper.destroy();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("默认 showSwitch=true 时渲染开关(存在容器)", () => {
|
|
21
|
+
const wrapper = mount(BusinessSwitch, {
|
|
22
|
+
propsData: { value: 1, showSwitch: true },
|
|
23
|
+
});
|
|
24
|
+
assert.ok(wrapper.find(".comp-BusinessSwitch").exists());
|
|
25
|
+
wrapper.destroy();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("showSwitch=false 时仍然渲染容器", () => {
|
|
29
|
+
const wrapper = mount(BusinessSwitch, {
|
|
30
|
+
propsData: { value: 1, showSwitch: false },
|
|
31
|
+
});
|
|
32
|
+
assert.ok(wrapper.find(".comp-BusinessSwitch").exists());
|
|
33
|
+
wrapper.destroy();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("Props", () => {
|
|
38
|
+
it("接收 value prop", () => {
|
|
39
|
+
const wrapper = mount(BusinessSwitch, {
|
|
40
|
+
propsData: { value: 1 },
|
|
41
|
+
});
|
|
42
|
+
assert.equal(wrapper.props().value, 1);
|
|
43
|
+
wrapper.destroy();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("默认 activeValue 为 1", () => {
|
|
47
|
+
const wrapper = mount(BusinessSwitch, {
|
|
48
|
+
propsData: { value: 0 },
|
|
49
|
+
});
|
|
50
|
+
assert.equal(wrapper.props().activeValue, 1);
|
|
51
|
+
wrapper.destroy();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("默认 inactiveValue 为 0", () => {
|
|
55
|
+
const wrapper = mount(BusinessSwitch, {
|
|
56
|
+
propsData: { value: 1 },
|
|
57
|
+
});
|
|
58
|
+
assert.equal(wrapper.props().inactiveValue, 0);
|
|
59
|
+
wrapper.destroy();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("支持自定义 activeValue 和 inactiveValue", () => {
|
|
63
|
+
const wrapper = mount(BusinessSwitch, {
|
|
64
|
+
propsData: {
|
|
65
|
+
value: "enabled",
|
|
66
|
+
activeValue: "enabled",
|
|
67
|
+
inactiveValue: "disabled",
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
assert.equal(wrapper.props().activeValue, "enabled");
|
|
71
|
+
assert.equal(wrapper.props().inactiveValue, "disabled");
|
|
72
|
+
wrapper.destroy();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("支持 disabled prop", () => {
|
|
76
|
+
const wrapper = mount(BusinessSwitch, {
|
|
77
|
+
propsData: { value: 0, disabled: true },
|
|
78
|
+
});
|
|
79
|
+
assert.equal(wrapper.props().disabled, true);
|
|
80
|
+
wrapper.destroy();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("disabled 默认为 false", () => {
|
|
84
|
+
const wrapper = mount(BusinessSwitch, {
|
|
85
|
+
propsData: { value: 0 },
|
|
86
|
+
});
|
|
87
|
+
assert.equal(wrapper.props().disabled, false);
|
|
88
|
+
wrapper.destroy();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("value 支持 Boolean/String/Number 类型", () => {
|
|
92
|
+
const boolWrapper = mount(BusinessSwitch, {
|
|
93
|
+
propsData: { value: true },
|
|
94
|
+
});
|
|
95
|
+
assert.equal(boolWrapper.props().value, true);
|
|
96
|
+
boolWrapper.destroy();
|
|
97
|
+
|
|
98
|
+
const strWrapper = mount(BusinessSwitch, {
|
|
99
|
+
propsData: { value: "1" },
|
|
100
|
+
});
|
|
101
|
+
assert.equal(strWrapper.props().value, "1");
|
|
102
|
+
strWrapper.destroy();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe("按钮显示逻辑(showButton 计算属性)", () => {
|
|
107
|
+
it("默认 showButtonWhen='1' 且 value='1' 时 showButton 为 true", () => {
|
|
108
|
+
const wrapper = mount(BusinessSwitch, {
|
|
109
|
+
propsData: { value: "1" },
|
|
110
|
+
});
|
|
111
|
+
assert.equal(wrapper.vm.showButton, true);
|
|
112
|
+
wrapper.destroy();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("value 不匹配 showButtonWhen 时 showButton 为 false", () => {
|
|
116
|
+
const wrapper = mount(BusinessSwitch, {
|
|
117
|
+
propsData: { value: "0", showButtonWhen: "1" },
|
|
118
|
+
});
|
|
119
|
+
assert.equal(wrapper.vm.showButton, false);
|
|
120
|
+
wrapper.destroy();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("hideButton=true(布尔值)时 showButton 为 false", () => {
|
|
124
|
+
const wrapper = mount(BusinessSwitch, {
|
|
125
|
+
propsData: { value: "1", hideButton: true },
|
|
126
|
+
});
|
|
127
|
+
assert.equal(wrapper.vm.showButton, false);
|
|
128
|
+
wrapper.destroy();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("hideButton=false(布尔值)时 showButton 由 value 匹配决定", () => {
|
|
132
|
+
const wrapper = mount(BusinessSwitch, {
|
|
133
|
+
propsData: { value: "1", hideButton: false },
|
|
134
|
+
});
|
|
135
|
+
assert.equal(wrapper.vm.showButton, true);
|
|
136
|
+
wrapper.destroy();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("hideButton='false'(字符串,isBoolean 只识别 typeof boolean)时不生效,回退到 value 匹配", () => {
|
|
140
|
+
// Uts.isBoolean 仅对 typeof === 'boolean' 返回 true,字符串 'false' 不是 boolean
|
|
141
|
+
const wrapper = mount(BusinessSwitch, {
|
|
142
|
+
propsData: { value: "1", hideButton: "false" },
|
|
143
|
+
});
|
|
144
|
+
assert.equal(wrapper.vm.showButton, true);
|
|
145
|
+
wrapper.destroy();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("支持自定义 showButtonWhen", () => {
|
|
149
|
+
const wrapper = mount(BusinessSwitch, {
|
|
150
|
+
propsData: { value: "active", showButtonWhen: "active" },
|
|
151
|
+
});
|
|
152
|
+
assert.equal(wrapper.vm.showButton, true);
|
|
153
|
+
wrapper.destroy();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("支持自定义 buttonText", () => {
|
|
157
|
+
const wrapper = mount(BusinessSwitch, {
|
|
158
|
+
propsData: { value: "1", buttonText: "编辑" },
|
|
159
|
+
});
|
|
160
|
+
assert.equal(wrapper.props().buttonText, "编辑");
|
|
161
|
+
wrapper.destroy();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("支持自定义 buttonType", () => {
|
|
165
|
+
const wrapper = mount(BusinessSwitch, {
|
|
166
|
+
propsData: { value: "1", buttonType: "danger" },
|
|
167
|
+
});
|
|
168
|
+
assert.equal(wrapper.props().buttonType, "danger");
|
|
169
|
+
wrapper.destroy();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("支持自定义 buttonSize", () => {
|
|
173
|
+
const wrapper = mount(BusinessSwitch, {
|
|
174
|
+
propsData: { value: "1", buttonSize: "small" },
|
|
175
|
+
});
|
|
176
|
+
assert.equal(wrapper.props().buttonSize, "small");
|
|
177
|
+
wrapper.destroy();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("支持自定义 buttonClass", () => {
|
|
181
|
+
const wrapper = mount(BusinessSwitch, {
|
|
182
|
+
propsData: { value: "1", buttonClass: "custom-btn" },
|
|
183
|
+
});
|
|
184
|
+
assert.equal(wrapper.props().buttonClass, "custom-btn");
|
|
185
|
+
wrapper.destroy();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("value 为数字 1 时匹配字符串 '1' 的 showButtonWhen(宽松比较)", () => {
|
|
189
|
+
const wrapper = mount(BusinessSwitch, {
|
|
190
|
+
propsData: { value: 1, showButtonWhen: "1" },
|
|
191
|
+
});
|
|
192
|
+
assert.equal(wrapper.vm.showButton, true);
|
|
193
|
+
wrapper.destroy();
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe("事件", () => {
|
|
198
|
+
it("handleChange 同时触发 input 和 change 事件并透传新值", () => {
|
|
199
|
+
const wrapper = mount(BusinessSwitch, {
|
|
200
|
+
propsData: { value: 0 },
|
|
201
|
+
});
|
|
202
|
+
wrapper.vm.handleChange(1);
|
|
203
|
+
assert.deepEqual(wrapper.emitted().input, [[1]]);
|
|
204
|
+
assert.deepEqual(wrapper.emitted().change, [[1]]);
|
|
205
|
+
wrapper.destroy();
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("handleButtonClick 触发 click 事件", () => {
|
|
209
|
+
const wrapper = mount(BusinessSwitch, {
|
|
210
|
+
propsData: { value: 0 },
|
|
211
|
+
});
|
|
212
|
+
wrapper.vm.handleChange(1);
|
|
213
|
+
assert.ok(wrapper.emitted("input"));
|
|
214
|
+
assert.equal(wrapper.emitted("input")[0][0], 1);
|
|
215
|
+
wrapper.destroy();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("handleChange 同时触发 input 和 change 事件", () => {
|
|
219
|
+
const wrapper = mount(BusinessSwitch, {
|
|
220
|
+
propsData: { value: 0 },
|
|
221
|
+
});
|
|
222
|
+
wrapper.vm.handleChange(0);
|
|
223
|
+
assert.ok(wrapper.emitted("change"));
|
|
224
|
+
assert.equal(wrapper.emitted("change")[0][0], 0);
|
|
225
|
+
assert.ok(wrapper.emitted("input"));
|
|
226
|
+
wrapper.destroy();
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("handleButtonClick 触发 click 事件并传递当前 value", () => {
|
|
230
|
+
const wrapper = mount(BusinessSwitch, {
|
|
231
|
+
propsData: { value: "1" },
|
|
232
|
+
});
|
|
233
|
+
wrapper.vm.handleButtonClick();
|
|
234
|
+
assert.ok(wrapper.emitted("click"));
|
|
235
|
+
assert.equal(wrapper.emitted("click")[0][0], "1");
|
|
236
|
+
wrapper.destroy();
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
describe("inheritAttrs", () => {
|
|
241
|
+
it("透传 $attrs 到根元素", () => {
|
|
242
|
+
const wrapper = mount(BusinessSwitch, {
|
|
243
|
+
propsData: { value: 0 },
|
|
244
|
+
attrs: { "data-test-id": "business-switch" },
|
|
245
|
+
});
|
|
246
|
+
assert.ok(wrapper.find(".comp-BusinessSwitch").exists());
|
|
247
|
+
wrapper.destroy();
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="comp-BusinessSwitch">
|
|
3
|
+
<el-switch
|
|
4
|
+
v-if="!showSwitch"
|
|
5
|
+
:value="value"
|
|
6
|
+
:active-value="activeValue"
|
|
7
|
+
:inactive-value="inactiveValue"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
@change="handleChange()"
|
|
11
|
+
/>
|
|
12
|
+
<!-- 内容插槽(兼容旧版) -->
|
|
13
|
+
<slot name="content"></slot>
|
|
14
|
+
<!-- 右侧操作按钮插槽 -->
|
|
15
|
+
<slot name="action" :value="value">
|
|
16
|
+
<el-button
|
|
17
|
+
v-if="showButton"
|
|
18
|
+
:type="buttonType"
|
|
19
|
+
:size="buttonSize"
|
|
20
|
+
:class="buttonClass"
|
|
21
|
+
@click="handleButtonClick()"
|
|
22
|
+
>
|
|
23
|
+
{{ buttonText }}
|
|
24
|
+
</el-button>
|
|
25
|
+
</slot>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
import Uts from "../../utils/Uts.js";
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
name: "BusinessSwitch",
|
|
34
|
+
inheritAttrs: false,
|
|
35
|
+
props: {
|
|
36
|
+
// v-model 绑定值
|
|
37
|
+
value: {
|
|
38
|
+
type: [Boolean, String, Number],
|
|
39
|
+
default: 0
|
|
40
|
+
},
|
|
41
|
+
// 激活状态的值
|
|
42
|
+
activeValue: {
|
|
43
|
+
type: [String, Number, Boolean],
|
|
44
|
+
default: 1
|
|
45
|
+
},
|
|
46
|
+
// 未激活状态的值
|
|
47
|
+
inactiveValue: {
|
|
48
|
+
type: [String, Number, Boolean],
|
|
49
|
+
default: 0
|
|
50
|
+
},
|
|
51
|
+
// 是否禁用
|
|
52
|
+
disabled: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
// 按钮文本
|
|
57
|
+
buttonText: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: "修改"
|
|
60
|
+
},
|
|
61
|
+
// 按钮类型
|
|
62
|
+
buttonType: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: "blue"
|
|
65
|
+
},
|
|
66
|
+
// 按钮大小
|
|
67
|
+
buttonSize: {
|
|
68
|
+
type: String,
|
|
69
|
+
default: "mini"
|
|
70
|
+
},
|
|
71
|
+
// 按钮样式类
|
|
72
|
+
buttonClass: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: "editBtn"
|
|
75
|
+
},
|
|
76
|
+
// 按钮显示条件:当值等于此值时显示按钮
|
|
77
|
+
showButtonWhen: {
|
|
78
|
+
type: [String, Number, Boolean],
|
|
79
|
+
default: "1"
|
|
80
|
+
},
|
|
81
|
+
// 是否始终隐藏按钮
|
|
82
|
+
hideButton: {
|
|
83
|
+
type: [Boolean, String],
|
|
84
|
+
default: ""
|
|
85
|
+
},
|
|
86
|
+
showSwitch: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
computed: {
|
|
92
|
+
showButton() {
|
|
93
|
+
if (Uts.isBoolean(this.hideButton)) return !this.hideButton;
|
|
94
|
+
return this.value == this.showButtonWhen;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
methods: {
|
|
98
|
+
handleChange(val) {
|
|
99
|
+
this.$emit("input", val);
|
|
100
|
+
this.$emit("change", val);
|
|
101
|
+
},
|
|
102
|
+
handleButtonClick() {
|
|
103
|
+
this.$emit("click", this.value);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<style scoped lang="scss">
|
|
110
|
+
.comp-BusinessSwitch {
|
|
111
|
+
.editBtn {
|
|
112
|
+
margin-left: 5px;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BusinessTag 组件测试
|
|
3
|
+
*
|
|
4
|
+
* 验证业务标签组件的标签类型解析、文本解析和自定义 prop 映射。
|
|
5
|
+
* 注:与项目现有测试一致,通过 vm 访问计算属性而非检查 Element UI DOM 类。
|
|
6
|
+
*/
|
|
7
|
+
const { mount } = require("../../../test/helper");
|
|
8
|
+
const BusinessTag = require("./BusinessTag.vue");
|
|
9
|
+
|
|
10
|
+
const MOCK_OPTIONS = [
|
|
11
|
+
{ name: "启用", value: "1", tagType: "success" },
|
|
12
|
+
{ name: "禁用", value: "0", tagType: "danger" },
|
|
13
|
+
{ name: "审核中", value: "2", tagType: "warning" },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
describe("BusinessTag", () => {
|
|
17
|
+
describe("渲染", () => {
|
|
18
|
+
it("渲染成功(不抛异常)", () => {
|
|
19
|
+
const wrapper = mount(BusinessTag, {
|
|
20
|
+
propsData: { value: "1", options: MOCK_OPTIONS },
|
|
21
|
+
});
|
|
22
|
+
assert.ok(wrapper.exists());
|
|
23
|
+
wrapper.destroy();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("支持自定义 tagTypeProp", () => {
|
|
27
|
+
const wrapper = mount(BusinessTag, {
|
|
28
|
+
propsData: {
|
|
29
|
+
options: [
|
|
30
|
+
{ label: "已支付", id: 1, status: "success" },
|
|
31
|
+
{ label: "待支付", id: 2, status: "warning" },
|
|
32
|
+
],
|
|
33
|
+
value: 2,
|
|
34
|
+
valueProp: "id",
|
|
35
|
+
nameProp: "label",
|
|
36
|
+
tagTypeProp: "status",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
assert.equal(wrapper.vm.tagType, "warning");
|
|
40
|
+
assert.equal(wrapper.vm.tagTypeText, "待支付");
|
|
41
|
+
wrapper.destroy();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("边界行为", () => {
|
|
46
|
+
it("空 options 时回退到默认类型和原始值", () => {
|
|
47
|
+
const wrapper = mount(BusinessTag, {
|
|
48
|
+
propsData: { options: [], value: "未知状态" },
|
|
49
|
+
});
|
|
50
|
+
assert.equal(wrapper.vm.tagType, "info");
|
|
51
|
+
assert.equal(wrapper.vm.tagTypeText, "未知状态");
|
|
52
|
+
wrapper.destroy();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("数字 0 能匹配选项而不被当作空值", () => {
|
|
56
|
+
const wrapper = mount(BusinessTag, {
|
|
57
|
+
propsData: {
|
|
58
|
+
options: [
|
|
59
|
+
{ name: "有效", value: 1, tagType: "success" },
|
|
60
|
+
{ name: "无效", value: 0, tagType: "danger" },
|
|
61
|
+
],
|
|
62
|
+
value: 0,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
assert.equal(wrapper.vm.tagType, "danger");
|
|
66
|
+
assert.equal(wrapper.vm.tagTypeText, "无效");
|
|
67
|
+
wrapper.destroy();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-tag :type="tagType">
|
|
3
|
+
{{ tagTypeText }}
|
|
4
|
+
</el-tag>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import Uts from "../../utils/Uts.js";
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
name: "BusinessTag",
|
|
12
|
+
props: {
|
|
13
|
+
value: {
|
|
14
|
+
type: [String, Number],
|
|
15
|
+
default: ""
|
|
16
|
+
},
|
|
17
|
+
options: {
|
|
18
|
+
type: Array,
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
data: {
|
|
22
|
+
type: Object,
|
|
23
|
+
default: () => ({})
|
|
24
|
+
},
|
|
25
|
+
nameProp: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: "name"
|
|
28
|
+
},
|
|
29
|
+
valueProp: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "value"
|
|
32
|
+
},
|
|
33
|
+
tagTypeProp: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "tagType"
|
|
36
|
+
},
|
|
37
|
+
defaultTagType: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: "info"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
computed: {
|
|
43
|
+
tagType() {
|
|
44
|
+
return this.getMapOption()[this.value] || this.defaultTagType;
|
|
45
|
+
},
|
|
46
|
+
tagTypeText() {
|
|
47
|
+
return (
|
|
48
|
+
this.getMapOption(undefined, this.nameProp)[this.value] || this.value
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
methods: {
|
|
53
|
+
getMapOption(keyParam = this.valueProp, valueParam = this.tagTypeProp) {
|
|
54
|
+
return Uts.pluckMap(this.options, keyParam, valueParam);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
</script>
|