menuAddCtrl.js
1.79 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
(function (angular) {
function menuAddCtrl($scope, params, $http, $uibModalInstance, $uibModal, DTColumnBuilder, DTOptionsBuilder,systemService) {
console.log(params)
$scope.menuId = params.id;
$scope.addMenu = function () {
if($scope.creatForm.$invalid){
$scope.isInValidate = true;
return false;
}
var params = {};
if($scope.menuId){
params.id = $scope.menuId;
}
params.code = $scope.formData.code;
params.name = $scope.formData.name;
params.url = $scope.formData.url;
if($scope.formData.parentCode){
params.parentCode = $scope.formData.parentCode;
}
if($scope.formData.orderNo){
params.orderNo = $scope.formData.orderNo;
}
systemService.addOrUpdateMenu($.param(params),function(res){
if(res.returnCode == 0){
swal({type: 'success',title: '',text: res.message||'操作成功',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.init = function(){
if($scope.menuId){
systemService.getMenuById({'id':$scope.menuId},function(res){
if(res.returnCode == 0){
$scope.formData = res.data;
}else{
swal({type: 'error',title: '',text: res.message||'查询失败',timer: 1500},function(){window.sweetAlert.close();});
}
})
}
};
$scope.init();
}
angular.module('system').controller('menuAddCtrl', menuAddCtrl);
})(angular);