//弹出层索引
var index1, index2, index3;

//编辑院
function showChapterEditBox(chapterid){
  layer.load(0, {shade: [0.2, '#393D49']});
  index1 = layer.open({
    id: 'onedialog',
    type: 2,
    title: '编辑',
    area: ['600px', '400px'],
    fixed: false, //不固定
    content: '/glspecial/chapter/'+ chapterid
  });
  layer.closeAll('loading');
}
//删除院
function showChapterDeleBox(chapterid){
  var layerbox = layer.confirm('这将同时删除该院下的所有系、专业，<br>确认要删除吗？', {
    area: ['400px', '230px'],
    icon: 0,
    btn: ['确定','取消'] //按钮
  }, function(){
    $.ajax({
      url: '/glspecial/chapter/delete', 
      type: 'POST',
      data: {chapterid:chapterid,rnum:Math.random()},
      dataType: "json", 
      beforeSend: function(){
        layer.load(0, {shade: [0.2, '#393D49']});
      },
      success: function(data){
        if(data.code=="success"){
          layer.msg("成功", {icon:1}, function(){window.location.reload();});
        }else{
          layer.msg(data.msg, {icon:2});
        }
      },
      error: function(){
        layer.msg("系统错误，请联系管理员", {icon:2});
      },
      complete: function(){
        layer.closeAll('loading');
      }
    });
    return false;
  }, function(){
    //do nothing
  });
}

//编辑系
function showSectionEditBox(sectionid, chapterid){
  layer.load(0, {shade: [0.2, '#393D49']});
  index2 = layer.open({
    id: 'onedialog',
    type: 2,
    title: '编辑',
    area: ['600px', '400px'],
    fixed: false, //不固定
    content: '/glspecial/section/'+ sectionid +'-'+ chapterid
  });
  layer.closeAll('loading');
}
//删除系
function showSectionDeleBox(sectionid){
  var layerbox = layer.confirm('这将同时删除该系下的所有专业，<br>确认要删除吗？', {
    area: ['400px', '230px'],
    icon: 0,
    btn: ['确定','取消'] //按钮
  }, function(){
    $.ajax({
      url: '/glspecial/section/delete', 
      type: 'POST',
      data: {sectionid:sectionid,rnum:Math.random()},
      dataType: "json", 
      beforeSend: function(){
        layer.load(0, {shade: [0.2, '#393D49']});
      },
      success: function(data){
        if(data.code=="success"){
          layer.msg("成功", {icon:1}, function(){window.location.reload();});
        }else{
          layer.msg(data.msg, {icon:2});
        }
      },
      error: function(){
        layer.msg("系统错误，请联系管理员", {icon:2});
      },
      complete: function(){
        layer.closeAll('loading');
      }
    });
    return false;
  }, function(){
    //do nothing
  });
}

//编辑专业
function showKnowledEditBox(knowledid, sectionid){
  layer.load(0, {shade: [0.2, '#393D49']});
  index3 = layer.open({
    id: 'onedialog',
    type: 2,
    title: '编辑',
    area: ['600px', '400px'],
    fixed: false, //不固定
    content: '/glspecial/knowled/'+ knowledid +'-'+ sectionid
  });
  layer.closeAll('loading');
}
//删除专业
function showKnowledDeleBox(knowledid){
  var layerbox = layer.confirm('确认要删除该专业吗？', {
    area: ['400px', '230px'],
    icon: 0,
    btn: ['确定','取消'] //按钮
  }, function(){
    $.ajax({
      url: '/glspecial/knowled/delete', 
      type: 'POST',
      data: {knowledid:knowledid,rnum:Math.random()},
      dataType: "json", 
      beforeSend: function(){
        layer.load(0, {shade: [0.2, '#393D49']});
      },
      success: function(data){
        if(data.code=="success"){
          layer.msg("成功", {icon:1}, function(){window.location.reload();});
        }else{
          layer.msg(data.msg, {icon:2});
        }
      },
      error: function(){
        layer.msg("系统错误，请联系管理员", {icon:2});
      },
      complete: function(){
        layer.closeAll('loading');
      }
    });
    return false;
  }, function(){
    //do nothing
  });
}

//上下移动节点
function showNodeMoveupBox(treeid, direction){
  $.ajax({
    url: '/glspecial/default/moveupdown', 
    type: 'POST',
    data: {treeid:treeid,direction:direction,rnum:Math.random()},
    dataType: "json", 
    beforeSend: function(){
      layer.load(0, {shade: [0.2, '#393D49']});
    },
    success: function(data){
      if(data.code=="success"){
        layer.msg("成功", {icon:1}, function(){window.location.reload();});
      }else{
        layer.msg(data.msg, {icon:2});
      }
    },
    error: function(){
      layer.msg("系统错误，请联系管理员", {icon:2});
    },
    complete: function(){
      layer.closeAll('loading');
    }
  });
  return false;
}

//弹出层索引
var index11, index12, index13, index14;

//团队成员
function showLeaderListBox(treeid){
  layer.load(0, {shade: [0.2, '#393D49']});
  index11 = layer.open({
    id: 'onedialog',
    type: 2,
    title: '团队成员',
    area: ['900px', '570px'],
    fixed: false, //不固定
    content: '/glspecial/leader/'+ treeid
  });
  layer.closeAll('loading');
}

//添加成员
function showLeaderEditBox(treeid){
  layer.load(0, {shade: [0.2, '#393D49']});
  index12 = layer.open({
    id: 'twodialog',
    type: 2,
    title: '团队成员',
    area: ['900px', '570px'],
    fixed: false, //不固定
    content: '/glspecial/leaderadd/index?id='+ treeid
  });
  layer.closeAll('loading');
}

//刷新成员列表
function reloadLeaderListBox(treeid){
  layer.close(index12);
  layer.iframeSrc(index11, '/glspecial/leader/'+ treeid);
}