hy-app 0.3.12 → 0.3.14
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/api/http.ts +11 -3
- package/components/hy-card/hy-card.vue +4 -4
- package/components/hy-checkbox/hy-checkbox.vue +1 -5
- package/components/hy-checkbox/index.scss +1 -1
- package/components/hy-checkbox-group/hy-checkbox-group.vue +118 -0
- package/components/hy-checkbox-group/index.scss +16 -0
- package/components/hy-checkbox-group/typing.d.ts +71 -0
- package/components/hy-checkbox-item/hy-checkbox-item.vue +219 -0
- package/components/hy-checkbox-item/index.scss +89 -0
- package/components/hy-checkbox-item/typing.d.ts +5 -0
- package/components/hy-modal/hy-modal.vue +27 -13
- package/components/hy-modal/index.scss +2 -2
- package/components/hy-modal/typing.d.ts +24 -23
- package/components/hy-radio/hy-radio.vue +1 -1
- package/components/hy-radio/index.scss +1 -1
- package/components/hy-search/hy-search.vue +2 -2
- package/components/hy-search/index.scss +1 -0
- package/components/hy-transition/index.scss +0 -6
- package/global.d.ts +86 -84
- package/package.json +2 -2
- package/web-types.json +1 -1
package/api/http.ts
CHANGED
|
@@ -70,7 +70,7 @@ export default class Http {
|
|
|
70
70
|
* @description uni异步请求
|
|
71
71
|
* @param options 请求配置
|
|
72
72
|
*/
|
|
73
|
-
async request(options: UniNamespace.RequestOptions) {
|
|
73
|
+
async request<T = any>(options: UniNamespace.RequestOptions): Promise<T> {
|
|
74
74
|
options.url = this.config.baseURL + options.url || this.config.url;
|
|
75
75
|
options.data = options.data || this.config.data;
|
|
76
76
|
options.header = options.header || this.config.header;
|
|
@@ -104,7 +104,11 @@ export default class Http {
|
|
|
104
104
|
* @param params 请求JSON参数
|
|
105
105
|
* @param options 请求配置
|
|
106
106
|
*/
|
|
107
|
-
post
|
|
107
|
+
post<T = any>(
|
|
108
|
+
url: string,
|
|
109
|
+
params?: any,
|
|
110
|
+
options?: HttpRequestConfig,
|
|
111
|
+
): Promise<T> {
|
|
108
112
|
return this.request({
|
|
109
113
|
url: url,
|
|
110
114
|
method: "POST",
|
|
@@ -119,7 +123,11 @@ export default class Http {
|
|
|
119
123
|
* @param params URL查询参数
|
|
120
124
|
* @param options 请求配置
|
|
121
125
|
*/
|
|
122
|
-
get
|
|
126
|
+
get<T = any>(
|
|
127
|
+
url: string,
|
|
128
|
+
params?: any,
|
|
129
|
+
options?: HttpRequestConfig,
|
|
130
|
+
): Promise<T> {
|
|
123
131
|
if (params) {
|
|
124
132
|
url += "?" + objectToUrlParams(params);
|
|
125
133
|
}
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
footStyle,
|
|
65
65
|
]"
|
|
66
66
|
:class="{
|
|
67
|
-
'hy-
|
|
67
|
+
'hy-border__top': footBorderTop,
|
|
68
68
|
}"
|
|
69
69
|
>
|
|
70
70
|
<!-- @slot 底部插槽 -->
|
|
@@ -127,7 +127,7 @@ const props = defineProps({
|
|
|
127
127
|
/** 是否显示边框 */
|
|
128
128
|
border: {
|
|
129
129
|
type: Boolean,
|
|
130
|
-
default:
|
|
130
|
+
default: false,
|
|
131
131
|
},
|
|
132
132
|
/** 用于标识点击了第几个卡片 */
|
|
133
133
|
index: [String, Number],
|
|
@@ -144,12 +144,12 @@ const props = defineProps({
|
|
|
144
144
|
/** 是否显示头部的下边框 */
|
|
145
145
|
headBorderBottom: {
|
|
146
146
|
type: Boolean,
|
|
147
|
-
default:
|
|
147
|
+
default: false,
|
|
148
148
|
},
|
|
149
149
|
/** 是否显示底部的上边框 */
|
|
150
150
|
footBorderTop: {
|
|
151
151
|
type: Boolean,
|
|
152
|
-
default:
|
|
152
|
+
default: false,
|
|
153
153
|
},
|
|
154
154
|
/** 缩略图路径,如设置将显示在标题的左边,不建议使用相对路径 */
|
|
155
155
|
thumb: String,
|
|
@@ -303,7 +303,6 @@ const setRadioCheckedStatus = (temp: CheckboxColumnsVo) => {
|
|
|
303
303
|
}
|
|
304
304
|
return item;
|
|
305
305
|
});
|
|
306
|
-
emit("change", temp);
|
|
307
306
|
emit(
|
|
308
307
|
"update:modelValue",
|
|
309
308
|
columns_1.value.length === 1
|
|
@@ -312,10 +311,7 @@ const setRadioCheckedStatus = (temp: CheckboxColumnsVo) => {
|
|
|
312
311
|
.filter((item: CheckboxColumnsVo) => item[props.fieldNames.checked])
|
|
313
312
|
.map((item: CheckboxColumnsVo) => item[props.fieldNames.value]),
|
|
314
313
|
);
|
|
315
|
-
|
|
316
|
-
// if (this.usedAlone) {
|
|
317
|
-
// this.$emit('update:checked', this.isChecked)
|
|
318
|
-
// }
|
|
314
|
+
emit("change", temp);
|
|
319
315
|
};
|
|
320
316
|
</script>
|
|
321
317
|
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-checkbox-group" :class="bemClass">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed, provide } from "vue";
|
|
9
|
+
import type { CSSProperties, PropType } from "vue";
|
|
10
|
+
import { bem } from "../../utils";
|
|
11
|
+
import type { ICheckBoxGroupEmits } from "./typing";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 复选框组件一般用于需要多个选择的场景,需要搭配hy-checkbox-item组件一起使用
|
|
15
|
+
* @displayName hy-checkbox-group
|
|
16
|
+
*/
|
|
17
|
+
defineOptions({});
|
|
18
|
+
|
|
19
|
+
const props = defineProps({
|
|
20
|
+
/** 双向绑定值,数组类型 */
|
|
21
|
+
modelValue: {
|
|
22
|
+
type: Array<string | number>,
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* 标签的大小
|
|
27
|
+
* @values small,medium,large
|
|
28
|
+
* */
|
|
29
|
+
size: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "medium",
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* 标签的形状
|
|
35
|
+
* @values circle,square
|
|
36
|
+
* */
|
|
37
|
+
shape: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: "square",
|
|
40
|
+
},
|
|
41
|
+
/** 是否禁用 */
|
|
42
|
+
disabled: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false,
|
|
45
|
+
},
|
|
46
|
+
/** 选中状态下的颜色 */
|
|
47
|
+
activeColor: String,
|
|
48
|
+
/** 未选中的颜色 */
|
|
49
|
+
inactiveColor: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: "#c8c9cc",
|
|
52
|
+
},
|
|
53
|
+
/** 图标的大小,单位px */
|
|
54
|
+
iconSize: {
|
|
55
|
+
type: [String, Number],
|
|
56
|
+
default: "20",
|
|
57
|
+
},
|
|
58
|
+
/** 图标颜色 */
|
|
59
|
+
iconColor: String,
|
|
60
|
+
/**
|
|
61
|
+
* 勾选图标的对齐方式
|
|
62
|
+
* @values left,right
|
|
63
|
+
* */
|
|
64
|
+
iconPlacement: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: "left",
|
|
67
|
+
},
|
|
68
|
+
/** 竖向配列时,是否显示下划线 */
|
|
69
|
+
borderBottom: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false,
|
|
72
|
+
},
|
|
73
|
+
/** label的字体大小,px单位 */
|
|
74
|
+
labelSize: [String, Number],
|
|
75
|
+
/** label的颜色 */
|
|
76
|
+
labelColor: String,
|
|
77
|
+
/** 是否禁止点击提示语选中复选框 */
|
|
78
|
+
labelDisabled: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false,
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* 排列方式
|
|
84
|
+
* @values row,column
|
|
85
|
+
* */
|
|
86
|
+
placement: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: "row",
|
|
89
|
+
},
|
|
90
|
+
/** 定义需要用到的外部样式 */
|
|
91
|
+
customStyle: {
|
|
92
|
+
type: Object as PropType<CSSProperties>,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
const emit = defineEmits<ICheckBoxGroupEmits>();
|
|
96
|
+
|
|
97
|
+
const bemClass = computed(() => {
|
|
98
|
+
return bem("checkbox-group", props, ["placement"]);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
provide("hy-checkbox-group", {
|
|
102
|
+
...props,
|
|
103
|
+
setCheckedStatus(value: string | number) {
|
|
104
|
+
let arr = [...props.modelValue];
|
|
105
|
+
if (props.modelValue?.includes(value)) {
|
|
106
|
+
arr = props.modelValue?.filter((item) => item !== value);
|
|
107
|
+
} else {
|
|
108
|
+
arr.push(value);
|
|
109
|
+
}
|
|
110
|
+
emit("update:modelValue", arr);
|
|
111
|
+
emit("change", arr);
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
<style lang="scss" scoped>
|
|
117
|
+
@import "./index";
|
|
118
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@use "../../libs/css/mixin.scss" as *;
|
|
2
|
+
|
|
3
|
+
@include b(checkbox) {
|
|
4
|
+
@include m(group) {
|
|
5
|
+
@include m(row) {
|
|
6
|
+
/* #ifndef APP-NVUE */
|
|
7
|
+
display: flex;
|
|
8
|
+
/* #endif */
|
|
9
|
+
flex-flow: row wrap;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@include m(column) {
|
|
13
|
+
@include flex(column);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface HyCheckboxGroupProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 双向绑定值,数组类型
|
|
6
|
+
* */
|
|
7
|
+
modelValue: (string | number)[];
|
|
8
|
+
/**
|
|
9
|
+
* @description 形状,square为方形,circle为圆型
|
|
10
|
+
* */
|
|
11
|
+
shape?: HyApp.ShapeType;
|
|
12
|
+
/**
|
|
13
|
+
* @description 复选框大小
|
|
14
|
+
* */
|
|
15
|
+
size?: HyApp.SizeType | string | number;
|
|
16
|
+
/**
|
|
17
|
+
* @description 是否禁用
|
|
18
|
+
* */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description 选中状态下的颜色
|
|
22
|
+
* */
|
|
23
|
+
activeColor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 未选中的颜色
|
|
26
|
+
* */
|
|
27
|
+
inactiveColor?: string;
|
|
28
|
+
/**
|
|
29
|
+
* @description 图标的大小,单位px
|
|
30
|
+
* */
|
|
31
|
+
iconSize?: string | number;
|
|
32
|
+
/**
|
|
33
|
+
* @description 图标颜色
|
|
34
|
+
* */
|
|
35
|
+
iconColor?: string;
|
|
36
|
+
/**
|
|
37
|
+
* @description label的字体大小,px单位
|
|
38
|
+
* */
|
|
39
|
+
labelSize?: string | number;
|
|
40
|
+
/**
|
|
41
|
+
* @description label的颜色
|
|
42
|
+
* */
|
|
43
|
+
labelColor?: string;
|
|
44
|
+
/**
|
|
45
|
+
* @description 勾选图标的对齐方式,left-左边,right-右边
|
|
46
|
+
* */
|
|
47
|
+
iconPlacement?: HyApp.LeftRightType;
|
|
48
|
+
/**
|
|
49
|
+
* @description 竖向配列时,是否显示下划线
|
|
50
|
+
* */
|
|
51
|
+
borderBottom?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* @description 是否禁止点击提示语选中复选框
|
|
54
|
+
* */
|
|
55
|
+
labelDisabled?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* @description 定义需要用到的外部样式
|
|
58
|
+
* */
|
|
59
|
+
customStyle?: CSSProperties;
|
|
60
|
+
/**
|
|
61
|
+
* @description 排列方式,row-横向,column-纵向
|
|
62
|
+
* */
|
|
63
|
+
placement?: HyApp.DirectionType;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ICheckBoxGroupEmits {
|
|
67
|
+
/** 选择触发 */
|
|
68
|
+
(e: "change", temp: CheckboxColumnsVo): void;
|
|
69
|
+
/** 更新值触发 */
|
|
70
|
+
(e: "update:modelValue", value: any): void;
|
|
71
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="hy-checkbox cursor-pointer"
|
|
4
|
+
@tap.stop="wrapperClickHandler"
|
|
5
|
+
:style="checkboxStyle"
|
|
6
|
+
:class="[
|
|
7
|
+
`hy-checkbox--label__${checkboxGroup?.iconPlacement}`,
|
|
8
|
+
checkboxGroup?.borderBottom &&
|
|
9
|
+
checkboxGroup?.placement === 'column' &&
|
|
10
|
+
'hy-border__bottom',
|
|
11
|
+
]"
|
|
12
|
+
>
|
|
13
|
+
<view
|
|
14
|
+
class="hy-checkbox--icon-wrap cursor-pointer"
|
|
15
|
+
@tap.stop="iconClickHandler"
|
|
16
|
+
:class="iconClasses"
|
|
17
|
+
:style="iconWrapStyle"
|
|
18
|
+
>
|
|
19
|
+
<slot name="icon">
|
|
20
|
+
<HyIcon
|
|
21
|
+
class="hy-checkbox--icon-wrap__icon"
|
|
22
|
+
:name="IconConfig.CHECK_MASK"
|
|
23
|
+
:size="
|
|
24
|
+
addUnit(sizeType[checkboxGroup?.size] ?? checkboxGroup?.iconSize)
|
|
25
|
+
"
|
|
26
|
+
:color="checkboxGroup?.iconColor || '#ffffff'"
|
|
27
|
+
/>
|
|
28
|
+
</slot>
|
|
29
|
+
</view>
|
|
30
|
+
<view
|
|
31
|
+
:class="[
|
|
32
|
+
'hy-checkbox--label__wrap',
|
|
33
|
+
'cursor-pointer',
|
|
34
|
+
disabled && 'hy-checkbox--label__wrap--disabled',
|
|
35
|
+
]"
|
|
36
|
+
@tap.stop="labelClickHandler"
|
|
37
|
+
>
|
|
38
|
+
<slot name="label">
|
|
39
|
+
<text
|
|
40
|
+
:style="{
|
|
41
|
+
color: checkboxGroup?.labelColor,
|
|
42
|
+
fontSize: addUnit(
|
|
43
|
+
sizeType[checkboxGroup?.size] ?? checkboxGroup?.labelSize,
|
|
44
|
+
),
|
|
45
|
+
}"
|
|
46
|
+
>
|
|
47
|
+
{{ label }}
|
|
48
|
+
</text>
|
|
49
|
+
</slot>
|
|
50
|
+
</view>
|
|
51
|
+
</view>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script lang="ts">
|
|
55
|
+
export default {
|
|
56
|
+
name: "hy-checkbox",
|
|
57
|
+
options: {
|
|
58
|
+
addGlobalClass: true,
|
|
59
|
+
virtualHost: true,
|
|
60
|
+
styleIsolation: "shared",
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<script setup lang="ts">
|
|
66
|
+
import { computed, watch, ref, reactive, inject } from "vue";
|
|
67
|
+
import type { CSSProperties } from "vue";
|
|
68
|
+
import { addUnit, error } from "../../utils";
|
|
69
|
+
import { IconConfig } from "../../config";
|
|
70
|
+
import type { ICheckboxGroupProps } from "./typing";
|
|
71
|
+
// 组件
|
|
72
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 复选框组件一般用于需要多个选择的场景,需要搭配hy-checkbox-group一起使用
|
|
76
|
+
* @displayName hy-checkbox-item
|
|
77
|
+
*/
|
|
78
|
+
defineOptions({});
|
|
79
|
+
|
|
80
|
+
const props = defineProps({
|
|
81
|
+
/** checkbox的名称 */
|
|
82
|
+
value: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: "",
|
|
85
|
+
},
|
|
86
|
+
/** 是否默认选中 */
|
|
87
|
+
checked: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: false,
|
|
90
|
+
},
|
|
91
|
+
/** 是否禁用 */
|
|
92
|
+
disabled: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
default: false,
|
|
95
|
+
},
|
|
96
|
+
/** label提示文字 */
|
|
97
|
+
label: {
|
|
98
|
+
type: String,
|
|
99
|
+
default: "",
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// 注入表单上下文
|
|
104
|
+
const checkboxGroup = inject<ICheckboxGroupProps>("hy-checkbox-group");
|
|
105
|
+
const isChecked = ref(false);
|
|
106
|
+
const sizeType: AnyObject = reactive({
|
|
107
|
+
small: 14,
|
|
108
|
+
medium: 18,
|
|
109
|
+
large: 22,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
watch(
|
|
113
|
+
() => props.checked,
|
|
114
|
+
(newValue) => {
|
|
115
|
+
isChecked.value = newValue;
|
|
116
|
+
if (props.checked) {
|
|
117
|
+
checkboxGroup?.setCheckedStatus(props.value);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{ immediate: true },
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const isDisabled = (): boolean => checkboxGroup?.disabled || props.disabled;
|
|
124
|
+
|
|
125
|
+
const checkboxStyle = computed(() => {
|
|
126
|
+
const style: CSSProperties = {};
|
|
127
|
+
if (checkboxGroup?.borderBottom && checkboxGroup?.placement === "row") {
|
|
128
|
+
error(
|
|
129
|
+
"检测到您将borderBottom设置为true,需要同时将hy-checkbox-group的placement设置为column才有效",
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
// 当父组件设置了显示下边框并且排列形式为纵向时,给内容和边框之间加上一定间隔
|
|
133
|
+
if (checkboxGroup?.borderBottom && checkboxGroup?.placement === "column") {
|
|
134
|
+
style.paddingBottom = "8px";
|
|
135
|
+
}
|
|
136
|
+
return Object.assign(style, checkboxGroup?.customStyle);
|
|
137
|
+
});
|
|
138
|
+
/**
|
|
139
|
+
* @description 定义icon的Class类名
|
|
140
|
+
* */
|
|
141
|
+
const iconClasses = computed(() => {
|
|
142
|
+
let classes: string[] = [];
|
|
143
|
+
// 组件的形状
|
|
144
|
+
classes.push("hy-checkbox--icon-wrap--" + checkboxGroup?.shape);
|
|
145
|
+
if (isDisabled()) {
|
|
146
|
+
classes.push("hy-checkbox--icon-wrap--disabled");
|
|
147
|
+
}
|
|
148
|
+
if (isChecked.value) {
|
|
149
|
+
classes.push("hy-checkbox--icon-wrap--checked");
|
|
150
|
+
if (isDisabled()) {
|
|
151
|
+
classes.push("hy-checkbox--icon-wrap--disabled--checked");
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return classes;
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @description 定义icon的样式
|
|
159
|
+
* */
|
|
160
|
+
const iconWrapStyle = computed(() => {
|
|
161
|
+
return (): CSSProperties => {
|
|
162
|
+
// checkbox的整体样式
|
|
163
|
+
const style: CSSProperties = {};
|
|
164
|
+
style.backgroundColor =
|
|
165
|
+
isChecked.value && !isDisabled()
|
|
166
|
+
? checkboxGroup?.activeColor
|
|
167
|
+
: !isDisabled()
|
|
168
|
+
? "#ffffff"
|
|
169
|
+
: "";
|
|
170
|
+
style.borderColor =
|
|
171
|
+
isChecked.value && !isDisabled()
|
|
172
|
+
? checkboxGroup?.activeColor
|
|
173
|
+
: checkboxGroup?.inactiveColor;
|
|
174
|
+
if (checkboxGroup?.size) {
|
|
175
|
+
style.width = addUnit(sizeType[checkboxGroup.size] ?? checkboxGroup.size);
|
|
176
|
+
style.height = addUnit(
|
|
177
|
+
sizeType[checkboxGroup.size] ?? checkboxGroup.size,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
return style;
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @description 点击图标
|
|
186
|
+
* */
|
|
187
|
+
const iconClickHandler = (e: Event) => {
|
|
188
|
+
e.stopPropagation();
|
|
189
|
+
if (!isDisabled()) {
|
|
190
|
+
setCheckedStatus();
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* @description 点击整行
|
|
195
|
+
* */
|
|
196
|
+
const wrapperClickHandler = (e: Event) => {
|
|
197
|
+
e.stopPropagation();
|
|
198
|
+
if (checkboxGroup?.labelDisabled || isDisabled()) return;
|
|
199
|
+
setCheckedStatus();
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* @description 点击label
|
|
203
|
+
* */
|
|
204
|
+
const labelClickHandler = (e: Event) => {
|
|
205
|
+
e.stopPropagation();
|
|
206
|
+
if (checkboxGroup?.labelDisabled || isDisabled()) return;
|
|
207
|
+
setCheckedStatus();
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const setCheckedStatus = () => {
|
|
211
|
+
// 将本组件标记为与原来相反的状态
|
|
212
|
+
isChecked.value = !isChecked.value;
|
|
213
|
+
checkboxGroup?.setCheckedStatus(props.value);
|
|
214
|
+
};
|
|
215
|
+
</script>
|
|
216
|
+
|
|
217
|
+
<style lang="scss" scoped>
|
|
218
|
+
@import "./index.scss";
|
|
219
|
+
</style>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
@use "../../libs/css/mixin.scss" as *;
|
|
2
|
+
@use "../../libs/css/theme" as *;
|
|
3
|
+
|
|
4
|
+
@include b(checkbox) {
|
|
5
|
+
/* #ifndef APP-NVUE */
|
|
6
|
+
@include flex(row);
|
|
7
|
+
/* #endif */
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
align-items: center;
|
|
11
|
+
margin-bottom: 5px;
|
|
12
|
+
margin-top: 5px;
|
|
13
|
+
|
|
14
|
+
@include m(label) {
|
|
15
|
+
@include e(left) {
|
|
16
|
+
flex-direction: row;
|
|
17
|
+
}
|
|
18
|
+
@include e(right) {
|
|
19
|
+
flex-direction: row-reverse;
|
|
20
|
+
justify-content: space-between;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@include e(wrap){
|
|
24
|
+
/* #ifndef APP-NVUE */
|
|
25
|
+
word-wrap: break-word;
|
|
26
|
+
/* #endif */
|
|
27
|
+
font-size: $hy-font-size-base;
|
|
28
|
+
margin-right: $hy-border-margin-padding-sm;
|
|
29
|
+
|
|
30
|
+
@include m(disabled) {
|
|
31
|
+
color: $hy-text-color--disabled;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@include m(icon-wrap) {
|
|
37
|
+
/* #ifndef APP-NVUE */
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
// nvue下,border-color过渡有问题
|
|
40
|
+
transition-property: border-color, background-color, color;
|
|
41
|
+
transition-duration: 0.2s;
|
|
42
|
+
/* #endif */
|
|
43
|
+
@include flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
color: transparent;
|
|
47
|
+
text-align: center;
|
|
48
|
+
margin-right: $hy-border-margin-padding-sm;
|
|
49
|
+
border: $hy-border-line;
|
|
50
|
+
|
|
51
|
+
/* #ifdef MP-TOUTIAO */
|
|
52
|
+
// 头条小程序兼容性问题,需要设置行高为0,否则图标偏下
|
|
53
|
+
@include e(icon) {
|
|
54
|
+
line-height: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* #endif */
|
|
58
|
+
|
|
59
|
+
@include m(circle) {
|
|
60
|
+
border-radius: 50%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@include m(square) {
|
|
64
|
+
border-radius: 3px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@include m(checked) {
|
|
68
|
+
color: #FFFFFF;
|
|
69
|
+
background-color: $hy-primary;
|
|
70
|
+
border-color: $hy-primary;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@include m(disabled) {
|
|
74
|
+
background-color: $hy-background--disabled;
|
|
75
|
+
:deep(.hy-icon) {
|
|
76
|
+
display: none;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@include m([disabled--checked]){
|
|
81
|
+
background-color: $hy-primary;
|
|
82
|
+
border-color: $hy-primary;
|
|
83
|
+
opacity: 0.5;
|
|
84
|
+
:deep(.hy-icon) {
|
|
85
|
+
display: block;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
v-if="showConfirmButton"
|
|
76
76
|
@tap="confirmHandler"
|
|
77
77
|
>
|
|
78
|
-
<HyLoading v-if="
|
|
78
|
+
<HyLoading v-if="load" mode="circle"></HyLoading>
|
|
79
79
|
<text
|
|
80
80
|
v-else
|
|
81
81
|
class="hy-modal__button-group__wrapper__text hy-modal__button-group__wrapper--confirm-text"
|
|
@@ -104,9 +104,9 @@ export default {
|
|
|
104
104
|
</script>
|
|
105
105
|
|
|
106
106
|
<script setup lang="ts">
|
|
107
|
-
import { ref, watch } from "vue";
|
|
107
|
+
import { ref, toRefs, watch } from "vue";
|
|
108
108
|
import type { IModalEmits } from "./typing";
|
|
109
|
-
import { addUnit } from "../../utils";
|
|
109
|
+
import { addUnit, sleep } from "../../utils";
|
|
110
110
|
// 组件
|
|
111
111
|
import HyPopup from "../hy-popup/hy-popup.vue";
|
|
112
112
|
import HyLoading from "../hy-loading/hy-loading.vue";
|
|
@@ -167,8 +167,13 @@ const props = defineProps({
|
|
|
167
167
|
type: [String, Number],
|
|
168
168
|
default: 16,
|
|
169
169
|
},
|
|
170
|
-
/**
|
|
171
|
-
|
|
170
|
+
/** 点击确认按钮自动关闭 */
|
|
171
|
+
autoClose: {
|
|
172
|
+
type: Boolean,
|
|
173
|
+
default: true,
|
|
174
|
+
},
|
|
175
|
+
/** 加载按钮 */
|
|
176
|
+
loading: {
|
|
172
177
|
type: Boolean,
|
|
173
178
|
default: false,
|
|
174
179
|
},
|
|
@@ -202,27 +207,36 @@ const props = defineProps({
|
|
|
202
207
|
},
|
|
203
208
|
});
|
|
204
209
|
const emit = defineEmits<IModalEmits>();
|
|
210
|
+
const load = ref(props.loading);
|
|
205
211
|
|
|
206
|
-
|
|
212
|
+
watch(
|
|
213
|
+
() => props.loading,
|
|
214
|
+
(newVal) => {
|
|
215
|
+
load.value = props.loading;
|
|
216
|
+
},
|
|
217
|
+
);
|
|
207
218
|
|
|
208
219
|
watch(
|
|
209
220
|
() => props.modelValue,
|
|
210
|
-
(
|
|
211
|
-
|
|
221
|
+
(newVal) => {
|
|
222
|
+
console.log(newVal, "newVal");
|
|
223
|
+
if (!newVal) load.value = false;
|
|
212
224
|
},
|
|
213
225
|
);
|
|
214
226
|
|
|
215
227
|
/**
|
|
216
228
|
* @description 点击确定按钮
|
|
217
229
|
* */
|
|
218
|
-
const confirmHandler = () => {
|
|
230
|
+
const confirmHandler = async () => {
|
|
231
|
+
console.log(load.value, "props.loading");
|
|
232
|
+
if (load.value) return;
|
|
219
233
|
// 如果配置了异步关闭,将按钮值为loading状态
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
234
|
+
emit("confirm");
|
|
235
|
+
|
|
236
|
+
await sleep();
|
|
237
|
+
if (!props.loading && props.autoClose) {
|
|
223
238
|
emit("update:modelValue", false);
|
|
224
239
|
}
|
|
225
|
-
emit("confirm");
|
|
226
240
|
};
|
|
227
241
|
|
|
228
242
|
/**
|