@ecolovo/uniapp-components 2.0.4 → 2.0.5
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/components/badge/badge.vue +22 -11
- package/components/badge/types.d.ts +6 -0
- package/components/badge/types.js +4 -0
- package/components/badge/types.ts +10 -0
- package/components/button/button.vue +77 -48
- package/components/button/types.d.ts +20 -0
- package/components/button/types.js +4 -0
- package/components/button/types.ts +24 -0
- package/components/checkbox/checkbox.scss +1 -1
- package/components/checkbox/checkbox.vue +2 -0
- package/components/checkbox/types.d.ts +10 -0
- package/components/checkbox/types.js +4 -0
- package/components/checkbox/types.ts +16 -0
- package/components/checkbox-group/checkbox-group.vue +2 -0
- package/components/checkbox-group/types.d.ts +10 -0
- package/components/checkbox-group/types.js +8 -0
- package/components/checkbox-group/types.ts +20 -0
- package/components/checkbox-group2/checkbox-group2.vue +2 -0
- package/components/data-list/data-list.vue +13 -7
- package/components/date-picker/date-picker.vue +2 -0
- package/components/date-picker/types.d.ts +12 -0
- package/components/date-picker/types.js +4 -0
- package/components/date-picker/types.ts +18 -0
- package/components/dialog/dialog-content.vue +61 -46
- package/components/dialog/dialog.vue +55 -29
- package/components/dialog/types.d.ts +20 -0
- package/components/dialog/types.js +4 -0
- package/components/dialog/types.ts +24 -0
- package/components/dropdown/dropdown.vue +2 -0
- package/components/dropdown/types.d.ts +10 -0
- package/components/dropdown/types.js +4 -0
- package/components/dropdown/types.ts +16 -0
- package/components/empty/empty.vue +37 -20
- package/components/empty/types.d.ts +12 -0
- package/components/empty/types.js +9 -0
- package/components/empty/types.ts +21 -0
- package/components/flex/flex.vue +2 -0
- package/components/flex/types.d.ts +12 -0
- package/components/flex/types.js +4 -0
- package/components/flex/types.ts +22 -0
- package/components/form/form.vue +2 -0
- package/components/form/types.d.ts +6 -0
- package/components/form/types.js +4 -0
- package/components/form/types.ts +10 -0
- package/components/form-item/form-item.scss +6 -0
- package/components/form-item/form-item.vue +9 -3
- package/components/form-item/types.d.ts +6 -0
- package/components/form-item/types.js +4 -0
- package/components/form-item/types.ts +12 -0
- package/components/image/image.vue +28 -21
- package/components/image/types.d.ts +18 -0
- package/components/image/types.js +4 -0
- package/components/image/types.ts +23 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +1 -0
- package/components/index.ts +1 -0
- package/components/input/input.scss +9 -0
- package/components/input/input.vue +11 -4
- package/components/input/password-input.vue +3 -1
- package/components/input/types.d.ts +20 -0
- package/components/input/types.js +8 -0
- package/components/input/types.ts +31 -0
- package/components/list-page/list-page.vue +21 -24
- package/components/list-page/types.d.ts +6 -0
- package/components/list-page/types.js +4 -0
- package/components/list-page/types.ts +12 -0
- package/components/load-more/load-more.scss +1 -0
- package/components/load-more/load-more.vue +66 -6
- package/components/load-more/types.d.ts +6 -0
- package/components/load-more/types.js +4 -0
- package/components/load-more/types.ts +12 -0
- package/components/loading/loading.vue +2 -0
- package/components/loading/types.d.ts +6 -0
- package/components/loading/types.js +4 -0
- package/components/loading/types.ts +12 -0
- package/components/message-box/message-box.d.ts +14 -16
- package/components/message-box/message-box.ts +0 -2
- package/components/message-box/message-box.vue +18 -43
- package/components/message-box/types.d.ts +16 -0
- package/components/message-box/types.js +4 -0
- package/components/message-box/types.ts +22 -0
- package/components/number-dialog/number-dialog.vue +5 -3
- package/components/number-dialog/types.d.ts +18 -0
- package/components/number-dialog/types.js +4 -0
- package/components/number-dialog/types.ts +24 -0
- package/components/number-input/number-input.scss +1 -1
- package/components/number-input/number-input.vue +5 -3
- package/components/number-input/types.d.ts +20 -0
- package/components/number-input/types.js +4 -0
- package/components/number-input/types.ts +26 -0
- package/components/numpad/numpad.vue +2 -0
- package/components/numpad/types.d.ts +10 -0
- package/components/numpad/types.js +4 -0
- package/components/numpad/types.ts +14 -0
- package/components/page/page-body.scss +1 -1
- package/components/page/page-footer.vue +2 -3
- package/components/page/page-header.vue +19 -9
- package/components/page/page.vue +45 -14
- package/components/page/types.d.ts +16 -0
- package/components/page/types.js +8 -0
- package/components/page/types.ts +27 -0
- package/components/picker/picker-popup.vue +10 -6
- package/components/picker/picker.vue +8 -0
- package/components/picker/types.d.ts +14 -0
- package/components/picker/types.js +4 -0
- package/components/picker/types.ts +18 -0
- package/components/popover/popover-content.vue +10 -1
- package/components/popover/popover-mask.vue +5 -5
- package/components/popover/popover.vue +34 -29
- package/components/popover/types.d.ts +10 -0
- package/components/popover/types.js +4 -0
- package/components/popover/types.ts +16 -0
- package/components/popup/popup-content.vue +61 -43
- package/components/popup/popup.vue +34 -28
- package/components/popup/types.d.ts +20 -0
- package/components/popup/types.js +4 -0
- package/components/popup/types.ts +24 -0
- package/components/price/price.scss +7 -3
- package/components/price/price.vue +6 -0
- package/components/price/types.d.ts +10 -0
- package/components/price/types.js +4 -0
- package/components/price/types.ts +14 -0
- package/components/search/search.vue +2 -0
- package/components/search/types.d.ts +14 -0
- package/components/search/types.js +4 -0
- package/components/search/types.ts +18 -0
- package/components/searching/searching.vue +2 -0
- package/components/searching/types.d.ts +8 -0
- package/components/searching/types.js +4 -0
- package/components/searching/types.ts +14 -0
- package/components/switch/switch.vue +5 -8
- package/components/switch/types.d.ts +8 -0
- package/components/switch/types.js +4 -0
- package/components/switch/types.ts +12 -0
- package/components/tab/tab.vue +2 -0
- package/components/tab/types.d.ts +8 -0
- package/components/tab/types.js +4 -0
- package/components/tab/types.ts +12 -0
- package/components/textarea/textarea.scss +10 -0
- package/components/textarea/textarea.vue +17 -9
- package/components/textarea/types.d.ts +12 -0
- package/components/textarea/types.js +4 -0
- package/components/textarea/types.ts +18 -0
- package/components/upload/composable.d.ts +24 -0
- package/components/upload/composable.js +173 -0
- package/components/upload/composable.ts +228 -0
- package/components/upload/media-upload.scss +12 -0
- package/components/upload/media-upload.vue +250 -0
- package/components/upload/types.d.ts +29 -0
- package/components/upload/types.js +4 -0
- package/components/upload/types.ts +38 -0
- package/composable/component-name.d.ts +8 -0
- package/composable/component-name.js +11 -4
- package/composable/component-name.ts +8 -0
- package/composable/dialog.d.ts +40 -0
- package/composable/dialog.js +96 -0
- package/composable/dialog.ts +113 -0
- package/composable/index.d.ts +5 -0
- package/composable/index.js +5 -0
- package/composable/index.ts +5 -0
- package/composable/message-box.d.ts +45 -28
- package/composable/message-box.js +68 -53
- package/composable/message-box.ts +101 -36
- package/composable/model.d.ts +8 -0
- package/composable/model.js +23 -0
- package/composable/model.ts +27 -0
- package/composable/page.d.ts +41 -0
- package/composable/page.js +25 -0
- package/composable/page.ts +34 -0
- package/configs/index.d.ts +24 -19
- package/configs/index.js +38 -35
- package/configs/index.ts +19 -0
- package/easyCom.d.ts +6 -6
- package/easyCom.js +19 -31
- package/easyCom.ts +4 -4
- package/globals.d.ts +93 -33
- package/globals.js +1 -0
- package/globals.ts +118 -0
- package/index.d.ts +3 -2
- package/index.js +2 -2
- package/index.ts +3 -2
- package/init.d.ts +11 -6
- package/init.js +84 -14
- package/init.ts +86 -1
- package/package.json +9 -9
- package/styles/var/component.scss +1 -0
- package/utils/date.d.ts +14 -19
- package/utils/date.js +77 -87
- package/utils/freezeDeep.js +7 -7
- package/utils/price.d.ts +15 -18
- package/utils/price.js +36 -37
- package/utils/upload.d.ts +1 -0
- package/utils/upload.js +8 -0
- package/utils/upload.ts +12 -0
- package/utils/windowInfo.d.ts +1 -9
- package/utils/windowInfo.js +10 -17
- package/utils/round.d.ts +0 -2
- package/utils/round.js +0 -13
- package/utils/round.ts +0 -14
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
<script lang="ts" setup>
|
|
19
19
|
import useClassNames from '../../composable/component-name';
|
|
20
20
|
import LoadingAnimation3 from './animations/loading-animation3.vue';
|
|
21
|
+
import { loadingProps } from './types';
|
|
21
22
|
|
|
22
23
|
defineOptions({
|
|
23
24
|
options: {
|
|
@@ -35,6 +36,7 @@ type _Props = {
|
|
|
35
36
|
|
|
36
37
|
withDefaults(defineProps<_Props>(), {
|
|
37
38
|
title: '加载中...',
|
|
39
|
+
...loadingProps,
|
|
38
40
|
});
|
|
39
41
|
</script>
|
|
40
42
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type ConfigurableLoadingProps = {
|
|
2
|
+
/** 加载文本 */
|
|
3
|
+
title?: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export let loadingProps: ConfigurableLoadingProps = {};
|
|
7
|
+
|
|
8
|
+
export const setDefaultLoadingProps = (
|
|
9
|
+
props: ConfigurableLoadingProps = {}
|
|
10
|
+
) => {
|
|
11
|
+
loadingProps = props;
|
|
12
|
+
};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
export type MessageBoxOptions = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/** 确认按钮文本,为 falsy 时( false 或 '' )不显示 */
|
|
17
|
-
confirm?: string | boolean;
|
|
2
|
+
/** 内容 */
|
|
3
|
+
content?: string;
|
|
4
|
+
/** 是否模态框 */
|
|
5
|
+
modal?: boolean;
|
|
6
|
+
/** 是否居中标题 */
|
|
7
|
+
centerTitle?: boolean;
|
|
8
|
+
/** 对话框标题 */
|
|
9
|
+
title?: string;
|
|
10
|
+
/** 是否显示关闭按钮 */
|
|
11
|
+
showClose?: boolean;
|
|
12
|
+
/** 取消按钮文本,为 falsy 时( false 或 '' )不显示 */
|
|
13
|
+
cancel?: string | boolean;
|
|
14
|
+
/** 确认按钮文本,为 falsy 时( false 或 '' )不显示 */
|
|
15
|
+
confirm?: string | boolean;
|
|
18
16
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<dialog-cpn
|
|
3
|
-
v-if="
|
|
4
|
-
|
|
3
|
+
v-if="isShow"
|
|
4
|
+
v-model="isShow"
|
|
5
5
|
:modal="innerOptions.modal"
|
|
6
6
|
:center-title="innerOptions.centerTitle"
|
|
7
7
|
:title="innerOptions.title"
|
|
@@ -9,21 +9,22 @@
|
|
|
9
9
|
:cancel="innerOptions.cancel"
|
|
10
10
|
:confirm="innerOptions.confirm"
|
|
11
11
|
:class="[...classNames, $style['MessageBox']]"
|
|
12
|
-
@update:model-value="emit('update:modelValue', $event)"
|
|
13
12
|
@confirm="onConfirm()"
|
|
14
13
|
@cancel="onCancel()"
|
|
15
|
-
@closed="
|
|
14
|
+
@closed="isShow = false"
|
|
16
15
|
>
|
|
17
|
-
{{ innerOptions.content }}
|
|
16
|
+
<slot>{{ innerOptions.content }}</slot>
|
|
18
17
|
</dialog-cpn>
|
|
19
18
|
</template>
|
|
20
19
|
|
|
21
20
|
<script lang="ts" setup>
|
|
22
|
-
import { mergeWith
|
|
21
|
+
import { mergeWith } from 'lodash-es';
|
|
23
22
|
import { ref, useCssModule, watch } from 'vue';
|
|
24
23
|
import useClassNames from '../../composable/component-name';
|
|
25
24
|
import DialogCpn from '../dialog/dialog.vue';
|
|
26
25
|
import type { MessageBoxOptions } from './message-box';
|
|
26
|
+
import { messageBoxProps } from './types';
|
|
27
|
+
import { useAwaitableDialog, useModelValue } from '../../composable';
|
|
27
28
|
|
|
28
29
|
defineOptions({
|
|
29
30
|
options: {
|
|
@@ -36,7 +37,6 @@ const classNames = useClassNames('message-box');
|
|
|
36
37
|
const $style = useCssModule();
|
|
37
38
|
|
|
38
39
|
const props = withDefaults(defineProps<MessageBoxOptions>(), {
|
|
39
|
-
modelValue: false,
|
|
40
40
|
content: '',
|
|
41
41
|
modal: true,
|
|
42
42
|
centerTitle: false,
|
|
@@ -44,17 +44,21 @@ const props = withDefaults(defineProps<MessageBoxOptions>(), {
|
|
|
44
44
|
showClose: false,
|
|
45
45
|
cancel: false,
|
|
46
46
|
confirm: '好的',
|
|
47
|
+
...messageBoxProps,
|
|
47
48
|
});
|
|
48
49
|
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const isShow_ = defineModel<boolean>();
|
|
51
|
+
/** 是否显示 */
|
|
52
|
+
const isShow = useModelValue(isShow_);
|
|
53
|
+
|
|
54
|
+
const { show: showDialog, onConfirm, onCancel } = useAwaitableDialog(isShow);
|
|
55
|
+
|
|
56
|
+
const innerOptions = ref<MessageBoxOptions>(props);
|
|
53
57
|
|
|
54
58
|
watch(
|
|
55
59
|
props,
|
|
56
60
|
(newProps, oldProps) => {
|
|
57
|
-
const {
|
|
61
|
+
const { ...otherProps } = newProps;
|
|
58
62
|
innerOptions.value = mergeWith(
|
|
59
63
|
innerOptions.value,
|
|
60
64
|
otherProps,
|
|
@@ -67,39 +71,10 @@ watch(
|
|
|
67
71
|
{ immediate: true, deep: true }
|
|
68
72
|
);
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
() => props.modelValue,
|
|
72
|
-
(v) => {
|
|
73
|
-
isVisible.value = v;
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const emit = defineEmits<{
|
|
78
|
-
(e: 'update:modelValue', val: boolean): void;
|
|
79
|
-
}>();
|
|
80
|
-
|
|
81
|
-
let resolvePromise: UniApp.PromiseResolvers<void>['resolve'] | undefined;
|
|
82
|
-
let rejectPromise: UniApp.PromiseResolvers<void>['reject'] | undefined;
|
|
83
|
-
|
|
84
|
-
const show = (options: Omit<MessageBoxOptions, 'modelValue'>) => {
|
|
74
|
+
const show = (options: MessageBoxOptions) => {
|
|
85
75
|
innerOptions.value = { ...innerOptions.value, ...options };
|
|
86
|
-
emit('update:modelValue', (isVisible.value = true));
|
|
87
|
-
|
|
88
|
-
// const { promise, resolve } = Promise.withResolvers();
|
|
89
|
-
const promise = new Promise<void>((resolve, reject) => {
|
|
90
|
-
resolvePromise = resolve;
|
|
91
|
-
rejectPromise = reject;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return promise;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const onConfirm = () => {
|
|
98
|
-
resolvePromise?.();
|
|
99
|
-
};
|
|
100
76
|
|
|
101
|
-
|
|
102
|
-
rejectPromise?.(undefined);
|
|
77
|
+
return showDialog();
|
|
103
78
|
};
|
|
104
79
|
|
|
105
80
|
defineExpose({ show });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type ConfigurableMessageBoxProps = {
|
|
2
|
+
/** 是否模态框 */
|
|
3
|
+
modal?: boolean;
|
|
4
|
+
/** 是否居中标题 */
|
|
5
|
+
centerTitle?: boolean;
|
|
6
|
+
/** 对话框标题 */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** 是否显示关闭按钮 */
|
|
9
|
+
showClose?: boolean;
|
|
10
|
+
/** 取消按钮文本,为 falsy 时( false 或 '' )不显示 */
|
|
11
|
+
cancel?: string | boolean;
|
|
12
|
+
/** 确认按钮文本,为 falsy 时( false 或 '' )不显示 */
|
|
13
|
+
confirm?: string | boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare let messageBoxProps: ConfigurableMessageBoxProps;
|
|
16
|
+
export declare const setDefaultMessageBoxProps: (props?: ConfigurableMessageBoxProps) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ConfigurableMessageBoxProps = {
|
|
2
|
+
/** 是否模态框 */
|
|
3
|
+
modal?: boolean;
|
|
4
|
+
/** 是否居中标题 */
|
|
5
|
+
centerTitle?: boolean;
|
|
6
|
+
/** 对话框标题 */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** 是否显示关闭按钮 */
|
|
9
|
+
showClose?: boolean;
|
|
10
|
+
/** 取消按钮文本,为 falsy 时( false 或 '' )不显示 */
|
|
11
|
+
cancel?: string | boolean;
|
|
12
|
+
/** 确认按钮文本,为 falsy 时( false 或 '' )不显示 */
|
|
13
|
+
confirm?: string | boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export let messageBoxProps: ConfigurableMessageBoxProps = {};
|
|
17
|
+
|
|
18
|
+
export const setDefaultMessageBoxProps = (
|
|
19
|
+
props: ConfigurableMessageBoxProps = {}
|
|
20
|
+
) => {
|
|
21
|
+
messageBoxProps = props;
|
|
22
|
+
};
|
|
@@ -98,13 +98,14 @@
|
|
|
98
98
|
|
|
99
99
|
<script lang="ts" setup>
|
|
100
100
|
import { computed, inject, ref, watch } from 'vue';
|
|
101
|
+
import { round } from '@ecolovo/utils';
|
|
101
102
|
import useClassNames from '../../composable/component-name';
|
|
102
|
-
import { round } from '../../utils/round';
|
|
103
103
|
import DialogContentCpn from '../dialog/dialog-content.vue';
|
|
104
104
|
import IconCpn from '../icon/icon.vue';
|
|
105
105
|
import NumpadCpn from '../numpad/numpad.vue';
|
|
106
106
|
import PopoverContentCpn from '../popover/popover-content.vue';
|
|
107
107
|
import PopoverMaskCpn from '../popover/popover-mask.vue';
|
|
108
|
+
import { numberDialogProps } from './types';
|
|
108
109
|
|
|
109
110
|
defineOptions({
|
|
110
111
|
options: {
|
|
@@ -149,6 +150,7 @@ const props = withDefaults(defineProps<_Props>(), {
|
|
|
149
150
|
step: 1,
|
|
150
151
|
max: MAX,
|
|
151
152
|
min: MIN,
|
|
153
|
+
...numberDialogProps,
|
|
152
154
|
});
|
|
153
155
|
|
|
154
156
|
const emit = defineEmits<{
|
|
@@ -249,7 +251,7 @@ const handleOneStep = (step: number) => {
|
|
|
249
251
|
) {
|
|
250
252
|
return false;
|
|
251
253
|
}
|
|
252
|
-
const nextValue = round(+props.modelValue + step, props.precision);
|
|
254
|
+
const nextValue = round(+props.modelValue + step, -1 * props.precision);
|
|
253
255
|
|
|
254
256
|
updateStepValue(nextValue + '');
|
|
255
257
|
return true;
|
|
@@ -282,7 +284,7 @@ const validateValue = (value: string, isStepButton = false) => {
|
|
|
282
284
|
nextValue = props.max;
|
|
283
285
|
emit('error', `数值不能大于 ${props.max}`);
|
|
284
286
|
} else {
|
|
285
|
-
nextValue = round(+value, props.precision);
|
|
287
|
+
nextValue = round(+value, -1 * props.precision);
|
|
286
288
|
}
|
|
287
289
|
return nextValue;
|
|
288
290
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ConfigurableNumberDialogProps = {
|
|
2
|
+
/** 是否可编辑,为 true 时点击中间数字会弹出键盘 */
|
|
3
|
+
editable?: boolean;
|
|
4
|
+
/** 是否只读 */
|
|
5
|
+
readonly?: boolean;
|
|
6
|
+
/** 占位提示文本 */
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** 小数的精度 */
|
|
9
|
+
precision?: number;
|
|
10
|
+
/** 步进器的步长 */
|
|
11
|
+
step?: number;
|
|
12
|
+
/** 最大值 */
|
|
13
|
+
max?: number;
|
|
14
|
+
/** 最小值 */
|
|
15
|
+
min?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare let numberDialogProps: ConfigurableNumberDialogProps;
|
|
18
|
+
export declare const setDefaultNumberDialogProps: (props?: ConfigurableNumberDialogProps) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type ConfigurableNumberDialogProps = {
|
|
2
|
+
/** 是否可编辑,为 true 时点击中间数字会弹出键盘 */
|
|
3
|
+
editable?: boolean;
|
|
4
|
+
/** 是否只读 */
|
|
5
|
+
readonly?: boolean;
|
|
6
|
+
/** 占位提示文本 */
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** 小数的精度 */
|
|
9
|
+
precision?: number;
|
|
10
|
+
/** 步进器的步长 */
|
|
11
|
+
step?: number;
|
|
12
|
+
/** 最大值 */
|
|
13
|
+
max?: number;
|
|
14
|
+
/** 最小值 */
|
|
15
|
+
min?: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export let numberDialogProps: ConfigurableNumberDialogProps = {};
|
|
19
|
+
|
|
20
|
+
export const setDefaultNumberDialogProps = (
|
|
21
|
+
props: ConfigurableNumberDialogProps = {}
|
|
22
|
+
) => {
|
|
23
|
+
numberDialogProps = props;
|
|
24
|
+
};
|
|
@@ -77,9 +77,10 @@
|
|
|
77
77
|
|
|
78
78
|
<script lang="ts" setup>
|
|
79
79
|
import { computed, inject, nextTick, ref, watch } from 'vue';
|
|
80
|
+
import { round } from '@ecolovo/utils';
|
|
80
81
|
import useClassNames from '../../composable/component-name';
|
|
81
|
-
import { round } from '../../utils/round';
|
|
82
82
|
import IconCpn from '../icon/icon.vue';
|
|
83
|
+
import { numberInputProps } from './types';
|
|
83
84
|
|
|
84
85
|
defineOptions({
|
|
85
86
|
options: {
|
|
@@ -131,6 +132,7 @@ const props = withDefaults(defineProps<_Props>(), {
|
|
|
131
132
|
step: 1,
|
|
132
133
|
max: MAX,
|
|
133
134
|
min: MIN,
|
|
135
|
+
...numberInputProps,
|
|
134
136
|
});
|
|
135
137
|
|
|
136
138
|
const emit = defineEmits<{
|
|
@@ -238,7 +240,7 @@ const handleOneStep = (step: number) => {
|
|
|
238
240
|
) {
|
|
239
241
|
return false;
|
|
240
242
|
}
|
|
241
|
-
const nextValue = round(+props.modelValue + step, props.precision);
|
|
243
|
+
const nextValue = round(+props.modelValue + step, -1 * props.precision);
|
|
242
244
|
|
|
243
245
|
updateStepValue(nextValue + '');
|
|
244
246
|
return true;
|
|
@@ -277,7 +279,7 @@ const validateValue = (value: string, isStepButton = false) => {
|
|
|
277
279
|
nextValue = props.max;
|
|
278
280
|
emit('error', `数值不能大于 ${props.max}`);
|
|
279
281
|
} else {
|
|
280
|
-
nextValue = round(+value, props.precision);
|
|
282
|
+
nextValue = round(+value, -1 * props.precision);
|
|
281
283
|
}
|
|
282
284
|
return nextValue;
|
|
283
285
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ConfigurableNumberInputProps = {
|
|
2
|
+
/** 是否可编辑 */
|
|
3
|
+
editable?: boolean;
|
|
4
|
+
/** 类型: input: 只有输入框 | step: 步进器,即带 + - 按钮 */
|
|
5
|
+
mode?: 'input' | 'step';
|
|
6
|
+
/** 输入模式: number: 只能输入整数 | digit: 小数 | text: 如需输入负数 */
|
|
7
|
+
type?: 'number' | 'digit' | 'text';
|
|
8
|
+
/** 占位提示文本 */
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
/** 小数的精度 */
|
|
11
|
+
precision?: number;
|
|
12
|
+
/** 步进器的步长 */
|
|
13
|
+
step?: number;
|
|
14
|
+
/** 最大值 */
|
|
15
|
+
max?: number;
|
|
16
|
+
/** 最小值 */
|
|
17
|
+
min?: number;
|
|
18
|
+
};
|
|
19
|
+
export declare let numberInputProps: ConfigurableNumberInputProps;
|
|
20
|
+
export declare const setDefaultNumberInputProps: (props?: ConfigurableNumberInputProps) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ConfigurableNumberInputProps = {
|
|
2
|
+
/** 是否可编辑 */
|
|
3
|
+
editable?: boolean;
|
|
4
|
+
/** 类型: input: 只有输入框 | step: 步进器,即带 + - 按钮 */
|
|
5
|
+
mode?: 'input' | 'step';
|
|
6
|
+
/** 输入模式: number: 只能输入整数 | digit: 小数 | text: 如需输入负数 */
|
|
7
|
+
type?: 'number' | 'digit' | 'text';
|
|
8
|
+
/** 占位提示文本 */
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
/** 小数的精度 */
|
|
11
|
+
precision?: number;
|
|
12
|
+
/** 步进器的步长 */
|
|
13
|
+
step?: number;
|
|
14
|
+
/** 最大值 */
|
|
15
|
+
max?: number;
|
|
16
|
+
/** 最小值 */
|
|
17
|
+
min?: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export let numberInputProps: ConfigurableNumberInputProps = {};
|
|
21
|
+
|
|
22
|
+
export const setDefaultNumberInputProps = (
|
|
23
|
+
props: ConfigurableNumberInputProps = {}
|
|
24
|
+
) => {
|
|
25
|
+
numberInputProps = props;
|
|
26
|
+
};
|
|
@@ -19,6 +19,7 @@ import { freezeDeep } from '../../utils/freezeDeep';
|
|
|
19
19
|
import useClassNames from '../../composable/component-name';
|
|
20
20
|
import ButtonCpn from '../button/button.vue';
|
|
21
21
|
import IconCpn from '../icon/icon.vue';
|
|
22
|
+
import { numpadProps } from './types';
|
|
22
23
|
|
|
23
24
|
defineOptions({
|
|
24
25
|
options: {
|
|
@@ -75,6 +76,7 @@ const props = withDefaults(defineProps<_Props>(), {
|
|
|
75
76
|
precision: 0,
|
|
76
77
|
max: MAX,
|
|
77
78
|
min: MIN,
|
|
79
|
+
...numpadProps,
|
|
78
80
|
});
|
|
79
81
|
|
|
80
82
|
const emit = defineEmits<{
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ConfigurableNumpadProps = {
|
|
2
|
+
/** 小数的精度 */
|
|
3
|
+
precision?: number;
|
|
4
|
+
/** 允许输入的最大值 */
|
|
5
|
+
max?: number;
|
|
6
|
+
/** 允许输入的最小值 */
|
|
7
|
+
min?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare let numpadProps: ConfigurableNumpadProps;
|
|
10
|
+
export declare const setDefaultNumpadProps: (props?: ConfigurableNumpadProps) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type ConfigurableNumpadProps = {
|
|
2
|
+
/** 小数的精度 */
|
|
3
|
+
precision?: number;
|
|
4
|
+
/** 允许输入的最大值 */
|
|
5
|
+
max?: number;
|
|
6
|
+
/** 允许输入的最小值 */
|
|
7
|
+
min?: number;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export let numpadProps: ConfigurableNumpadProps = {};
|
|
11
|
+
|
|
12
|
+
export const setDefaultNumpadProps = (props: ConfigurableNumpadProps = {}) => {
|
|
13
|
+
numpadProps = props;
|
|
14
|
+
};
|
|
@@ -32,14 +32,14 @@ type _Props = {
|
|
|
32
32
|
isTabPage?: boolean;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
withDefaults(defineProps<_Props>(), {
|
|
35
|
+
const props = withDefaults(defineProps<_Props>(), {
|
|
36
36
|
isTabPage: false,
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
const inlineStyle = computed(() => {
|
|
40
40
|
return [
|
|
41
41
|
// 底部安全区高度
|
|
42
|
-
`--safe-area-bottom: ${safeAreaInsetBottom}px;`,
|
|
42
|
+
`--safe-area-bottom: ${props.isTabPage ? 0 : safeAreaInsetBottom}px;`,
|
|
43
43
|
].join('');
|
|
44
44
|
});
|
|
45
45
|
</script>
|
|
@@ -67,7 +67,6 @@ const inlineStyle = computed(() => {
|
|
|
67
67
|
padding-bottom: var(--safe-area-bottom);
|
|
68
68
|
box-sizing: border-box;
|
|
69
69
|
z-index: UTILS__GLOBAL_VAR(z-index, page-footer);
|
|
70
|
-
box-shadow: 0 -4rpx 4rpx 4rpx #ccc;
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
// 将内容占满空间
|
|
@@ -60,8 +60,9 @@
|
|
|
60
60
|
/**
|
|
61
61
|
* 页面头部部分容器组件,不单独使用,通过 page 组件间接引入
|
|
62
62
|
*/
|
|
63
|
-
import { computed, onMounted
|
|
63
|
+
import { computed, onMounted } from 'vue';
|
|
64
64
|
import useClassNames from '../../composable/component-name';
|
|
65
|
+
import { useCurrentPageRoute } from '../../composable/page';
|
|
65
66
|
import { homePath } from '../../configs';
|
|
66
67
|
import {
|
|
67
68
|
navBarHeight,
|
|
@@ -69,6 +70,7 @@ import {
|
|
|
69
70
|
menuButtonWidthInCss,
|
|
70
71
|
} from '../../utils/windowInfo';
|
|
71
72
|
import IconCpn from '../icon/icon.vue';
|
|
73
|
+
import { pageHeaderProps } from './types';
|
|
72
74
|
|
|
73
75
|
defineOptions({
|
|
74
76
|
options: {
|
|
@@ -79,6 +81,14 @@ defineOptions({
|
|
|
79
81
|
|
|
80
82
|
const classNames = useClassNames('page-header');
|
|
81
83
|
|
|
84
|
+
type _Slots = {
|
|
85
|
+
default: () => void;
|
|
86
|
+
/** 额外内容 */
|
|
87
|
+
extra: () => void;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
defineSlots<_Slots>();
|
|
91
|
+
|
|
82
92
|
type _Props = {
|
|
83
93
|
/** 导航栏标题 */
|
|
84
94
|
title?: string;
|
|
@@ -98,14 +108,10 @@ const props = withDefaults(defineProps<_Props>(), {
|
|
|
98
108
|
fixed: false,
|
|
99
109
|
theme: 'light',
|
|
100
110
|
navType: undefined,
|
|
111
|
+
...pageHeaderProps,
|
|
101
112
|
});
|
|
102
113
|
|
|
103
|
-
|
|
104
|
-
const currentPages = ref<ReturnType<typeof getCurrentPages>>([]);
|
|
105
|
-
/** 当前页面路由 */
|
|
106
|
-
const currentPageRoute = computed(() => {
|
|
107
|
-
return currentPages.value.slice(-1)[0]?.route || '';
|
|
108
|
-
});
|
|
114
|
+
const { currentPages, currentPageRoute, isTabbarPage } = useCurrentPageRoute();
|
|
109
115
|
|
|
110
116
|
/** 是否显示返回按钮 */
|
|
111
117
|
const hasBack = computed(() => {
|
|
@@ -113,6 +119,8 @@ const hasBack = computed(() => {
|
|
|
113
119
|
if (props.navType !== undefined) return !!(props.navType & 1);
|
|
114
120
|
// 在首页不显示返回按钮
|
|
115
121
|
if (homePath === '/' + currentPageRoute.value) return false;
|
|
122
|
+
// 如果是 tabbar 页面,则不显示返回按钮
|
|
123
|
+
if (isTabbarPage.value) return false;
|
|
116
124
|
// 页面栈只有一个时不显示返回按钮
|
|
117
125
|
if (currentPages.value.length <= 1) return false;
|
|
118
126
|
// 其他情况均显示返回按钮
|
|
@@ -125,9 +133,11 @@ const hasHome = computed(() => {
|
|
|
125
133
|
if (props.navType !== undefined) return !!(props.navType & 2);
|
|
126
134
|
// 在首页不显示返回首页按钮
|
|
127
135
|
if (homePath === '/' + currentPageRoute.value) return false;
|
|
128
|
-
//
|
|
136
|
+
// 如果是 tabbar 页面,则不显示首页按钮
|
|
137
|
+
if (isTabbarPage.value) return false;
|
|
138
|
+
// 页面栈只有一个时显示首页按钮
|
|
129
139
|
if (currentPages.value.length === 1) return true;
|
|
130
|
-
//
|
|
140
|
+
// 其他情况均不显示首页按钮
|
|
131
141
|
return false;
|
|
132
142
|
});
|
|
133
143
|
|