2025年度投票修改
This commit is contained in:
@@ -0,0 +1,291 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0,
|
||||
maximum-scale=1.0, user-scalable=no" />
|
||||
<link rel="stylesheet" href="../../lib/element-ui/theme-chalk/index.css">
|
||||
<script src="../../lib/vue2/vue.min.js"></script>
|
||||
<script src="../../lib/element-ui/theme-chalk/index.js"></script>
|
||||
<script src="../../lib/axios/axios.min.js"></script>
|
||||
<script src="../../lib/qs/qs.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app" v-loading="loading">
|
||||
<h3 style="text-align:center;">2024年度宁波市市级优质工程免于现场评估项目</h3>
|
||||
<el-collapse>
|
||||
<el-collapse-item v-for="(prolist,idx) in projects1" :title="prolist.name" :name="idx" v-show="prolist.data.length>0" :key="idx">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in prolist.data" :key="project.id">
|
||||
<el-descriptions-item label-class-name="buhuanhang" label="项目名称">{{project.serial_number}}:{{project.name}}</el-descriptions-item>
|
||||
<el-descriptions-item label="请投票">
|
||||
<template>
|
||||
<el-radio-group v-model="project.vote">
|
||||
<el-radio label="true">同意</el-radio>
|
||||
<el-radio label="false">淘汰</el-radio>
|
||||
</el-radio-group>
|
||||
</template>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
<h3 style="text-align:center;">2024年度宁波市市级优质工程现场评估项目</h3>
|
||||
<el-collapse>
|
||||
<el-collapse-item v-for="(prolist,idx) in projects2" :title="prolist.name" :name="idx" v-show="prolist.data.length>0" :key="idx">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in prolist.data" :key="project.id">
|
||||
<el-descriptions-item label-class-name="buhuanhang" label="项目名称">{{project.serial_number}}:{{project.name}}</el-descriptions-item>
|
||||
<el-descriptions-item label="请投票">
|
||||
<template>
|
||||
<el-radio-group v-model="project.vote">
|
||||
<el-radio label="true">同意</el-radio>
|
||||
<el-radio label="false">淘汰</el-radio>
|
||||
</el-radio-group>
|
||||
</template>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
<h3 style="text-align:center;">
|
||||
<el-input v-model="logincode" placeholder="请输入提交码"></el-input>
|
||||
</h3>
|
||||
<h3 style="text-align:center;">
|
||||
<el-button @click="alltrue">重置</el-button>
|
||||
<el-button type="primary" @click="submit">提交</el-button>
|
||||
</h3>
|
||||
</div>
|
||||
</body>
|
||||
<style scoped>
|
||||
.buhuanhang {
|
||||
white-space: nowrap;
|
||||
width: 21%;
|
||||
}
|
||||
|
||||
.el-message-box {
|
||||
width: 300px !important;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data: function () {
|
||||
return {
|
||||
projects1: [],
|
||||
projects2: [],
|
||||
confirm_title: '',
|
||||
loading: false,
|
||||
logincode: ''
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
this.loading = true;
|
||||
this.load_projects();
|
||||
|
||||
},
|
||||
methods: {
|
||||
alltrue() {
|
||||
this.projects1.map(a => {
|
||||
a.data.map(b => { b.vote = "true"; return b; })
|
||||
});
|
||||
this.projects2.map(a => {
|
||||
a.data.map(b => { b.vote = "true"; return b; })
|
||||
});
|
||||
},
|
||||
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) });
|
||||
alert("提交码输入错误");
|
||||
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) });
|
||||
alert("提交码输入错误");
|
||||
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 msg1 = "";
|
||||
var msg2 = "";
|
||||
var all_no_select_num = 0;
|
||||
var select_false_list = [];
|
||||
var all_select_false_num = 0;
|
||||
var all_select_true_num = 0;
|
||||
var allselects = [];
|
||||
let projects = _this.projects1.concat(_this.projects2);
|
||||
for (var i = 0; i < projects.length; i++) {
|
||||
var _p = projects[i];
|
||||
if (_p.data.length > 0) {
|
||||
var no_select = _p.data.filter(a => { return !a.vote }).length;
|
||||
all_no_select_num += no_select;
|
||||
if (no_select > 0) {
|
||||
msg1 += `<p>目前[` + _p.name + `]未选择的有` + no_select + `个</p>`;
|
||||
}
|
||||
var select_false = _p.data.filter(a => { return a.vote == "false" }).length;
|
||||
select_false_list.push(select_false)
|
||||
if (select_false < 1) {
|
||||
msg2 += `<p>目前[` + _p.name + `]淘汰的有` + select_false + `个</p>`;
|
||||
}
|
||||
all_select_false_num += select_false;
|
||||
all_select_true_num += _p.data.filter(a => { return a.vote == "true" }).length;
|
||||
allselects = allselects.concat(_p.data)
|
||||
}
|
||||
}
|
||||
if (all_no_select_num > 0) {
|
||||
//this.$alert(`<div>请全部选择完毕后再次提交!</div>` + msg1, '错误', {
|
||||
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||||
//}).then(a => { }).catch(err => { console.log(err) });
|
||||
alert("请全部选择完毕后再次提交");
|
||||
return;
|
||||
}
|
||||
debugger
|
||||
//if (select_false_list.filter(a => a < 1).length > 0) {
|
||||
// this.$alert(`<div>每个专业必须有一个淘汰!</div>` + msg2, '错误', {
|
||||
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||||
// }).then(a => { }).catch(err => { console.log(err) });
|
||||
// return;
|
||||
//}
|
||||
////房建不少于5个
|
||||
//if (select_false_list[0] < 5) {
|
||||
// this.$alert(`<div>房建工程不少于5个淘汰!</div>` + msg2, '错误', {
|
||||
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||||
// }).then(a => { }).catch(err => { console.log(err) });
|
||||
// return;
|
||||
//}
|
||||
////市政不少于4个
|
||||
//if (select_false_list[1] < 1) {
|
||||
// this.$alert(`<div>市政工程不少于4个淘汰!</div>` + msg2, '错误', {
|
||||
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||||
// }).then(a => { }).catch(err => { console.log(err) });
|
||||
// return;
|
||||
//}
|
||||
////交通不少于1个
|
||||
//if (select_false_list[3] < 1) {
|
||||
// this.$alert(`<div>交通工程不少于1个淘汰!</div>` + msg2, '错误', {
|
||||
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||||
// }).then(a => { }).catch(err => { console.log(err) });
|
||||
// return;
|
||||
//}
|
||||
////水利不少于1个
|
||||
//if (select_false_list[4] < 1) {
|
||||
// this.$alert(`<div>水利工程不少于1个淘汰!</div>` + msg2, '错误', {
|
||||
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||||
// }).then(a => { }).catch(err => { console.log(err) });
|
||||
// return;
|
||||
//}
|
||||
if (all_select_false_num <= 5) {
|
||||
//this.$alert(`<div>淘汰总数必须大于20个!</div>` + msg2, '错误', {
|
||||
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||||
//}).then(a => { }).catch(err => { console.log(err) });
|
||||
alert("淘汰总数必须大于5个");
|
||||
return;
|
||||
}
|
||||
this.$confirm('您此次选择了同意' + all_select_true_num + '个,淘汰' + all_select_false_num + '个,是否继续提交?', '提示', {
|
||||
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) });
|
||||
alert(response.data.message);
|
||||
} else {
|
||||
//_this.$alert(`<div>提交成功</div>`, '成功', {
|
||||
// confirmButtonText: '确定', dangerouslyUseHTMLString: true, center: true, closeOnClickModal: true
|
||||
//}).then(a => { }).catch(err => { console.log(err) });
|
||||
alert("提交成功");
|
||||
}
|
||||
_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/projects2025/list',
|
||||
data: {},
|
||||
responseType: "json",
|
||||
}).then(function (response) {
|
||||
//console.log(response)
|
||||
var typeList = response.data.data.typeList
|
||||
let _data1 = response.data.data.data1
|
||||
_data1.map(a => { a.vote = !a.vote ? '' : a.vote.toString(); return a; });
|
||||
for (var i = 0; i < typeList.length; i++) {
|
||||
var _p = _data1.filter(a => { return a.type == i; });
|
||||
_this.projects1.push({ name: typeList[i], data: _p })
|
||||
}
|
||||
let _data2 = response.data.data.data2
|
||||
_data2.map(a => { a.vote = !a.vote ? '' : a.vote.toString(); return a; });
|
||||
for (var i = 0; i < typeList.length; i++) {
|
||||
var _p = _data2.filter(a => { return a.type == i; });
|
||||
_this.projects2.push({ name: typeList[i], data: _p })
|
||||
}
|
||||
_this.alltrue();
|
||||
_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>
|
||||
Reference in New Issue
Block a user