|
1 | 1 | <template>
|
2 |
| - <nut-popup |
3 |
| - v-model:visible="show" |
4 |
| - position="bottom" |
5 |
| - :pop-class="popClass" |
6 |
| - :overlay="overlay" |
7 |
| - overlay-class="nut-number-keyboard-overlay" |
8 |
| - :lock-scroll="lockScroll" |
9 |
| - :catch-move="lockScroll" |
10 |
| - @click-overlay="closeBoard()" |
11 |
| - > |
| 2 | + <nut-popup v-model:visible="show" position="bottom" :pop-class="popClass" :overlay="overlay" |
| 3 | + overlay-class="nut-number-keyboard-overlay" :lock-scroll="lockScroll" :catch-move="lockScroll" |
| 4 | + @click-overlay="closeBoard()"> |
12 | 5 | <div ref="root" class="nut-number-keyboard">
|
13 | 6 | <div v-if="title" class="nut-number-keyboard__header">
|
14 | 7 | <h3 class="nut-number-keyboard__title">{{ title }}</h3>
|
|
18 | 11 | </div>
|
19 | 12 | <div class="nut-number-keyboard__body">
|
20 | 13 | <div class="nut-number-keyboard__keys">
|
21 |
| - <div |
22 |
| - v-for="item of keysList" |
23 |
| - :key="'key' + item.id" |
24 |
| - :class="[ |
25 |
| - 'nut-key__wrapper', |
26 |
| - { |
27 |
| - 'nut-key__wrapper--wider': |
28 |
| - item.id == 0 && type == 'rightColumn' && Array.isArray(customKey) && customKey.length == 1 |
29 |
| - } |
30 |
| - ]" |
31 |
| - > |
32 |
| - <div |
33 |
| - :class="[ |
34 |
| - 'nut-key', |
35 |
| - { 'nut-key--active': item.id == clickKeyIndex }, |
36 |
| - { 'nut-key--lock': item.type == 'lock' }, |
37 |
| - { 'nut-key--delete': item.type == 'delete' } |
38 |
| - ]" |
39 |
| - @touchstart="(event: TouchEvent) => onTouchstart(item, event)" |
40 |
| - @touchmove="(event: TouchEvent) => onTouchMove(event)" |
41 |
| - @touchend="onTouchEnd" |
42 |
| - > |
| 14 | + <div v-for="item of keysList" :key="'key' + item.id" :class="[ |
| 15 | + 'nut-key__wrapper', |
| 16 | + { |
| 17 | + 'nut-key__wrapper--wider': |
| 18 | + item.id == 0 && type == 'rightColumn' && Array.isArray(customKey) && customKey.length == 1 |
| 19 | + } |
| 20 | + ]"> |
| 21 | + <div :class="[ |
| 22 | + 'nut-key', |
| 23 | + { 'nut-key--active': item.id == clickKeyIndex }, |
| 24 | + { 'nut-key--lock': item.type == 'lock' }, |
| 25 | + { 'nut-key--delete': item.type == 'delete' } |
| 26 | + ]" @touchstart="(event: TouchEvent) => onTouchstart(item, event)" |
| 27 | + @touchmove="(event: TouchEvent) => onTouchMove(event)" @touchend="onTouchEnd"> |
43 | 28 | <template v-if="item.type == 'number' || item.type == 'custom'">{{ item.id }}</template>
|
44 |
| - <img |
45 |
| - v-if="item.type == 'lock'" |
46 |
| - src="https://img11.360buyimg.com/imagetools/jfs/t1/146371/38/8485/738/5f606425Eca239740/14f4b4f5f20d8a68.png" |
47 |
| - /> |
48 |
| - <img |
49 |
| - v-if="item.type == 'delete'" |
50 |
| - src="https://img11.360buyimg.com/imagetools/jfs/t1/129395/8/12735/2030/5f61ac37E70cab338/fb477dc11f46056c.png" |
51 |
| - /> |
| 29 | + <img v-if="item.type == 'lock'" |
| 30 | + src="https://img11.360buyimg.com/imagetools/jfs/t1/146371/38/8485/738/5f606425Eca239740/14f4b4f5f20d8a68.png" /> |
| 31 | + <img v-if="item.type == 'delete'" |
| 32 | + src="https://img11.360buyimg.com/imagetools/jfs/t1/129395/8/12735/2030/5f61ac37E70cab338/fb477dc11f46056c.png" /> |
52 | 33 | </div>
|
53 | 34 | </div>
|
54 | 35 | </div>
|
55 | 36 | <div v-if="type == 'rightColumn'" class="nut-number-keyboard__sidebar">
|
56 | 37 | <div class="nut-key__wrapper">
|
57 |
| - <div |
58 |
| - :class="['nut-key', { active: clickKeyIndex == 'delete' }]" |
59 |
| - @touchstart="(event: TouchEvent) => onTouchstart({ id: 'delete', type: 'delete' }, event)" |
60 |
| - @touchmove="(event: TouchEvent) => onTouchMove(event)" |
61 |
| - @touchend="onTouchEnd" |
62 |
| - > |
| 38 | + <div :class="['nut-key', { active: clickKeyIndex == 'delete' }]" |
| 39 | + @touchstart="(event: TouchEvent) => onTouchstart({ id: 'delete', type: 'delete' }, event)" |
| 40 | + @touchmove="(event: TouchEvent) => onTouchMove(event)" @touchend="onTouchEnd"> |
63 | 41 | <img
|
64 |
| - src="https://img11.360buyimg.com/imagetools/jfs/t1/129395/8/12735/2030/5f61ac37E70cab338/fb477dc11f46056c.png" |
65 |
| - /> |
| 42 | + src="https://img11.360buyimg.com/imagetools/jfs/t1/129395/8/12735/2030/5f61ac37E70cab338/fb477dc11f46056c.png" /> |
66 | 43 | </div>
|
67 | 44 | </div>
|
68 |
| - <div class="nut-key__wrapper nut-key__wrapper--finish" @click="closeBoard()"> |
| 45 | + <div class="nut-key__wrapper nut-key__wrapper--finish" @click="confirm"> |
69 | 46 | <div :class="['nut-key', 'nut-key--finish ', { activeFinsh: clickKeyIndex == 'finish' }]">
|
70 | 47 | {{ confirmText || translate('done') }}
|
71 | 48 | </div>
|
@@ -138,7 +115,7 @@ export default create({
|
138 | 115 | default: true
|
139 | 116 | }
|
140 | 117 | },
|
141 |
| - emits: ['input', 'delete', 'close', 'update:modelValue', 'update:visible'], |
| 118 | + emits: ['input', 'delete', 'close', 'confirm', 'update:modelValue', 'update:visible'], |
142 | 119 | setup(props, { emit }) {
|
143 | 120 | const translate = useLocale(cN)
|
144 | 121 | const clickKeyIndex: Ref<string | undefined | number> = ref(undefined)
|
@@ -239,10 +216,15 @@ export default create({
|
239 | 216 | emit('close')
|
240 | 217 | }
|
241 | 218 |
|
| 219 | + const confirm = () => { |
| 220 | + emit('confirm') |
| 221 | + } |
| 222 | +
|
242 | 223 | return {
|
243 | 224 | clickKeyIndex,
|
244 | 225 | defaultKey,
|
245 | 226 | closeBoard,
|
| 227 | + confirm, |
246 | 228 | onTouchEnd,
|
247 | 229 | onTouchMove,
|
248 | 230 | onTouchstart,
|
|
0 commit comments