userAppOpenCtrl.js
2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
(function (angular) {
function userAppOpenCtrl($scope, params, $http, $uibModalInstance, $uibModal,systemService,$filter,$rootScope,$q) {
$scope.accountName = params.accountName;
$scope.bankList=[];
$scope.isSelectAll=false;
$scope.ok = function () {
$scope.saveBtnDisabled = true;
var openWechatAppids = new Array();
var closeWechatAppids = new Array();
for(var i=0;i<$scope.wechatAppList.length;i++){
if($scope.wechatAppList[i].checked){
openWechatAppids.push($scope.wechatAppList[i].wechatAppid);
}else{
closeWechatAppids.push($scope.wechatAppList[i].wechatAppid);
}
}
var params = {};
params.accountName = $scope.accountName;
params.openWechatAppids = openWechatAppids;
params.closeWechatAppids = closeWechatAppids;
systemService.batachOpenBWeapp(params,function(res){
$scope.saveBtnDisabled = false;
if(res.returnCode == 0){
swal({type: 'success',title: '',text:'操作成功',showConfirmButton:false,timer: 1500},function(){
window.sweetAlert.close();
$uibModalInstance.close();
});
}else{
swal({type: 'error',title: '',text: res.message||'操作失败',timer: 1500},function(){window.sweetAlert.close();});
}
});
};
$scope.selectAllCheck=function(){
angular.forEach($scope.wechatAppList, function(item){
item.checked = $scope.isSelectAll;
});
};
$scope.selectCheck=function(item){
if(!item.checked){
$scope.isSelectAll = false;
}else{
var isSelectAll = true;
for(var i=0;i<$scope.wechatAppList.length;i++){
if(!$scope.wechatAppList[i].checked){
isSelectAll = false;
break;
}
}
$scope.isSelectAll = isSelectAll;
}
}
$scope.init = function(){
systemService.getBWeappList({'accountName':$scope.accountName},function(res){
if(res.returnCode == 0){
$scope.wechatAppList = res.data.wechatAppList;
$scope.userAppList = res.data.userAppList;
if($scope.userAppList){
var isSelectAll = true;
for(var i=0;i<$scope.wechatAppList.length;i++){
for(var j=0;j<$scope.userAppList.length;j++){
if($scope.wechatAppList[i].wechatAppid == $scope.userAppList[j].wechatAppid){
$scope.wechatAppList[i].checked = true;
break;
}
}
if(!$scope.wechatAppList[i].checked){
isSelectAll = false;
}
}
$scope.isSelectAll = isSelectAll;
}
}else{
swal({type: 'error',title: '',text: res.message||'查询失败',timer: 1500},function(){window.sweetAlert.close();});
}
});
};
$scope.init();
}
angular.module('system').controller('userAppOpenCtrl', userAppOpenCtrl);
})(angular);