Browse Source

增加精选项目超过9个数处理

tags/v1.21.12.2^2
wangjr 3 years ago
parent
commit
23e29f1e78
1 changed files with 20 additions and 7 deletions
  1. +20
    -7
      templates/org/select_pro.tmpl

+ 20
- 7
templates/org/select_pro.tmpl View File

@@ -20,7 +20,7 @@
}

.content_list{
max-height: 200px;
max-height: 130px;
overflow: auto;
}
.Relist{
@@ -152,11 +152,12 @@
var num=0;

function showcreate(obj){
document.getElementById("search_selectPro").value=''
$('.ui.modal')
.modal({
centered: false,
onShow:function(){
$("#org_list").empty()
$("#org_list").empty()
getPro(1)
},
@@ -179,7 +180,7 @@
pro_html = getHTML(data)
$("#org_list").append(pro_html)
console.log('原始',data)
checkedNum()
checkedNum(0)
}
});
}
@@ -188,11 +189,11 @@
for (let i=0;i<data.length;i++){
if (data[i].Selected==true){
console.log("data[i]:",data[i])
pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" checked="" onclick="checkedNum()" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected=${data[i].Selected} > <label> ${data[i].RepoName} </label></div>`
pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" id = " ${i}" checked="" onclick="checkedNum(${i})" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected=${data[i].Selected} > <label> ${data[i].RepoName} </label></div>`
pro_html += '</div>'
}
else{
pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" onclick="checkedNum()" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected= ${data[i].Selected}> <label> ${data[i].RepoName} </label></div>`
pro_html += `<div class="ui checkbox" style="width: 33%;margin-bottom:10px" > <input type="checkbox" id = "${i}" onclick="checkedNum(${i})" class="Relist" name ='select_pro_name' data-repoid="${data[i].RepoID}" data-reponame="${data[i].RepoName}" data-selected= ${data[i].Selected}> <label> ${data[i].RepoName} </label></div>`
pro_html += '</div>'
}
}
@@ -205,6 +206,10 @@

saveData.push(parseInt(this.dataset.repoid));
})
if(saveData.length>9){
alert("最多可选9个,保存失败")
return
}
// saveData = getSelecteDataID();
// console.log("数据:",saveData)
$.ajax({
@@ -227,7 +232,7 @@
var selectedData=[];
$('input[name="select_pro_name"]:checked').each(function(){
// console.log(this)
console.log('值',this.dataset.selected)
// console.log('值',this.dataset.selected)

selectedData.push({"RepoID":parseInt(this.dataset.repoid),"RepoName":this.dataset.reponame,"Selected":JSON.parse(this.dataset.selected)});
})
@@ -272,14 +277,22 @@
}
}

function checkedNum(){
function checkedNum(id){

num=0;
var inputs = document.getElementsByName("select_pro_name")
for (var i=0;i<inputs.length;i++){
if(inputs[i].checked){
num++
if(num>9){
document.getElementById(id).checked=false
alert("选择超过9个,请重新选择!")
return
}
}
}

var show_num = 9-num;
document.getElementById("recommend").innerHTML="还能推荐"+show_num+"个"



Loading…
Cancel
Save