@infly/ui 1.0.18 → 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
package/README.md CHANGED
@@ -321,10 +321,10 @@ export default {
321
321
  | `formData` | `Object` | 必填 | 表单数据对象,字段通过 `name` 双向绑定。 | `:formData="{ keyword: '' }"` |
322
322
  | `formRef` | `String` | `"formRef"` | 内部 `el-form` ref 名称,供 `validate()` 等方法使用。 | `formRef="searchFormRef"` |
323
323
  | `btnList` | `Array` | `[]` | 表单上方按钮列表。 | `[{ label: "上传", type: "blue", btnEvent: this.openDialog }]` |
324
- | `filterList` | `Array` | `[]` | 表单字段配置。 | `[{ label: "名称", name: "name", type: "infly-input" }]` |
325
- | `reqParams` | `Object` | `{}` | 当前请求参数,导出按钮会从中取参数。通常由 `InflyList` 传入。 | `:reqParams="{ keyword: formData.keyword }"` |
326
- | `request` | `Function` | `null` | 导出按钮使用的请求实例。导出请求优先级为按钮 `exportFunc`、`request` prop、组件实例 `this.$axios`。 | `:request="$axios"` |
327
- | `hideSearchBtn` | `Boolean` | `false` | 隐藏底部默认“查询”按钮。 | `hideSearchBtn` |
324
+ | `filterList` | `Array` | `[]` | 表单字段配置。 | `[{ label: "名称", name: "name", type: "infly-input" }]` |
325
+ | `reqParams` | `Object` | `{}` | 当前请求参数,导出按钮会从中取参数。通常由 `InflyList` 传入。 | `:reqParams="{ keyword: formData.keyword }"` |
326
+ | `request` | `Function` | `null` | 导出按钮使用的请求实例。导出请求优先级为按钮 `exportFunc`、`request` prop、组件实例 `this.$axios`。 | `:request="$axios"` |
327
+ | `hideSearchBtn` | `Boolean` | `false` | 隐藏底部默认“查询”按钮。 | `hideSearchBtn` |
328
328
  | `hideResetBtn` | `Boolean` | `true` | 隐藏底部默认“重置”按钮。默认隐藏。 | `:hideResetBtn="false"` |
329
329
  | `isEdit` | `Boolean \| null` | `null` | 强制编辑/展示态;为 `null` 时按路由 `mode` 判断。 | `:isEdit="false"` |
330
330
  | `optBtnList` | `Array` | `[]` | 底部查询/重置后的附加按钮。 | `:optBtnList="[{ label: '保存', type: 'primary', btnEvent: 'submit' }]"` |
@@ -351,10 +351,10 @@ export default {
351
351
  | --- | --- | --- |
352
352
  | `initData` | 底部默认“查询”按钮点击。 | `@initData="search"` |
353
353
  | `reset-form` | 底部默认“重置”按钮点击,参数为初始表单快照。 | `@reset-form="(data) => Object.assign(formData, data)"` |
354
- | `submit` | 按钮 `btnEvent: "submit"` 且校验通过。 | `@submit="submitForm"` |
355
- | `secTabChange` / `sec-tab-change` | `type: "secTab"` 切换。 | `@secTabChange="handleSecTabChange"` |
356
- | `export-request-error` | 导出按钮配置了 `exportUrl` 但没有可用请求实例时触发。 | `@export-request-error="handleExportRequestError"` |
357
- | 自定义事件 | `btnEvent` 为字符串时直接 emit。 | `{ label: "保存", btnEvent: "save" }` + `@save="save"` |
354
+ | `submit` | 按钮 `btnEvent: "submit"` 且校验通过。 | `@submit="submitForm"` |
355
+ | `secTabChange` / `sec-tab-change` | `type: "secTab"` 切换。 | `@secTabChange="handleSecTabChange"` |
356
+ | `export-request-error` | 导出按钮配置了 `exportUrl` 但没有可用请求实例时触发。 | `@export-request-error="handleExportRequestError"` |
357
+ | 自定义事件 | `btnEvent` 为字符串时直接 emit。 | `{ label: "保存", btnEvent: "save" }` + `@save="save"` |
358
358
 
359
359
  ### 方法
360
360
 
@@ -444,19 +444,19 @@ filterList: [
444
444
  label: "所属省份",
445
445
  name: "province_level_id",
446
446
  type: "institution-select",
447
- title: "选择省份",
448
- btnText: "选择",
449
- request: this.$axios,
450
- reqModule: "admin",
451
- levelTypes: "1",
452
- levelNameKey: "province_level_name_filter",
453
- hideTips: true
454
- }
455
- ]
456
- ```
457
-
458
- `InstitutionSelect` 请求实例优先使用 `request` prop,其次使用组件实例 `this.$axios`。默认接口为 `/${reqModule}/level/`,也可以通过 `reqUrl` 显式覆盖;组件不再读取外部工具库的环境信息推导 `reqModule`。
459
-
447
+ title: "选择省份",
448
+ btnText: "选择",
449
+ request: this.$axios,
450
+ reqModule: "admin",
451
+ levelTypes: "1",
452
+ levelNameKey: "province_level_name_filter",
453
+ hideTips: true
454
+ }
455
+ ]
456
+ ```
457
+
458
+ `InstitutionSelect` 请求实例优先使用 `request` prop,其次使用组件实例 `this.$axios`。默认接口为 `/${reqModule}/level/`,也可以通过 `reqUrl` 显式覆盖;组件不再读取外部工具库的环境信息推导 `reqModule`。
459
+
460
460
  #### 复选:`infly-checkbox` / `InflyCheckBox`
461
461
 
462
462
  ```js
@@ -692,11 +692,11 @@ filterList: [
692
692
  #### 顶部按钮:`btnList`
693
693
 
694
694
  ```js
695
- btnList: [
696
- { label: "上传账单", type: "blue", btnEvent: () => { this.uploadDialogVisible = true; } },
697
- { label: "导出", type: "primary", isShow: () => this.canExport, btnEvent: this.exportList }
698
- ]
699
- ```
695
+ btnList: [
696
+ { label: "上传账单", type: "blue", btnEvent: () => { this.uploadDialogVisible = true; } },
697
+ { label: "导出", type: "primary", isShow: () => this.canExport, btnEvent: this.exportList }
698
+ ]
699
+ ```
700
700
 
701
701
  #### 底部按钮:默认查询、重置和 `optBtnList`
702
702
 
@@ -711,23 +711,23 @@ btnList: [
711
711
  />
712
712
  ```
713
713
 
714
- #### 导出按钮
715
-
716
- 导出请求实例按 `exportFunc -> request prop -> this.$axios` 的顺序解析;组件不再内置 `REST` fallback。独立使用 `InflyForm` 时,如果页面没有全局注入 `$axios`,需要显式传入 `request` 或在按钮上配置 `exportFunc`。
717
-
718
- ```vue
719
- <InflyForm
720
- :formData="formData"
721
- :filterList="filterList"
722
- :btnList="btnList"
723
- :request="$axios"
724
- />
725
- ```
726
-
727
- ```js
728
- btnList: [
729
- {
730
- label: "导出",
714
+ #### 导出按钮
715
+
716
+ 导出请求实例按 `exportFunc -> request prop -> this.$axios` 的顺序解析;组件不再内置 `REST` fallback。独立使用 `InflyForm` 时,如果页面没有全局注入 `$axios`,需要显式传入 `request` 或在按钮上配置 `exportFunc`。
717
+
718
+ ```vue
719
+ <InflyForm
720
+ :formData="formData"
721
+ :filterList="filterList"
722
+ :btnList="btnList"
723
+ :request="$axios"
724
+ />
725
+ ```
726
+
727
+ ```js
728
+ btnList: [
729
+ {
730
+ label: "导出",
731
731
  type: "success",
732
732
  exportUrl: "/admin/reconciliation/bills/export/",
733
733
  exportFileName: "金融营销对账账单",
package/package.json CHANGED
@@ -1,29 +1,53 @@
1
- {
2
- "name": "@infly/ui",
3
- "version": "1.0.18",
4
- "description": "组件库 ",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
8
- "publishPkg": "npm version patch && npm publish --access=public --registry=https://registry.npmjs.org/"
9
- },
10
- "exports": {
11
- ".": {
12
- "import": "./index.js",
13
- "require": "./index.js"
14
- }
15
- },
16
- "files": [
17
- "dist"
18
- ],
19
- "repository": {
20
- "type": "git",
21
- "url": "https://gitee.com/gdinfly_1/infly-ui.git"
22
- },
23
- "keywords": [
24
- "infly",
25
- "infly-ui"
26
- ],
27
- "author": "Kahal",
28
- "license": "ISC"
29
- }
1
+ {
2
+ "name": "@infly/ui",
3
+ "version": "1.0.19",
4
+ "description": "Infly 公共 UI 组件库(Vue 2)",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "node --test --test-timeout=30000 *.test.js src/**/*.test.js test/**/*.test.js",
8
+ "test:watch": "node --test --watch *.test.js src/**/*.test.js test/**/*.test.js",
9
+ "check": "node --test --test-timeout=30000 *.test.js src/**/*.test.js test/**/*.test.js",
10
+ "lint": "eslint .",
11
+ "lint:strict": "eslint . --max-warnings 0",
12
+ "prepublishOnly": "node --test --test-timeout=30000 *.test.js",
13
+ "publishPkg": "npm publish --access=public --registry=https://registry.npmjs.org/"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "import": "./index.js",
18
+ "require": "./index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "index.js",
23
+ "src/",
24
+ "styles/",
25
+ "scripts/install-comp.js",
26
+ "README.md"
27
+ ],
28
+ "dependencies": {
29
+ "@infly/libs": "workspace:*",
30
+ "@infly/ts-libs": "workspace:*"
31
+ },
32
+ "peerDependencies": {
33
+ "element-ui": "^2.15.0",
34
+ "vue": "^2.6.0 || ^2.7.0",
35
+ "vuex": "^3.0.0"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://gitee.com/gdinfly_1/infly-ui.git"
40
+ },
41
+ "keywords": [
42
+ "infly",
43
+ "infly-ui",
44
+ "vue2",
45
+ "element-ui",
46
+ "admin"
47
+ ],
48
+ "author": "Kahal",
49
+ "license": "ISC",
50
+ "devDependencies": {
51
+ "vue-template-compiler": "2.7.16"
52
+ }
53
+ }
@@ -0,0 +1,13 @@
1
+ // utils/withInstall.js
2
+ /**
3
+ * 为 Vue 组件添加 install 方法
4
+ * @param {Object} comp Vue 组件对象
5
+ * @param {string} name 组件名(可选,默认使用组件自身的 name 属性)
6
+ * @returns {Object} 添加了 install 方法的组件
7
+ */
8
+ export const withInstall = (comp, name) => {
9
+ comp.install = app => {
10
+ app.component(name || comp.name, comp);
11
+ };
12
+ return comp;
13
+ };
@@ -0,0 +1,154 @@
1
+ /**
2
+ * InflyCheckBox 组件测试
3
+ *
4
+ * 验证多选框组件的全选/取消全选、单选、半选状态、disabled 和按钮模式。
5
+ */
6
+ const { describe, it, assert, mount } = require("../../../test/helper");
7
+ const InflyCheckBox = require("./InflyCheckBox.vue");
8
+
9
+ const MOCK_OPTIONS = [
10
+ { name: "选项A", value: "a" },
11
+ { name: "选项B", value: "b" },
12
+ { name: "选项C", value: "c" },
13
+ ];
14
+
15
+ describe("InflyCheckBox", () => {
16
+ describe("渲染", () => {
17
+ it("渲染所有选项", () => {
18
+ const wrapper = mount(InflyCheckBox, {
19
+ propsData: { value: [], options: MOCK_OPTIONS },
20
+ });
21
+ const text = wrapper.text();
22
+ assert.ok(text.includes("选项A"));
23
+ assert.ok(text.includes("选项B"));
24
+ assert.ok(text.includes("选项C"));
25
+ wrapper.destroy();
26
+ });
27
+
28
+ it("默认显示全选框", () => {
29
+ const wrapper = mount(InflyCheckBox, {
30
+ propsData: { value: [], options: MOCK_OPTIONS },
31
+ });
32
+ assert.ok(wrapper.text().includes("全选"));
33
+ wrapper.destroy();
34
+ });
35
+
36
+ it("showSelectAll=false 隐藏全选框", () => {
37
+ const wrapper = mount(InflyCheckBox, {
38
+ propsData: {
39
+ value: [],
40
+ options: MOCK_OPTIONS,
41
+ showSelectAll: false,
42
+ },
43
+ });
44
+ assert.ok(!wrapper.text().includes("全选"));
45
+ wrapper.destroy();
46
+ });
47
+ });
48
+
49
+ describe("类型模式", () => {
50
+ it("type=checkbox 时渲染 el-checkbox", () => {
51
+ const wrapper = mount(InflyCheckBox, {
52
+ propsData: { value: [], options: MOCK_OPTIONS, type: "checkbox" },
53
+ });
54
+ assert.ok(wrapper.find(".el-checkbox").exists());
55
+ wrapper.destroy();
56
+ });
57
+
58
+ it("type=button 时隐藏全选框", () => {
59
+ const wrapper = mount(InflyCheckBox, {
60
+ propsData: { value: [], options: MOCK_OPTIONS, type: "button" },
61
+ });
62
+ // 按钮模式下不应显示"全选"文字
63
+ assert.ok(!wrapper.text().includes("全选"));
64
+ wrapper.destroy();
65
+ });
66
+ });
67
+
68
+ describe("全选逻辑", () => {
69
+ it("全选所有可用选项", () => {
70
+ const wrapper = mount(InflyCheckBox, {
71
+ propsData: { value: [], options: MOCK_OPTIONS },
72
+ });
73
+ wrapper.vm.selectChange(true);
74
+ assert.deepEqual(wrapper.vm.$data.selectedValue, ["a", "b", "c"]);
75
+ assert.equal(wrapper.emitted("select-all")[0][0], true);
76
+ wrapper.destroy();
77
+ });
78
+
79
+ it("取消全选清空所有选项", () => {
80
+ const wrapper = mount(InflyCheckBox, {
81
+ propsData: { value: ["a", "b", "c"], options: MOCK_OPTIONS },
82
+ });
83
+ wrapper.vm.selectChange(false);
84
+ assert.deepEqual(wrapper.vm.$data.selectedValue, []);
85
+ wrapper.destroy();
86
+ });
87
+
88
+ it("部分选中时为半选状态", () => {
89
+ const wrapper = mount(InflyCheckBox, {
90
+ propsData: { value: ["a"], options: MOCK_OPTIONS },
91
+ });
92
+ assert.equal(wrapper.vm.$data.isIndeterminate, true);
93
+ assert.equal(wrapper.vm.$data.checkAll, false);
94
+ wrapper.destroy();
95
+ });
96
+
97
+ it("全选后 checkAll 为 true", () => {
98
+ const wrapper = mount(InflyCheckBox, {
99
+ propsData: { value: ["a", "b", "c"], options: MOCK_OPTIONS },
100
+ });
101
+ assert.equal(wrapper.vm.$data.checkAll, true);
102
+ assert.equal(wrapper.vm.$data.isIndeterminate, false);
103
+ wrapper.destroy();
104
+ });
105
+ });
106
+
107
+ describe("Props", () => {
108
+ it("支持 disabled 属性", () => {
109
+ const wrapper = mount(InflyCheckBox, {
110
+ propsData: {
111
+ value: [],
112
+ options: MOCK_OPTIONS,
113
+ disabled: true,
114
+ },
115
+ });
116
+ assert.ok(wrapper.exists());
117
+ wrapper.destroy();
118
+ });
119
+
120
+ it("支持 border 模式", () => {
121
+ const wrapper = mount(InflyCheckBox, {
122
+ propsData: {
123
+ value: [],
124
+ options: MOCK_OPTIONS,
125
+ border: true,
126
+ },
127
+ });
128
+ assert.ok(wrapper.exists());
129
+ wrapper.destroy();
130
+ });
131
+
132
+ it("支持自定义 selectAllText", () => {
133
+ const wrapper = mount(InflyCheckBox, {
134
+ propsData: {
135
+ value: [],
136
+ options: MOCK_OPTIONS,
137
+ selectAllText: "全部选择",
138
+ },
139
+ });
140
+ assert.ok(wrapper.text().includes("全部选择"));
141
+ wrapper.destroy();
142
+ });
143
+
144
+ it("外部 value 变化时同步内部状态", async () => {
145
+ const wrapper = mount(InflyCheckBox, {
146
+ propsData: { value: [], options: MOCK_OPTIONS },
147
+ });
148
+ wrapper.setProps({ value: ["a", "b"] });
149
+ await wrapper.vm.$nextTick();
150
+ assert.deepEqual(wrapper.vm.$data.selectedValue, ["a", "b"]);
151
+ wrapper.destroy();
152
+ });
153
+ });
154
+ });
@@ -0,0 +1,227 @@
1
+ <template>
2
+ <!-- 统一多选框组件 - 整合了普通多选框和按钮样式多选框 -->
3
+ <div :class="['comp-InflyCheckbox infly-checkbox__wrap', wrapClass]">
4
+ <!-- 全选框 (仅在 checkbox 类型且 showSelectAll 为 true 时显示) -->
5
+ <el-checkbox
6
+ v-if="showSelectAllCheckbox"
7
+ class="infly-checkbox__select-all"
8
+ :indeterminate="isIndeterminate"
9
+ v-model="checkAll"
10
+ :border="border"
11
+ :size="size"
12
+ :disabled="disabled"
13
+ @change="selectChange"
14
+ >
15
+ {{ selectAllText }}
16
+ </el-checkbox>
17
+
18
+ <!-- 多选框组 -->
19
+ <el-checkbox-group
20
+ class="infly-checkbox__group"
21
+ v-model="selectedValue"
22
+ :size="size"
23
+ :disabled="disabled"
24
+ @change="itemChange"
25
+ >
26
+ <template v-if="!isButtonType">
27
+ <el-checkbox
28
+ v-for="(item, index) in computedOptions"
29
+ :key="`checkbox-${index}`"
30
+ :label="item[valueProp]"
31
+ :border="border"
32
+ :disabled="item.disabled || disabled"
33
+ >
34
+ {{ item.name || item.label }}
35
+ </el-checkbox>
36
+ </template>
37
+ <template v-else>
38
+ <el-checkbox-button
39
+ v-for="(item, index) in computedOptions"
40
+ :key="`button-${index}`"
41
+ :label="item[valueProp]"
42
+ :disabled="item.disabled || disabled"
43
+ >
44
+ {{ item.name || item.label }}
45
+ </el-checkbox-button>
46
+ </template>
47
+ </el-checkbox-group>
48
+
49
+ <!-- 自定义插槽 -->
50
+ <slot name="extra"></slot>
51
+ </div>
52
+ </template>
53
+
54
+ <script>
55
+ import Uts from "@infly/libs/module/Uts.js";
56
+
57
+ export default {
58
+ name: "InflyCheckbox",
59
+ inheritAttrs: false,
60
+ props: {
61
+ // 必需 Props
62
+ value: {
63
+ type: Array,
64
+ required: true,
65
+ default: () => []
66
+ },
67
+ wrapClass: {
68
+ type: String,
69
+ default: ""
70
+ },
71
+ // 数据字段
72
+ nameProp: {
73
+ type: String,
74
+ default: "name"
75
+ },
76
+ valueProp: {
77
+ type: String,
78
+ default: "value"
79
+ },
80
+ boxs: {
81
+ // 兼容旧参数
82
+ type: Array,
83
+ required: false,
84
+ default: () => []
85
+ },
86
+ options: {
87
+ type: Array,
88
+ required: false,
89
+ default: () => []
90
+ },
91
+ // 可选 Props
92
+ type: {
93
+ type: String,
94
+ default: "checkbox",
95
+ validator: type => ["checkbox", "button"].includes(type)
96
+ },
97
+ showSelectAll: {
98
+ type: Boolean,
99
+ default: true
100
+ },
101
+ border: {
102
+ type: Boolean,
103
+ default: false
104
+ },
105
+ size: {
106
+ type: String,
107
+ default: "default",
108
+ validator: type => ["large", "default", "small", "mini"].includes(type)
109
+ },
110
+ disabled: {
111
+ type: Boolean,
112
+ default: false
113
+ },
114
+ selectAllText: {
115
+ type: String,
116
+ default: "全选"
117
+ },
118
+
119
+ // 兼容旧组件的 Props
120
+ totalCheckbox: {
121
+ type: Boolean,
122
+ default: true
123
+ },
124
+ span: {
125
+ type: Number,
126
+ default: 21
127
+ }
128
+ },
129
+
130
+ data() {
131
+ return {
132
+ selectedValue: [...this.value],
133
+ checkAll: false,
134
+ isIndeterminate: false
135
+ };
136
+ },
137
+
138
+ computed: {
139
+ // 判断是否为按钮类型
140
+ isButtonType() {
141
+ return this.type === "button";
142
+ },
143
+ computedOptions() {
144
+ return Uts.notEmptyArray(this.options) ? this.options : this.boxs;
145
+ },
146
+ // 判断是否显示全选框
147
+ showSelectAllCheckbox() {
148
+ return this.showSelectAll && !this.isButtonType && this.totalCheckbox;
149
+ },
150
+ // 所有可选项的值数组
151
+ allValues() {
152
+ return this.computedOptions.filter(item => !item.disabled).map(item => item[this.valueProp]);
153
+ }
154
+ },
155
+
156
+ watch: {
157
+ // 监听外部 value 变化
158
+ value: {
159
+ handler(newValue) {
160
+ if (JSON.stringify(newValue) !== JSON.stringify(this.selectedValue)) {
161
+ this.selectedValue = [...newValue];
162
+ this.updateSelectAllState();
163
+ }
164
+ },
165
+ deep: true,
166
+ immediate: true
167
+ },
168
+
169
+ // 监听内部 selectedValue 变化
170
+ selectedValue: {
171
+ handler(newValue) {
172
+ this.$emit("input", [...newValue]);
173
+ this.$emit("change", [...newValue]);
174
+ },
175
+ deep: true
176
+ },
177
+
178
+ // 监听 boxs 变化,重新计算状态
179
+ computedOptions: {
180
+ handler() {
181
+ this.updateSelectAllState();
182
+ },
183
+ deep: true
184
+ }
185
+ },
186
+
187
+ created() {
188
+ this.updateSelectAllState();
189
+ },
190
+
191
+ methods: {
192
+ // 全选/取消全选
193
+ selectChange(val) {
194
+ this.selectedValue = val ? [...this.allValues] : [];
195
+ this.isIndeterminate = false;
196
+ this.$emit("select-all", val);
197
+ },
198
+
199
+ // 单项选择变化
200
+ itemChange(val) {
201
+ this.updateSelectAllState();
202
+ },
203
+
204
+ // 更新全选和半选状态
205
+ updateSelectAllState() {
206
+ const checkedCount = this.selectedValue.length;
207
+ const totalCount = this.allValues.length;
208
+
209
+ this.checkAll = checkedCount === totalCount && totalCount > 0;
210
+ this.isIndeterminate = checkedCount > 0 && checkedCount < totalCount;
211
+ }
212
+ }
213
+ };
214
+ </script>
215
+
216
+ <style lang="scss" scoped>
217
+ .infly-checkbox__wrap {
218
+ display: flex;
219
+ align-items: flex-start;
220
+ flex-wrap: wrap;
221
+
222
+ .infly-checkbox__select-all {
223
+ margin-right: 30px;
224
+ flex-shrink: 0;
225
+ }
226
+ }
227
+ </style>
@@ -0,0 +1,6 @@
1
+ import InflyCheckBox from "./InflyCheckBox.vue";
2
+ import { withInstall } from "../../../scripts/install-comp";
3
+
4
+ export { InflyCheckBox };
5
+
6
+ export default withInstall(InflyCheckBox);