@infly/ui 1.0.17 → 1.0.19

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.
Files changed (33) hide show
  1. package/README.md +43 -43
  2. package/package.json +53 -29
  3. package/scripts/install-comp.js +13 -0
  4. package/src/Base/InflyCheckBox/InflyCheckBox.test.js +154 -0
  5. package/src/Base/InflyCheckBox/InflyCheckBox.vue +227 -0
  6. package/src/Base/InflyCheckBox/index.js +6 -0
  7. package/src/Base/InflyDialog/InflyDialog.test.js +122 -0
  8. package/src/Base/InflyDialog/InflyDialog.vue +111 -0
  9. package/src/Base/InflyDialog/index.js +6 -0
  10. package/src/Base/InflyForm/InflyForm.test.js +239 -0
  11. package/src/Base/InflyForm/InflyForm.vue +974 -0
  12. package/src/Base/InflyForm/index.js +6 -0
  13. package/src/Base/InflyInput/InflyInput.test.js +105 -0
  14. package/src/Base/InflyInput/InflyInput.vue +167 -0
  15. package/src/Base/InflyInput/index.js +6 -0
  16. package/src/Base/InflyList/InflyList.test.js +229 -0
  17. package/src/Base/InflyList/InflyList.vue +925 -0
  18. package/src/Base/InflyList/index.js +6 -0
  19. package/src/Base/InflySelect/InflySelect.js +0 -0
  20. package/src/Business/BusinessSwitch/BusinessSwitch.test.js +96 -0
  21. package/src/Business/BusinessSwitch/BusinessSwitch.vue +115 -0
  22. package/src/Business/BusinessSwitch/index.js +6 -0
  23. package/src/Business/BusinessTag/BusinessTag.test.js +83 -0
  24. package/src/Business/BusinessTag/BusinessTag.vue +58 -0
  25. package/src/Business/BusinessTag/index.js +6 -0
  26. package/src/Business/InstitutionSelect/InstitutionSelect.test.js +158 -0
  27. package/src/Business/InstitutionSelect/InstitutionSelect.vue +770 -0
  28. package/src/Business/InstitutionSelect/index.js +6 -0
  29. package/src/index.js +30 -0
  30. package/styles/base.scss +755 -0
  31. package/styles/index.scss +202 -0
  32. package/styles/mixin.scss +19 -0
  33. package/styles/variables.scss +24 -0
