fix(vote): 修复投票页面淘汰数据显示问题

- 将变量声明从 var 改为 let 以修复数据过滤逻辑
- 修改电力工程的淘汰条件判断逻辑,只在符合条件时显示消息
- 优化淘汰数量显示格式,添加"目前:"前缀以提高可读性
- 修复确认对话框中的 HTML 格式显示问题
- 添加 dangerouslyUseHTMLString 选项以正确渲染 HTML 内容
This commit is contained in:
路 范
2025-12-23 09:52:16 +08:00
parent 3cf26ceded
commit 513c40a4f3

View File

@@ -128,30 +128,32 @@ maximum-scale=1.0, user-scalable=no"/>
async submit() { async submit() {
let _this = this; let _this = this;
await this.checkcode().then(a => { await this.checkcode().then(a => {
if (a == false) if (a === false)
return; return;
var msg1 = ""; let msg1 = "";
var msg2 = ""; let msg2 = "";
var all_no_select_num = 0; let all_no_select_num = 0;
var select_false_list = []; let select_false_list = [];
var all_select_false_num = 0; let all_select_false_num = 0;
var all_select_true_num = 0; let all_select_true_num = 0;
var allselects = []; let allselects = [];
for (var i = 0; i < _this.projects.length; i++) { for (let i = 0; i < _this.projects.length; i++) {
var _p = _this.projects[i]; let _p = _this.projects[i];
if (_p.data.length > 0) { if (_p.data.length > 0) {
// var no_select = _p.data.filter(a => { return !a.vote }).length; // let no_select = _p.data.filter(a => { return !a.vote }).length;
// all_no_select_num += no_select; // all_no_select_num += no_select;
// if (no_select > 0) { // if (no_select > 0) {
// msg1 += `<p>目前[` + _p.name + `]未选择的有` + no_select + `个</p>`; // msg1 += `<p>目前[` + _p.name + `]未选择的有` + no_select + `个</p>`;
// } // }
var select_false = _p.data.filter(a => { let select_false = _p.data.filter(a => {
return a.vote == "false" return a.vote == "false"
}).length; }).length;
select_false_list.push(select_false); select_false_list.push(select_false);
// if (select_false < 1) { // if (select_false < 1) {
if(_p.name!=="电力工程") if (_p.name === "电力工程" && select_false === 0) {
msg2 += `目前[` + _p.name + `]淘汰的有 ` + select_false + `\n`; } else {
msg2 += `[` + _p.name + `]淘汰的有 ` + select_false + ` 个; \n`;
}
// } // }
all_select_false_num += select_false; all_select_false_num += select_false;
all_select_true_num += _p.data.filter(a => { all_select_true_num += _p.data.filter(a => {
@@ -182,7 +184,7 @@ maximum-scale=1.0, user-scalable=no"/>
// }).catch(err => { // }).catch(err => {
// console.log(err) // console.log(err)
// }); // });
alert("房屋建筑工程不少于 10 个淘汰!\n\n" + msg2); alert("房屋建筑工程不少于 10 个淘汰!\n目前:\n" + msg2);
return; return;
} }
//市政不少于4个 //市政不少于4个
@@ -193,7 +195,7 @@ maximum-scale=1.0, user-scalable=no"/>
// }).catch(err => { // }).catch(err => {
// console.log(err) // console.log(err)
// }); // });
alert("市政基础设施工程不少于 5 个淘汰!\n\n" + msg2); alert("市政基础设施工程不少于 5 个淘汰!\n目前:\n" + msg2);
return; return;
} }
//交通不少于1个 //交通不少于1个
@@ -204,7 +206,7 @@ maximum-scale=1.0, user-scalable=no"/>
// }).catch(err => { // }).catch(err => {
// console.log(err) // console.log(err)
// }); // });
alert("轨道交通工程不少于 2 个淘汰!\n\n" + msg2); alert("轨道交通工程不少于 2 个淘汰!\n目前:\n" + msg2);
return; return;
} }
////水利不少于1个 ////水利不少于1个
@@ -221,10 +223,12 @@ maximum-scale=1.0, user-scalable=no"/>
alert("淘汰总数必须大于17个"); alert("淘汰总数必须大于17个");
return; return;
} }
this.$confirm('您此次选择了同意' + all_select_true_num + '个,淘汰' + all_select_false_num + '个,是否继续提交?', '提示', { this.$confirm(`您此次选择了同意` + all_select_true_num + `个,淘汰` + all_select_false_num + `个,是否继续提交? <br>目前:<br> ` +
msg2.replaceAll('\n', '<br>'), '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning',
dangerouslyUseHTMLString: true
}).then(() => { }).then(() => {
_this.loading = true; _this.loading = true;
axios({ axios({
@@ -269,14 +273,14 @@ maximum-scale=1.0, user-scalable=no"/>
responseType: "json", responseType: "json",
}).then(function (response) { }).then(function (response) {
//console.log(response) //console.log(response)
var _data = response.data.data.data let _data = response.data.data.data
var typeList = response.data.data.typeList let typeList = response.data.data.typeList
_data.map(a => { _data.map(a => {
a.vote = !a.vote ? '' : a.vote.toString(); a.vote = !a.vote ? '' : a.vote.toString();
return a; return a;
}); });
for (var i = 0; i < typeList.length; i++) { for (let i = 0; i < typeList.length; i++) {
var _p = _data.filter(a => { let _p = _data.filter(a => {
return a.type == i; return a.type == i;
}); });
_this.projects.push({name: typeList[i], data: _p}) _this.projects.push({name: typeList[i], data: _p})