hy-app 0.1.1
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 +42 -0
- package/api/http.ts +138 -0
- package/api/index.ts +1 -0
- package/common/index.ts +1 -0
- package/common/versionControl.ts +102 -0
- package/components/dialog/TheDialog.vue +128 -0
- package/components/dialog/index.ts +38 -0
- package/components/hy-address-picker/hy-address-picker.vue +262 -0
- package/components/hy-address-picker/props.ts +27 -0
- package/components/hy-address-picker/typing.d.ts +98 -0
- package/components/hy-avatar/hy-avatar.vue +217 -0
- package/components/hy-avatar/props.ts +20 -0
- package/components/hy-avatar/typing.d.ts +64 -0
- package/components/hy-back-top/hy-back-top.vue +71 -0
- package/components/hy-back-top/props.ts +23 -0
- package/components/hy-back-top/typing.d.ts +49 -0
- package/components/hy-badge/hy-badge.vue +155 -0
- package/components/hy-badge/props.ts +19 -0
- package/components/hy-badge/typing.d.ts +60 -0
- package/components/hy-button/hy-button.vue +394 -0
- package/components/hy-button/props.ts +36 -0
- package/components/hy-button/typing.d.ts +125 -0
- package/components/hy-card/hy-card.vue +198 -0
- package/components/hy-card/props.ts +29 -0
- package/components/hy-card/typing.d.ts +112 -0
- package/components/hy-cell/hy-cell.vue +268 -0
- package/components/hy-cell/props.ts +20 -0
- package/components/hy-cell/typing.d.ts +98 -0
- package/components/hy-check-button/hy-check-button.vue +71 -0
- package/components/hy-check-button/props.ts +20 -0
- package/components/hy-check-button/typing.d.ts +79 -0
- package/components/hy-checkbox/hy-checkbox.vue +299 -0
- package/components/hy-checkbox/props.ts +28 -0
- package/components/hy-checkbox/typing.d.ts +77 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +584 -0
- package/components/hy-datetime-picker/props.ts +36 -0
- package/components/hy-datetime-picker/typing.d.ts +135 -0
- package/components/hy-divider/hy-divider.vue +164 -0
- package/components/hy-divider/props.ts +21 -0
- package/components/hy-divider/typing.d.ts +64 -0
- package/components/hy-empty/hy-empty.vue +122 -0
- package/components/hy-empty/props.ts +21 -0
- package/components/hy-empty/typing.d.ts +68 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +94 -0
- package/components/hy-folding-panel/props.ts +17 -0
- package/components/hy-folding-panel/typing.d.ts +59 -0
- package/components/hy-form/hy-form.vue +372 -0
- package/components/hy-form/props.ts +15 -0
- package/components/hy-form/typing.d.ts +51 -0
- package/components/hy-grid/hy-grid.vue +126 -0
- package/components/hy-grid/props.ts +16 -0
- package/components/hy-grid/typing.d.ts +62 -0
- package/components/hy-icon/hy-icon.vue +207 -0
- package/components/hy-icon/props.ts +24 -0
- package/components/hy-icon/typing.d.ts +80 -0
- package/components/hy-input/hy-input.vue +402 -0
- package/components/hy-input/props.ts +41 -0
- package/components/hy-input/typing.d.ts +148 -0
- package/components/hy-line/hy-line.vue +44 -0
- package/components/hy-line/props.ts +12 -0
- package/components/hy-line/typing.d.ts +32 -0
- package/components/hy-line-progress/hy-line-progress.vue +118 -0
- package/components/hy-line-progress/props.ts +12 -0
- package/components/hy-line-progress/typing.d.ts +28 -0
- package/components/hy-list/hy-list.vue +250 -0
- package/components/hy-list/props.ts +18 -0
- package/components/hy-list/typing.d.ts +50 -0
- package/components/hy-login/ThePhoneLogin.vue +106 -0
- package/components/hy-login/TheUserLogin.vue +391 -0
- package/components/hy-login/hy-login.vue +283 -0
- package/components/hy-login/props.ts +32 -0
- package/components/hy-login/typing.d.ts +60 -0
- package/components/hy-modal/hy-modal.vue +240 -0
- package/components/hy-modal/props.ts +24 -0
- package/components/hy-modal/typing.d.ts +70 -0
- package/components/hy-navbar/hy-navbar.vue +194 -0
- package/components/hy-navbar/props.ts +24 -0
- package/components/hy-navbar/typing.d.ts +81 -0
- package/components/hy-notice-bar/hy-column-notice.vue +130 -0
- package/components/hy-notice-bar/hy-notice-bar.vue +82 -0
- package/components/hy-notice-bar/hy-row-notice.vue +182 -0
- package/components/hy-notice-bar/props.ts +19 -0
- package/components/hy-notice-bar/typing.d.ts +56 -0
- package/components/hy-number-step/hy-number-step.vue +428 -0
- package/components/hy-number-step/props.ts +29 -0
- package/components/hy-number-step/typing.d.ts +104 -0
- package/components/hy-overlay/hy-overlay.vue +54 -0
- package/components/hy-overlay/props.ts +10 -0
- package/components/hy-overlay/typing.d.ts +24 -0
- package/components/hy-picker/hy-picker.vue +499 -0
- package/components/hy-picker/props.ts +30 -0
- package/components/hy-picker/typing.d.ts +115 -0
- package/components/hy-popup/hy-popup.vue +269 -0
- package/components/hy-popup/props.ts +21 -0
- package/components/hy-popup/typing.d.ts +68 -0
- package/components/hy-price/hy-price.vue +86 -0
- package/components/hy-price/props.ts +13 -0
- package/components/hy-price/typing.d.ts +36 -0
- package/components/hy-qrcode/hy-qrcode.vue +153 -0
- package/components/hy-qrcode/props.ts +20 -0
- package/components/hy-qrcode/qrcode.js +1364 -0
- package/components/hy-qrcode/typing.d.ts +64 -0
- package/components/hy-radio/hy-radio.vue +319 -0
- package/components/hy-radio/props.ts +28 -0
- package/components/hy-radio/typing.d.ts +85 -0
- package/components/hy-rate/hy-rate.vue +261 -0
- package/components/hy-rate/props.ts +18 -0
- package/components/hy-rate/typing.d.ts +60 -0
- package/components/hy-read-more/hy-read-more.vue +134 -0
- package/components/hy-read-more/props.ts +20 -0
- package/components/hy-read-more/typing.d.ts +44 -0
- package/components/hy-safe-bottom/hy-safe-bottom.vue +64 -0
- package/components/hy-scroll-list/hy-scroll-list.vue +146 -0
- package/components/hy-scroll-list/props.ts +12 -0
- package/components/hy-scroll-list/typing.d.ts +28 -0
- package/components/hy-search/hy-search.vue +294 -0
- package/components/hy-search/props.ts +29 -0
- package/components/hy-search/typing.d.ts +109 -0
- package/components/hy-slider/hy-slider.vue +511 -0
- package/components/hy-slider/props.ts +21 -0
- package/components/hy-slider/typing.d.ts +68 -0
- package/components/hy-steps/hy-steps.vue +352 -0
- package/components/hy-steps/props.ts +15 -0
- package/components/hy-steps/typing.d.ts +58 -0
- package/components/hy-subsection/hy-subsection.vue +272 -0
- package/components/hy-subsection/props.ts +16 -0
- package/components/hy-subsection/typing.d.ts +44 -0
- package/components/hy-swiper/hy-swiper-indicator.vue +105 -0
- package/components/hy-swiper/hy-swiper.vue +242 -0
- package/components/hy-swiper/props.ts +30 -0
- package/components/hy-swiper/typing.d.ts +107 -0
- package/components/hy-switch/hy-switch.vue +168 -0
- package/components/hy-switch/props.ts +16 -0
- package/components/hy-switch/typing.d.ts +48 -0
- package/components/hy-tabs/hy-tabs.vue +416 -0
- package/components/hy-tabs/props.ts +26 -0
- package/components/hy-tabs/typing.d.ts +86 -0
- package/components/hy-tag/hy-tag.vue +374 -0
- package/components/hy-tag/props.ts +22 -0
- package/components/hy-tag/typing.d.ts +76 -0
- package/components/hy-textarea/hy-textarea.vue +229 -0
- package/components/hy-textarea/props.ts +26 -0
- package/components/hy-textarea/typing.d.ts +27 -0
- package/components/hy-tooltip/hy-tooltip.vue +332 -0
- package/components/hy-tooltip/props.ts +17 -0
- package/components/hy-tooltip/typing.d.ts +52 -0
- package/components/hy-transition/hy-transition.vue +150 -0
- package/components/hy-transition/index.scss +113 -0
- package/components/hy-transition/props.ts +10 -0
- package/components/hy-transition/typing.d.ts +36 -0
- package/components/hy-upload/hy-upload.vue +557 -0
- package/components/hy-upload/props.ts +29 -0
- package/components/hy-upload/typing.d.ts +147 -0
- package/components/hy-warn/hy-warn.vue +228 -0
- package/components/hy-warn/props.ts +14 -0
- package/components/hy-warn/typing.d.ts +40 -0
- package/components/hy-waterfall/hy-waterfall.vue +51 -0
- package/components/hy-waterfall/props.ts +10 -0
- package/components/hy-waterfall/typing.d.ts +20 -0
- package/components/index.ts +162 -0
- package/components/message/TheMessage.vue +169 -0
- package/components/message/index.ts +54 -0
- package/components/u-form/form.js +22 -0
- package/components/u-form/hy-form.vue +324 -0
- package/components/u-form/props.js +49 -0
- package/components/u-form/schema.js +1451 -0
- package/components/u-form/u-form.vue +267 -0
- package/components/u-form/utils.js +65 -0
- package/components/u-form-item/formItem.js +24 -0
- package/components/u-form-item/hy-form-item.vue +360 -0
- package/components/u-form-item/props.js +57 -0
- package/components/u-form-item/u-form-item.vue +294 -0
- package/components/yk-dialog/yk-dialog.vue +129 -0
- package/components/yk-tabbar/props.ts +49 -0
- package/components/yk-tabbar/yk-tabbar.vue +224 -0
- package/config/color.ts +6 -0
- package/config/icon.ts +366 -0
- package/config/index.ts +2 -0
- package/global/index.ts +6 -0
- package/global/register-properties.ts +37 -0
- package/index.ts +8 -0
- package/libs/css/common.scss +0 -0
- package/libs/css/iconfont.css +379 -0
- package/libs/css/iconfont.ttf +0 -0
- package/libs/css/mixin.scss +15 -0
- package/package.json +42 -0
- package/public/icons/error.png +0 -0
- package/public/icons/success.png +0 -0
- package/public/icons/warning.png +0 -0
- package/store/index.ts +1 -0
- package/store/userInfo.ts +25 -0
- package/theme.scss +94 -0
- package/typing/index.ts +7 -0
- package/typing/modules/common.d.ts +50 -0
- package/typing/modules/dialog.ts +17 -0
- package/typing/modules/enum.ts +67 -0
- package/typing/modules/form.ts +161 -0
- package/typing/modules/http.ts +68 -0
- package/typing/modules/icon.d.ts +366 -0
- package/typing/modules/img.ts +15 -0
- package/typing/modules/rect.ts +10 -0
- package/utils/address.json +5890 -0
- package/utils/base64.ts +119 -0
- package/utils/index.ts +3 -0
- package/utils/inside.ts +310 -0
- package/utils/utils.ts +446 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export interface CellContentVo extends AnyObject {
|
|
4
|
+
/**
|
|
5
|
+
* @description 单元格左图标
|
|
6
|
+
* */
|
|
7
|
+
icon?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @description 单元格标题
|
|
10
|
+
* */
|
|
11
|
+
title?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @description 单元格副标题
|
|
14
|
+
* */
|
|
15
|
+
subhead?: string;
|
|
16
|
+
/**
|
|
17
|
+
* @description 是否禁用单元格
|
|
18
|
+
* */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description 单元格右图标
|
|
22
|
+
* */
|
|
23
|
+
rightIcon?: string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 单元格值
|
|
26
|
+
* */
|
|
27
|
+
value?: string;
|
|
28
|
+
/**
|
|
29
|
+
* @description 跳转页面地址
|
|
30
|
+
* */
|
|
31
|
+
url?: string;
|
|
32
|
+
/**
|
|
33
|
+
* @description 单元格右侧箭头的方向,可选值为:left,up,down
|
|
34
|
+
* */
|
|
35
|
+
arrowDirection?: "left" | "up" | "down";
|
|
36
|
+
}
|
|
37
|
+
export default interface IProps {
|
|
38
|
+
/**
|
|
39
|
+
* @description cell列表数据
|
|
40
|
+
* */
|
|
41
|
+
list: CellContentVo[];
|
|
42
|
+
/**
|
|
43
|
+
* @description 头部标题
|
|
44
|
+
* */
|
|
45
|
+
title?: string;
|
|
46
|
+
/**
|
|
47
|
+
* @description 是否显示头部底部边框
|
|
48
|
+
* */
|
|
49
|
+
titleBorder?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* @description 是否显示cell下边框 (默认 true )
|
|
52
|
+
* */
|
|
53
|
+
border?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* @description 标题前缀竖线颜色
|
|
56
|
+
* */
|
|
57
|
+
verticalColor?: string;
|
|
58
|
+
/**
|
|
59
|
+
* @description 是否显示标题前缀竖线
|
|
60
|
+
* */
|
|
61
|
+
showVertical?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* @description 是否禁用cell(默认false)
|
|
64
|
+
* */
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* @description 是否开启点击反馈(表现为点击时加上灰色背景) (默认 false )
|
|
68
|
+
* */
|
|
69
|
+
clickable?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* @description 单元的大小,可选值为 large,medium,small
|
|
72
|
+
* */
|
|
73
|
+
size?: HyApp.SizeType;
|
|
74
|
+
/**
|
|
75
|
+
* @description 右侧的内容
|
|
76
|
+
* */
|
|
77
|
+
value?: string;
|
|
78
|
+
/**
|
|
79
|
+
* @description 内容是否垂直居中(主要是针对右侧的value部分) (默认 false )
|
|
80
|
+
* */
|
|
81
|
+
arrange?: HyApp.LeftRightType | "center";
|
|
82
|
+
/**
|
|
83
|
+
* @description 右侧的图标箭头 (默认 'right')
|
|
84
|
+
* */
|
|
85
|
+
rightIcon?: string;
|
|
86
|
+
/**
|
|
87
|
+
* @description 右侧箭头的方向,可选值为:left,up,down
|
|
88
|
+
* */
|
|
89
|
+
arrowDirection?: "left" | "up" | "down";
|
|
90
|
+
/**
|
|
91
|
+
* @description 自定义右侧icon样式
|
|
92
|
+
* */
|
|
93
|
+
rightIconStyle?: CSSProperties;
|
|
94
|
+
/**
|
|
95
|
+
* @description 定义需要用到的外部样式
|
|
96
|
+
* */
|
|
97
|
+
customStyle?: CSSProperties;
|
|
98
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-check-button">
|
|
3
|
+
<template v-for="(item, i) in columns_1" :key="i">
|
|
4
|
+
<HyTag
|
|
5
|
+
:text="item?.[fieldNames.label] as string | number"
|
|
6
|
+
:name="i"
|
|
7
|
+
:type="type"
|
|
8
|
+
:size="size"
|
|
9
|
+
:shape="shape"
|
|
10
|
+
:disabled="isDisabled(item.disabled)"
|
|
11
|
+
:plain="!item?.[fieldNames.checked]"
|
|
12
|
+
@click="onCheckbox"
|
|
13
|
+
></HyTag>
|
|
14
|
+
</template>
|
|
15
|
+
</view>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { toRefs, watch, ref } from "vue";
|
|
20
|
+
import defaultProps from "./props";
|
|
21
|
+
import IProps, { CheckboxColumnsVo } from "./typing";
|
|
22
|
+
import HyTag from "../hy-tag/hy-tag.vue";
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
25
|
+
const { modelValue, columns, fieldNames, disabled, selectType } = toRefs(props);
|
|
26
|
+
const emit = defineEmits(["change", "update:modelValue"]);
|
|
27
|
+
|
|
28
|
+
const isDisabled = (disabledVal?: boolean): boolean =>
|
|
29
|
+
disabled.value || !!disabledVal;
|
|
30
|
+
|
|
31
|
+
const columns_1 = ref<CheckboxColumnsVo[]>();
|
|
32
|
+
|
|
33
|
+
watch(
|
|
34
|
+
() => modelValue.value,
|
|
35
|
+
(newValue: string | (string | number)[]) => {
|
|
36
|
+
if (!columns.value.length) return;
|
|
37
|
+
columns_1.value = columns.value.map((item) => {
|
|
38
|
+
item[fieldNames.value.checked] = newValue.includes(
|
|
39
|
+
item[fieldNames.value.value] as string
|
|
40
|
+
);
|
|
41
|
+
return item;
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
{ immediate: true }
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const onCheckbox = ({ name }: { name: number }) => {
|
|
48
|
+
if (selectType.value === "checkbox") {
|
|
49
|
+
columns.value[name][fieldNames.value.checked] =
|
|
50
|
+
!columns.value[name][fieldNames.value.checked];
|
|
51
|
+
emit(
|
|
52
|
+
"update:modelValue",
|
|
53
|
+
columns.value
|
|
54
|
+
.filter((item) => item[fieldNames.value.checked])
|
|
55
|
+
.map((item) => item[fieldNames.value.value])
|
|
56
|
+
);
|
|
57
|
+
} else {
|
|
58
|
+
emit("update:modelValue", columns.value[name][fieldNames.value.value]);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
emit("change", columns.value[name]);
|
|
62
|
+
};
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<style lang="scss" scoped>
|
|
66
|
+
.hy-check-button {
|
|
67
|
+
display: grid;
|
|
68
|
+
grid-template-columns: v-bind(col);
|
|
69
|
+
gap: v-bind(gap);
|
|
70
|
+
}
|
|
71
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import IProps from "./typing";
|
|
2
|
+
|
|
3
|
+
const defaultProps: IProps = {
|
|
4
|
+
modelValue: "",
|
|
5
|
+
columns: [],
|
|
6
|
+
fieldNames: {
|
|
7
|
+
label: "label",
|
|
8
|
+
value: "value",
|
|
9
|
+
checked: "checked"
|
|
10
|
+
},
|
|
11
|
+
selectType: "checkbox",
|
|
12
|
+
disabled: false,
|
|
13
|
+
col: "repeat(3, 1fr)",
|
|
14
|
+
gap: "10px",
|
|
15
|
+
type: "primary",
|
|
16
|
+
size: "medium",
|
|
17
|
+
shape: "square"
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default defaultProps;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export interface CheckboxColumnsVo extends FieldNamesType {
|
|
2
|
+
/**
|
|
3
|
+
* @description 显示文本内容
|
|
4
|
+
* */
|
|
5
|
+
label?: string;
|
|
6
|
+
/**
|
|
7
|
+
* @description 值
|
|
8
|
+
* */
|
|
9
|
+
value?: string | number;
|
|
10
|
+
/**
|
|
11
|
+
* @description 是否选中
|
|
12
|
+
* */
|
|
13
|
+
checked?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @description 是否禁用
|
|
16
|
+
* */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface IFieldNames {
|
|
20
|
+
/**
|
|
21
|
+
* @description 自定义columns的文本键
|
|
22
|
+
* */
|
|
23
|
+
label: string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 自定义columns的值键
|
|
26
|
+
* */
|
|
27
|
+
value: string;
|
|
28
|
+
/**
|
|
29
|
+
* @description 自定义columns的选中键
|
|
30
|
+
* */
|
|
31
|
+
checked: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type FieldNamesType = {
|
|
35
|
+
[key in keyof IFieldNames as IFieldNames[key]]?: string | number | boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default interface IProps {
|
|
39
|
+
/**
|
|
40
|
+
* @description 选中得值,radio是字符串,checkbox是数组
|
|
41
|
+
* */
|
|
42
|
+
modelValue: (string | number) | (string | number)[];
|
|
43
|
+
/**
|
|
44
|
+
* @description 选择列表数据
|
|
45
|
+
* */
|
|
46
|
+
columns: CheckboxColumnsVo[];
|
|
47
|
+
/**
|
|
48
|
+
* @description columns对应得键
|
|
49
|
+
* */
|
|
50
|
+
fieldNames?: IFieldNames;
|
|
51
|
+
/**
|
|
52
|
+
* @description 选择单选框还是复选框
|
|
53
|
+
* */
|
|
54
|
+
selectType?: "checkbox" | "radio";
|
|
55
|
+
/**
|
|
56
|
+
* @description 禁用
|
|
57
|
+
* */
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* @description 每行几列,每列等宽
|
|
61
|
+
* */
|
|
62
|
+
col?: string;
|
|
63
|
+
/**
|
|
64
|
+
* @description 设置每行间距,需要加单位
|
|
65
|
+
* */
|
|
66
|
+
gap?: string;
|
|
67
|
+
/**
|
|
68
|
+
* @description 标签类型info、primary、success、warning、error (默认 'primary' )
|
|
69
|
+
* */
|
|
70
|
+
type?: HyApp.ThemeType;
|
|
71
|
+
/**
|
|
72
|
+
* @description 标签的大小,large,medium,small (默认 'medium' )
|
|
73
|
+
* */
|
|
74
|
+
size?: HyApp.SizeType;
|
|
75
|
+
/**
|
|
76
|
+
* @description tag的形状,circle(两边半圆形), square(方形,带圆角)(默认 'square' )
|
|
77
|
+
* */
|
|
78
|
+
shape?: HyApp.ShapeType;
|
|
79
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-checkbox-group" :class="bemClass">
|
|
3
|
+
<template v-for="(item, i) in columns_1" :key="i">
|
|
4
|
+
<view
|
|
5
|
+
class="hy-checkbox cursor-pointer"
|
|
6
|
+
@tap.stop="wrapperClickHandler"
|
|
7
|
+
:style="checkboxStyle"
|
|
8
|
+
:class="[
|
|
9
|
+
`hy-checkbox-label--${iconPlacement}`,
|
|
10
|
+
borderBottom && placement === 'column' && 'hy-border-bottom'
|
|
11
|
+
]"
|
|
12
|
+
>
|
|
13
|
+
<view
|
|
14
|
+
class="hy-checkbox__icon-wrap cursor-pointer"
|
|
15
|
+
@tap.stop="iconClickHandler($event, item)"
|
|
16
|
+
:class="iconClasses(item)"
|
|
17
|
+
:style="iconWrapStyle(item)"
|
|
18
|
+
>
|
|
19
|
+
<slot
|
|
20
|
+
name="icon"
|
|
21
|
+
:iconColor="iconColor"
|
|
22
|
+
:iconSize="addUnit(iconSize)"
|
|
23
|
+
>
|
|
24
|
+
<HyIcon
|
|
25
|
+
class="hy-checkbox__icon-wrap__icon"
|
|
26
|
+
:name="IconConfig.CHECK_MASK"
|
|
27
|
+
:size="addUnit(iconSize)"
|
|
28
|
+
:color="iconColor || '#ffffff'"
|
|
29
|
+
/>
|
|
30
|
+
</slot>
|
|
31
|
+
</view>
|
|
32
|
+
<view
|
|
33
|
+
class="hy-checkbox__label-wrap cursor-pointer"
|
|
34
|
+
@tap.stop="labelClickHandler($event, item)"
|
|
35
|
+
>
|
|
36
|
+
<slot name="label" :record="item">
|
|
37
|
+
<text
|
|
38
|
+
:style="{
|
|
39
|
+
color: labelColor,
|
|
40
|
+
fontSize: labelSize
|
|
41
|
+
}"
|
|
42
|
+
>{{ item[fieldNames.label] }}</text
|
|
43
|
+
>
|
|
44
|
+
</slot>
|
|
45
|
+
</view>
|
|
46
|
+
</view>
|
|
47
|
+
</template>
|
|
48
|
+
</view>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
import defaultProps from "./props";
|
|
53
|
+
import IProps, { CheckboxColumnsVo } from "./typing";
|
|
54
|
+
import { computed, CSSProperties, toRefs, watch, ref } from "vue";
|
|
55
|
+
import { addUnit, bem, error } from "../../utils";
|
|
56
|
+
import { IconConfig } from "../../config";
|
|
57
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
58
|
+
|
|
59
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
60
|
+
const {
|
|
61
|
+
modelValue,
|
|
62
|
+
columns,
|
|
63
|
+
fieldNames,
|
|
64
|
+
disabled,
|
|
65
|
+
shape,
|
|
66
|
+
size,
|
|
67
|
+
iconSize,
|
|
68
|
+
activeColor,
|
|
69
|
+
inactiveColor,
|
|
70
|
+
customStyle,
|
|
71
|
+
borderBottom,
|
|
72
|
+
placement
|
|
73
|
+
} = toRefs(props);
|
|
74
|
+
const emit = defineEmits(["change", "update:modelValue"]);
|
|
75
|
+
|
|
76
|
+
const columns_1 = ref();
|
|
77
|
+
|
|
78
|
+
watch(
|
|
79
|
+
() => modelValue.value,
|
|
80
|
+
(newValue) => {
|
|
81
|
+
if (Array.isArray(newValue)) {
|
|
82
|
+
columns_1.value = columns.value.map((item) => {
|
|
83
|
+
item[fieldNames.value.checked] = newValue.includes(
|
|
84
|
+
item[fieldNames.value.value] as string
|
|
85
|
+
);
|
|
86
|
+
return item;
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
error("传入值不是数组,请传数组值");
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{ immediate: true }
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const isDisabled = (disabledVal?: boolean): boolean =>
|
|
96
|
+
disabled.value || !!disabledVal;
|
|
97
|
+
|
|
98
|
+
const checkboxStyle = computed(() => {
|
|
99
|
+
const style: CSSProperties = {};
|
|
100
|
+
if (borderBottom.value && placement.value === "row") {
|
|
101
|
+
error(
|
|
102
|
+
"检测到您将borderBottom设置为true,需要同时将u-checkbox-group的placement设置为column才有效"
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
// 当父组件设置了显示下边框并且排列形式为纵向时,给内容和边框之间加上一定间隔
|
|
106
|
+
if (borderBottom.value && placement.value === "column") {
|
|
107
|
+
style.paddingBottom = "8px";
|
|
108
|
+
}
|
|
109
|
+
return Object.assign(style, customStyle.value);
|
|
110
|
+
});
|
|
111
|
+
const bemClass = computed(() => {
|
|
112
|
+
return bem("checkbox-group", props, ["placement"]);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @description 定义icon的Class类名
|
|
117
|
+
* */
|
|
118
|
+
const iconClasses = computed(() => {
|
|
119
|
+
return (temp: CheckboxColumnsVo): string[] => {
|
|
120
|
+
let classes: string[] = [];
|
|
121
|
+
// 组件的形状
|
|
122
|
+
classes.push("hy-checkbox__icon-wrap--" + shape.value);
|
|
123
|
+
if (isDisabled(temp?.disabled)) {
|
|
124
|
+
classes.push("hy-checkbox__icon-wrap--disabled");
|
|
125
|
+
}
|
|
126
|
+
if (temp[fieldNames.value.checked] && isDisabled(temp?.disabled)) {
|
|
127
|
+
classes.push("hy-checkbox__icon-wrap--disabled--checked");
|
|
128
|
+
}
|
|
129
|
+
return classes;
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @description 定义icon的样式
|
|
135
|
+
* */
|
|
136
|
+
const iconWrapStyle = computed(() => {
|
|
137
|
+
return (temp: CheckboxColumnsVo): CSSProperties => {
|
|
138
|
+
// checkbox的整体样式
|
|
139
|
+
const style: CSSProperties = {};
|
|
140
|
+
style.backgroundColor =
|
|
141
|
+
temp[fieldNames.value.checked] && !isDisabled(temp?.disabled)
|
|
142
|
+
? activeColor.value
|
|
143
|
+
: "#ffffff";
|
|
144
|
+
style.borderColor =
|
|
145
|
+
temp[fieldNames.value.checked] && !isDisabled(temp?.disabled)
|
|
146
|
+
? activeColor.value
|
|
147
|
+
: inactiveColor.value;
|
|
148
|
+
style.width = addUnit(size.value);
|
|
149
|
+
style.height = addUnit(size.value);
|
|
150
|
+
return style;
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @description 点击图标
|
|
156
|
+
* */
|
|
157
|
+
const iconClickHandler = (e: Event, temp: CheckboxColumnsVo) => {
|
|
158
|
+
e.stopPropagation();
|
|
159
|
+
if (!isDisabled(temp?.disabled)) {
|
|
160
|
+
setRadioCheckedStatus(temp);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const wrapperClickHandler = (e: Event, temp: CheckboxColumnsVo) => {
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
if (!isDisabled(temp?.disabled)) {
|
|
166
|
+
setRadioCheckedStatus(temp);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* @description 点击label
|
|
171
|
+
* */
|
|
172
|
+
const labelClickHandler = (e: Event, temp: CheckboxColumnsVo) => {
|
|
173
|
+
e.stopPropagation();
|
|
174
|
+
if (!isDisabled(temp?.disabled)) {
|
|
175
|
+
setRadioCheckedStatus(temp);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @description 执行函数改变状态传给父值
|
|
181
|
+
* */
|
|
182
|
+
const setRadioCheckedStatus = (temp: CheckboxColumnsVo) => {
|
|
183
|
+
// 将本组件标记为与原来相反的状态
|
|
184
|
+
columns_1.value = columns_1.value.map((item: CheckboxColumnsVo) => {
|
|
185
|
+
if (temp[fieldNames.value.value] === item[fieldNames.value.value]) {
|
|
186
|
+
item[fieldNames.value.checked] = !item[fieldNames.value.checked];
|
|
187
|
+
}
|
|
188
|
+
return item;
|
|
189
|
+
});
|
|
190
|
+
emit("change", temp);
|
|
191
|
+
emit(
|
|
192
|
+
"update:modelValue",
|
|
193
|
+
columns_1.value
|
|
194
|
+
.filter((item: CheckboxColumnsVo) => item[fieldNames.value.checked])
|
|
195
|
+
.map((item: CheckboxColumnsVo) => item[fieldNames.value.value])
|
|
196
|
+
);
|
|
197
|
+
// 双向绑定
|
|
198
|
+
// if (this.usedAlone) {
|
|
199
|
+
// this.$emit('update:checked', this.isChecked)
|
|
200
|
+
// }
|
|
201
|
+
};
|
|
202
|
+
</script>
|
|
203
|
+
|
|
204
|
+
<style lang="scss" scoped>
|
|
205
|
+
@import "../../libs/css/mixin.scss";
|
|
206
|
+
@import "../../theme.scss";
|
|
207
|
+
|
|
208
|
+
.hy-checkbox {
|
|
209
|
+
&-group {
|
|
210
|
+
&--row {
|
|
211
|
+
/* #ifndef APP-NVUE */
|
|
212
|
+
display: flex;
|
|
213
|
+
/* #endif */
|
|
214
|
+
flex-flow: row wrap;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
&--column {
|
|
218
|
+
@include flex(column);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* #ifndef APP-NVUE */
|
|
223
|
+
@include flex(row);
|
|
224
|
+
/* #endif */
|
|
225
|
+
overflow: hidden;
|
|
226
|
+
flex-direction: row;
|
|
227
|
+
align-items: center;
|
|
228
|
+
margin-bottom: 5px;
|
|
229
|
+
margin-top: 5px;
|
|
230
|
+
|
|
231
|
+
&-label--left {
|
|
232
|
+
flex-direction: row;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
&-label--right {
|
|
236
|
+
flex-direction: row-reverse;
|
|
237
|
+
justify-content: space-between;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
&__icon-wrap {
|
|
241
|
+
/* #ifndef APP-NVUE */
|
|
242
|
+
box-sizing: border-box;
|
|
243
|
+
// nvue下,border-color过渡有问题
|
|
244
|
+
transition-property: border-color, background-color, color;
|
|
245
|
+
transition-duration: 0.2s;
|
|
246
|
+
/* #endif */
|
|
247
|
+
@include flex;
|
|
248
|
+
align-items: center;
|
|
249
|
+
justify-content: center;
|
|
250
|
+
color: transparent;
|
|
251
|
+
text-align: center;
|
|
252
|
+
margin-right: $hy-border-margin-padding-sm;
|
|
253
|
+
border: $hy-border-line;
|
|
254
|
+
|
|
255
|
+
/* #ifdef MP-TOUTIAO */
|
|
256
|
+
// 头条小程序兼容性问题,需要设置行高为0,否则图标偏下
|
|
257
|
+
&__icon {
|
|
258
|
+
line-height: 0;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* #endif */
|
|
262
|
+
|
|
263
|
+
&--circle {
|
|
264
|
+
border-radius: 50%;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
&--square {
|
|
268
|
+
border-radius: 3px;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
&--checked {
|
|
272
|
+
color: $hy-text-color-inverse;
|
|
273
|
+
background-color: $hy-primary;
|
|
274
|
+
border-color: $hy-primary;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
&--disabled {
|
|
278
|
+
background-color: $hy-color-disable-bg !important;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
&--disabled--checked {
|
|
282
|
+
color: $hy-color-disable-icon !important;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
&__label-wrap {
|
|
287
|
+
/* #ifndef APP-NVUE */
|
|
288
|
+
word-wrap: break-word;
|
|
289
|
+
/* #endif */
|
|
290
|
+
color: $hy-text-color;
|
|
291
|
+
font-size: $hy-font-size-base;
|
|
292
|
+
margin-right: $hy-border-margin-padding-sm;
|
|
293
|
+
|
|
294
|
+
&--disabled {
|
|
295
|
+
color: $hy-text-color-disable;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import IProps from "./typing";
|
|
2
|
+
import { ColorConfig } from "../../config";
|
|
3
|
+
|
|
4
|
+
const defaultProps: IProps = {
|
|
5
|
+
modelValue: [],
|
|
6
|
+
columns: [],
|
|
7
|
+
fieldNames: {
|
|
8
|
+
label: "label",
|
|
9
|
+
value: "value",
|
|
10
|
+
checked: "checked"
|
|
11
|
+
},
|
|
12
|
+
shape: "square",
|
|
13
|
+
size: 18,
|
|
14
|
+
disabled: false,
|
|
15
|
+
activeColor: ColorConfig.primary,
|
|
16
|
+
inactiveColor: "#c8c9cc",
|
|
17
|
+
iconSize: "20",
|
|
18
|
+
iconColor: "",
|
|
19
|
+
iconPlacement: "left",
|
|
20
|
+
borderBottom: false,
|
|
21
|
+
label: "",
|
|
22
|
+
labelSize: "",
|
|
23
|
+
labelColor: "",
|
|
24
|
+
labelDisabled: "",
|
|
25
|
+
placement: "row"
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default defaultProps;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { CSSProperties } from "vue";
|
|
2
|
+
import { CheckboxColumnsVo, IFieldNames } from "../hy-check-button/typing";
|
|
3
|
+
|
|
4
|
+
export default interface IProps {
|
|
5
|
+
/**
|
|
6
|
+
* @description 双向绑定值,数组类型
|
|
7
|
+
* */
|
|
8
|
+
modelValue: (string | number)[];
|
|
9
|
+
/**
|
|
10
|
+
* @description 接收数组值
|
|
11
|
+
* */
|
|
12
|
+
columns: CheckboxColumnsVo[];
|
|
13
|
+
/**
|
|
14
|
+
* @description 自定义接收columns的键
|
|
15
|
+
* */
|
|
16
|
+
fieldNames?: IFieldNames;
|
|
17
|
+
/**
|
|
18
|
+
* @description 形状,square为方形,circle为圆型
|
|
19
|
+
* */
|
|
20
|
+
shape?: HyApp.ShapeType;
|
|
21
|
+
/**
|
|
22
|
+
* @description 复选框大小
|
|
23
|
+
* */
|
|
24
|
+
size?: string | number;
|
|
25
|
+
/**
|
|
26
|
+
* @description 是否禁用
|
|
27
|
+
* */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @description 选中状态下的颜色
|
|
31
|
+
* */
|
|
32
|
+
activeColor?: string;
|
|
33
|
+
/**
|
|
34
|
+
* @description 未选中的颜色
|
|
35
|
+
* */
|
|
36
|
+
inactiveColor?: string;
|
|
37
|
+
/**
|
|
38
|
+
* @description 图标的大小,单位px
|
|
39
|
+
* */
|
|
40
|
+
iconSize?: string | number;
|
|
41
|
+
/**
|
|
42
|
+
* @description 图标颜色
|
|
43
|
+
* */
|
|
44
|
+
iconColor?: string;
|
|
45
|
+
/**
|
|
46
|
+
* @description label提示文字,因为nvue下,直接slot进来的文字,由于特殊的结构,无法修改样式
|
|
47
|
+
* */
|
|
48
|
+
label?: string;
|
|
49
|
+
/**
|
|
50
|
+
* @description label的字体大小,px单位
|
|
51
|
+
* */
|
|
52
|
+
labelSize?: string | number;
|
|
53
|
+
/**
|
|
54
|
+
* @description label的颜色
|
|
55
|
+
* */
|
|
56
|
+
labelColor?: string;
|
|
57
|
+
/**
|
|
58
|
+
* @description 勾选图标的对齐方式,left-左边,right-右边
|
|
59
|
+
* */
|
|
60
|
+
iconPlacement?: HyApp.LeftRightType;
|
|
61
|
+
/**
|
|
62
|
+
* @description 竖向配列时,是否显示下划线
|
|
63
|
+
* */
|
|
64
|
+
borderBottom?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* @description 是否禁止点击提示语选中复选框
|
|
67
|
+
* */
|
|
68
|
+
labelDisabled?: string;
|
|
69
|
+
/**
|
|
70
|
+
* @description 定义需要用到的外部样式
|
|
71
|
+
* */
|
|
72
|
+
customStyle?: CSSProperties;
|
|
73
|
+
/**
|
|
74
|
+
* @description 排列方式,row-横向,column-纵向
|
|
75
|
+
* */
|
|
76
|
+
placement?: HyApp.PermutationType;
|
|
77
|
+
}
|