
<template>
	<el-form
		ref="formRef"
		:model="state.userInfo"
		label-position="top"
	>
		<el-form-item
			prop="password"
			label="原始密码"
			:rules="[
        {
          required: true,
          message: '原始密码不能为空',
          trigger: 'blur',
        },
      ]"
		>
			<el-input v-model="state.userInfo.password" />
		</el-form-item>

		<el-form-item
			prop="newPassword"
			label="新密码"
			:rules="[
        {
          required: true,
          message: '新密码不能为空',
          trigger: 'blur',
        },
      ]"
		>
			<el-input v-model="state.userInfo.newPassword" />
		</el-form-item>
		<el-form-item>
			<el-button type="primary" @click="submitForm(formRef)">确定修改</el-button>
		</el-form-item>
	</el-form>
</template>
<script setup lang="ts">

import type { FormInstance } from 'element-plus'

const formRef = ref<FormInstance>()
const state = reactive(<any>{
	userInfo:{}
})

/**
 * 修改密码
 * @param formEl
 */
const submitForm = (formEl: FormInstance | undefined) => {
	if (!formEl) return
	formEl.validate((valid) => {
		if (valid) {
			updatePasswordAdmin(state.userInfo).then(result => {
				ElMessage.success("修改成功")
			})
		}
	})
}
</script>

<style scoped>

</style>
