index.js
6.49 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/**
 * Created by 王冠伦 on 2018/2/26.
 */
(function () {
    "user strict";
    var railwayController = function($scope,$modal,$http,$interval,dialogService,railwayService){
        $scope.$emit('navShow', 5);
        $scope.vm = {
            pageSize : 0,
            totalCount : 0,
            type:"LAID_ON"
        }
        $scope.getList = function(){
            railwayService.findEscortAttendance($scope.vm).success(function(data){
                if (data.errors == null || data.errors.length > 0) {
                    dialogService.tip(data.errors);
                }else{
                    $scope.escortAttendanceList = data.result;
                    for(var i =0 ;i< $scope.escortAttendanceList.length;i++){
                        if ($scope.escortAttendanceList[i].laidTime != null) {
                            var time = new Date(Number($scope.escortAttendanceList[i].laidTime));
                            $scope.escortAttendanceList[i].laidTime = time.format("yyyy-MM-dd hh:mm:ss ");
                        }
                    }
                    $scope.vm.totalCount = data.totalCount;
                }
            })
        }
        $scope.getList();
        /*var timer=$interval(function(){
            $scope.getList();
        },10000);   //间隔2秒定时执行
        timer.then(function(){ console.log('查询成功')},
            function(){ console.log('查询不成功')});*/
        $scope.doAddTag = function(){
            var vm = {};
            var modalInstance = $modal.open({
                templateUrl: "create.html",
                controller:createTagController,
                size:"md",
                resolve: {
                    items: function () {
                        return vm;
                    }
                }
            });
            modalInstance.result.then(function () {
                $scope.getList();
            });
        }
        $scope.doEdit = function (id) {
            var vm = {
                id:id
            };
            var modalInstance = $modal.open({
                templateUrl: "create.html",
                controller:editTagController,
                size:"md",
                resolve: {
                    items: function () {
                        return vm;
                    }
                }
            });
            modalInstance.result.then(function () {
                $scope.getList();
            });
        }
        $scope.doSearch = function(){
            $scope.vm.pageNumber = 1;
            $scope.getList();
        }
        $scope.doDelete = function(id){
            var dialogDefaults = {
                size: "sm"
            };
            var dialogOptions = {
                closeButtonText: "取消",
                actionButtonText: "确定",
                headerText: "提示",
                bodyText: "确认删除吗",
                callback: function () {
                    PartnerService.deleteTag({id:id}).success(function(data){
                        if (data.errors == null || data.errors.length > 0) {
                            dialogService.tip(data.errors);
                        }else{
                            dialogService.tip([{"message": "删除成功!" }]);
                            $scope.getList();
                        }
                    })
                }
            };
            dialogService.confirm(dialogDefaults, dialogOptions);
        }
    }
    var createTagController = ["$scope","$modalInstance","dialogService","PartnerService","items",
        function($scope,$modalInstance,dialogService,PartnerService,items){
            $scope.headTitle = "新增标签";
            //关闭弹出窗
            $scope.clean = function () {
                $modalInstance.close();
            };
            //关闭错误
            $scope.closeAlert = function (index,form) {
                form.splice(index,1);
            };
            $scope.vm = {
                type : "PARTNER",
                orderIndex : 0
            };
            //保存方法
            $scope.doSave = function () {
                if ($scope.vm.name==null || $scope.vm.name==""){
                    $scope.validateForm.$errors.push("标签的名称不能为空");
                    return;
                }
                PartnerService.createTag($scope.vm).success(function(data){
                    if (data.errors == null || data.errors.length > 0) {
                        $scope.validateForm.$errors.push(data.errors[0].message);
                        //dialogService.tip(data.errors);
                    } else{
                        dialogService.tip([{"message": "创建成功"}]);
                        $scope.clean();
                    }
                })
            }
        }];
    var editTagController = ["$scope","$modalInstance","dialogService","PartnerService","items",
        function($scope,$modalInstance,dialogService,PartnerService,items){
            $scope.headTitle = "编辑标签";
            var id = items.id;
            //关闭弹出窗
            $scope.clean = function () {
                $modalInstance.close();
            };
            //关闭错误
            $scope.closeAlert = function (index,form) {
                form.splice(index,1);
            };
            $scope.getTag = function(){
                PartnerService.getTag({id:id}).success(function(data){
                    if (data.errors == null || data.errors.length > 0) {
                        dialogService.tip(data.errors);
                    }else{
                        $scope.vm = data.tag;
                    }
                })
            }
            $scope.getTag();
            //保存方法
            $scope.doSave = function () {
                if ($scope.vm.name==null || $scope.vm.name==""){
                    $scope.validateForm.$errors.push("标签的名称不能为空");
                    return;
                }
                PartnerService.updateTag($scope.vm).success(function(data){
                    if (data.errors == null || data.errors.length > 0) {
                        $scope.validateForm.$errors.push(data.errors[0].message);
                    } else{
                        dialogService.tip([{"message": "编辑成功"}]);
                        $scope.clean();
                    }
                })
            }
        }];
    angular.module("xn.page", ["xn.directive.form"])
        .controller("RailwayController",["$scope","$modal","$http","$interval","dialogService","RailwayService",railwayController])
})();