hy-app 0.3.0 → 0.3.2
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 +6 -3
- package/common/shakeService.ts +31 -29
- package/components/avatar.zip +0 -0
- package/components/hy-action-sheet/hy-action-sheet.vue +71 -46
- package/components/hy-address-picker/hy-address-picker.vue +94 -83
- package/components/hy-avatar/hy-avatar.vue +84 -85
- package/components/hy-back-top/hy-back-top.vue +8 -6
- package/components/hy-badge/hy-badge.vue +47 -46
- package/components/hy-button/hy-button.vue +117 -93
- package/components/hy-calendar/hy-calendar.vue +168 -160
- package/components/hy-card/hy-card.vue +50 -43
- package/components/hy-card/typing.d.ts +33 -32
- package/components/hy-cell/hy-cell.vue +73 -51
- package/components/hy-check-button/hy-check-button.vue +54 -47
- package/components/hy-checkbox/hy-checkbox.vue +97 -105
- package/components/hy-code-input/hy-code-input.vue +80 -89
- package/components/hy-config-provider/hy-config-provider.vue +20 -21
- package/components/hy-count-down/hy-count-down.vue +66 -67
- package/components/hy-count-to/hy-count-to.vue +105 -99
- package/components/hy-count-to/typing.d.ts +13 -12
- package/components/hy-datetime-picker/hy-datetime-picker.vue +261 -253
- package/components/hy-datetime-picker/typing.d.ts +42 -40
- package/components/hy-divider/hy-divider.vue +68 -73
- package/components/hy-dropdown/hy-dropdown.vue +20 -19
- package/components/hy-dropdown-item/hy-dropdown-item.vue +66 -61
- package/components/hy-dropdown-item/typing.d.ts +9 -9
- package/components/hy-empty/hy-empty.vue +42 -42
- package/components/hy-flex/hy-flex.vue +99 -0
- package/components/hy-flex/index.scss +8 -0
- package/components/hy-flex/typing.d.ts +23 -0
- package/components/hy-float-button/hy-float-button.vue +218 -210
- package/components/hy-folding-panel/hy-folding-panel.vue +32 -33
- package/components/hy-form/hy-form.vue +264 -252
- package/components/hy-form/typing.d.ts +4 -0
- package/components/hy-form-group/hy-form-group.vue +114 -183
- package/components/hy-form-item/hy-form-item.vue +12 -10
- package/components/hy-form-item/index.scss +2 -2
- package/components/hy-form-item/typing.d.ts +3 -6
- package/components/hy-grid/hy-grid.vue +44 -43
- package/components/hy-icon/hy-icon.vue +61 -67
- package/components/hy-image/hy-image.vue +112 -88
- package/components/hy-image/typing.d.ts +27 -23
- package/components/hy-input/hy-input.vue +157 -127
- package/components/hy-input/typing.d.ts +53 -47
- package/components/hy-line/hy-line.vue +26 -26
- package/components/hy-line-progress/hy-line-progress.vue +42 -35
- package/components/hy-list/hy-list.vue +76 -85
- package/components/hy-loading/hy-loading.vue +26 -23
- package/components/hy-login/TheUserLogin.vue +1 -1
- package/components/hy-menu/hy-menu.vue +48 -43
- package/components/hy-menu/typing.d.ts +18 -17
- package/components/hy-modal/hy-modal.vue +39 -35
- package/components/hy-navbar/hy-navbar.vue +25 -25
- package/components/hy-navbar/typing.d.ts +24 -22
- package/components/hy-notice-bar/hy-notice-bar.vue +26 -27
- package/components/hy-notify/hy-notify.vue +53 -53
- package/components/hy-number-step/hy-number-step.vue +134 -146
- package/components/hy-number-step/typing.d.ts +35 -35
- package/components/hy-overlay/hy-overlay.vue +23 -21
- package/components/hy-pagination/hy-pagination.vue +41 -36
- package/components/hy-picker/hy-picker.vue +184 -154
- package/components/hy-picker/typing.d.ts +39 -39
- package/components/hy-popover/hy-popover.vue +97 -77
- package/components/hy-popup/hy-popup.vue +107 -98
- package/components/hy-price/hy-price.vue +38 -34
- package/components/hy-qrcode/hy-qrcode.vue +50 -51
- package/components/hy-radio/hy-radio.vue +101 -113
- package/components/hy-rate/hy-rate.vue +107 -88
- package/components/hy-read-more/hy-read-more.vue +64 -49
- package/components/hy-scroll-list/hy-scroll-list.vue +45 -48
- package/components/hy-search/hy-search.vue +73 -66
- package/components/hy-search/typing.d.ts +36 -35
- package/components/hy-signature/hy-signature.vue +282 -240
- package/components/hy-slider/hy-slider.vue +195 -153
- package/components/hy-slider/typing.d.ts +21 -21
- package/components/hy-steps/hy-steps.vue +118 -90
- package/components/hy-steps/index.scss +31 -21
- package/components/hy-submit-bar/hy-submit-bar.vue +61 -70
- package/components/hy-subsection/hy-subsection.vue +99 -102
- package/components/hy-subsection/typing.d.ts +19 -19
- package/components/hy-swipe-action/hy-swipe-action.vue +131 -118
- package/components/hy-swiper/hy-swiper.vue +85 -71
- package/components/hy-switch/hy-switch.vue +67 -72
- package/components/hy-switch/typing.d.ts +21 -19
- package/components/hy-tabs/hy-tabs.vue +168 -113
- package/components/hy-tag/hy-tag.vue +90 -86
- package/components/hy-tag/typing.d.ts +26 -21
- package/components/hy-text/hy-text.vue +119 -111
- package/components/hy-textarea/hy-textarea.vue +100 -93
- package/components/hy-textarea/typing.d.ts +36 -31
- package/components/hy-toast/hy-toast.vue +77 -67
- package/components/hy-tooltip/hy-tooltip.vue +109 -91
- package/components/hy-transition/hy-transition.vue +62 -66
- package/components/hy-upload/hy-upload.vue +294 -152
- package/components/hy-upload/typing.d.ts +41 -36
- package/components/hy-warn/hy-warn.vue +34 -27
- package/components/hy-waterfall/hy-waterfall.vue +83 -74
- package/components/hy-watermark/hy-watermark.vue +134 -115
- package/components/index.ts +1 -1
- package/composables/usePopover.ts +236 -221
- package/composables/useQueue.ts +53 -52
- package/global.d.ts +1 -0
- package/package.json +2 -2
- package/store/index.ts +9 -1
- package/theme.scss +5 -5
- package/typing/index.ts +0 -1
- package/typing/modules/common.d.ts +0 -2
- package/web-types.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<view class="hy-check-button">
|
|
3
3
|
<template v-for="(item, i) in columns_1" :key="i">
|
|
4
4
|
<HyTag
|
|
5
|
-
:text="item?.[fieldNames.label] as string
|
|
5
|
+
:text="item?.[fieldNames.label] as string"
|
|
6
6
|
:name="i"
|
|
7
7
|
:type="type"
|
|
8
8
|
:size="size"
|
|
@@ -17,27 +17,28 @@
|
|
|
17
17
|
|
|
18
18
|
<script lang="ts">
|
|
19
19
|
export default {
|
|
20
|
-
name:
|
|
20
|
+
name: "hy-check-button",
|
|
21
21
|
options: {
|
|
22
22
|
addGlobalClass: true,
|
|
23
23
|
virtualHost: true,
|
|
24
|
-
styleIsolation:
|
|
24
|
+
styleIsolation: "shared",
|
|
25
25
|
},
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
27
|
</script>
|
|
28
28
|
|
|
29
29
|
<script setup lang="ts">
|
|
30
|
-
import { toRefs, watch, ref, type PropType } from
|
|
31
|
-
import type { ICheckButtonEmits, IFieldNames } from
|
|
32
|
-
import type { CheckboxColumnsVo } from
|
|
33
|
-
import HyTag from
|
|
34
|
-
import { isArray } from
|
|
30
|
+
import { toRefs, watch, ref, type PropType } from "vue";
|
|
31
|
+
import type { ICheckButtonEmits, IFieldNames } from "./typing";
|
|
32
|
+
import type { CheckboxColumnsVo } from "./typing";
|
|
33
|
+
import HyTag from "../hy-tag/hy-tag.vue";
|
|
34
|
+
import { isArray, isNumber } from "../../utils";
|
|
35
|
+
import type { TagParamsVo } from "../hy-tag/typing";
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* 该组件内部实现以tag二次封装按钮复选框和单选框
|
|
38
39
|
* @displayName hy-check-button
|
|
39
40
|
*/
|
|
40
|
-
defineOptions({})
|
|
41
|
+
defineOptions({});
|
|
41
42
|
|
|
42
43
|
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
43
44
|
const props = defineProps({
|
|
@@ -56,9 +57,9 @@ const props = defineProps({
|
|
|
56
57
|
fieldNames: {
|
|
57
58
|
type: Object as unknown as PropType<IFieldNames>,
|
|
58
59
|
default: {
|
|
59
|
-
label:
|
|
60
|
-
value:
|
|
61
|
-
checked:
|
|
60
|
+
label: "label",
|
|
61
|
+
value: "value",
|
|
62
|
+
checked: "checked",
|
|
62
63
|
},
|
|
63
64
|
},
|
|
64
65
|
/**
|
|
@@ -67,7 +68,7 @@ const props = defineProps({
|
|
|
67
68
|
* */
|
|
68
69
|
selectType: {
|
|
69
70
|
type: String,
|
|
70
|
-
default:
|
|
71
|
+
default: "checkbox",
|
|
71
72
|
},
|
|
72
73
|
/** 禁用 */
|
|
73
74
|
disabled: {
|
|
@@ -77,12 +78,12 @@ const props = defineProps({
|
|
|
77
78
|
/** 每行几列,每列等宽 */
|
|
78
79
|
col: {
|
|
79
80
|
type: String,
|
|
80
|
-
default:
|
|
81
|
+
default: "repeat(3, 1fr)",
|
|
81
82
|
},
|
|
82
83
|
/** 设置每行间距,需要加单位 */
|
|
83
84
|
gap: {
|
|
84
85
|
type: String,
|
|
85
|
-
default:
|
|
86
|
+
default: "10px",
|
|
86
87
|
},
|
|
87
88
|
/**
|
|
88
89
|
* 标签类型
|
|
@@ -90,7 +91,7 @@ const props = defineProps({
|
|
|
90
91
|
* */
|
|
91
92
|
type: {
|
|
92
93
|
type: String,
|
|
93
|
-
default:
|
|
94
|
+
default: "primary",
|
|
94
95
|
},
|
|
95
96
|
/**
|
|
96
97
|
* 标签的大小
|
|
@@ -98,7 +99,7 @@ const props = defineProps({
|
|
|
98
99
|
* */
|
|
99
100
|
size: {
|
|
100
101
|
type: String,
|
|
101
|
-
default:
|
|
102
|
+
default: "medium",
|
|
102
103
|
},
|
|
103
104
|
/**
|
|
104
105
|
* 标签的形状
|
|
@@ -106,51 +107,57 @@ const props = defineProps({
|
|
|
106
107
|
* */
|
|
107
108
|
shape: {
|
|
108
109
|
type: String,
|
|
109
|
-
default:
|
|
110
|
+
default: "square",
|
|
110
111
|
},
|
|
111
|
-
})
|
|
112
|
-
const
|
|
113
|
-
const emit = defineEmits<ICheckButtonEmits>()
|
|
112
|
+
});
|
|
113
|
+
const emit = defineEmits<ICheckButtonEmits>();
|
|
114
114
|
|
|
115
|
-
const isDisabled = (disabledVal?: boolean): boolean =>
|
|
115
|
+
const isDisabled = (disabledVal?: boolean): boolean =>
|
|
116
|
+
props.disabled || !!disabledVal;
|
|
116
117
|
|
|
117
|
-
const columns_1 = ref<CheckboxColumnsVo[]>()
|
|
118
|
+
const columns_1 = ref<CheckboxColumnsVo[]>();
|
|
118
119
|
|
|
119
120
|
watch(
|
|
120
|
-
() => modelValue
|
|
121
|
+
() => props.modelValue,
|
|
121
122
|
(newValue: string | number | (string | number)[]) => {
|
|
122
|
-
if (!isArray(columns
|
|
123
|
-
columns_1.value = columns.
|
|
123
|
+
if (!isArray(props.columns) || !props.columns.length) return;
|
|
124
|
+
columns_1.value = props.columns.map((item) => {
|
|
124
125
|
if (isArray(newValue)) {
|
|
125
|
-
item[fieldNames.
|
|
126
|
+
item[props.fieldNames.checked] = newValue.includes(
|
|
127
|
+
item[props.fieldNames.value] as string,
|
|
128
|
+
);
|
|
126
129
|
} else {
|
|
127
|
-
item[fieldNames.
|
|
130
|
+
item[props.fieldNames.checked] =
|
|
131
|
+
newValue === item[props.fieldNames.value];
|
|
128
132
|
}
|
|
129
|
-
return item
|
|
130
|
-
})
|
|
133
|
+
return item;
|
|
134
|
+
});
|
|
131
135
|
},
|
|
132
136
|
{ immediate: true },
|
|
133
|
-
)
|
|
137
|
+
);
|
|
134
138
|
|
|
135
|
-
const onCheckbox = ({ name }:
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
const onCheckbox = ({ name }: TagParamsVo) => {
|
|
140
|
+
if (isNumber(name)) {
|
|
141
|
+
const index = Number(name);
|
|
142
|
+
if (props.selectType === "checkbox") {
|
|
143
|
+
props.columns[index][props.fieldNames.checked] =
|
|
144
|
+
!props.columns[index][props.fieldNames.checked];
|
|
145
|
+
emit(
|
|
146
|
+
"update:modelValue",
|
|
147
|
+
props.columns
|
|
148
|
+
.filter((item) => item[props.fieldNames.checked])
|
|
149
|
+
.map((item) => item[props.fieldNames.value]),
|
|
150
|
+
);
|
|
151
|
+
} else {
|
|
152
|
+
emit("update:modelValue", props.columns[index][props.fieldNames.value]);
|
|
153
|
+
}
|
|
154
|
+
emit("change", props.columns[index]);
|
|
146
155
|
}
|
|
147
|
-
|
|
148
|
-
emit('change', columns.value[name])
|
|
149
|
-
}
|
|
156
|
+
};
|
|
150
157
|
</script>
|
|
151
158
|
|
|
152
159
|
<style lang="scss" scoped>
|
|
153
|
-
@import
|
|
160
|
+
@import "../../libs/css/mixin.scss";
|
|
154
161
|
@include b(check-button) {
|
|
155
162
|
display: grid;
|
|
156
163
|
grid-template-columns: v-bind(col);
|
|
@@ -16,7 +16,11 @@
|
|
|
16
16
|
:class="iconClasses(item)"
|
|
17
17
|
:style="iconWrapStyle(item)"
|
|
18
18
|
>
|
|
19
|
-
<slot
|
|
19
|
+
<slot
|
|
20
|
+
name="icon"
|
|
21
|
+
:iconColor="iconColor"
|
|
22
|
+
:iconSize="addUnit(iconSize)"
|
|
23
|
+
>
|
|
20
24
|
<HyIcon
|
|
21
25
|
class="hy-checkbox__icon-wrap__icon"
|
|
22
26
|
:name="IconConfig.CHECK_MASK"
|
|
@@ -51,30 +55,30 @@
|
|
|
51
55
|
|
|
52
56
|
<script lang="ts">
|
|
53
57
|
export default {
|
|
54
|
-
name:
|
|
58
|
+
name: "hy-checkbox",
|
|
55
59
|
options: {
|
|
56
60
|
addGlobalClass: true,
|
|
57
61
|
virtualHost: true,
|
|
58
|
-
styleIsolation:
|
|
62
|
+
styleIsolation: "shared",
|
|
59
63
|
},
|
|
60
|
-
}
|
|
64
|
+
};
|
|
61
65
|
</script>
|
|
62
66
|
|
|
63
67
|
<script setup lang="ts">
|
|
64
|
-
import { computed, toRefs, watch, ref, reactive } from
|
|
65
|
-
import type { CSSProperties, PropType } from
|
|
66
|
-
import { addUnit, bem, error } from
|
|
67
|
-
import { IconConfig } from
|
|
68
|
-
import type { ICheckBoxEmits } from
|
|
69
|
-
import type { CheckboxColumnsVo, IFieldNames } from
|
|
68
|
+
import { computed, toRefs, watch, ref, reactive } from "vue";
|
|
69
|
+
import type { CSSProperties, PropType } from "vue";
|
|
70
|
+
import { addUnit, bem, error } from "../../utils";
|
|
71
|
+
import { IconConfig } from "../../config";
|
|
72
|
+
import type { ICheckBoxEmits } from "./typing";
|
|
73
|
+
import type { CheckboxColumnsVo, IFieldNames } from "../hy-check-button/typing";
|
|
70
74
|
// 组件
|
|
71
|
-
import HyIcon from
|
|
75
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
72
76
|
|
|
73
77
|
/**
|
|
74
78
|
* 复选框组件一般用于需要多个选择的场景,该组件功能完整,使用方便
|
|
75
79
|
* @displayName hy-checkbox
|
|
76
80
|
*/
|
|
77
|
-
defineOptions({})
|
|
81
|
+
defineOptions({});
|
|
78
82
|
|
|
79
83
|
// const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
80
84
|
const props = defineProps({
|
|
@@ -93,9 +97,9 @@ const props = defineProps({
|
|
|
93
97
|
fieldNames: {
|
|
94
98
|
type: Object as unknown as PropType<IFieldNames>,
|
|
95
99
|
default: {
|
|
96
|
-
label:
|
|
97
|
-
value:
|
|
98
|
-
checked:
|
|
100
|
+
label: "label",
|
|
101
|
+
value: "value",
|
|
102
|
+
checked: "checked",
|
|
99
103
|
},
|
|
100
104
|
},
|
|
101
105
|
/**
|
|
@@ -104,7 +108,7 @@ const props = defineProps({
|
|
|
104
108
|
* */
|
|
105
109
|
size: {
|
|
106
110
|
type: String,
|
|
107
|
-
default:
|
|
111
|
+
default: "medium",
|
|
108
112
|
},
|
|
109
113
|
/**
|
|
110
114
|
* 标签的形状
|
|
@@ -112,7 +116,7 @@ const props = defineProps({
|
|
|
112
116
|
* */
|
|
113
117
|
shape: {
|
|
114
118
|
type: String,
|
|
115
|
-
default:
|
|
119
|
+
default: "square",
|
|
116
120
|
},
|
|
117
121
|
/** 是否禁用 */
|
|
118
122
|
disabled: {
|
|
@@ -124,12 +128,12 @@ const props = defineProps({
|
|
|
124
128
|
/** 未选中的颜色 */
|
|
125
129
|
inactiveColor: {
|
|
126
130
|
type: String,
|
|
127
|
-
default:
|
|
131
|
+
default: "#c8c9cc",
|
|
128
132
|
},
|
|
129
133
|
/** 图标的大小,单位px */
|
|
130
134
|
iconSize: {
|
|
131
135
|
type: [String, Number],
|
|
132
|
-
default:
|
|
136
|
+
default: "20",
|
|
133
137
|
},
|
|
134
138
|
/** 图标颜色 */
|
|
135
139
|
iconColor: String,
|
|
@@ -139,7 +143,7 @@ const props = defineProps({
|
|
|
139
143
|
* */
|
|
140
144
|
iconPlacement: {
|
|
141
145
|
type: String,
|
|
142
|
-
default:
|
|
146
|
+
default: "left",
|
|
143
147
|
},
|
|
144
148
|
/** 竖向配列时,是否显示下划线 */
|
|
145
149
|
borderBottom: {
|
|
@@ -161,95 +165,83 @@ const props = defineProps({
|
|
|
161
165
|
* */
|
|
162
166
|
placement: {
|
|
163
167
|
type: String,
|
|
164
|
-
default:
|
|
168
|
+
default: "row",
|
|
165
169
|
},
|
|
166
170
|
/** 定义需要用到的外部样式 */
|
|
167
171
|
customStyle: {
|
|
168
172
|
type: Object as PropType<CSSProperties>,
|
|
169
173
|
},
|
|
170
|
-
})
|
|
171
|
-
const
|
|
172
|
-
modelValue,
|
|
173
|
-
columns,
|
|
174
|
-
fieldNames,
|
|
175
|
-
disabled,
|
|
176
|
-
shape,
|
|
177
|
-
size,
|
|
178
|
-
iconSize,
|
|
179
|
-
activeColor,
|
|
180
|
-
inactiveColor,
|
|
181
|
-
customStyle,
|
|
182
|
-
borderBottom,
|
|
183
|
-
placement,
|
|
184
|
-
labelDisabled,
|
|
185
|
-
} = toRefs(props)
|
|
186
|
-
const emit = defineEmits<ICheckBoxEmits>()
|
|
174
|
+
});
|
|
175
|
+
const emit = defineEmits<ICheckBoxEmits>();
|
|
187
176
|
|
|
188
|
-
const columns_1 = ref()
|
|
177
|
+
const columns_1 = ref();
|
|
189
178
|
const sizeType: AnyObject = reactive({
|
|
190
179
|
small: 14,
|
|
191
180
|
medium: 18,
|
|
192
181
|
large: 22,
|
|
193
|
-
})
|
|
182
|
+
});
|
|
194
183
|
|
|
195
184
|
watch(
|
|
196
|
-
() => modelValue
|
|
185
|
+
() => props.modelValue,
|
|
197
186
|
(newValue: boolean | (string | number)[]) => {
|
|
198
187
|
// 判断数组长度为1可以传true/false
|
|
199
|
-
if (columns
|
|
200
|
-
columns
|
|
201
|
-
columns_1.value = columns
|
|
188
|
+
if (props.columns?.length === 1 && typeof newValue === "boolean") {
|
|
189
|
+
props.columns[0][props.fieldNames.checked] = newValue;
|
|
190
|
+
columns_1.value = props.columns;
|
|
202
191
|
} else if (Array.isArray(newValue)) {
|
|
203
|
-
columns_1.value = columns.
|
|
204
|
-
item[fieldNames.
|
|
205
|
-
|
|
206
|
-
|
|
192
|
+
columns_1.value = props.columns.map((item) => {
|
|
193
|
+
item[props.fieldNames.checked] = newValue.includes(
|
|
194
|
+
item[props.fieldNames.value] as string,
|
|
195
|
+
);
|
|
196
|
+
return item;
|
|
197
|
+
});
|
|
207
198
|
} else {
|
|
208
|
-
error(
|
|
199
|
+
error("传入值不是数组,请传数组值");
|
|
209
200
|
}
|
|
210
201
|
},
|
|
211
202
|
{ immediate: true },
|
|
212
|
-
)
|
|
203
|
+
);
|
|
213
204
|
|
|
214
|
-
const isDisabled = (disabledVal?: boolean): boolean =>
|
|
205
|
+
const isDisabled = (disabledVal?: boolean): boolean =>
|
|
206
|
+
props.disabled || !!disabledVal;
|
|
215
207
|
|
|
216
208
|
const checkboxStyle = computed(() => {
|
|
217
|
-
const style: CSSProperties = {}
|
|
218
|
-
if (borderBottom
|
|
209
|
+
const style: CSSProperties = {};
|
|
210
|
+
if (props.borderBottom && props.placement === "row") {
|
|
219
211
|
error(
|
|
220
|
-
|
|
221
|
-
)
|
|
212
|
+
"检测到您将borderBottom设置为true,需要同时将u-checkbox-group的placement设置为column才有效",
|
|
213
|
+
);
|
|
222
214
|
}
|
|
223
215
|
// 当父组件设置了显示下边框并且排列形式为纵向时,给内容和边框之间加上一定间隔
|
|
224
|
-
if (borderBottom
|
|
225
|
-
style.paddingBottom =
|
|
216
|
+
if (props.borderBottom && props.placement === "column") {
|
|
217
|
+
style.paddingBottom = "8px";
|
|
226
218
|
}
|
|
227
|
-
return Object.assign(style, customStyle
|
|
228
|
-
})
|
|
219
|
+
return Object.assign(style, props.customStyle);
|
|
220
|
+
});
|
|
229
221
|
const bemClass = computed(() => {
|
|
230
|
-
return bem(
|
|
231
|
-
})
|
|
222
|
+
return bem("checkbox-group", props, ["placement"]);
|
|
223
|
+
});
|
|
232
224
|
|
|
233
225
|
/**
|
|
234
226
|
* @description 定义icon的Class类名
|
|
235
227
|
* */
|
|
236
228
|
const iconClasses = computed(() => {
|
|
237
229
|
return (temp: CheckboxColumnsVo): string[] => {
|
|
238
|
-
let classes: string[] = []
|
|
230
|
+
let classes: string[] = [];
|
|
239
231
|
// 组件的形状
|
|
240
|
-
classes.push(
|
|
232
|
+
classes.push("hy-checkbox__icon-wrap--" + props.shape);
|
|
241
233
|
if (isDisabled(temp?.disabled)) {
|
|
242
|
-
classes.push(
|
|
234
|
+
classes.push("hy-checkbox__icon-wrap--disabled");
|
|
243
235
|
}
|
|
244
|
-
if (temp[fieldNames.
|
|
245
|
-
classes.push(
|
|
236
|
+
if (temp[props.fieldNames.checked]) {
|
|
237
|
+
classes.push("hy-checkbox__icon-wrap--checked");
|
|
246
238
|
if (isDisabled(temp?.disabled)) {
|
|
247
|
-
classes.push(
|
|
239
|
+
classes.push("hy-checkbox__icon-wrap--disabled--checked");
|
|
248
240
|
}
|
|
249
241
|
}
|
|
250
|
-
return classes
|
|
251
|
-
}
|
|
252
|
-
})
|
|
242
|
+
return classes;
|
|
243
|
+
};
|
|
244
|
+
});
|
|
253
245
|
|
|
254
246
|
/**
|
|
255
247
|
* @description 定义icon的样式
|
|
@@ -257,48 +249,48 @@ const iconClasses = computed(() => {
|
|
|
257
249
|
const iconWrapStyle = computed(() => {
|
|
258
250
|
return (temp: CheckboxColumnsVo): CSSProperties => {
|
|
259
251
|
// checkbox的整体样式
|
|
260
|
-
const style: CSSProperties = {}
|
|
252
|
+
const style: CSSProperties = {};
|
|
261
253
|
style.backgroundColor =
|
|
262
|
-
temp[fieldNames.
|
|
263
|
-
? activeColor
|
|
254
|
+
temp[props.fieldNames.checked] && !isDisabled(temp?.disabled)
|
|
255
|
+
? props.activeColor
|
|
264
256
|
: !isDisabled(temp?.disabled)
|
|
265
|
-
?
|
|
266
|
-
:
|
|
257
|
+
? "#ffffff"
|
|
258
|
+
: "";
|
|
267
259
|
style.borderColor =
|
|
268
|
-
temp[fieldNames.
|
|
269
|
-
? activeColor
|
|
270
|
-
: inactiveColor
|
|
271
|
-
style.width = addUnit(sizeType[size
|
|
272
|
-
style.height = addUnit(sizeType[size
|
|
273
|
-
return style
|
|
274
|
-
}
|
|
275
|
-
})
|
|
260
|
+
temp[props.fieldNames.checked] && !isDisabled(temp?.disabled)
|
|
261
|
+
? props.activeColor
|
|
262
|
+
: props.inactiveColor;
|
|
263
|
+
style.width = addUnit(sizeType[props.size] ?? props.size);
|
|
264
|
+
style.height = addUnit(sizeType[props.size] ?? props.size);
|
|
265
|
+
return style;
|
|
266
|
+
};
|
|
267
|
+
});
|
|
276
268
|
|
|
277
269
|
/**
|
|
278
270
|
* @description 点击图标
|
|
279
271
|
* */
|
|
280
272
|
const iconClickHandler = (e: Event, temp: CheckboxColumnsVo) => {
|
|
281
|
-
e.stopPropagation()
|
|
273
|
+
e.stopPropagation();
|
|
282
274
|
if (!isDisabled(temp?.disabled)) {
|
|
283
|
-
setRadioCheckedStatus(temp)
|
|
275
|
+
setRadioCheckedStatus(temp);
|
|
284
276
|
}
|
|
285
|
-
}
|
|
277
|
+
};
|
|
286
278
|
/**
|
|
287
279
|
* @description 点击整行
|
|
288
280
|
* */
|
|
289
281
|
const wrapperClickHandler = (e: Event, temp: CheckboxColumnsVo) => {
|
|
290
|
-
e.stopPropagation()
|
|
291
|
-
if (labelDisabled
|
|
292
|
-
setRadioCheckedStatus(temp)
|
|
293
|
-
}
|
|
282
|
+
e.stopPropagation();
|
|
283
|
+
if (props.labelDisabled || isDisabled(temp?.disabled)) return;
|
|
284
|
+
setRadioCheckedStatus(temp);
|
|
285
|
+
};
|
|
294
286
|
/**
|
|
295
287
|
* @description 点击label
|
|
296
288
|
* */
|
|
297
289
|
const labelClickHandler = (e: Event, temp: CheckboxColumnsVo) => {
|
|
298
|
-
e.stopPropagation()
|
|
299
|
-
if (labelDisabled
|
|
300
|
-
setRadioCheckedStatus(temp)
|
|
301
|
-
}
|
|
290
|
+
e.stopPropagation();
|
|
291
|
+
if (props.labelDisabled || isDisabled(temp?.disabled)) return;
|
|
292
|
+
setRadioCheckedStatus(temp);
|
|
293
|
+
};
|
|
302
294
|
|
|
303
295
|
/**
|
|
304
296
|
* @description 执行函数改变状态传给父值
|
|
@@ -306,27 +298,27 @@ const labelClickHandler = (e: Event, temp: CheckboxColumnsVo) => {
|
|
|
306
298
|
const setRadioCheckedStatus = (temp: CheckboxColumnsVo) => {
|
|
307
299
|
// 将本组件标记为与原来相反的状态
|
|
308
300
|
columns_1.value = columns_1.value.map((item: CheckboxColumnsVo) => {
|
|
309
|
-
if (temp[fieldNames.value
|
|
310
|
-
item[fieldNames.
|
|
301
|
+
if (temp[props.fieldNames.value] === item[props.fieldNames.value]) {
|
|
302
|
+
item[props.fieldNames.checked] = !item[props.fieldNames.checked];
|
|
311
303
|
}
|
|
312
|
-
return item
|
|
313
|
-
})
|
|
314
|
-
emit(
|
|
304
|
+
return item;
|
|
305
|
+
});
|
|
306
|
+
emit("change", temp);
|
|
315
307
|
emit(
|
|
316
|
-
|
|
308
|
+
"update:modelValue",
|
|
317
309
|
columns_1.value.length === 1
|
|
318
310
|
? columns_1.value[0].checked
|
|
319
311
|
: columns_1.value
|
|
320
|
-
.filter((item: CheckboxColumnsVo) => item[fieldNames.
|
|
321
|
-
.map((item: CheckboxColumnsVo) => item[fieldNames.value
|
|
322
|
-
)
|
|
312
|
+
.filter((item: CheckboxColumnsVo) => item[props.fieldNames.checked])
|
|
313
|
+
.map((item: CheckboxColumnsVo) => item[props.fieldNames.value]),
|
|
314
|
+
);
|
|
323
315
|
// 双向绑定
|
|
324
316
|
// if (this.usedAlone) {
|
|
325
317
|
// this.$emit('update:checked', this.isChecked)
|
|
326
318
|
// }
|
|
327
|
-
}
|
|
319
|
+
};
|
|
328
320
|
</script>
|
|
329
321
|
|
|
330
322
|
<style lang="scss" scoped>
|
|
331
|
-
@import
|
|
323
|
+
@import "./index.scss";
|
|
332
324
|
</style>
|