|
|
|
|
|
<template>
|
|
|
<div>
|
|
|
<div class="front">
|
|
|
<el-form ref="ruleForm" :model="ruleForm" :rules="rules" class="login-box" label-width="80px" status-icon>
|
|
|
<h4 align="center" class="login-title">欢迎来到国防科大请销假系统!</h4>
|
|
|
<el-form-item label="账号" maxlength="255" prop="username">
|
|
|
<el-input v-model="ruleForm.username"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="密码" maxlength="64" prop="password">
|
|
|
<el-input v-model="ruleForm.password" autocomplete="off" type="password"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
|
|
|
<el-button @click="resetForm('ruleForm')">重置</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
<script>
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
ruleForm: {
|
|
|
username: '',
|
|
|
password: '',
|
|
|
},
|
|
|
rules: {
|
|
|
username: [
|
|
|
{required: true, message: '请输入账号', trigger: 'blur'}
|
|
|
],
|
|
|
password: [
|
|
|
{required: true, message: '请输入密码', trigger: 'blur'}
|
|
|
],
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
|
|
|
submitForm(formName) {
|
|
|
|
|
|
const _this = this
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
if (valid) {
|
|
|
axios.get('http://localhost:8181/user/findAndCheck/' + this.ruleForm.username + '/' + this.ruleForm.password, this.ruleForm).then(function (resp) {
|
|
|
if (resp.data == 'error:wrong username') {
|
|
|
_this.$alert('用户名错误')
|
|
|
} else if (resp.data == 'error:wrong password') {
|
|
|
_this.$alert('密码错误')
|
|
|
} else {
|
|
|
const id = resp.data.split(' ')[0];
|
|
|
const type = resp.data.split(' ')[1];
|
|
|
_this.$cookieStore.delCookie("login_id");
|
|
|
_this.$cookieStore.setCookie("login_id", id, 1);
|
|
|
_this.$alert('登录成功!', '登录消息', {
|
|
|
confirmButtonText: '确定',
|
|
|
callback: action => {
|
|
|
_this.$router.push('/user/' + type + '/' + id)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
})
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
},
|
|
|
resetForm(formName) {
|
|
|
this.$refs[formName].resetFields();
|
|
|
|
|
|
},
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
.inputStyle {
|
|
|
text-align: center;
|
|
|
}
|
|
|
|
|
|
.login-box {
|
|
|
border: 1px solid #DCDFE6;
|
|
|
width: 350px;
|
|
|
margin: 180px auto;
|
|
|
padding: 35px 35px 15px 35px;
|
|
|
border-radius: 5px;
|
|
|
-webkit-border-radius: 5px;
|
|
|
-moz-border-radius: 5px;
|
|
|
box-shadow: 0 0 25px #909399;
|
|
|
}
|
|
|
|
|
|
.login-title {
|
|
|
text-align: center;
|
|
|
margin: 0 auto 40px auto;
|
|
|
color: #303133;
|
|
|
}
|
|
|
|
|
|
.background {
|
|
|
position: fixed;
|
|
|
height: 100%;
|
|
|
width: 100%;
|
|
|
background-color: #658ea9 !important;
|
|
|
}
|
|
|
|
|
|
</style> |