serviceManagerCtrl.js
2.91 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
(function(angular) {
function serviceManagerCtrl($scope, DTOptionsBuilder, DTColumnBuilder, dopService,$uibModal, $filter, $state, $rootScope,SweetAlertX) {
$scope.dtColumns = [
DTColumnBuilder.newColumn('serviceName').withOption('width',120).withTitle('服务名称'),
DTColumnBuilder.newColumn('serviceMethod').withOption('width',180).withTitle('服务方法'),
DTColumnBuilder.newColumn('serviceModule').withOption('width',80).withTitle('所属模块'),
DTColumnBuilder.newColumn('serviceStatus').withOption('width',60).withTitle('服务状态').renderWith(function(e, dt, node, config){
if(node.serviceStatus == 1){
return '启用';
}else if(node.serviceStatus == 2){
return '停用';
}else if(node.serviceStatus == 3){
return '异常';
}
return "";
}),
DTColumnBuilder.newColumn('updatedDate').withOption('width',120).withTitle('更新时间').renderWith(function(e, dt, node, config){
return $filter('date')(new Date(node.updatedDate), 'yyyy-MM-dd HH:mm:ss');
})
];
if($rootScope.loginUser.isSuper){
$scope.dtColumns.push(DTColumnBuilder.newColumn(null).withTitle(function(){
return '操作';
}).withOption('width', 120).withClass('text-center').renderWith(function(data, type, full, oSettings) {
var str = '<div class="form-inline">'
+'<div class="form-group"><a class="btn btn-link" ng-click="insertOrUpdate('+ data.id +')">修改</a></div>';
str += '</div>';
return str;
}))
}
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('id','id')
.withFixedColumns({
rightColumns: 1
});
$scope.dtInstance = {
serverData : dopService.searchService
};
$scope.getParams =function(){
var condition = {};
if($scope.serviceName){
condition.serviceName = $scope.serviceName;
}
if($scope.serviceMethod){
condition.serviceMethod = $scope.serviceMethod;
}
if($scope.serviceModule){
condition.serviceModule = $scope.serviceModule;
}
return {'condition':condition};
}
//查询
$scope.submitForm = function(){
$scope.dtInstance.query($scope.getParams());
}
$scope.insertOrUpdate = function (id) {
$uibModal.open({
templateUrl: 'biz/dop/view/serviceManagerDialog.html',
controller: 'serviceManagerDialogCtrl',
size: 'lg',
resolve: {
params: function () {
return {'id':id}
}
}
}).result.then(function (data) {
$scope.dtInstance.query($scope.getParams());
},function(){
$scope.dtInstance.query($scope.getParams());
})
};
}
angular.module('dop').controller('serviceManagerCtrl', serviceManagerCtrl)
})(angular);