86 lines
2.1 KiB
Vue
86 lines
2.1 KiB
Vue
<template>
|
|
<el-dialog v-model="dialogVisible" title="修改密码" width="60%">
|
|
<el-form
|
|
ref="ruleFormRef"
|
|
:model="ruleForm"
|
|
:rules="rules"
|
|
label-width="120px"
|
|
class="demo-ruleForm"
|
|
:size="formSize"
|
|
>
|
|
<el-form-item label="姓名">
|
|
<el-input v-model="ruleForm.name" disabled></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="手机号码">
|
|
<el-input v-model="ruleForm.mobile" disabled></el-input>
|
|
</el-form-item>
|
|
<el-form-item label="修改密码" prop="password">
|
|
<el-input v-model="ruleForm.password"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<el-button @click="dialogVisible = false">取消</el-button>
|
|
<el-button type="primary" @click="submitForm(ruleFormRef)">确定</el-button>
|
|
</span>
|
|
</template>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ref, defineExpose, reactive } from 'vue'
|
|
import { ElMessageBox } from 'element-plus'
|
|
import type { ElForm } from 'element-plus'
|
|
const dialogVisible = ref(false)
|
|
const show = () => {
|
|
dialogVisible.value = true
|
|
}
|
|
const hide = () => {
|
|
dialogVisible.value = false
|
|
}
|
|
type FormInstance = InstanceType<typeof ElForm>
|
|
|
|
const formSize = ref('')
|
|
const ruleFormRef = ref<FormInstance>()
|
|
const ruleForm = reactive({
|
|
name: '',
|
|
mobile: '',
|
|
password: '',
|
|
})
|
|
const rules = reactive({
|
|
password: [
|
|
{
|
|
required: true,
|
|
message: '请输入密码',
|
|
trigger: 'blur',
|
|
},
|
|
],
|
|
})
|
|
const submitForm = (formEl: FormInstance | undefined) => {
|
|
if (!formEl) return
|
|
formEl.validate((valid) => {
|
|
if (valid) {
|
|
console.log('submit!')
|
|
} else {
|
|
console.log('error submit!')
|
|
return false
|
|
}
|
|
})
|
|
}
|
|
|
|
const resetForm = (formEl: FormInstance | undefined) => {
|
|
if (!formEl) return
|
|
formEl.resetFields()
|
|
}
|
|
|
|
defineExpose({
|
|
show,
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.dialog-footer button:first-child {
|
|
margin-right: 10px;
|
|
}
|
|
</style>
|