|
@@ -1,6 +1,7 @@
|
1
|
1
|
'use strict';
|
2
|
2
|
|
3
|
|
-app.controller('workingHistoryFormCtr', ["$scope", "moment", "SweetAlert", "api_user_data", function ($scope, moment, SweetAlert, api_user_data) {
|
|
3
|
+app.controller('workingHistoryFormCtr', ["$scope", "moment", "SweetAlert", "$state", "api_user_data", function ($scope, moment, SweetAlert, $state, api_user_data) {
|
|
4
|
+ console.log($state.params)
|
4
|
5
|
//上班记录状态
|
5
|
6
|
$scope.statesOn = [
|
6
|
7
|
{ name: '全部', value: '0' },
|
|
@@ -15,10 +16,26 @@ app.controller('workingHistoryFormCtr', ["$scope", "moment", "SweetAlert", "api_
|
15
|
16
|
{ name: '未打卡', value: '4' }
|
16
|
17
|
];
|
17
|
18
|
// 查询条件
|
18
|
|
- $scope.searchkeys = {
|
19
|
|
- state: $scope.statesOn[0],
|
20
|
|
- date: moment().format('YYYY-MM-DD')
|
|
19
|
+ if ($state.params.state) {
|
|
20
|
+ var stateItem = $scope.statesOn.find(v => v.value == $state.params.state);
|
|
21
|
+ if (stateItem) {
|
|
22
|
+ $scope.searchkeys = {
|
|
23
|
+ state: stateItem,
|
|
24
|
+ date: moment().format('YYYY-MM-DD')
|
|
25
|
+ }
|
|
26
|
+ } else {
|
|
27
|
+ $scope.searchkeys = {
|
|
28
|
+ state: $scope.statesOn[0],
|
|
29
|
+ date: moment().format('YYYY-MM-DD')
|
|
30
|
+ }
|
|
31
|
+ }
|
|
32
|
+ } else {
|
|
33
|
+ $scope.searchkeys = {
|
|
34
|
+ state: $scope.statesOn[0],
|
|
35
|
+ date: moment().format('YYYY-MM-DD')
|
|
36
|
+ }
|
21
|
37
|
}
|
|
38
|
+
|
22
|
39
|
// 查询的重置条件
|
23
|
40
|
$scope.resetSearchkeys = {
|
24
|
41
|
state: $scope.statesOn[0],
|
|
@@ -97,7 +114,11 @@ app.controller('workingHistoryFormCtr', ["$scope", "moment", "SweetAlert", "api_
|
97
|
114
|
}
|
98
|
115
|
];
|
99
|
116
|
//默认选择上班记录
|
100
|
|
- $scope.searchstate = 'on';
|
|
117
|
+ if ($state.params.tab) {
|
|
118
|
+ $scope.searchstate = $state.params.tab;
|
|
119
|
+ } else {
|
|
120
|
+ $scope.searchstate = 'on';
|
|
121
|
+ }
|
101
|
122
|
$scope.states = $scope.statesOn;
|
102
|
123
|
// 切换tab
|
103
|
124
|
$scope.onChange = function (searchType) {
|
|
@@ -121,7 +142,7 @@ app.controller('workingHistoryFormCtr', ["$scope", "moment", "SweetAlert", "api_
|
121
|
142
|
$scope.startOpened = !$scope.startOpened;
|
122
|
143
|
};
|
123
|
144
|
// 选择日期
|
124
|
|
- $scope.changeDate = function(){
|
|
145
|
+ $scope.changeDate = function () {
|
125
|
146
|
$scope.searchkeys.date = moment($scope.searchkeys.date).format('YYYY-MM-DD');
|
126
|
147
|
}
|
127
|
148
|
// 重置
|
|
@@ -130,7 +151,7 @@ app.controller('workingHistoryFormCtr', ["$scope", "moment", "SweetAlert", "api_
|
130
|
151
|
$scope.refreshData();
|
131
|
152
|
}
|
132
|
153
|
//处理过滤数据
|
133
|
|
- $scope.stateChange = function(data){
|
|
154
|
+ $scope.stateChange = function (data) {
|
134
|
155
|
var arr = [];
|
135
|
156
|
//过滤上班记录或下班记录
|
136
|
157
|
if ($scope.searchstate === "on") {
|
|
@@ -145,7 +166,7 @@ app.controller('workingHistoryFormCtr', ["$scope", "moment", "SweetAlert", "api_
|
145
|
166
|
//实到
|
146
|
167
|
let arr1 = arr.filter(v => v.extra2 == "迟到");
|
147
|
168
|
let arr2 = arr.filter(v => v.extra2 == "正常");
|
148
|
|
- $scope.myData = [...arr1,...arr2];
|
|
169
|
+ $scope.myData = [...arr1, ...arr2];
|
149
|
170
|
} else if ($scope.searchkeys.state.value === "2") {
|
150
|
171
|
//迟到
|
151
|
172
|
$scope.myData = arr.filter(v => v.extra2 == "迟到");
|
|
@@ -154,19 +175,19 @@ app.controller('workingHistoryFormCtr', ["$scope", "moment", "SweetAlert", "api_
|
154
|
175
|
$scope.myData = arr.filter(v => v.extra2 == "早退");
|
155
|
176
|
} else if ($scope.searchkeys.state.value === "4") {
|
156
|
177
|
//未打卡
|
157
|
|
- if($scope.searchstate === 'on'){
|
|
178
|
+ if ($scope.searchstate === 'on') {
|
158
|
179
|
// 上班
|
159
|
180
|
$scope.myData = angular.copy($scope.itemsSaveNoOn);
|
160
|
|
- }else if($scope.searchstate === 'off'){
|
|
181
|
+ } else if ($scope.searchstate === 'off') {
|
161
|
182
|
// 下班
|
162
|
183
|
$scope.myData = angular.copy($scope.itemsSaveNoOff);
|
163
|
184
|
}
|
164
|
185
|
} else if ($scope.searchkeys.state.value === "0") {
|
165
|
186
|
//全部
|
166
|
|
- if($scope.searchstate === 'on'){
|
|
187
|
+ if ($scope.searchstate === 'on') {
|
167
|
188
|
// 上班
|
168
|
189
|
$scope.myData = angular.copy(arr.concat($scope.itemsSaveNoOn));
|
169
|
|
- }else if($scope.searchstate === 'off'){
|
|
190
|
+ } else if ($scope.searchstate === 'off') {
|
170
|
191
|
// 下班
|
171
|
192
|
$scope.myData = angular.copy(arr.concat($scope.itemsSaveNoOff));
|
172
|
193
|
}
|