js.migration.js Maven / Gradle / Ivy
function initProjects(select){
$.ajax({
url:'migration/projects',
success:function(projects){
for(let p of projects){
var option=$("");
select.append(option);
}
},
error:function(error){
console.log(error);
alert('加载项目出现错误')
}
});
}
function initGroups(select){
$.ajax({
url:'migration/groups',
success:function(groups){
for(let g of groups){
var option=$("");
select.append(option);
}
},
error:function(error){
console.log(error);
alert('加载团队出现错误')
}
});
}
$(function(){
var container=$('');
$('#container').append(container);
var projectsContainer=$('');
container.append(projectsContainer);
var projectsSelect=$(``);
projectsContainer.append(projectsSelect);
initProjects(projectsSelect);
var groupsContainer=$('');
container.append(groupsContainer);
var groupsSelect=$(``);
groupsContainer.append(groupsSelect);
initGroups(groupsSelect);
var buttonContainer=$('');
container.append(buttonContainer);
var button=$('');
buttonContainer.append(button);
button.on('click',function(){
var project=projectsSelect.val();
var group=groupsSelect.val();
if(!project || !group){
alert('项目和目标团队都不能为空!');
return;
}
var data={project:project,group:group};
var loading=$('#loading');
loading.show();
$.ajax({
url:'migration/doMigration',
type:'POST',
data:data,
success:function(){
alert("已成功将项目【"+project+"】迁移到团队【"+group+"】中!");
loading.hide();
},
error:function(info){
loading.hide();
alert("迁移操作出错");
throw info;
}
});
});
});