4. easyui删除功能实例

Posted on 2017-06-01 15:27  zkx4213  阅读(263)  评论(0编辑  收藏  举报

############实例1##############

function delPerson(id) {
  $.messager.defaults = {
    ok : "确定",
    cancel : "取消"
  };

  var rows = $('#personInfoGrid').datagrid('getSelections');
  if (rows.length == 0 && id == undefined) {
    $.messager.alert("警告", "请至少勾选一条待删除记录", "warning");
  } else {

    $.messager.confirm('警告', '确定要删除吗?', function(result) {
      if (result) {
        var personIds = "";
        if (id == undefined) {
        $.each(rows, function(i, n) {
          if (i == 0) {
            personIds += "" + n.ID + "";
          } else {
            personIds += "," + n.ID + "";
          }
        });
      } else {
        personIds = id;
      }
      var url = basePath + 'rest/personControllerForDQ/delPersonAuth';
      $.messager.progress({
        title : '消息提示',
        msg : '',
        text : '',
        interval : 1000
      });
      $.ajax({
        url : url,
        type : "POST",
        data : {
          id : personIds
        },
        async : true,
        success : function(data) {
          $.messager.progress('close'); // 隐藏进度条
          $.messager.alert('提示', data.message, 'info');
          $('#personInfoGrid').datagrid('reload');
        }
      });
    }
  });
 }
}

 

############实例2###############

function delRoleCategory() {
  var node = $('#roleCategoryTree').tree('getSelected');
  if(node.parentId=="/"){
    $.messager.alert("警告", "根节点不允许删除!", "warning");
    return;
  }
  if(node.children != null && node.children.length > 0) {
    $.messager.alert('提示',"请先删除子节点",'info');
    return;
  }

  $.messager.confirm('提示','确定要删除吗?',function(result){
    if (result){
      var id = "";
      if(node != null && node != undefined){
        id = node.id;
      }
      var url = basePath + 'rest/roleCategoryControllerForDQ/delCategoryTree';
      $.ajax({
        url : url,
        type : "POST",
        data : {
          id : id
        },
        async : true,
        success : function(data) {
          if(data.success){
            $.messager.alert("消息", data["message"], "info");
            queryRoleCategoryTree();
          } else {
            $.messager.alert("提示", data["message"], "warning");
            return;
          }
        },
        error : function(data) {
          $.messager.progress("close");
          $.messager.alert("错误", data["message"], "error");
        }
      });
    }
  });
}

Copyright © 2024 zkx4213
Powered by .NET 9.0 on Kubernetes