|
@@ -0,0 +1,673 @@
|
|
1
|
+app.controller('phoneListCtrl', ["$rootScope", "$scope", "$http", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", "api_cmdb2", function ($rootScope, $scope, $http, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data, api_cmdb2) {
|
|
2
|
+ $scope.langs = i18nService.getAllLangs();
|
|
3
|
+ $scope.lang = 'zh-cn';
|
|
4
|
+ $scope.cancles = true;
|
|
5
|
+ var loginUser = $rootScope.user;
|
|
6
|
+ $scope.xinzeng = false;
|
|
7
|
+ $scope.shanchu = false;
|
|
8
|
+ $scope.bianji = false;
|
|
9
|
+ for (var i = 0; i < loginUser.menu.length; i++) {
|
|
10
|
+ if (loginUser.menu[i].link == "quyudidianguanli_xinzeng") {
|
|
11
|
+ $scope.xinzeng = true
|
|
12
|
+ }
|
|
13
|
+ if (loginUser.menu[i].link == "quyudidianguanli_shanchu") {
|
|
14
|
+ $scope.shanchu = true
|
|
15
|
+ }
|
|
16
|
+ if (loginUser.menu[i].link == "quyudidianguanli_bianji") {
|
|
17
|
+ $scope.bianji = true
|
|
18
|
+ }
|
|
19
|
+ }
|
|
20
|
+ var fildata = {
|
|
21
|
+ "idx": 0,
|
|
22
|
+ "sum": 1000
|
|
23
|
+ };
|
|
24
|
+ $scope.choice = false;
|
|
25
|
+ $scope.backcolor = [];
|
|
26
|
+ $scope.outarea = [];
|
|
27
|
+ $scope.outplace = [];
|
|
28
|
+ $scope.pla = {};
|
|
29
|
+ $scope.areaid = {};
|
|
30
|
+ $scope.areaname = "";
|
|
31
|
+ $scope.area = {};
|
|
32
|
+ $scope.areaplace = true;
|
|
33
|
+ $scope.freshenarea = function () {
|
|
34
|
+ api_user_data.fetchDataList('phoneUnit', fildata).then(function (response) {
|
|
35
|
+ if (response) {
|
|
36
|
+ if (response.status = 200) {
|
|
37
|
+ if (!$scope.outarea.length&&response.list.length) {
|
|
38
|
+ $scope.ckickrow(response.list[0]);
|
|
39
|
+ }
|
|
40
|
+ $scope.outarea = response.list;
|
|
41
|
+ }
|
|
42
|
+ }
|
|
43
|
+ })
|
|
44
|
+ }
|
|
45
|
+ $scope.freshenarea();
|
|
46
|
+
|
|
47
|
+ $scope.freshenplace = function (id) {
|
|
48
|
+ if (id) {
|
|
49
|
+ var fildata = {
|
|
50
|
+ "idx": 0,
|
|
51
|
+ "sum": 1000,
|
|
52
|
+ "phoneDirectory": {
|
|
53
|
+ "unit": {
|
|
54
|
+ "id": id
|
|
55
|
+ }
|
|
56
|
+ }
|
|
57
|
+ };
|
|
58
|
+ api_user_data.fetchDataList('phoneDirectory', fildata).then(function (response) {
|
|
59
|
+ if (response) {
|
|
60
|
+ if (response.status = 200) {
|
|
61
|
+ $scope.outplace = response.list;
|
|
62
|
+ }
|
|
63
|
+ }
|
|
64
|
+ })
|
|
65
|
+ }
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ $scope.ckickrow = function (data) {
|
|
69
|
+ $scope.choice = false;
|
|
70
|
+ $scope.areaid = data.id;
|
|
71
|
+ $scope.areaname = data.unit;
|
|
72
|
+ $scope.areaplace = true;
|
|
73
|
+ $scope.areaData = data;
|
|
74
|
+ if (data.id) {
|
|
75
|
+ $scope.freshenplace(data.id);
|
|
76
|
+ // var fildata={"idx":0,"sum":1000,"place":{areaId:data.id}};
|
|
77
|
+ // api_user_data.fetchDataList('place',fildata).then(function(response){
|
|
78
|
+ // if(response){
|
|
79
|
+ // if(response.status=200){
|
|
80
|
+ // $scope.outplace= response.list;
|
|
81
|
+ // }
|
|
82
|
+ // }
|
|
83
|
+ // })
|
|
84
|
+ } else { }
|
|
85
|
+ }
|
|
86
|
+ // 置空单位下的部门
|
|
87
|
+ $scope.clear = function () {
|
|
88
|
+ $scope.areaname = ''
|
|
89
|
+ $scope.outplace = []
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+ $scope.clickplace = function (pla) {
|
|
94
|
+ $scope.areaplace = false;
|
|
95
|
+ $scope.pla = pla
|
|
96
|
+ }
|
|
97
|
+ // 编辑单位
|
|
98
|
+ $scope.editArea = function (data) {
|
|
99
|
+ var modalInstance = $modal.open({
|
|
100
|
+ templateUrl: 'assets/views/system/tpl/company.html',
|
|
101
|
+ controller: function ($scope, scope, $modalInstance, api_user_data) {
|
|
102
|
+ $scope.title = "修改单位";
|
|
103
|
+ $scope.cancel = function () {
|
|
104
|
+ $modalInstance.dismiss('cancel');
|
|
105
|
+ };
|
|
106
|
+ $scope.areaName = data.unit;
|
|
107
|
+ $scope.ok = function (areaName) {
|
|
108
|
+ if (areaName != data.unit) {
|
|
109
|
+ if ($scope.areaName) {
|
|
110
|
+ $modalInstance.close(areaName);
|
|
111
|
+ } else {
|
|
112
|
+ SweetAlert.swal({
|
|
113
|
+ title: "修改失败!",
|
|
114
|
+ text: "名称不能为空",
|
|
115
|
+ type: "error"
|
|
116
|
+ })
|
|
117
|
+ }
|
|
118
|
+ } else {
|
|
119
|
+ $modalInstance.dismiss('cancel');
|
|
120
|
+ }
|
|
121
|
+ }
|
|
122
|
+ },
|
|
123
|
+ resolve: {
|
|
124
|
+ scope: function () {
|
|
125
|
+ return $scope;
|
|
126
|
+ }
|
|
127
|
+ }
|
|
128
|
+ });
|
|
129
|
+ modalInstance.result.then(function (selectedItem) {
|
|
130
|
+ if (selectedItem) {
|
|
131
|
+ var fildata = {
|
|
132
|
+ "phoneUnit": {
|
|
133
|
+ "id": data.id,
|
|
134
|
+ "deleteFlag": 0,
|
|
135
|
+ "unit": selectedItem
|
|
136
|
+ }
|
|
137
|
+ }
|
|
138
|
+ api_user_data.addData('phoneUnit', fildata).then(function (response) {
|
|
139
|
+ if (response) {
|
|
140
|
+ if (response.data && response.data.id) {
|
|
141
|
+ SweetAlert.swal({
|
|
142
|
+ title: "修改成功!",
|
|
143
|
+ type: "success"
|
|
144
|
+ }, function () {
|
|
145
|
+ $scope.freshenarea()
|
|
146
|
+ })
|
|
147
|
+ } else {
|
|
148
|
+ SweetAlert.swal({
|
|
149
|
+ title: "修改失败!",
|
|
150
|
+ text: response.msg || '',
|
|
151
|
+ type: "error"
|
|
152
|
+ })
|
|
153
|
+ }
|
|
154
|
+ }
|
|
155
|
+ })
|
|
156
|
+ }
|
|
157
|
+ })
|
|
158
|
+ }
|
|
159
|
+ // 新增单位
|
|
160
|
+ $scope.addArea = function (state) {
|
|
161
|
+ var modalInstance = $modal.open({
|
|
162
|
+ templateUrl: 'assets/views/system/tpl/company.html',
|
|
163
|
+ controller: function ($scope, scope, $modalInstance, api_user_data) {
|
|
164
|
+ $scope.title = "新增单位";
|
|
165
|
+ $scope.areaName = "";
|
|
166
|
+ $scope.cancel = function () {
|
|
167
|
+ $modalInstance.dismiss('cancel');
|
|
168
|
+ };
|
|
169
|
+ $scope.ok = function (areaName) {
|
|
170
|
+ if ($scope.areaName) {
|
|
171
|
+ $modalInstance.close(areaName);
|
|
172
|
+ } else {
|
|
173
|
+ SweetAlert.swal({
|
|
174
|
+ title: "新增失败!",
|
|
175
|
+ text: "名称不能为空",
|
|
176
|
+ type: "error"
|
|
177
|
+ })
|
|
178
|
+ }
|
|
179
|
+ }
|
|
180
|
+ },
|
|
181
|
+ resolve: {
|
|
182
|
+ scope: function () {
|
|
183
|
+ return $scope;
|
|
184
|
+ }
|
|
185
|
+ }
|
|
186
|
+ });
|
|
187
|
+ modalInstance.result.then(function (selectedItem) {
|
|
188
|
+ if (selectedItem) {
|
|
189
|
+ var fildata = {
|
|
190
|
+ "phoneUnit": {
|
|
191
|
+ "unit": selectedItem
|
|
192
|
+ }
|
|
193
|
+ }
|
|
194
|
+ api_user_data.addData('phoneUnit', fildata).then(function (response) {
|
|
195
|
+ if (response) {
|
|
196
|
+ if (response.status == 200) {
|
|
197
|
+ SweetAlert.swal({
|
|
198
|
+ title: "新增成功!",
|
|
199
|
+ type: "success"
|
|
200
|
+ }, function () {
|
|
201
|
+ $scope.freshenarea()
|
|
202
|
+ })
|
|
203
|
+ } else {
|
|
204
|
+ SweetAlert.swal({
|
|
205
|
+ title: "新增失败!",
|
|
206
|
+ text: response.msg || '',
|
|
207
|
+ type: "error"
|
|
208
|
+ })
|
|
209
|
+ }
|
|
210
|
+ }
|
|
211
|
+ })
|
|
212
|
+ }
|
|
213
|
+ })
|
|
214
|
+ }
|
|
215
|
+ //删除单位
|
|
216
|
+ $scope.closearea = function (index, data) {
|
|
217
|
+ if (!data.id) {
|
|
218
|
+ $scope.cancles = true;
|
|
219
|
+ $scope.outarea.splice(index, 1);
|
|
220
|
+ } else {
|
|
221
|
+ var rmvList = data;
|
|
222
|
+ var modalInstance = $modal.open({
|
|
223
|
+ templateUrl: 'assets/views/delete.html',
|
|
224
|
+ controller: function ($scope, $modalInstance) {
|
|
225
|
+ $scope.ok = function () {
|
|
226
|
+ $modalInstance.close(data);
|
|
227
|
+ };
|
|
228
|
+ $scope.cancel = function () {
|
|
229
|
+ $modalInstance.dismiss('cancel');
|
|
230
|
+ };
|
|
231
|
+ $scope.title = '单位删除';
|
|
232
|
+ $scope.connect = '是否删除该单位'
|
|
233
|
+ },
|
|
234
|
+ size: 'sm'
|
|
235
|
+ });
|
|
236
|
+ modalInstance.result.then(function (selectedItem) {
|
|
237
|
+ if (selectedItem) {
|
|
238
|
+ if (selectedItem.id) {
|
|
239
|
+ var fildata = [selectedItem.id];
|
|
240
|
+ api_user_data.rmvData('phoneUnit', fildata).then(function (response) {
|
|
241
|
+ if (response) {
|
|
242
|
+ if (response.status == 200) {
|
|
243
|
+ $scope.outplace = [];
|
|
244
|
+ $scope.areaname = "";
|
|
245
|
+ $scope.outarea.splice(index, 1);
|
|
246
|
+ SweetAlert.swal({
|
|
247
|
+ title: "删除成功!",
|
|
248
|
+ type: "success"
|
|
249
|
+ })
|
|
250
|
+ } else {
|
|
251
|
+ SweetAlert.swal({
|
|
252
|
+ title: "删除失败!",
|
|
253
|
+ text: response.msg || '',
|
|
254
|
+ type: "error"
|
|
255
|
+ })
|
|
256
|
+ }
|
|
257
|
+ }
|
|
258
|
+ })
|
|
259
|
+ }
|
|
260
|
+ }
|
|
261
|
+ })
|
|
262
|
+ }
|
|
263
|
+ }
|
|
264
|
+ // 编辑部门
|
|
265
|
+ $scope.editPlace = function (data) {
|
|
266
|
+ var modalInstance = $modal.open({
|
|
267
|
+ templateUrl: 'assets/views/system/tpl/department.html',
|
|
268
|
+ controller: function ($scope, scope, $modalInstance, api_user_data) {
|
|
269
|
+ $scope.title = "修改部门";
|
|
270
|
+ $scope.check = {
|
|
271
|
+ unit: data.unit,
|
|
272
|
+ dept: data.dept,
|
|
273
|
+ phone: data.phone,
|
|
274
|
+ address: data.address
|
|
275
|
+ }
|
|
276
|
+ $scope.outarea = scope.outarea;
|
|
277
|
+ $scope.cancel = function () {
|
|
278
|
+ $modalInstance.dismiss('cancel');
|
|
279
|
+ };
|
|
280
|
+ $scope.ok = function (check) {
|
|
281
|
+ if (true) {
|
|
282
|
+ if (check.dept && check.phone) {
|
|
283
|
+ $modalInstance.close(check);
|
|
284
|
+ } else {
|
|
285
|
+ SweetAlert.swal({
|
|
286
|
+ title: "编辑失败!",
|
|
287
|
+ text: "请填写必填项",
|
|
288
|
+ type: "error"
|
|
289
|
+ })
|
|
290
|
+ }
|
|
291
|
+ } else {
|
|
292
|
+ $modalInstance.dismiss('cancel');
|
|
293
|
+ }
|
|
294
|
+ }
|
|
295
|
+ },
|
|
296
|
+ resolve: {
|
|
297
|
+ scope: function () {
|
|
298
|
+ return $scope;
|
|
299
|
+ }
|
|
300
|
+ }
|
|
301
|
+ });
|
|
302
|
+ modalInstance.result.then(function (check) {
|
|
303
|
+ if (check) {
|
|
304
|
+ var fildata = {
|
|
305
|
+ "phoneDirectory": {
|
|
306
|
+ "dept": check.dept,
|
|
307
|
+ "address": check.address,
|
|
308
|
+ "phone": check.phone,
|
|
309
|
+ "unit": {
|
|
310
|
+ "id": check.unit.id
|
|
311
|
+ },
|
|
312
|
+ "deleteFlag": 0,
|
|
313
|
+ "id": data.id
|
|
314
|
+ }
|
|
315
|
+ }
|
|
316
|
+ api_user_data.addData('phoneDirectory', fildata).then(function (response) {
|
|
317
|
+ if (response) {
|
|
318
|
+ if (response.data && response.data.id) {
|
|
319
|
+ SweetAlert.swal({
|
|
320
|
+ title: "修改成功!",
|
|
321
|
+ type: "success"
|
|
322
|
+ }, function () {
|
|
323
|
+ $scope.freshenplace($scope.areaData.id);
|
|
324
|
+ })
|
|
325
|
+ } else {
|
|
326
|
+ SweetAlert.swal({
|
|
327
|
+ title: "修改失败!",
|
|
328
|
+ text: response.msg || '',
|
|
329
|
+ type: "error"
|
|
330
|
+ })
|
|
331
|
+ }
|
|
332
|
+ }
|
|
333
|
+ })
|
|
334
|
+ }
|
|
335
|
+ })
|
|
336
|
+ }
|
|
337
|
+ // 新增部门
|
|
338
|
+ $scope.addplace = function (area) {
|
|
339
|
+ var modalInstance = $modal.open({
|
|
340
|
+ templateUrl: 'assets/views/system/tpl/department.html',
|
|
341
|
+ controller: function ($scope, scope, $modalInstance, api_user_data) {
|
|
342
|
+ $scope.title = "新增部门";
|
|
343
|
+ if (area !== undefined) {
|
|
344
|
+ $scope.check = { unit: area }
|
|
345
|
+ } else {
|
|
346
|
+ $scope.check = {}
|
|
347
|
+ }
|
|
348
|
+ $scope.outarea = scope.outarea;
|
|
349
|
+ $scope.cancel = function () {
|
|
350
|
+ $modalInstance.dismiss('cancel');
|
|
351
|
+ };
|
|
352
|
+ $scope.ok = function (check) {
|
|
353
|
+ if (check && check.unit && check.dept && check.phone) {
|
|
354
|
+ console.log(check, 9999)
|
|
355
|
+ $modalInstance.close(check);
|
|
356
|
+ } else {
|
|
357
|
+ SweetAlert.swal({
|
|
358
|
+ title: "新增失败!",
|
|
359
|
+ text: "请填写必填项",
|
|
360
|
+ type: "error"
|
|
361
|
+ })
|
|
362
|
+ }
|
|
363
|
+ }
|
|
364
|
+ },
|
|
365
|
+ resolve: {
|
|
366
|
+ scope: function () {
|
|
367
|
+ return $scope;
|
|
368
|
+ }
|
|
369
|
+ }
|
|
370
|
+ });
|
|
371
|
+ modalInstance.result.then(function (check) {
|
|
372
|
+ if (check) {
|
|
373
|
+ var fildata = {
|
|
374
|
+ "phoneDirectory": {
|
|
375
|
+ "dept": check.dept,
|
|
376
|
+ "phone": check.phone,
|
|
377
|
+ "address": check.address
|
|
378
|
+ }
|
|
379
|
+ }
|
|
380
|
+ if (check.unit) {
|
|
381
|
+ fildata.phoneDirectory.unit = {
|
|
382
|
+ "id": check.unit.id
|
|
383
|
+ }
|
|
384
|
+ }
|
|
385
|
+ api_user_data.addData('phoneDirectory', fildata).then(function (response) {
|
|
386
|
+ if (response) {
|
|
387
|
+ if (response.status == 200) {
|
|
388
|
+ SweetAlert.swal({
|
|
389
|
+ title: "新增成功!",
|
|
390
|
+ type: "success"
|
|
391
|
+ }, function () {
|
|
392
|
+ $scope.freshenplace($scope.areaData.id);
|
|
393
|
+ })
|
|
394
|
+ } else {
|
|
395
|
+ SweetAlert.swal({
|
|
396
|
+ title: "新增失败!",
|
|
397
|
+ text: response.msg || '',
|
|
398
|
+ type: "error"
|
|
399
|
+ })
|
|
400
|
+ }
|
|
401
|
+ }
|
|
402
|
+ })
|
|
403
|
+ }
|
|
404
|
+ })
|
|
405
|
+ }
|
|
406
|
+ //删除部门
|
|
407
|
+ $scope.closeplace = function (index, data) {
|
|
408
|
+ if (!data.id) {
|
|
409
|
+ $scope.cancles = true;
|
|
410
|
+ $scope.outplace.splice(index, 1);
|
|
411
|
+ } else {
|
|
412
|
+
|
|
413
|
+ var rmvList = data;
|
|
414
|
+ var modalInstance = $modal.open({
|
|
415
|
+ templateUrl: 'assets/views/delete.html',
|
|
416
|
+ controller: function ($scope, $modalInstance) {
|
|
417
|
+ $scope.ok = function () {
|
|
418
|
+ $modalInstance.close(data);
|
|
419
|
+ };
|
|
420
|
+ $scope.cancel = function () {
|
|
421
|
+ $modalInstance.dismiss('cancel');
|
|
422
|
+ };
|
|
423
|
+ $scope.title = '部门删除';
|
|
424
|
+ $scope.connect = '是否删除该部门'
|
|
425
|
+ },
|
|
426
|
+ size: 'sm'
|
|
427
|
+ });
|
|
428
|
+ modalInstance.result.then(function (selectedItem) {
|
|
429
|
+ if (selectedItem) {
|
|
430
|
+ if (selectedItem.id) {
|
|
431
|
+ var fildata = [selectedItem.id];
|
|
432
|
+ api_user_data.rmvData('phoneDirectory', fildata).then(function (response) {
|
|
433
|
+ if (response) {
|
|
434
|
+ if (response.status == 200) {
|
|
435
|
+ $scope.outplace.splice(index, 1);
|
|
436
|
+ SweetAlert.swal({
|
|
437
|
+ title: "删除成功!",
|
|
438
|
+ type: "success"
|
|
439
|
+ })
|
|
440
|
+ } else {
|
|
441
|
+ SweetAlert.swal({
|
|
442
|
+ title: "删除失败!",
|
|
443
|
+ type: "error"
|
|
444
|
+ })
|
|
445
|
+ }
|
|
446
|
+ }
|
|
447
|
+ })
|
|
448
|
+ }
|
|
449
|
+ }
|
|
450
|
+ })
|
|
451
|
+ }
|
|
452
|
+ }
|
|
453
|
+
|
|
454
|
+ //导入
|
|
455
|
+
|
|
456
|
+ $scope.importopen = function () { //导入触发事件
|
|
457
|
+ var modalInstance = $modal.open({
|
|
458
|
+ templateUrl: 'assets/views/import.html',
|
|
459
|
+ controller: function ($scope, $modalInstance, FileUploader) {
|
|
460
|
+ var importUploader = $scope.importUploader = new FileUploader({
|
|
461
|
+ url: api_user_data.importData().getRequestedUrl(),
|
|
462
|
+ });
|
|
463
|
+ importUploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/, filter, options) {
|
|
464
|
+ console.info('onWhenAddingFileFailed', item, filter, options);
|
|
465
|
+ };
|
|
466
|
+ importUploader.onAfterAddingFile = function (fileItem) {
|
|
467
|
+ console.info('onAfterAddingFile', fileItem);
|
|
468
|
+ };
|
|
469
|
+ importUploader.onAfterAddingAll = function (addedFileItems) {
|
|
470
|
+ console.info('onAfterAddingAll', addedFileItems);
|
|
471
|
+ };
|
|
472
|
+
|
|
473
|
+ importUploader.onProgressItem = function (fileItem, progress) {
|
|
474
|
+ console.info('onProgressItem', fileItem, progress);
|
|
475
|
+ };
|
|
476
|
+ importUploader.onProgressAll = function (progress) {
|
|
477
|
+ console.info('onProgressAll', progress);
|
|
478
|
+ };
|
|
479
|
+ importUploader.onSuccessItem = function (fileItem, response, status, headers) {
|
|
480
|
+ if (response.status == 200) {
|
|
481
|
+ SweetAlert.swal({
|
|
482
|
+ title: "导入成功!",
|
|
483
|
+ confirmButtonColor: "#007AFF",
|
|
484
|
+ type: "success"
|
|
485
|
+ }, function () {
|
|
486
|
+ // $scope.ldloading.contract_overlay = false;
|
|
487
|
+ $rootScope.isMask = false;
|
|
488
|
+ $scope.refreshData('expand-right', defaultFilterData);
|
|
489
|
+ });
|
|
490
|
+ } else {
|
|
491
|
+ // $scope.ldloading.contract_overlay = false;
|
|
492
|
+ $rootScope.isMask = false;
|
|
493
|
+ SweetAlert.swal({
|
|
494
|
+ title: "导入失败!",
|
|
495
|
+ text: response.error,
|
|
496
|
+ type: "error"
|
|
497
|
+ })
|
|
498
|
+ }
|
|
499
|
+
|
|
500
|
+ console.info('onSuccessItem', fileItem, response, status, headers);
|
|
501
|
+
|
|
502
|
+ };
|
|
503
|
+ importUploader.onErrorItem = function (fileItem, response, status, headers) {
|
|
504
|
+ console.info('onErrorItem', fileItem, response, status, headers);
|
|
505
|
+ SweetAlert.swal({
|
|
506
|
+ title: "系统错误!",
|
|
507
|
+ text: "系统错误,请稍候重试!",
|
|
508
|
+ type: "error"
|
|
509
|
+ });
|
|
510
|
+ };
|
|
511
|
+ importUploader.onCancelItem = function (fileItem, response, status, headers) {
|
|
512
|
+ console.info('onCancelItem', fileItem, response, status, headers);
|
|
513
|
+ };
|
|
514
|
+ importUploader.onCompleteItem = function (fileItem, response, status, headers) {
|
|
515
|
+ console.info('onCompleteItem', fileItem, response, status, headers);
|
|
516
|
+ };
|
|
517
|
+ importUploader.onCompleteAll = function () {
|
|
518
|
+ console.info('onCompleteAll');
|
|
519
|
+ };
|
|
520
|
+ $scope.ldloading = {};
|
|
521
|
+ $rootScope.isMask = false;
|
|
522
|
+ $scope.import = function (style) {
|
|
523
|
+ // $scope.ldloading[style.replace('-', '_')] = true;
|
|
524
|
+ $modalInstance.dismiss('cancel');
|
|
525
|
+ $rootScope.isMask = true;
|
|
526
|
+ importUploader.onBeforeUploadItem = function (item) {
|
|
527
|
+ angular.extend(item.headers, $rootScope.getSession());
|
|
528
|
+ item.formData.push({
|
|
529
|
+ 'filename': item.file.name
|
|
530
|
+ });
|
|
531
|
+ item.formData.push({
|
|
532
|
+ 'type': "areaPlace"
|
|
533
|
+ });
|
|
534
|
+ console.info('onBeforeUploadItem', item);
|
|
535
|
+ };
|
|
536
|
+ importUploader.uploadAll();
|
|
537
|
+ }
|
|
538
|
+ $scope.cancel = function () {
|
|
539
|
+ $modalInstance.dismiss('cancel');
|
|
540
|
+ };
|
|
541
|
+ },
|
|
542
|
+ size: 'sm',
|
|
543
|
+ resolve: {
|
|
544
|
+ importUploader: function () {
|
|
545
|
+ return $scope.importUploader;
|
|
546
|
+ }
|
|
547
|
+ }
|
|
548
|
+ });
|
|
549
|
+ modalInstance.result.then(function (selectedItem) {
|
|
550
|
+ if (selectedItem) { }
|
|
551
|
+ })
|
|
552
|
+ }
|
|
553
|
+ //导出
|
|
554
|
+ $scope.openmodel = function () {
|
|
555
|
+ // var modalInstance = $modal.open({
|
|
556
|
+ // templateUrl: 'assets/views/system/tpl/getdown.html',
|
|
557
|
+ // controller: function($scope, $modalInstance) {
|
|
558
|
+ // $scope.key = {};
|
|
559
|
+ // $scope.onChange = function(key) {
|
|
560
|
+ // $scope.key = key;
|
|
561
|
+ // }
|
|
562
|
+ // // $scope.downmodel = [{ id: 1, name: "EXCEL2003版(xls)" }, { id: 2, name: "EXCEL2007及以上版(xlsx)" }]
|
|
563
|
+ // $scope.ok = function() {
|
|
564
|
+ // $modalInstance.close($scope.key);
|
|
565
|
+ // };
|
|
566
|
+ // $scope.cancel = function() {
|
|
567
|
+ // $modalInstance.dismiss('cancel');
|
|
568
|
+ // };
|
|
569
|
+ // },
|
|
570
|
+ // size: 'sm',
|
|
571
|
+ // });
|
|
572
|
+ // modalInstance.result.then(function(selectedItem) {
|
|
573
|
+ // if (selectedItem) {
|
|
574
|
+ // var selectedItemId = "";
|
|
575
|
+ // if (selectedItem.id == 2) {
|
|
576
|
+ // selectedItemId = ".xlsx";
|
|
577
|
+ // }
|
|
578
|
+ // var type = "areaPlace";
|
|
579
|
+ // var month = 0;
|
|
580
|
+ $http({
|
|
581
|
+ url: api_user_data.downDataModel("areaPlace", 0).getRequestedUrl(),
|
|
582
|
+ method: 'GET',
|
|
583
|
+ headers: {
|
|
584
|
+ 'Accept': '*/*'
|
|
585
|
+ },
|
|
586
|
+ responseType: 'arraybuffer'
|
|
587
|
+ }).success(function (data, status, headers, config) {
|
|
588
|
+ var file = new Blob([data], {
|
|
589
|
+ // type : 'application/octet-stream'
|
|
590
|
+ type: 'application/vnd.ms-excel'
|
|
591
|
+ });
|
|
592
|
+ //trick to download store a file having its URL
|
|
593
|
+ var fileURL = URL.createObjectURL(file);
|
|
594
|
+ var a = document.createElement('a');
|
|
595
|
+ a.href = fileURL;
|
|
596
|
+ a.target = '_blank';
|
|
597
|
+ a.download = "单位部门.xlsx";
|
|
598
|
+ document.body.appendChild(a);
|
|
599
|
+ a.click();
|
|
600
|
+ }).error(function (data, status, headers, config) {
|
|
601
|
+ console.log(data);
|
|
602
|
+ });
|
|
603
|
+ }
|
|
604
|
+ // });
|
|
605
|
+ // }
|
|
606
|
+
|
|
607
|
+ // 2021
|
|
608
|
+ //导入模板
|
|
609
|
+ $scope.importDataTpl = function () {
|
|
610
|
+ var wt_url = api_user_data.importData1('areaPlace').getRequestedUrl();
|
|
611
|
+ var form = new FormData();
|
|
612
|
+ var file = document.getElementById("importTplIpt").files[0];
|
|
613
|
+ form.append('filename', file.name)
|
|
614
|
+ form.append('file', file);
|
|
615
|
+ console.log(document.getElementById("importTplIpt").files)
|
|
616
|
+ $http({
|
|
617
|
+ method: 'POST',
|
|
618
|
+ url: wt_url,
|
|
619
|
+ data: form,
|
|
620
|
+ headers: { 'Content-Type': undefined },
|
|
621
|
+ transformRequest: angular.identity
|
|
622
|
+ }).success(function (data) {
|
|
623
|
+ document.getElementById("importTplIpt").outerHTML = document.getElementById("importTplIpt").outerHTML;
|
|
624
|
+ if (data.status == 200) {
|
|
625
|
+ SweetAlert.swal({
|
|
626
|
+ title: "导入成功",
|
|
627
|
+ confirmButtonColor: "#007AFF",
|
|
628
|
+ type: "success"
|
|
629
|
+ }, function (flag) {
|
|
630
|
+ $scope.freshenarea();
|
|
631
|
+ $scope.freshenplace();
|
|
632
|
+ });
|
|
633
|
+ } else {
|
|
634
|
+ SweetAlert.swal({
|
|
635
|
+ title: "导入失败",
|
|
636
|
+ text: data.error,
|
|
637
|
+ type: "error"
|
|
638
|
+ });
|
|
639
|
+ }
|
|
640
|
+ }).error(function (data) {
|
|
641
|
+ document.getElementById("importTplIpt").outerHTML = document.getElementById("importTplIpt").outerHTML;
|
|
642
|
+ SweetAlert.swal({
|
|
643
|
+ title: "导入失败",
|
|
644
|
+ text: data.error,
|
|
645
|
+ type: "error"
|
|
646
|
+ });
|
|
647
|
+ })
|
|
648
|
+ };
|
|
649
|
+ //导出模板
|
|
650
|
+ $scope.exportDataTpl = function () {
|
|
651
|
+ var wt_url = api_cmdb2.exportData1("downDataModels/operationSystem", {}).getRequestedUrl()
|
|
652
|
+ $http({
|
|
653
|
+ url: wt_url,
|
|
654
|
+ method: 'POST',
|
|
655
|
+ headers: {
|
|
656
|
+ 'Accept': '*/*'
|
|
657
|
+ },
|
|
658
|
+ responseType: 'arraybuffer'
|
|
659
|
+ }).success(function (data, status, headers, config) {
|
|
660
|
+ var fileName = headers("Content-Disposition").split(";")[1].split("filename=")[1];
|
|
661
|
+ var file = new Blob([data], {
|
|
662
|
+ type: 'application/vnd.ms-excel'
|
|
663
|
+ });
|
|
664
|
+ var fileURL = URL.createObjectURL(file);
|
|
665
|
+ var a = document.createElement('a');
|
|
666
|
+ a.href = fileURL;
|
|
667
|
+ a.target = '_blank';
|
|
668
|
+ a.download = decodeURIComponent(fileName);
|
|
669
|
+ document.body.appendChild(a);
|
|
670
|
+ a.click();
|
|
671
|
+ }).error(function (data, status, headers, config) { });
|
|
672
|
+ };
|
|
673
|
+}]);
|