fix bugs
This commit is contained in:
2025-10-14 22:17:40 +08:00
parent aa8f274333
commit 3f443ad67c

View File

@@ -1,14 +1,14 @@
<template>
<span v-if="text" @click="handleLock">{{ text }}</span>
<i v-else class="icon-suoping" @click="handleLock"></i>
<el-dialog title="Set Lock Code" v-model="box" width="30%" append-to-body>
<el-form :model="form" ref="form" label-width="80px">
<el-dialog title="Set Lock Code" v-model="box" width="30%" append-to-body @opened="focusInput">
<el-form :model="form" ref="form" label-width="80px" @submit.prevent="handleSetLock">
<el-form-item
label="Code"
prop="passwd"
:rules="[{ required: true, message: 'Code can not be empty' }]"
>
<el-input v-model="form.passwd" placeholder="Please input code">
<el-input ref="lockInput" v-model="form.passwd" placeholder="Please input code" @keyup.enter="handleSetLock">
<template #append>
<el-button @click="handleSetLock" icon="el-icon-lock"></el-button>
</template>
@@ -41,6 +41,15 @@ export default {
text: String,
},
methods: {
focusInput() {
this.$nextTick(() => {
const input = this.$refs.lockInput;
if (input && input.focus) {
const nativeInput = input.$el.querySelector('input');
nativeInput?.focus();
}
});
},
handleSetLock() {
this.$refs['form'].validate(valid => {
if (valid) {