@ecolovo/uniapp-components 1.0.10 → 2.0.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 +202 -66
- package/components/aspect/aspect.vue +24 -15
- package/components/badge/badge.scss +20 -0
- package/components/badge/badge.vue +49 -40
- package/components/button/button.scss +15 -0
- package/components/button/button.vue +121 -177
- package/components/checkbox/checkbox.scss +10 -0
- package/components/checkbox/checkbox.vue +118 -146
- package/components/checkbox-group/checkbox-group.vue +79 -85
- package/components/checkbox-group2/checkbox-group2.vue +111 -107
- package/components/checkbox-group2/checkbox2.vue +104 -0
- package/components/data-list/data-list.scss +9 -0
- package/components/data-list/data-list.vue +70 -79
- package/components/date-picker/date-picker-view.vue +125 -124
- package/components/date-picker/date-picker.vue +145 -146
- package/components/dialog/dialog-content.vue +39 -47
- package/components/dialog/dialog.scss +11 -0
- package/components/dialog/dialog.vue +125 -138
- package/components/dropdown/dropdown.scss +11 -0
- package/components/dropdown/dropdown.vue +55 -97
- package/components/empty/empty.scss +14 -0
- package/components/empty/empty.vue +42 -41
- package/components/flex/flex.vue +45 -54
- package/components/form/form.vue +29 -24
- package/components/form-item/form-item.scss +11 -0
- package/components/form-item/form-item.vue +43 -40
- package/components/icon/icon.vue +70 -85
- package/components/image/image.vue +35 -38
- package/components/input/input.vue +65 -79
- package/components/input/password-input.vue +34 -42
- package/components/list-page/list-page.vue +73 -99
- package/components/load-more/load-more.scss +12 -0
- package/components/load-more/load-more.vue +29 -29
- package/components/loading/animations/loading-animation1.vue +8 -8
- package/components/loading/animations/loading-animation2.vue +8 -9
- package/components/loading/animations/loading-animation3.vue +11 -11
- package/components/loading/animations/loading-animation4.vue +8 -8
- package/components/loading/loading.vue +19 -20
- package/components/message-box/message-box.vue +59 -41
- package/components/number-dialog/number-dialog.scss +9 -0
- package/components/number-dialog/number-dialog.vue +209 -204
- package/components/number-input/number-input.scss +9 -0
- package/components/number-input/number-input.vue +233 -232
- package/components/numpad/numpad.scss +9 -0
- package/components/numpad/numpad.vue +133 -150
- package/components/page/page-body.scss +15 -0
- package/components/page/page-body.vue +137 -119
- package/components/page/page-footer.scss +13 -0
- package/components/page/page-footer.vue +31 -33
- package/components/page/page-header.scss +17 -0
- package/components/page/page-header.vue +89 -94
- package/components/page/page.scss +9 -0
- package/components/page/page.vue +105 -81
- package/components/picker/picker-popup.vue +218 -209
- package/components/picker/picker.vue +99 -104
- package/components/popover/popover-content.vue +54 -63
- package/components/popover/popover-mask.vue +63 -63
- package/components/popover/popover.scss +28 -0
- package/components/popover/popover.vue +49 -47
- package/components/popup/popup-content.vue +49 -53
- package/components/popup/popup.scss +11 -0
- package/components/popup/popup.vue +117 -132
- package/components/price/price.scss +20 -0
- package/components/price/price.vue +31 -42
- package/components/search/search.scss +12 -0
- package/components/search/search.vue +93 -117
- package/components/searching/searching.vue +33 -40
- package/components/selector/selector.vue +43 -48
- package/components/switch/switch.scss +12 -0
- package/components/switch/switch.vue +99 -96
- package/components/tab/tab.scss +19 -0
- package/components/tab/tab.vue +151 -145
- package/components/textarea/textarea.vue +104 -101
- package/composable/component-name.d.ts +2 -0
- package/composable/component-name.js +8 -0
- package/composable/component-name.ts +10 -0
- package/configs/index.d.ts +25 -10
- package/configs/index.js +14 -23
- package/configs/index.ts +82 -0
- package/easyCom.d.ts +9 -0
- package/easyCom.js +1 -2
- package/easyCom.ts +31 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.ts +1 -0
- package/init.d.ts +4 -7
- package/init.js +5 -4
- package/init.ts +34 -0
- package/package.json +14 -4
- package/styles/utils/css-var.scss +12 -15
- package/styles/utils/ellipsis.scss +0 -7
- package/styles/utils/z-index.scss +1 -1
- package/styles/var/component.scss +21 -245
- package/utils/date.d.ts +47 -0
- package/utils/date.js +23 -43
- package/utils/date.ts +153 -0
- package/utils/freezeDeep.d.ts +1 -0
- package/utils/freezeDeep.js +4 -14
- package/utils/freezeDeep.ts +9 -0
- package/utils/price.d.ts +24 -0
- package/utils/price.js +14 -8
- package/utils/price.ts +57 -0
- package/utils/round.d.ts +2 -0
- package/utils/round.js +2 -14
- package/utils/round.ts +11 -0
- package/utils/windowInfo.d.ts +24 -0
- package/utils/windowInfo.js +8 -36
- package/utils/windowInfo.ts +50 -0
- package/components/checkbox-group2/checkbox.vue +0 -109
- package/components/datetime-picker/datetime-picker-view.vue +0 -209
- package/components/datetime-picker/datetime-picker.vue +0 -235
- package/components/form/mixin.js +0 -13
- package/components/list-page/list-page.js +0 -10
- package/components/table/table.vue +0 -112
- package/components/time-picker/time-picker-view.vue +0 -127
- package/components/time-picker/time-picker.vue +0 -140
- package/components/uploader/download.js +0 -81
- package/components/uploader/file-uploader.vue +0 -52
- package/components/uploader/files.js +0 -225
- package/components/uploader/media-uploader.vue +0 -189
- package/components/uploader/mixin.js +0 -171
- package/components/uploader/uni.js +0 -38
- package/components/uploader/upload-button.vue +0 -29
- package/components/uploader/uploader copy.vue +0 -547
- package/components/uploader/uploader.vue +0 -117
- package/mixins/componentName.js +0 -32
- package/mixins/listPage.js +0 -1
- package/mixins/windowInfo.js +0 -1
- package/utils/fileSize.js +0 -39
- package/utils/floor.js +0 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view
|
|
3
|
-
:class="[
|
|
3
|
+
:class="[...classNames, $style['NumberDialog'], { [$style['NumberDialog--disabled']]: disabled }]"
|
|
4
4
|
@click.stop.prevent="doNothing"
|
|
5
5
|
>
|
|
6
6
|
<view
|
|
@@ -14,16 +14,18 @@
|
|
|
14
14
|
<icon-cpn
|
|
15
15
|
icon="step-minus"
|
|
16
16
|
tap-size="60rpx"
|
|
17
|
-
@touchstart
|
|
18
|
-
@touchend
|
|
19
|
-
@touchcancel
|
|
17
|
+
@touchstart="handleStepLongTouchStart($event, -step, disabledDecrease)"
|
|
18
|
+
@touchend="handleStepLongTouchEnd(-step)"
|
|
19
|
+
@touchcancel="handleStepLongTouchEnd(-step)"
|
|
20
20
|
/>
|
|
21
21
|
</view>
|
|
22
22
|
<view
|
|
23
23
|
:class="[$style['NumberDialog--input'], { [$style['NumberDialog--readonly']]: isReadonly }]"
|
|
24
24
|
@click="showPad"
|
|
25
25
|
>
|
|
26
|
-
<text v-if="isReadonly ||
|
|
26
|
+
<text v-if="isReadonly || modelValue === 0 || modelValue" :class="$style['NumberDialog--value']">{{
|
|
27
|
+
modelValue
|
|
28
|
+
}}</text>
|
|
27
29
|
<text v-else :class="$style['NumberDialog--placeholder']">{{ placeholder }}</text>
|
|
28
30
|
</view>
|
|
29
31
|
<view
|
|
@@ -37,13 +39,13 @@
|
|
|
37
39
|
<icon-cpn
|
|
38
40
|
icon="step-plus"
|
|
39
41
|
tap-size="60rpx"
|
|
40
|
-
@touchstart
|
|
41
|
-
@touchend
|
|
42
|
-
@touchcancel
|
|
42
|
+
@touchstart="handleStepLongTouchStart($event, step, disabledIncrease)"
|
|
43
|
+
@touchend="handleStepLongTouchEnd(step)"
|
|
44
|
+
@touchcancel="handleStepLongTouchEnd(step)"
|
|
43
45
|
/>
|
|
44
46
|
</view>
|
|
45
47
|
|
|
46
|
-
<popover-mask-cpn v-if="isShowPad" ref="
|
|
48
|
+
<popover-mask-cpn v-if="isShowPad" ref="maskRef" v-model="isShowPad">
|
|
47
49
|
<dialog-content-cpn
|
|
48
50
|
title="请输入数字"
|
|
49
51
|
center-title
|
|
@@ -64,9 +66,9 @@
|
|
|
64
66
|
</view>
|
|
65
67
|
</template>
|
|
66
68
|
|
|
67
|
-
<script>
|
|
68
|
-
import
|
|
69
|
-
import
|
|
69
|
+
<script lang="ts" setup>
|
|
70
|
+
import { computed, inject, ref, watch } from 'vue';
|
|
71
|
+
import useClassNames from '../../composable/component-name';
|
|
70
72
|
import { round } from '../../utils/round';
|
|
71
73
|
import DialogContentCpn from '../dialog/dialog-content.vue';
|
|
72
74
|
import IconCpn from '../icon/icon.vue';
|
|
@@ -74,210 +76,213 @@ import NumpadCpn from '../numpad/numpad.vue';
|
|
|
74
76
|
import PopoverContentCpn from '../popover/popover-content.vue';
|
|
75
77
|
import PopoverMaskCpn from '../popover/popover-mask.vue';
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
const MAX = 9999;
|
|
79
|
-
|
|
80
|
-
export default {
|
|
81
|
-
name: 'NumberDialog',
|
|
79
|
+
defineOptions({
|
|
82
80
|
options: {
|
|
83
81
|
virtualHost: true,
|
|
84
82
|
styleIsolation: 'shared',
|
|
85
83
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
},
|
|
169
|
-
methods: {
|
|
170
|
-
doNothing() {},
|
|
171
|
-
/** 长按步进按钮开始处理 */
|
|
172
|
-
handleStepLongTouchStart(event, step, disabled) {
|
|
173
|
-
if (disabled) return;
|
|
174
|
-
if (event.touches && event.touches.length > 1) return;
|
|
175
|
-
|
|
176
|
-
this._lastValue = this.value;
|
|
177
|
-
this._touchingStep = step;
|
|
178
|
-
let interval = 400;
|
|
179
|
-
let times = 0;
|
|
180
|
-
|
|
181
|
-
const longTouch = () => {
|
|
182
|
-
if (!this.handleOneStep(step * (times >= 30 ? 4 : times >= 12 ? 2 : 1))) return;
|
|
183
|
-
|
|
184
|
-
this._touchTimer = setTimeout(longTouch, interval);
|
|
185
|
-
interval = Math.max(100, interval - 50);
|
|
186
|
-
times++;
|
|
187
|
-
};
|
|
188
|
-
longTouch();
|
|
189
|
-
},
|
|
190
|
-
/** 长按步进按钮结束处理 */
|
|
191
|
-
handleStepLongTouchEnd(step) {
|
|
192
|
-
if (this._touchingStep !== step) return;
|
|
193
|
-
if (this._touchTimer) {
|
|
194
|
-
clearTimeout(this._touchTimer);
|
|
195
|
-
this._touchTimer = null;
|
|
196
|
-
}
|
|
197
|
-
this._touchingStep = null;
|
|
198
|
-
this.confirmValue(this.editValue + '', true);
|
|
199
|
-
},
|
|
200
|
-
/** 单次步进处理 */
|
|
201
|
-
handleOneStep(step) {
|
|
202
|
-
if ((step > 0 && this.disabledIncrease) || (step < 0 && this.disabledDecrease)) {
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
let nextValue = round(+this.value + step, this.precision);
|
|
206
|
-
|
|
207
|
-
this.updateStepValue(nextValue + '');
|
|
208
|
-
return true;
|
|
209
|
-
},
|
|
210
|
-
/** 每次步进处理 */
|
|
211
|
-
updateStepValue(value) {
|
|
212
|
-
value = this.validateValue(value, true);
|
|
213
|
-
this.$emit('input', value);
|
|
214
|
-
this.editValue = value;
|
|
215
|
-
},
|
|
216
|
-
/** 校验数据
|
|
217
|
-
* @param {string} value 输入值
|
|
218
|
-
* @param {boolean} isStepButton 是否为步进按钮触发
|
|
219
|
-
*/
|
|
220
|
-
validateValue(value, isStepButton = false) {
|
|
221
|
-
let nextValue;
|
|
222
|
-
if (isNaN(value)) {
|
|
223
|
-
// 输入不合法,取消此次输入
|
|
224
|
-
nextValue = isStepButton ? 0 : this._lastValue;
|
|
225
|
-
this.$emit('error', '请输入正确的数值');
|
|
226
|
-
} else if (value === '') {
|
|
227
|
-
// 输入空值
|
|
228
|
-
nextValue = isStepButton ? 0 : '';
|
|
229
|
-
this.$emit('error', '请输入数值');
|
|
230
|
-
} else if (+value < this.min) {
|
|
231
|
-
// 超过最小输入值
|
|
232
|
-
nextValue = this.min;
|
|
233
|
-
this.$emit('error', `数值不能小于 ${this.min}`);
|
|
234
|
-
} else if (+value > this.max) {
|
|
235
|
-
// 超过最大输入值
|
|
236
|
-
nextValue = this.max;
|
|
237
|
-
this.$emit('error', `数值不能大于 ${this.max}`);
|
|
238
|
-
} else {
|
|
239
|
-
nextValue = round(+value, this.precision);
|
|
240
|
-
}
|
|
241
|
-
return nextValue;
|
|
242
|
-
},
|
|
243
|
-
/** 确认数据
|
|
244
|
-
* @param {string} value
|
|
245
|
-
*/
|
|
246
|
-
confirmValue(value, isStepButton = false) {
|
|
247
|
-
value = this.validateValue(value, isStepButton);
|
|
248
|
-
this.editValue = value + '';
|
|
249
|
-
|
|
250
|
-
this.$emit('input', value);
|
|
251
|
-
this.$emit('change', { value, lastValue: this._lastValue });
|
|
252
|
-
},
|
|
253
|
-
/** 显示数字键盘弹框 */
|
|
254
|
-
showPad() {
|
|
255
|
-
if (this.isReadonly || this.disabled || !this.editable) return;
|
|
256
|
-
|
|
257
|
-
this.editValue = this.value + '';
|
|
258
|
-
this.isShowPad = true;
|
|
259
|
-
},
|
|
260
|
-
/** 关闭数字键盘弹框 */
|
|
261
|
-
closePad() {
|
|
262
|
-
this.$refs.mask.close();
|
|
263
|
-
},
|
|
264
|
-
/** 点击弹框确认按钮 */
|
|
265
|
-
onConfirm() {
|
|
266
|
-
this.confirmValue(this.editValue);
|
|
267
|
-
this.closePad();
|
|
268
|
-
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const classNames = useClassNames('number-dialog');
|
|
87
|
+
|
|
88
|
+
const MIN = 0;
|
|
89
|
+
const MAX = 9999;
|
|
90
|
+
|
|
91
|
+
type _Props = {
|
|
92
|
+
/** 绑定值 */
|
|
93
|
+
modelValue?: string | number;
|
|
94
|
+
/** 是否禁用 */
|
|
95
|
+
disabled?: boolean;
|
|
96
|
+
/** 是否可编辑,为 true 时点击中间数字会弹出键盘 */
|
|
97
|
+
editable?: boolean;
|
|
98
|
+
/** 是否只读 */
|
|
99
|
+
readonly?: boolean;
|
|
100
|
+
/** 占位提示文本 */
|
|
101
|
+
placeholder?: string;
|
|
102
|
+
/** 小数的精度 */
|
|
103
|
+
precision?: number;
|
|
104
|
+
/** 步进器的步长 */
|
|
105
|
+
step?: number;
|
|
106
|
+
/** 最大值 */
|
|
107
|
+
max?: number;
|
|
108
|
+
/** 最小值 */
|
|
109
|
+
min?: number;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const props = withDefaults(defineProps<_Props>(), {
|
|
113
|
+
modelValue: '',
|
|
114
|
+
disabled: false,
|
|
115
|
+
editable: true,
|
|
116
|
+
readonly: false,
|
|
117
|
+
placeholder: '请输入',
|
|
118
|
+
precision: 0,
|
|
119
|
+
step: 1,
|
|
120
|
+
max: MAX,
|
|
121
|
+
min: MIN,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const emit = defineEmits<{
|
|
125
|
+
(e: 'update:modelValue', val: string | number): void;
|
|
126
|
+
(e: 'change', payload: { value: string | number; lastValue: string | number }): void;
|
|
127
|
+
(e: 'error', msg: string): void;
|
|
128
|
+
}>();
|
|
129
|
+
|
|
130
|
+
/** 表单是否只读 */
|
|
131
|
+
const isFormReadonly = inject(
|
|
132
|
+
'ecolovo/form/readonly',
|
|
133
|
+
computed(() => false)
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
/** 编辑值 */
|
|
137
|
+
const editValue = ref<string | number>('');
|
|
138
|
+
/** 是否显示数字键盘 */
|
|
139
|
+
const isShowPad = ref(false);
|
|
140
|
+
|
|
141
|
+
const maskRef = ref<InstanceType<typeof PopoverMaskCpn>>();
|
|
142
|
+
|
|
143
|
+
/** 是否只读 */
|
|
144
|
+
const isReadonly = computed(() => props.readonly || isFormReadonly.value);
|
|
145
|
+
|
|
146
|
+
/** 是否禁用减 */
|
|
147
|
+
const disabledDecrease = computed(() => {
|
|
148
|
+
if (props.disabled) return true;
|
|
149
|
+
const val = Number(props.modelValue);
|
|
150
|
+
if (!Number.isNaN(val) && val <= Number(props.min)) return true;
|
|
151
|
+
return false;
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
/** 是否禁用增 */
|
|
155
|
+
const disabledIncrease = computed(() => {
|
|
156
|
+
if (props.disabled) return true;
|
|
157
|
+
const val = Number(props.modelValue);
|
|
158
|
+
if (!Number.isNaN(val) && val >= Number(props.max)) return true;
|
|
159
|
+
return false;
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
watch(
|
|
163
|
+
() => props.modelValue,
|
|
164
|
+
(n) => {
|
|
165
|
+
editValue.value = (n ?? '') + '';
|
|
269
166
|
},
|
|
167
|
+
{ immediate: true }
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
let _lastValue: string | number = '';
|
|
171
|
+
let _touchingStep: number | null = null;
|
|
172
|
+
let _touchTimer: ReturnType<typeof setTimeout> | null = null;
|
|
173
|
+
|
|
174
|
+
const doNothing = () => {};
|
|
175
|
+
|
|
176
|
+
/** 长按步进按钮开始处理 */
|
|
177
|
+
const handleStepLongTouchStart = (event: TouchEvent, step: number, disabled: boolean) => {
|
|
178
|
+
if (disabled) return;
|
|
179
|
+
if (event.touches.length > 1) return;
|
|
180
|
+
|
|
181
|
+
_lastValue = props.modelValue;
|
|
182
|
+
_touchingStep = step;
|
|
183
|
+
let interval = 400;
|
|
184
|
+
let times = 0;
|
|
185
|
+
|
|
186
|
+
const longTouch = () => {
|
|
187
|
+
if (!handleOneStep(step * (times >= 30 ? 4 : times >= 12 ? 2 : 1))) return;
|
|
188
|
+
|
|
189
|
+
_touchTimer = setTimeout(longTouch, interval);
|
|
190
|
+
interval = Math.max(100, interval - 50);
|
|
191
|
+
times++;
|
|
192
|
+
};
|
|
193
|
+
longTouch();
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/** 长按步进按钮结束处理 */
|
|
197
|
+
const handleStepLongTouchEnd = (step: number) => {
|
|
198
|
+
if (_touchingStep !== step) return;
|
|
199
|
+
if (_touchTimer) {
|
|
200
|
+
clearTimeout(_touchTimer);
|
|
201
|
+
_touchTimer = null;
|
|
202
|
+
}
|
|
203
|
+
_touchingStep = null;
|
|
204
|
+
confirmValue(editValue.value + '', true);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/** 单次步进处理 */
|
|
208
|
+
const handleOneStep = (step: number) => {
|
|
209
|
+
if ((step > 0 && disabledIncrease.value) || (step < 0 && disabledDecrease.value)) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
const nextValue = round(+props.modelValue + step, props.precision);
|
|
213
|
+
|
|
214
|
+
updateStepValue(nextValue + '');
|
|
215
|
+
return true;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/** 每次步进处理 */
|
|
219
|
+
const updateStepValue = (value: string) => {
|
|
220
|
+
const nextValue = validateValue(value, true);
|
|
221
|
+
emit('update:modelValue', nextValue);
|
|
222
|
+
editValue.value = nextValue + '';
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/** 校验数据 */
|
|
226
|
+
const validateValue = (value: string, isStepButton = false) => {
|
|
227
|
+
let nextValue: string | number;
|
|
228
|
+
if (isNaN(+value)) {
|
|
229
|
+
// 输入不合法,取消此次输入
|
|
230
|
+
nextValue = isStepButton ? 0 : _lastValue;
|
|
231
|
+
emit('error', '请输入正确的数值');
|
|
232
|
+
} else if (value === '') {
|
|
233
|
+
// 输入空值
|
|
234
|
+
nextValue = isStepButton ? 0 : '';
|
|
235
|
+
emit('error', '请输入数值');
|
|
236
|
+
} else if (+value < props.min) {
|
|
237
|
+
// 超过最小输入值
|
|
238
|
+
nextValue = props.min;
|
|
239
|
+
emit('error', `数值不能小于 ${props.min}`);
|
|
240
|
+
} else if (+value > props.max) {
|
|
241
|
+
// 超过最大输入值
|
|
242
|
+
nextValue = props.max;
|
|
243
|
+
emit('error', `数值不能大于 ${props.max}`);
|
|
244
|
+
} else {
|
|
245
|
+
nextValue = round(+value, props.precision);
|
|
246
|
+
}
|
|
247
|
+
return nextValue;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/** 确认数据 */
|
|
251
|
+
const confirmValue = (value: string, isStepButton = false) => {
|
|
252
|
+
const nextValue = validateValue(value, isStepButton);
|
|
253
|
+
editValue.value = nextValue + '';
|
|
254
|
+
|
|
255
|
+
emit('update:modelValue', nextValue);
|
|
256
|
+
emit('change', { value, lastValue: _lastValue });
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/** 显示数字键盘弹框 */
|
|
260
|
+
const showPad = () => {
|
|
261
|
+
if (isReadonly.value || props.disabled || !props.editable) return;
|
|
262
|
+
|
|
263
|
+
editValue.value = (props.modelValue ?? '') + '';
|
|
264
|
+
isShowPad.value = true;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/** 关闭数字键盘弹框 */
|
|
268
|
+
const closePad = () => {
|
|
269
|
+
maskRef.value?.close();
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/** 点击弹框确认按钮 */
|
|
273
|
+
const onConfirm = () => {
|
|
274
|
+
confirmValue(editValue.value as string);
|
|
275
|
+
closePad();
|
|
270
276
|
};
|
|
271
277
|
</script>
|
|
272
278
|
|
|
273
279
|
<style lang="scss" module>
|
|
274
|
-
@use '../../styles/
|
|
280
|
+
@use '../../styles/utils' as *;
|
|
281
|
+
@use './number-dialog' as *;
|
|
275
282
|
|
|
276
283
|
// 定义外部变量
|
|
277
|
-
$component-name: 'number-dialog';
|
|
278
|
-
$component-vars: $number-dialog;
|
|
279
284
|
%external-vars {
|
|
280
|
-
@include UTILS__DEFINE_COMPONENT_VARS();
|
|
285
|
+
@include UTILS__DEFINE_COMPONENT_VARS($number-dialog, 'number-dialog');
|
|
281
286
|
}
|
|
282
287
|
|
|
283
288
|
.NumberDialog {
|