2022年度甬江杯投票系统
This commit is contained in:
@@ -18,75 +18,10 @@
|
||||
|
||||
<body>
|
||||
<div id="app" v-loading="loading">
|
||||
<h3 style="text-align:center;">2021年度宁波市“甬江建设杯”选票</h3>
|
||||
<h3 style="text-align:center;">2022年度宁波市“甬江建设杯”选票</h3>
|
||||
<el-collapse>
|
||||
<el-collapse-item title="房建工程" name="1">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects0" :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-item title="市政工程" name="2">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects1" :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-item title="轨道工程" name="3">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects2" :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-item title="电力工程" name="4">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects3" :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-item title="交通工程" name="5">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects4" :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-item title="水利工程" name="6">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects5" :key="project.id">
|
||||
<el-collapse-item v-for="(prolist,idx) in projects" :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>
|
||||
@@ -98,6 +33,87 @@
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-collapse-item>
|
||||
|
||||
|
||||
|
||||
@*<el-collapse-item title="房建工程" name="1" v-show="projects0.length>0">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects0" :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-item title="市政工程" name="2" v-show="projects1.length>0">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects1" :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-item title="轨道工程" name="3" v-show="projects2.length>0">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects2" :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-item title="电力工程" name="4" v-show="projects3.length>0">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects3" :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-item title="交通工程" name="5" v-show="projects4.length>0">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects4" :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-item title="水利工程" name="6" v-show="projects5.length>0">
|
||||
<el-descriptions class="margin-top" title="" :column="1" border v-for="project in projects5" :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>
|
||||
@@ -138,12 +154,15 @@
|
||||
},
|
||||
methods: {
|
||||
alltrue() {
|
||||
this.projects0 = this.projects0.map(a => { a.vote = "true"; return a; });
|
||||
this.projects1 = this.projects1.map(a => { a.vote = "true"; return a; });
|
||||
this.projects2 = this.projects2.map(a => { a.vote = "true"; return a; });
|
||||
this.projects3 = this.projects3.map(a => { a.vote = "true"; return a; });
|
||||
this.projects4 = this.projects4.map(a => { a.vote = "true"; return a; });
|
||||
this.projects5 = this.projects5.map(a => { a.vote = "true"; return a; });
|
||||
this.projects.map(a => {
|
||||
a.data.map(b => { b.vote = "true"; return b; })
|
||||
});
|
||||
//this.projects0 = this.projects0.map(a => { a.vote = "true"; return a; });
|
||||
//this.projects1 = this.projects1.map(a => { a.vote = "true"; return a; });
|
||||
//this.projects2 = this.projects2.map(a => { a.vote = "true"; return a; });
|
||||
//this.projects3 = this.projects3.map(a => { a.vote = "true"; return a; });
|
||||
//this.projects4 = this.projects4.map(a => { a.vote = "true"; return a; });
|
||||
//this.projects5 = this.projects5.map(a => { a.vote = "true"; return a; });
|
||||
},
|
||||
async checkcode() {
|
||||
let _this = this;
|
||||
@@ -186,41 +205,50 @@
|
||||
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>`, '错误', {
|
||||
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 = [];
|
||||
for (var i = 0; i < _this.projects.length; i++) {
|
||||
var _p = _this.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) });
|
||||
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>`, '错误', {
|
||||
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;
|
||||
}
|
||||
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>`, '错误', {
|
||||
if (all_select_false_num != 8) {
|
||||
this.$alert(`<div>不同意总数只能等于8个!</div>` + msg2, '错误', {
|
||||
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 + '个,是否继续提交?', '提示', {
|
||||
this.$confirm('您此次选择了同意' + all_select_true_num + '个,不同意' + all_select_false_num + '个,是否继续提交?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
@@ -254,6 +282,74 @@
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
//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 != 8) {
|
||||
// this.$alert(`<div>不同意总数只能等于8个!</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(() => {
|
||||
|
||||
//});
|
||||
|
||||
|
||||
})
|
||||
@@ -267,14 +363,23 @@
|
||||
data: {},
|
||||
responseType: "json",
|
||||
}).then(function (response) {
|
||||
_this.projects = response.data.data
|
||||
_this.projects.map(a => { a.vote = !a.vote ? '' : a.vote.toString(); return a; });
|
||||
_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; })
|
||||
//console.log(response)
|
||||
var _data = response.data.data.data
|
||||
var typeList = response.data.data.typeList
|
||||
_data.map(a => { a.vote = !a.vote ? '' : a.vote.toString(); return a; });
|
||||
for (var i = 0; i < typeList.length; i++) {
|
||||
var _p = _data.filter(a => { return a.type == i; });
|
||||
_this.projects.push({ name: typeList[i], data: _p })
|
||||
}
|
||||
//console.log(_this.projects)
|
||||
//_this.projects.map(a => { a.vote = !a.vote ? '' : a.vote.toString(); return a; });
|
||||
//_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.alltrue();
|
||||
_this.loading = false;
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
|
||||
Reference in New Issue
Block a user