<!-- 管理员：修改密码 -->
<template>
    <div class="vue-box submit-box--dialog">
        <div class="c-card" style="width: 500px;">
            <el-form :inline="false" label-width="10em" v-if="state.model">
                <in-input type="password" name="旧密码：" v-model="state.model.oldPwd"></in-input>
                <in-input type="password" name="再次输入旧密码：" v-model="state.model.oldPwd2"></in-input>
                <in-input type="password" name="新密码：" v-model="state.model.newPwd"></in-input>
                <in-input type="password" name="再次输入新密码：" v-model="state.model.newPwd2"></in-input>
            </el-form>
        </div>
    </div>
</template>

<script setup name="update-password">
import {reactive} from "vue";
import InInput from "../../sa-frame/com/in/in-input";

// ------------------ 数据 ------------------
const state = reactive({
    model: {    // 数据 Model
        oldPwd: '',
        oldPwd2: '',
        newPwd: '',
        newPwd2: ''
    }
});

// ------------------ 函数 ------------------
// 提交表单 
const ok = function () {
    // 表单校验
    let model = state.model;
    sa.checkNull(model.oldPwd && model.oldPwd2 && model.newPwd && model.newPwd2, '请填写');
    sa.check(model.oldPwd !== model.oldPwd2, '旧密码两次输入不一致');
    sa.check(model.newPwd !== model.newPwd2, '新密码两次输入不一致');
    sa.check(model.newPwd.length < 4, '新密码请不要低于六位数');
    // 开始修改 
    sa.ajax('/AdminPassword/update', model, function() {
        sa.closeModel();
        sa.msg('修改成功！');
    })
}

// 对外开放函数 
defineExpose({
    ok: ok
});


</script>

<style scoped>

</style>