@@ -0,0 +1,6 @@
1
+ import InflyList from "./InflyList.vue";
2
+ import { withInstall } from "../../../scripts/install-comp";
3
+
4
+ export { InflyList };
5
+
6
+ export default withInstall(InflyList);
File without changes
@@ -0,0 +1,96 @@
1
+ /**
2
+ * BusinessSwitch 组件测试
3
+ *
4
+ * 验证开关组件的行为:值切换、按钮显示条件、事件触发。
5
+ */
6
+ const { describe, it, assert, mount } = require("../../../test/helper");
7
+ const BusinessSwitch = require("./BusinessSwitch.vue");
8
+
9
+ describe("BusinessSwitch", () => {
10
+ describe("渲染", () => {
11
+ it("默认不渲染 el-switch(showSwitch=true 时 v-if=!showSwitch)", () => {
12
+ // 注意:showSwitch prop 的模板逻辑是 v-if="!showSwitch"
13
+ // showSwitch=true(默认)→隐藏, showSwitch=false→显示
14
+ const wrapper = mount(BusinessSwitch, {
15
+ propsData: { value: 0, showSwitch: false },
16
+ });
17
+ assert.ok(wrapper.find(".el-switch").exists());
18
+ wrapper.destroy();
19
+ });
20
+
21
+ it("showSwitch=true 时不渲染 el-switch", () => {
22
+ const wrapper = mount(BusinessSwitch, {
23
+ propsData: { value: 0, showSwitch: true },
24
+ });
25
+ assert.equal(wrapper.find(".el-switch").exists(), false);
26
+ wrapper.destroy();
27
+ });
28
+
29
+ it("默认隐藏操作按钮(value != showButtonWhen)", () => {
30
+ const wrapper = mount(BusinessSwitch, {
31
+ propsData: { value: 0 },
32
+ });
33
+ // showButton 为 false 时应无操作按钮
34
+ assert.equal(wrapper.vm.showButton, false);
35
+ wrapper.destroy();
36
+ });
37
+
38
+ it("value 匹配 showButtonWhen 时显示操作按钮", () => {
39
+ const wrapper = mount(BusinessSwitch, {
40
+ propsData: { value: 1, showButtonWhen: 1 },
41
+ });
42
+ assert.equal(wrapper.vm.showButton, true);
43
+ wrapper.destroy();
44
+ });
45
+ });
46
+
47
+ describe("事件", () => {
48
+ it("handleButtonClick 触发 click 事件", () => {
49
+ const wrapper = mount(BusinessSwitch, {
50
+ propsData: { value: 1, showButtonWhen: 1 },
51
+ });
52
+ wrapper.vm.handleButtonClick();
53
+ assert.equal(wrapper.emitted().click.length, 1);
54
+ assert.equal(wrapper.emitted().click[0][0], 1);
55
+ wrapper.destroy();
56
+ });
57
+ });
58
+
59
+ describe("Props", () => {
60
+ it("支持自定义 activeValue 和 inactiveValue", () => {
61
+ const wrapper = mount(BusinessSwitch, {
62
+ propsData: {
63
+ value: "on",
64
+ activeValue: "on",
65
+ inactiveValue: "off",
66
+ },
67
+ });
68
+ assert.ok(wrapper.exists());
69
+ wrapper.destroy();
70
+ });
71
+
72
+ it("支持自定义按钮文本", () => {
73
+ const wrapper = mount(BusinessSwitch, {
74
+ propsData: {
75
+ value: 1,
76
+ showButtonWhen: 1,
77
+ buttonText: "编辑",
78
+ },
79
+ });
80
+ assert.ok(wrapper.text().includes("编辑"));
81
+ wrapper.destroy();
82
+ });
83
+
84
+ it("hideButton 强制隐藏按钮", () => {
85
+ const wrapper = mount(BusinessSwitch, {
86
+ propsData: {
87
+ value: 1,
88
+ showButtonWhen: 1,
89
+ hideButton: true,
90
+ },
91
+ });
92
+ assert.equal(wrapper.vm.showButton, false);
93
+ wrapper.destroy();
94
+ });
95
+ });
96
+ });
@@ -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 "@infly/libs/module/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,6 @@
1
+ import BusinessSwitch from "./BusinessSwitch.vue";
2
+ import { withInstall } from "../../../scripts/install-comp";
3
+
4
+ export { BusinessSwitch };
5
+
6
+ export default withInstall(BusinessSwitch);
@@ -0,0 +1,83 @@
1
+ /**
2
+ * BusinessTag 组件测试
3
+ *
4
+ * 验证标签组件的选项映射、tagType 计算和默认行为。
5
+ */
6
+ const { describe, it, assert, mount } = require("../../../test/helper");
7
+ const BusinessTag = require("./BusinessTag.vue");
8
+
9
+ const MOCK_OPTIONS = [
10
+ { name: "待审核", value: 0, tagType: "info" },
11
+ { name: "已通过", value: 1, tagType: "success" },
12
+ { name: "已拒绝", value: 2, tagType: "danger" },
13
+ ];
14
+
15
+ describe("BusinessTag", () => {
16
+ describe("渲染", () => {
17
+ it("根据 value 显示对应的 name 文本", () => {
18
+ const wrapper = mount(BusinessTag, {
19
+ propsData: { options: MOCK_OPTIONS, value: 1 },
20
+ });
21
+ assert.ok(wrapper.text().includes("已通过"));
22
+ wrapper.destroy();
23
+ });
24
+
25
+ it("value 不在 options 中时显示原始 value", () => {
26
+ const wrapper = mount(BusinessTag, {
27
+ propsData: { options: MOCK_OPTIONS, value: 99 },
28
+ });
29
+ assert.ok(wrapper.text().includes("99"));
30
+ wrapper.destroy();
31
+ });
32
+
33
+ it("根据 value 计算 tagType", () => {
34
+ const wrapper = mount(BusinessTag, {
35
+ propsData: { options: MOCK_OPTIONS, value: 2 },
36
+ });
37
+ const elTag = wrapper.find(".el-tag");
38
+ assert.ok(elTag.exists());
39
+ assert.ok(elTag.classes().includes("el-tag--danger"));
40
+ wrapper.destroy();
41
+ });
42
+
43
+ it("无匹配时使用 defaultTagType", () => {
44
+ const wrapper = mount(BusinessTag, {
45
+ propsData: {
46
+ options: MOCK_OPTIONS,
47
+ value: 99,
48
+ defaultTagType: "warning",
49
+ },
50
+ });
51
+ const elTag = wrapper.find(".el-tag");
52
+ assert.ok(elTag.classes().includes("el-tag--warning"));
53
+ wrapper.destroy();
54
+ });
55
+ });
56
+
57
+ describe("Props", () => {
58
+ it("支持自定义 valueProp 和 nameProp", () => {
59
+ const customOptions = [
60
+ { label: "选项A", key: "a" },
61
+ { label: "选项B", key: "b" },
62
+ ];
63
+ const wrapper = mount(BusinessTag, {
64
+ propsData: {
65
+ options: customOptions,
66
+ value: "b",
67
+ valueProp: "key",
68
+ nameProp: "label",
69
+ },
70
+ });
71
+ assert.ok(wrapper.text().includes("选项B"));
72
+ wrapper.destroy();
73
+ });
74
+
75
+ it("默认值时不抛错", () => {
76
+ const wrapper = mount(BusinessTag, {
77
+ propsData: { options: MOCK_OPTIONS },
78
+ });
79
+ assert.ok(wrapper.exists());
80
+ wrapper.destroy();
81
+ });
82
+ });
83
+ });
@@ -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 "@infly/libs/module/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>
@@ -0,0 +1,6 @@
1
+ import BusinessTag from "./BusinessTag.vue";
2
+ import { withInstall } from "../../../scripts/install-comp";
3
+
4
+ export { BusinessTag };
5
+
6
+ export default withInstall(BusinessTag);
@@ -0,0 +1,158 @@
1
+ /**
2
+ * InstitutionSelect 组件测试
3
+ *
4
+ * 验证机构选择器的渲染、单选/多选模式、props 和事件。
5
+ * 使用 shallowMount 隔离 vuex mapGetters 和 axios 依赖。
6
+ */
7
+ const { describe, it, assert, shallowMount } = require("../../../test/helper");
8
+ const InstitutionSelect = require("./InstitutionSelect.vue");
9
+
10
+ describe("InstitutionSelect", () => {
11
+ describe("渲染", () => {
12
+ it("渲染容器 div", () => {
13
+ const wrapper = shallowMount(InstitutionSelect, {
14
+ propsData: { value: "" },
15
+ });
16
+ assert.ok(wrapper.find(".comp-InstitutionSelect").exists());
17
+ wrapper.destroy();
18
+ });
19
+
20
+ it("默认显示选择按钮", () => {
21
+ const wrapper = shallowMount(InstitutionSelect, {
22
+ propsData: { value: "" },
23
+ });
24
+ // showSelectBtn 默认 true
25
+ assert.equal(wrapper.props().showSelectBtn, true);
26
+ wrapper.destroy();
27
+ });
28
+
29
+ it("showSelectBtn=false 时隐藏选择按钮", () => {
30
+ const wrapper = shallowMount(InstitutionSelect, {
31
+ propsData: {
32
+ value: "",
33
+ showSelectBtn: false,
34
+ },
35
+ });
36
+ assert.equal(wrapper.props().showSelectBtn, false);
37
+ wrapper.destroy();
38
+ });
39
+ });
40
+
41
+ describe("Props", () => {
42
+ it("接收初始 value", () => {
43
+ const wrapper = shallowMount(InstitutionSelect, {
44
+ propsData: { value: "123" },
45
+ });
46
+ assert.equal(wrapper.props().value, "123");
47
+ wrapper.destroy();
48
+ });
49
+
50
+ it("支持自定义 IdKey", () => {
51
+ const wrapper = shallowMount(InstitutionSelect, {
52
+ propsData: {
53
+ value: "",
54
+ IdKey: "org_id",
55
+ },
56
+ });
57
+ assert.equal(wrapper.props().IdKey, "org_id");
58
+ wrapper.destroy();
59
+ });
60
+
61
+ it("支持自定义 btnText", () => {
62
+ const wrapper = shallowMount(InstitutionSelect, {
63
+ propsData: {
64
+ value: "",
65
+ btnText: "选择机构",
66
+ },
67
+ });
68
+ assert.equal(wrapper.props().btnText, "选择机构");
69
+ wrapper.destroy();
70
+ });
71
+
72
+ it("支持多选模式 showTableSelect", () => {
73
+ const wrapper = shallowMount(InstitutionSelect, {
74
+ propsData: {
75
+ value: [],
76
+ showTableSelect: true,
77
+ },
78
+ });
79
+ assert.equal(wrapper.props().showTableSelect, true);
80
+ wrapper.destroy();
81
+ });
82
+
83
+ it("单选模式接收字符串值", () => {
84
+ const wrapper = shallowMount(InstitutionSelect, {
85
+ propsData: { value: "level_001" },
86
+ });
87
+ // 不抛错即可
88
+ assert.ok(wrapper.exists());
89
+ wrapper.destroy();
90
+ });
91
+
92
+ it("多选模式接收数组值", () => {
93
+ const wrapper = shallowMount(InstitutionSelect, {
94
+ propsData: {
95
+ value: [{ id: 1 }, { id: 2 }],
96
+ showTableSelect: true,
97
+ },
98
+ });
99
+ // 不抛错即可
100
+ assert.ok(wrapper.exists());
101
+ wrapper.destroy();
102
+ });
103
+ });
104
+
105
+ describe("表单数据", () => {
106
+ it("formData 可传入外部数据", () => {
107
+ const wrapper = shallowMount(InstitutionSelect, {
108
+ propsData: {
109
+ value: "",
110
+ formData: { level_id: "", level_name: "" },
111
+ },
112
+ });
113
+ assert.ok(wrapper.exists());
114
+ wrapper.destroy();
115
+ });
116
+ });
117
+
118
+ describe("弹窗", () => {
119
+ it("modalVisible 初始为 false", () => {
120
+ const wrapper = shallowMount(InstitutionSelect, {
121
+ propsData: { value: "" },
122
+ });
123
+ assert.equal(wrapper.vm.modalVisible, false);
124
+ wrapper.destroy();
125
+ });
126
+
127
+ it("openModal 打开弹窗", () => {
128
+ const wrapper = shallowMount(InstitutionSelect, {
129
+ propsData: { value: "" },
130
+ });
131
+ wrapper.vm.openModal();
132
+ assert.equal(wrapper.vm.$data.isShowModal, true);
133
+ wrapper.destroy();
134
+ });
135
+
136
+ it("closeModal 关闭弹窗并触发 close 事件", () => {
137
+ const wrapper = shallowMount(InstitutionSelect, {
138
+ propsData: { value: "" },
139
+ });
140
+ wrapper.vm.closeModal();
141
+ assert.equal(wrapper.vm.$data.isShowModal, false);
142
+ assert.ok(wrapper.emitted().close);
143
+ wrapper.destroy();
144
+ });
145
+ });
146
+
147
+ describe("选择逻辑", () => {
148
+ it("onDelete 清空选择并触发 input 事件", () => {
149
+ const wrapper = shallowMount(InstitutionSelect, {
150
+ propsData: { value: "123" },
151
+ });
152
+ wrapper.vm.onDelete();
153
+ assert.ok(wrapper.emitted().input);
154
+ assert.equal(wrapper.emitted().input[0][0], "");
155
+ wrapper.destroy();
156
+ });
157
+ });
158
+ });