mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 16:54:25 +08:00
migrate pin code input sheet to composition API and typescript
This commit is contained in:
@@ -26,50 +26,49 @@
|
|||||||
</f7-sheet>
|
</f7-sheet>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
export default {
|
import { type Ref, ref, computed } from 'vue';
|
||||||
props: [
|
|
||||||
'modelValue',
|
|
||||||
'title',
|
|
||||||
'hint',
|
|
||||||
'confirmDisabled',
|
|
||||||
'cancelDisabled',
|
|
||||||
'show'
|
|
||||||
],
|
|
||||||
emits: [
|
|
||||||
'update:modelValue',
|
|
||||||
'update:show',
|
|
||||||
'pincode:confirm'
|
|
||||||
],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
currentPinCode: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
currentPinCodeValid() {
|
|
||||||
return this.currentPinCode && this.currentPinCode.length === 6;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
onSheetOpen() {
|
|
||||||
this.currentPinCode = '';
|
|
||||||
},
|
|
||||||
onSheetClosed() {
|
|
||||||
this.$emit('update:show', false);
|
|
||||||
},
|
|
||||||
confirm() {
|
|
||||||
if (!this.currentPinCodeValid || this.confirmDisabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$emit('update:modelValue', this.currentPinCode);
|
const props = defineProps<{
|
||||||
this.$emit('pincode:confirm', this.currentPinCode);
|
modelValue: string
|
||||||
},
|
title?: string
|
||||||
cancel() {
|
hint?: string
|
||||||
this.$emit('update:show', false);
|
confirmDisabled?: boolean
|
||||||
}
|
cancelDisabled?: boolean
|
||||||
|
show: boolean
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:modelValue', value: string): void
|
||||||
|
(e: 'update:show', value: boolean): void
|
||||||
|
(e: 'pincode:confirm', value: string): void
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const currentPinCode: Ref<string> = ref('');
|
||||||
|
|
||||||
|
const currentPinCodeValid = computed<boolean>(() => {
|
||||||
|
return currentPinCode.value?.length === 6 || false;
|
||||||
|
});
|
||||||
|
|
||||||
|
function confirm() {
|
||||||
|
if (!currentPinCodeValid.value || props.confirmDisabled) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit('update:modelValue', currentPinCode.value);
|
||||||
|
emit('pincode:confirm', currentPinCode.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancel() {
|
||||||
|
emit('update:show', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSheetOpen() {
|
||||||
|
currentPinCode.value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSheetClosed() {
|
||||||
|
cancel();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user