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