addPrivilege.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. (function(vc){
  2. vc.extends({
  3. data:{
  4. addPrivilegeInfo:{
  5. _currentPgId:'',
  6. name:'',
  7. description:'',
  8. errorInfo:'',
  9. _noAddPrivilege:[]
  10. }
  11. },
  12. _initMethod:function(){
  13. },
  14. _initEvent:function(){
  15. vc.component.$on('addPrivilege_openPrivilegeModel',function(_params){
  16. $('#addPrivilegeModel').modal('show');
  17. vc.component.addPrivilegeInfo._currentPgId = _params.pgId;
  18. //查询没有添加的权限
  19. vc.component.listNoAddPrivilege();
  20. });
  21. },
  22. methods:{
  23. listNoAddPrivilege:function(){
  24. vc.component.addPrivilegeInfo._noAddPrivilege=[];
  25. var param = {
  26. params:{
  27. pgId:vc.component.addPrivilegeInfo._currentPgId
  28. }
  29. }
  30. vc.http.get(
  31. 'addPrivilege',
  32. 'listNoAddPrivilege',
  33. param,
  34. function(json,res){
  35. //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
  36. if(res.status == 200){
  37. vc.component.addPrivilegeInfo._noAddPrivilege = JSON.parse(json);
  38. return ;
  39. }
  40. vc.component.addPrivilegeInfo.errorInfo = json;
  41. },
  42. function(errInfo,error){
  43. console.log('请求失败处理');
  44. vc.component.addPrivilegeInfo.errorInfo = errInfo;
  45. });
  46. },
  47. addPrivilegeToPrivilegeGroup:function(_privilegeInfo){
  48. vc.component.addPrivilegeInfo.errorInfo = "";
  49. _privilegeInfo.pgId = vc.component.addPrivilegeInfo._currentPgId;
  50. vc.http.post(
  51. 'addPrivilege',
  52. 'addPrivilegeToPrivilegeGroup',
  53. JSON.stringify(_privilegeInfo),
  54. {
  55. emulateJSON:true
  56. },
  57. function(json,res){
  58. //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
  59. if(res.status == 200){
  60. //关闭model
  61. vc.component.listNoAddPrivilege();
  62. return ;
  63. }
  64. vc.component.addPrivilegeInfo.errorInfo = json;
  65. },
  66. function(errInfo,error){
  67. console.log('请求失败处理');
  68. vc.component.addPrivilegeInfo.errorInfo = errInfo;
  69. });
  70. }
  71. }
  72. });
  73. })(window.vc);