role.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * 角色模块js
  3. */
  4. $.namespace("role.main");
  5. role.main.init=function(){
  6. //把form传入,构造翻页控件
  7. pageinfo($("#roleform"));
  8. }
  9. //查询
  10. role.main.search=function(){
  11. $("#roleform").submit();
  12. }
  13. //删除
  14. role.main.del=function(data){
  15. var _this = $(this);
  16. base.delGetAction({
  17. tip : '确定删除?',
  18. execute : function() {
  19. var roleId = _this.parent().find('#roleId').val();
  20. var action = 'role/delOneRole.html';
  21. var data = {
  22. roleId : roleId
  23. };
  24. base.WAP_POST(action, data, 'json', function(o) {
  25. if (o.statusCode == 10000) {
  26. alert('删除成功!');
  27. base.getAction('role/querylist.html');
  28. } else {
  29. alert('删除失败!');
  30. }
  31. });
  32. }
  33. });
  34. }
  35. //清空新增输入
  36. role.main.clear=function(){
  37. $("#editid").val("");
  38. $("#editroleName").val("");
  39. $("#editroleCode").val("");
  40. $("#editsortno").val("");
  41. }
  42. /*role.main.edit=function(data){
  43. var roleId = $('#roleId').val();
  44. var action = 'role/roleInfo.html?roleId=' + roleId;
  45. base.getAction(action);
  46. }*/
  47. //编辑
  48. role.main.edit=function(data){
  49. $.post(basePath+"/role/edit.html", {
  50. id : data
  51. }, function(data) {
  52. alert(1)
  53. debugger;
  54. if(data){
  55. for(var a in data){
  56. if($("#edit"+a)){
  57. $("#edit"+a).val(data[a]);
  58. }
  59. }
  60. }
  61. }, "json");
  62. }
  63. //编辑和新增保存
  64. role.main.save=function save(){
  65. $.ajax({
  66. url:basePath+"/role/saveRole.html",
  67. data:$("#addform").serialize(),
  68. type:"post",
  69. dataType:"json",
  70. success:function(data){//ajax返回的数据
  71. if (data.success) {
  72. $.alert({
  73. title: '提示',
  74. content: '保存成功',
  75. confirm: function(){
  76. }
  77. });
  78. }else {
  79. $.alert({
  80. title: '提示',
  81. content: data.message,
  82. confirm: function(){
  83. }
  84. });
  85. }
  86. }
  87. });
  88. },
  89. role.main.grant=function(date){
  90. alert(date)
  91. location.href=$.app+"/role/rolegrant.html?roleId="+date;
  92. }