SetController.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. var app = angular.module('app',['baseServices','SysTransDefService','commonListService','arrayToolService']);
  2. app.controller("SetController",['$scope','BaseService','SysTransDef','CommonListService','ArrayToolService',function($scope,BaseService,SysTransDef,CommonListService,ArrayToolService){
  3. $scope.CommonList=CommonListService;
  4. $scope.ArrayTool=ArrayToolService;
  5. //对象
  6. $scope.prop={};
  7. //页面用到的参数或临时变量
  8. $scope.param={};
  9. $scope.param.author={};//授权人
  10. $scope.param.targetPerson={};//目的人
  11. SysTransDef.detail({id:id},function(data){
  12. $scope.std=data;
  13. });
  14. //执行selectSql
  15. $scope.excuteSelectSql=function(){
  16. if(id=="1") return;//1是为显示好看的父节点,没意义的
  17. var json={};
  18. json.id=id;
  19. json.authorId=$scope.param.author.id;
  20. SysTransDef.excuteSelectSql(json,function(data){
  21. $scope.param.list=jQuery.extend(true,[], data);
  22. for(var i=0;i<data.length;i++){
  23. delete data[i].id;
  24. delete data[i].name;
  25. }
  26. $scope.param.showList=jQuery.extend(true,[], data);
  27. });
  28. }
  29. //选择人员
  30. $scope.selectUser=function(json,callback){
  31. UserDialog({
  32. selectUserIds:"",
  33. selectUserNames:"",
  34. isSingle:true,
  35. callback:function(ids,names){
  36. $scope.$apply(function(){
  37. json.name=names;
  38. });
  39. json.id=ids;
  40. if(callback){//回调函数
  41. callback();
  42. }
  43. }
  44. });
  45. }
  46. //授权人改变,刷新左边的树
  47. $scope.authorChange=function(){
  48. var aid=$scope.param.author.id;
  49. var ztreeCreator = new ZtreeCreator('glTypeTree',"treeListJson.ht?authorId="+aid)
  50. .setCallback({onClick:zTreeOnClick})
  51. .initZtree();
  52. $scope.$apply(function(){
  53. $scope.param.list=[];
  54. $scope.param.showList=[];
  55. });
  56. }
  57. //点击列
  58. $scope.clickItem=function(item){
  59. if(!item.selected) item.selected=false;
  60. item.selected=!item.selected;
  61. }
  62. //点击全选
  63. $scope.clickAll=function(){
  64. if(!$scope.param.selectAll) $scope.param.selectAll=false;
  65. $scope.param.selectAll=!$scope.param.selectAll;
  66. for(var i=0;i<$scope.param.list.length;i++){
  67. $scope.param.list[i].selected=$scope.param.selectAll;
  68. }
  69. }
  70. //执行updateSql
  71. $scope.excuteUpdateSql=function(){
  72. var param={};//发送到后台的参数
  73. param.id=id;
  74. param.selectedItem=[];//选中的列
  75. param.authorId=$scope.param.author.id;
  76. param.targetPersonId=$scope.param.targetPerson.id;
  77. if(id==""||!id){
  78. $.ligerDialog.warn("请选择权限转移的类型(左边的树)", "提示信息");
  79. return;
  80. }
  81. if(param.authorId==""||!param.authorId){
  82. $.ligerDialog.warn("请选择授权人", "提示信息");
  83. return;
  84. }
  85. if(param.targetPersonId==""||!param.targetPersonId){
  86. $.ligerDialog.warn("请选择转移到的目标人", "提示信息");
  87. return;
  88. }
  89. if(param.targetPersonId==param.authorId){
  90. $.ligerDialog.warn("授权人跟目标人不能为同一个人", "提示信息");
  91. return;
  92. }
  93. for(var i=0;i<$scope.param.list.length;i++){
  94. var item=$scope.param.list[i];
  95. if(item.selected){
  96. var json ={};
  97. json.id=item.id;
  98. json.name=item.name;
  99. param.selectedItem.push(json);
  100. }
  101. }
  102. if(param.selectedItem.length<=0){
  103. $.ligerDialog.warn("请选择数据列表", "提示信息");
  104. return;
  105. }
  106. param.selectedItem=JSON.stringify(param.selectedItem);
  107. SysTransDef.excuteUpdateSql(param,function(data){
  108. if(data.result==1){
  109. $.ligerDialog.success(data.message,"操作成功",function(){
  110. window.location.reload();
  111. });
  112. }else{
  113. $.ligerDialog.error(data.message,"操作失败");
  114. }
  115. });
  116. }
  117. }]);