<template>
    <div class="pd10">
        <el-form :inline="true" class="demo-form-inline">
            <el-form-item>
                <el-button @click="AddClick()" type="primary" icon="el-icon-plus">保存</el-button>
                <!-- <el-button @click="info()" type="primary" icon="el-icon-close">取消</el-button> -->
<!--                <el-button @click="unlock()" type="primary" icon="el-icon-user">解锁超级管理员</el-button>-->
            </el-form-item>
        </el-form>
        <div style="width: 500px">
            <el-form ref="form" :model="form" label-width="auto" :rules="rules">
                <el-divider content-position="left">系统策略</el-divider>
                <el-form-item label="最大并发数:" prop="errorsCount">
                    <el-input-number v-model.number="form.maxUseUser" :min="10" :max="99" style="width: 100%"></el-input-number>
                </el-form-item>
                <el-divider content-position="left">账号锁定策略</el-divider>
                <el-form-item label="密码输入错误次数:" prop="errorsCount">
                    <el-input-number v-model.number="form.errorsCount" :min="3" :max="20" style="width: 100%"></el-input-number>
                </el-form-item>
                <el-form-item label="自动解锁(分钟):" prop="releaseTime">
                    <el-input-number v-model.number="form.releaseTime" :min="5" :max="60" style="width: 100%"></el-input-number>
                </el-form-item>
                <el-form-item label="会话超时时间(秒):" prop="sessionTime">
                    <el-input-number v-model.number="form.sessionTime" :min="10"   style="width: 100%"></el-input-number>
                </el-form-item>
                <el-form-item label="token刷新时间(秒):" prop="sessionRefreshTime">
                    <el-input-number v-model.number="form.sessionRefreshTime" :min="10" style="width: 100%"></el-input-number>
                </el-form-item>
                <el-divider content-position="left">账号密码复杂度校验</el-divider>
                <el-form-item label="密码有效期(月):" prop="passwordExpirationMonth">
                    <el-input-number
                        v-model.number="form.passwordExpirationMonth"
                        :min="1"
                        :max="6"
                        style="width: 100%"
                    ></el-input-number>
                </el-form-item>
                <el-form-item label="账号长时间未登录休眠期(天):" prop="passwordExpirationMonth">
                    <el-input-number
                        v-model.number="form.sleepDay"
                        :min="1"
                        :max="180"
                        style="width: 100%"
                    ></el-input-number>
                </el-form-item>
<!--                <el-form-item label="">
                    <el-checkbox v-model="form.mixedCheckFlag" :true-label="1" :false-label="0">
                        密码符号混合校验
                    </el-checkbox>
                </el-form-item>
                <el-form-item label="">
                    <el-checkbox v-model="form.doubleCheckFlag" :true-label="1" :false-label="0">
                        密码重复校验
                    </el-checkbox>
                </el-form-item>
                <el-form-item label="">
                    <el-checkbox v-model="form.mixedCaseCheckFlag" :true-label="1" :false-label="0">
                        密码大小写混合校验
                    </el-checkbox>
                </el-form-item>-->
            </el-form>
        </div>
    </div>
</template>

<script>
import { ruleUpdate, getRule, unlockRoot } from '@/api/admin/user.js'
export default {
    name: 'reportingmanagerdd',
    components: {},
    data() {
        return {
            form: {
                //doubleCheckFlag: 0,
                maxUseUser:50,
                errorsCount: 0,
                //mixedCaseCheckFlag: 1,
                //mixedCheckFlag: 0,
                passwordExpirationMonth: 0,
                sleepDay:90,
                releaseTime: 0,
                sessionTime: 0,
                sessionRefreshTime:0,
            },
            rules: {
                errorsCount: [{ required: true, message: '请填写密码输入错误次数', trigger: 'blur' }],
                releaseTime: [{ required: true, message: '请填写自动解锁(分钟)', trigger: 'blur' }],
                sessionTime: [{ required: true, message: '请填写会话超时时间', trigger: 'blur' }],
                sessionRefreshTime:[{ required: true, message: '请填写会话刷新时间', trigger: 'blur' }],
                passwordExpirationMonth: [{ required: true, message: '请填写密码超期天数', trigger: 'blur' }]
            }
        }
    },
    created() {},
    mounted() {
        this.info()
    },
    methods: {
        info() {
            getRule().then(res => {
                this.form = res.data
            })
        },
        AddClick() {
            this.$refs['form'].validate(valid => {
                if (valid) {
                    ruleUpdate(this.form)
                        .then(res => {
                            this.form = res.data
                        })
                        .then(res => {
                            this.$message({
                                message: '保存成功',
                                type: 'success'
                            })
                            this.info()
                        })
                }
            })
        },
        unlock() {
            unlockRoot().then(res => {
                if(res.code === 'A0000'){
                    this.$message({
                        message: '解锁成功',
                        type: 'success'
                    })
                }
            })
        }
    }
}
</script>

<style lang="less" scoped>
@import url('../../../../styles/comStyle.less');
</style>
