270 lines
14 KiB
Plaintext
270 lines
14 KiB
Plaintext
@*
|
||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||
*@
|
||
@{
|
||
}
|
||
|
||
<!DOCTYPE html>
|
||
<html>
|
||
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
|
||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
||
<script src="http://lib.baomitu.com/qs/6.10.3/qs.min.js"></script>
|
||
<script src="http://lib.baomitu.com/jsencrypt/3.2.1/jsencrypt.min.js"></script>
|
||
</head>
|
||
|
||
<body>
|
||
<div id="app" v-loading="loading">
|
||
<h3 style="text-align:center;">后台登录</h3>
|
||
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm" style="width:500px;margin:0 auto;">
|
||
<el-form-item label="账号" prop="account">
|
||
<el-input v-model="ruleForm.account" autocomplete="off"></el-input>
|
||
</el-form-item>
|
||
<el-form-item label="密码" prop="password">
|
||
<el-input type="password" v-model="ruleForm.password" autocomplete="off"></el-input>
|
||
</el-form-item>
|
||
|
||
<el-form-item>
|
||
<el-button type="primary" @@click="login('ruleForm')">登录</el-button>
|
||
@*<el-button @@click="resetForm('ruleForm')">重置</el-button>*@
|
||
</el-form-item>
|
||
</el-form>
|
||
</div>
|
||
</body>
|
||
<style scoped>
|
||
.buhuanhang {
|
||
white-space: nowrap;
|
||
width: 21%;
|
||
}
|
||
</style>
|
||
<script>
|
||
new Vue({
|
||
el: '#app',
|
||
data: function () {
|
||
return {
|
||
RSA_PUBLIC_KEY: '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC273zAyijb3uX6O66VThrdfHtzZJn3d/SBM8qiETS7PijyNY3zNecAB+F/owxOWSB/6ojBo5Eu0FCiENxfpenTZB7sKrYu6NVH5gkfHLa6jz4pNzlGP93Q6RON4KjMZolAfRevBQ7vD6sOfJfMDnYi8xk+dRXcqc6PWY8fQiGs5QIDAQAB-----END PUBLIC KEY-----'
|
||
,
|
||
ruleForm: {
|
||
account: '',
|
||
password: '',
|
||
},
|
||
loading: false,
|
||
rules: {
|
||
account: [
|
||
{ required: true, message: '请输入账号', trigger: 'blur' },
|
||
{ min: 3, message: '最少 3 个字符', trigger: 'blur' }
|
||
],
|
||
password: [
|
||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||
{ min: 5, message: '最少 5 个字符', trigger: 'blur' }
|
||
],
|
||
}
|
||
}
|
||
},
|
||
created: function () {
|
||
},
|
||
methods: {
|
||
encryptByRSA(message, publicKey) {
|
||
const Encrypt = new JSEncrypt()
|
||
Encrypt.setPublicKey(publicKey)
|
||
return Encrypt.encrypt(message)
|
||
},
|
||
resetForm(formName) {
|
||
this.$refs[formName].resetFields();
|
||
},
|
||
login(formName) {
|
||
let _this = this;
|
||
this.$refs[formName].validate((valid) => {
|
||
if (valid) {
|
||
_this.ruleForm.password = _this.encryptByRSA(_this.ruleForm.password, _this.RSA_PUBLIC_KEY)
|
||
//return new Promise((resolve, reject) => {
|
||
axios({
|
||
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
|
||
method: 'post',
|
||
url: '/gb/yjb/login',
|
||
data: _this.ruleForm,
|
||
responseType: "json",
|
||
}).then(async response => {
|
||
if (response.data.success != true) {
|
||
_this.$alert(`<div>` + response.data.message + `</div>`, '错误', {
|
||
confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||
}).then(a => { }).catch(err => { console.log(err) });
|
||
//reject();
|
||
} else {
|
||
//resolve(true)
|
||
//location = '/manage/index'
|
||
if (!response.data.data.passed)
|
||
_this.$alert(response.data.data.descriptions);
|
||
else {
|
||
window.sessionStorage.setItem('__TOKEN', response.data.data.token);
|
||
//location = '/gb/yjb/manage/VoteResult'
|
||
location = '/gb/yjb/manage/nbczResult'
|
||
}
|
||
}
|
||
_this.loading = false;
|
||
}).catch(async error => {
|
||
console.log(error)
|
||
_this.$message({
|
||
type: 'error',
|
||
message: error.message
|
||
})
|
||
_this.loading = false;
|
||
})
|
||
//})
|
||
} else {
|
||
console.log('error submit!!');
|
||
return false;
|
||
}
|
||
});
|
||
|
||
},
|
||
|
||
async checkcode() {
|
||
let _this = this;
|
||
//检验码
|
||
if (this.logincode.length < 6) {
|
||
this.$alert(`<div>提交码输入错误</div>`, '错误', {
|
||
confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||
}).then(a => { }).catch(err => { console.log(err) });
|
||
return false;
|
||
}
|
||
return new Promise((resolve, reject) => {
|
||
axios({
|
||
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
|
||
method: 'post',
|
||
url: '/gb/yjb/api/projects/check-submit-code',
|
||
data: { 'code': this.logincode },
|
||
responseType: "json",
|
||
}).then(async response => {
|
||
if (response.data.data != true) {
|
||
_this.$alert(`<div>提交码输入错误</div>`, '错误', {
|
||
confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||
}).then(a => { }).catch(err => { console.log(err) });
|
||
reject();
|
||
} else {
|
||
resolve(true)
|
||
}
|
||
_this.loading = false;
|
||
}).catch(async error => {
|
||
console.log(error)
|
||
_this.$message({
|
||
type: 'error',
|
||
message: error.message
|
||
})
|
||
_this.loading = false;
|
||
})
|
||
})
|
||
},
|
||
async submit() {
|
||
let _this = this;
|
||
await this.checkcode().then(a => {
|
||
if (a == false)
|
||
return;
|
||
var no_select0 = this.projects0.filter(a => { return !a.vote }).length;
|
||
var no_select1 = this.projects1.filter(a => { return !a.vote }).length;
|
||
var no_select2 = this.projects2.filter(a => { return !a.vote }).length;
|
||
var no_select3 = this.projects3.filter(a => { return !a.vote }).length;
|
||
var no_select4 = this.projects4.filter(a => { return !a.vote }).length;
|
||
var no_select5 = this.projects5.filter(a => { return !a.vote }).length;
|
||
if (no_select0 > 0 || no_select1 > 0 || no_select2 > 0 || no_select3 > 0 || no_select4 > 0 || no_select5 > 0) {
|
||
this.$alert(`<div>请全部选择完毕后再次提交!</div><p>目前[房建工程]未选择的有` + no_select0 + `个</p><p>目前[市政工程]未选择的有` + no_select1 + `个</p><p>目前[轨道工程]未选择的有` + no_select2 + `个</p><p>目前[电力工程]未选择的有` + no_select3 + `个</p><p>目前[交通工程]未选择的有` + no_select4 + `个</p><p>目前[水利工程]未选择的有` + no_select5 + `个</p>`, '错误', {
|
||
confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||
}).then(a => { }).catch(err => { console.log(err) });
|
||
return;
|
||
}
|
||
//每个专业必须有一个不同意
|
||
no_select0 = this.projects0.filter(a => { return a.vote == "false" }).length;
|
||
no_select1 = this.projects1.filter(a => { return a.vote == "false" }).length;
|
||
no_select2 = this.projects2.filter(a => { return a.vote == "false" }).length;
|
||
no_select3 = this.projects3.filter(a => { return a.vote == "false" }).length;
|
||
no_select4 = this.projects4.filter(a => { return a.vote == "false" }).length;
|
||
no_select5 = this.projects5.filter(a => { return a.vote == "false" }).length;
|
||
if (no_select0 < 1 || no_select1 < 1 || no_select2 < 1 || no_select3 < 1 || no_select4 < 1 || no_select5 < 1) {
|
||
this.$alert(`<div>每个专业必须有一个不同意!</div><p>目前[房建工程]不同意的有` + no_select0 + `个</p><p>目前[市政工程]不同意的有` + no_select1 + `个</p><p>目前[轨道工程]不同意的有` + no_select2 + `个</p><p>目前[电力工程]不同意的有` + no_select3 + `个</p><p>目前[交通工程]不同意的有` + no_select4 + `个</p><p>目前[水利工程]不同意的有` + no_select5 + `个</p>`, '错误', {
|
||
confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||
}).then(a => { }).catch(err => { console.log(err) });
|
||
return;
|
||
}
|
||
var allselects = this.projects0.concat(this.projects1).concat(this.projects2).concat(this.projects3).concat(this.projects4).concat(this.projects5);
|
||
console.log('allselects:', allselects)
|
||
if (allselects.filter(a => { return a.vote == "false" }).length < 10) {
|
||
this.$alert(`<div>不同意总数不能少于10个!</div>`, '错误', {
|
||
confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||
}).then(a => { }).catch(err => { console.log(err) });
|
||
return;
|
||
}
|
||
var allselects = this.projects0.concat(this.projects1).concat(this.projects2).concat(this.projects3).concat(this.projects4).concat(this.projects5);
|
||
this.$confirm('您此次选择了同意' + allselects.filter(a => { return a.vote == "true" }).length + '个,不同意' + allselects.filter(a => { return a.vote == "false" }).length + '个,是否继续提交?', '提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
_this.loading = true;
|
||
axios({
|
||
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
|
||
method: 'post',
|
||
url: '/gb/yjb/api/projects/submit-vote',
|
||
data: { 'code': this.logincode, 'projects': allselects },
|
||
responseType: "json",
|
||
}).then(async response => {
|
||
if (response.data.data != true) {
|
||
_this.$alert(`<div>` + response.data.message + `</div>`, '错误', {
|
||
confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||
}).then(a => { }).catch(err => { console.log(err) });
|
||
} else {
|
||
_this.$alert(`<div>提交成功</div>`, '成功', {
|
||
confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||
}).then(a => { }).catch(err => { console.log(err) });
|
||
}
|
||
_this.loading = false;
|
||
}).catch(async error => {
|
||
console.log(error)
|
||
_this.$message({
|
||
type: 'error',
|
||
message: error.message
|
||
})
|
||
_this.loading = false;
|
||
})
|
||
}).catch(() => {
|
||
|
||
});
|
||
|
||
|
||
})
|
||
},
|
||
load_projects() {
|
||
let _this = this;
|
||
axios({
|
||
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
|
||
method: 'post',
|
||
url: '/gb/yjb/api/projects/list',
|
||
data: {},
|
||
responseType: "json",
|
||
}).then(function (response) {
|
||
_this.projects = response.data.data
|
||
_this.projects0 = _this.projects.filter(a => { return a.type == 0; })
|
||
_this.projects1 = _this.projects.filter(a => { return a.type == 1; })
|
||
_this.projects2 = _this.projects.filter(a => { return a.type == 2; })
|
||
_this.projects3 = _this.projects.filter(a => { return a.type == 3; })
|
||
_this.projects4 = _this.projects.filter(a => { return a.type == 4; })
|
||
_this.projects5 = _this.projects.filter(a => { return a.type == 5; })
|
||
_this.loading = false;
|
||
}).catch(function (error) {
|
||
console.log(error)
|
||
_this.$message({
|
||
type: 'error',
|
||
message: error.message
|
||
})
|
||
_this.loading = false;
|
||
})
|
||
},
|
||
loading_false() { this.loading = false },
|
||
}
|
||
})
|
||
</script>
|
||
|
||
</html> |