|
@@ -0,0 +1,736 @@
|
|
1
|
+"use strict";
|
|
2
|
+/**
|
|
3
|
+ * controller for User Profile Example
|
|
4
|
+ */
|
|
5
|
+app.controller("faultConsumablesCtrl", [
|
|
6
|
+ "$rootScope",
|
|
7
|
+ "$scope",
|
|
8
|
+ "$state",
|
|
9
|
+ "$timeout",
|
|
10
|
+ "$interval",
|
|
11
|
+ "$modal",
|
|
12
|
+ "SweetAlert",
|
|
13
|
+ "i18nService",
|
|
14
|
+ "uiGridConstants",
|
|
15
|
+ "uiGridGroupingConstants",
|
|
16
|
+ "Restangular",
|
|
17
|
+ "api_user_data",
|
|
18
|
+ 'api_bpm_data',
|
|
19
|
+ function (
|
|
20
|
+ $rootScope,
|
|
21
|
+ $scope,
|
|
22
|
+ $state,
|
|
23
|
+ $timeout,
|
|
24
|
+ $interval,
|
|
25
|
+ $modal,
|
|
26
|
+ SweetAlert,
|
|
27
|
+ i18nService,
|
|
28
|
+ uiGridConstants,
|
|
29
|
+ uiGridGroupingConstants,
|
|
30
|
+ Restangular,
|
|
31
|
+ api_user_data,
|
|
32
|
+ api_bpm_data
|
|
33
|
+ ) {
|
|
34
|
+ $scope.langs = i18nService.getAllLangs();
|
|
35
|
+ $scope.lang = "zh-cn";
|
|
36
|
+ i18nService.setCurrentLang($scope.lang);
|
|
37
|
+ var loginUser = $rootScope.user;
|
|
38
|
+ $scope.xinzeng = false;
|
|
39
|
+ $scope.shanchu = false;
|
|
40
|
+ $scope.bianji = false;
|
|
41
|
+ for (var i = 0; i < loginUser.menu.length; i++) {
|
|
42
|
+ if (loginUser.menu[i].link == "responsibilityDept_add") {
|
|
43
|
+ $scope.xinzeng = true;
|
|
44
|
+ }
|
|
45
|
+ if (loginUser.menu[i].link == "responsibilityDept_del") {
|
|
46
|
+ $scope.shanchu = true;
|
|
47
|
+ }
|
|
48
|
+ if (loginUser.menu[i].link == "responsibilityDept_edit") {
|
|
49
|
+ $scope.bianji = true;
|
|
50
|
+ }
|
|
51
|
+ }
|
|
52
|
+ $scope.gridOptions = {};
|
|
53
|
+ $scope.gridOptions.data = "myData";
|
|
54
|
+ $scope.gridOptions.enableColumnResizing = true;
|
|
55
|
+ $scope.gridOptions.enableFiltering = true;
|
|
56
|
+ $scope.gridOptions.enableGridMenu = true;
|
|
57
|
+ $scope.gridOptions.enableRowSelection = true;
|
|
58
|
+ $scope.gridOptions.showGridFooter = true;
|
|
59
|
+ $scope.gridOptions.showColumnFooter = false;
|
|
60
|
+ $scope.gridOptions.fastWatch = true;
|
|
61
|
+ $scope.gridOptions.useExternalFiltering = true;
|
|
62
|
+ $scope.gridOptions.useExternalPagination = true;
|
|
63
|
+ $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
|
|
64
|
+ $scope.gridOptions.paginationPageSize = 10;
|
|
65
|
+ $scope.gridOptions.multiSelect = false;
|
|
66
|
+
|
|
67
|
+ $scope.gridOptions.rowTemplate =
|
|
68
|
+ '<div ng-dblclick="grid.appScope.onDblClick(row)" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" ui-grid-one-bind-id-grid="rowRenderIndex + \'-\' + col.uid + \'-cell\'" class="ui-grid-cell" ng-class="{ \'ui-grid-row-header-cell\': col.isRowHeader }" role="{{col.isRowHeader ? \'rowheader\' : \'gridcell\'}}" ui-grid-cell></div>';
|
|
69
|
+
|
|
70
|
+ $scope.gridOptions.rowIdentity = function (row) {
|
|
71
|
+ return row.id;
|
|
72
|
+ };
|
|
73
|
+ $scope.gridOptions.getRowIdentity = function (row) {
|
|
74
|
+ return row.id;
|
|
75
|
+ };
|
|
76
|
+
|
|
77
|
+ $scope.gridOptions.columnDefs = [
|
|
78
|
+ {
|
|
79
|
+ name: "item",
|
|
80
|
+ displayName: "序号",
|
|
81
|
+ width: 50,
|
|
82
|
+ enableFiltering: false,
|
|
83
|
+ },
|
|
84
|
+ {
|
|
85
|
+ name: "content",
|
|
86
|
+ displayName: "别名",
|
|
87
|
+ width: "30%",
|
|
88
|
+ enableFiltering: false,
|
|
89
|
+ },
|
|
90
|
+ {
|
|
91
|
+ name: "category.category",
|
|
92
|
+ displayName: "故障现象",
|
|
93
|
+ width: "30%",
|
|
94
|
+ enableFiltering: false,
|
|
95
|
+ },
|
|
96
|
+ {
|
|
97
|
+ name: "操作",
|
|
98
|
+ cellTemplate:
|
|
99
|
+ '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
|
|
100
|
+ // '<a ng-click="grid.appScope.saveData(row.entity)" tooltip="编辑" tooltip-placement="right">' +
|
|
101
|
+ // '<i class="fa fa-pencil-square-o"></i></a>'+
|
|
102
|
+ '<a ng-click="grid.appScope.saveData(row.entity)" ng-show="grid.appScope.bianji" class="bianjifont">编辑</a>' +
|
|
103
|
+ "</div></div>",
|
|
104
|
+ enableFiltering: false,
|
|
105
|
+ },
|
|
106
|
+ ];
|
|
107
|
+ $scope.transferDept = function (data) {
|
|
108
|
+ if (data) {
|
|
109
|
+ return data;
|
|
110
|
+ } else {
|
|
111
|
+ return "无";
|
|
112
|
+ }
|
|
113
|
+ };
|
|
114
|
+ function selectItem(pmodel, childrens) {
|
|
115
|
+ if (angular.isArray(pmodel)) {
|
|
116
|
+ angular.forEach(pmodel, function (index) {
|
|
117
|
+ if (index && index.id) {
|
|
118
|
+ angular.forEach(childrens, function (item) {
|
|
119
|
+ if (item.id == index.id) {
|
|
120
|
+ item.selected = true;
|
|
121
|
+ }
|
|
122
|
+ if (item && item.children) {
|
|
123
|
+ selectItem(pmodel, item.children);
|
|
124
|
+ }
|
|
125
|
+ });
|
|
126
|
+ }
|
|
127
|
+ });
|
|
128
|
+ } else {
|
|
129
|
+ if (pmodel && pmodel.id) {
|
|
130
|
+ angular.forEach(childrens, function (item, index) {
|
|
131
|
+ if (item.id == pmodel.id) {
|
|
132
|
+ item.selected = true;
|
|
133
|
+ }
|
|
134
|
+ if (item && item.children) {
|
|
135
|
+ selectItem(pmodel, item.children);
|
|
136
|
+ }
|
|
137
|
+ });
|
|
138
|
+ }
|
|
139
|
+ }
|
|
140
|
+ }
|
|
141
|
+ $scope.saveData = function (selectdata) {
|
|
142
|
+ console.log(selectdata);
|
|
143
|
+ var modalInstance = $modal.open({
|
|
144
|
+ templateUrl: "assets/views/system/tpl/commonFaultSymptomschange.html",
|
|
145
|
+ controller: function ($scope, scope, $modalInstance, api_user_data,api_bpm_data) {
|
|
146
|
+ selectdata.category.selected = true;
|
|
147
|
+ $scope.deptdata = {
|
|
148
|
+ id: selectdata.id,
|
|
149
|
+ content: selectdata.content,
|
|
150
|
+ category: selectdata.category
|
|
151
|
+ };
|
|
152
|
+ $scope.categoryList = [];
|
|
153
|
+ $scope.title = "常用故障现象修改";
|
|
154
|
+ // --------------------
|
|
155
|
+ $scope.select_treedata = [];
|
|
156
|
+ $scope.try_async_load = function (s, fn) {
|
|
157
|
+ if (s) {
|
|
158
|
+ var filterKeyword = s.filterKeyword;
|
|
159
|
+ }
|
|
160
|
+ var postData = {
|
|
161
|
+ idx: 0,
|
|
162
|
+ sum: 1000,
|
|
163
|
+ };
|
|
164
|
+ if (filterKeyword) {
|
|
165
|
+ postData.incidentcategory = {
|
|
166
|
+ selectType: "pinyin_qs",
|
|
167
|
+ category: filterKeyword,
|
|
168
|
+ };
|
|
169
|
+ }
|
|
170
|
+ $scope.my_data = [];
|
|
171
|
+ $scope.doing_async = true;
|
|
172
|
+ api_bpm_data
|
|
173
|
+ .fetchDataList("incidentcategory", postData)
|
|
174
|
+ .then(function (response) {
|
|
175
|
+ if (response.status == 200) {
|
|
176
|
+ var data = response.list;
|
|
177
|
+ if (filterKeyword) {
|
|
178
|
+ data.forEach((e) => {
|
|
179
|
+ e.isExpanded = true;
|
|
180
|
+ });
|
|
181
|
+ var li = transform(data).children;
|
|
182
|
+ console.log(li);
|
|
183
|
+ fn(li);
|
|
184
|
+ return;
|
|
185
|
+ } else {
|
|
186
|
+ var objects = [];
|
|
187
|
+ for (var i = 0; i < data.length; i++) {
|
|
188
|
+ var object = {};
|
|
189
|
+ object.id = data[i].id;
|
|
190
|
+ object.parent = data[i].parent;
|
|
191
|
+ object.category = data[i].category;
|
|
192
|
+ object.isExpanded = true;
|
|
193
|
+ objects.push(object);
|
|
194
|
+ }
|
|
195
|
+ $scope.my_data = convertParentToChildList(objects);
|
|
196
|
+ $scope.select_treedata = angular.copy($scope.my_data);
|
|
197
|
+ }
|
|
198
|
+ if ($scope.my_data.length > 0) {
|
|
199
|
+ $scope.doing_async = false;
|
|
200
|
+ }
|
|
201
|
+ selectItem(selectdata.category,$scope.select_treedata);
|
|
202
|
+ $scope.deptdata.category = selectdata.category;
|
|
203
|
+ } else {
|
|
204
|
+ SweetAlert.swal({
|
|
205
|
+ title: "系统错误!",
|
|
206
|
+ text: "请刷新重试!",
|
|
207
|
+ type: "error",
|
|
208
|
+ });
|
|
209
|
+ }
|
|
210
|
+ });
|
|
211
|
+ };
|
|
212
|
+ $scope.try_async_load();
|
|
213
|
+ // --------------------
|
|
214
|
+ $scope.cancel = function () {
|
|
215
|
+ $modalInstance.dismiss("cancel");
|
|
216
|
+ };
|
|
217
|
+ // 保存
|
|
218
|
+ $scope.savercode = function (deptdata) {
|
|
219
|
+ if (
|
|
220
|
+ deptdata &&
|
|
221
|
+ deptdata.content &&
|
|
222
|
+ deptdata.category
|
|
223
|
+ ) {
|
|
224
|
+ var fildata = {
|
|
225
|
+ incidentCategoryContent: {
|
|
226
|
+ id: deptdata.id,
|
|
227
|
+ deleteFlag: 0,
|
|
228
|
+ content: deptdata.content,
|
|
229
|
+ category: deptdata.category,
|
|
230
|
+ },
|
|
231
|
+ };
|
|
232
|
+ api_user_data
|
|
233
|
+ .updData("incidentCategoryContent", fildata)
|
|
234
|
+ .then(function (response) {
|
|
235
|
+ if (response) {
|
|
236
|
+ if (response.status == 200) {
|
|
237
|
+ SweetAlert.swal(
|
|
238
|
+ {
|
|
239
|
+ title: "修改成功!",
|
|
240
|
+ type: "success",
|
|
241
|
+ },
|
|
242
|
+ function () {
|
|
243
|
+ scope.refreshData("expand-right", scope.fileData);
|
|
244
|
+ }
|
|
245
|
+ );
|
|
246
|
+ } else if (response.status == 500) {
|
|
247
|
+ SweetAlert.swal(
|
|
248
|
+ {
|
|
249
|
+ title: "修改失败!",
|
|
250
|
+ text: "该故障现象已存在",
|
|
251
|
+ type: "error",
|
|
252
|
+ },
|
|
253
|
+ function () {
|
|
254
|
+ scope.refreshData("expand-right", scope.fileData);
|
|
255
|
+ }
|
|
256
|
+ );
|
|
257
|
+ } else {
|
|
258
|
+ SweetAlert.swal(
|
|
259
|
+ {
|
|
260
|
+ title: "修改失败!",
|
|
261
|
+ type: "error",
|
|
262
|
+ },
|
|
263
|
+ function () {
|
|
264
|
+ scope.refreshData("expand-right", scope.fileData);
|
|
265
|
+ }
|
|
266
|
+ );
|
|
267
|
+ }
|
|
268
|
+ $modalInstance.close();
|
|
269
|
+ } else {
|
|
270
|
+ SweetAlert.swal(
|
|
271
|
+ {
|
|
272
|
+ title: "修改失败!",
|
|
273
|
+ type: "error",
|
|
274
|
+ },
|
|
275
|
+ function () {
|
|
276
|
+ scope.refreshData("expand-right", scope.fileData);
|
|
277
|
+ }
|
|
278
|
+ );
|
|
279
|
+ }
|
|
280
|
+ });
|
|
281
|
+ } else {
|
|
282
|
+ SweetAlert.swal(
|
|
283
|
+ {
|
|
284
|
+ title: "修改失败!",
|
|
285
|
+ text: "请填写必填项!",
|
|
286
|
+ type: "error",
|
|
287
|
+ confirmButtonColor: "#DD6B55",
|
|
288
|
+ },
|
|
289
|
+ function () {}
|
|
290
|
+ );
|
|
291
|
+ }
|
|
292
|
+ };
|
|
293
|
+ },
|
|
294
|
+ resolve: {
|
|
295
|
+ scope: function () {
|
|
296
|
+ return $scope;
|
|
297
|
+ },
|
|
298
|
+ },
|
|
299
|
+ });
|
|
300
|
+ };
|
|
301
|
+ function convertListToTree(data, treeMap) {
|
|
302
|
+ var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
|
|
303
|
+ var root = null; //Initially set our loop to null
|
|
304
|
+ var parentNode = null;
|
|
305
|
+ //loop over data
|
|
306
|
+ for (var i = 0; i < data.length; i++) {
|
|
307
|
+ var datum = data[i];
|
|
308
|
+ //each node will have children, so let's give it a "children" poperty
|
|
309
|
+ datum.children = [];
|
|
310
|
+
|
|
311
|
+ //add an entry for this node to the map so that any future children can
|
|
312
|
+ //lookup the parent
|
|
313
|
+ idToNodeMap[datum.id] = datum;
|
|
314
|
+
|
|
315
|
+ //Does this node have a parent?
|
|
316
|
+ if (typeof datum.parent === "undefined" || datum.parent == null) {
|
|
317
|
+ //Doesn't look like it, so this node is the root of the tree
|
|
318
|
+ root = datum;
|
|
319
|
+ treeMap[datum.id] = root;
|
|
320
|
+ } else {
|
|
321
|
+ //This node has a parent, so let's look it up using the id
|
|
322
|
+ parentNode = idToNodeMap[datum.parent.id];
|
|
323
|
+
|
|
324
|
+ //We don't need this property, so let's delete it.
|
|
325
|
+ delete datum.parent;
|
|
326
|
+
|
|
327
|
+ //Let's add the current node as a child of the parent node.
|
|
328
|
+ parentNode.children.push(datum);
|
|
329
|
+ }
|
|
330
|
+ }
|
|
331
|
+ return root;
|
|
332
|
+ }
|
|
333
|
+ function convertParentToChildList(data) {
|
|
334
|
+ var treeMap = {};
|
|
335
|
+ var list = [];
|
|
336
|
+ convertListToTree(data, treeMap);
|
|
337
|
+ angular.forEach(treeMap, function (item) {
|
|
338
|
+ list.push(item);
|
|
339
|
+ });
|
|
340
|
+ return list;
|
|
341
|
+ }
|
|
342
|
+ $scope.addData = function () {
|
|
343
|
+ var modalInstance = $modal.open({
|
|
344
|
+ templateUrl: "assets/views/system/tpl/commonFaultSymptomschange.html",
|
|
345
|
+ controller: function ($scope, $modalInstance, api_user_data,api_bpm_data) {
|
|
346
|
+ $scope.deptdata = {
|
|
347
|
+ content: "",
|
|
348
|
+ category: "",
|
|
349
|
+ };
|
|
350
|
+ $scope.title = "常用故障现象新增";
|
|
351
|
+ // --------------------
|
|
352
|
+ $scope.select_treedata = [];
|
|
353
|
+ $scope.try_async_load = function (s, fn) {
|
|
354
|
+ if (s) {
|
|
355
|
+ var filterKeyword = s.filterKeyword;
|
|
356
|
+ }
|
|
357
|
+ var postData = {
|
|
358
|
+ idx: 0,
|
|
359
|
+ sum: 9999,
|
|
360
|
+ incidentcategory: {
|
|
361
|
+ selectType: "pinyin_qs",
|
|
362
|
+ }
|
|
363
|
+ };
|
|
364
|
+ if (filterKeyword) {
|
|
365
|
+ postData.incidentcategory.category = filterKeyword;
|
|
366
|
+ }
|
|
367
|
+ $scope.my_data = [];
|
|
368
|
+ $scope.doing_async = true;
|
|
369
|
+ api_bpm_data
|
|
370
|
+ .fetchDataList("incidentcategory", postData)
|
|
371
|
+ .then(function (response) {
|
|
372
|
+ if (response.status == 200) {
|
|
373
|
+ var data = response.list;
|
|
374
|
+ if (filterKeyword) {
|
|
375
|
+ data.forEach((e) => {
|
|
376
|
+ e.isExpanded = true;
|
|
377
|
+ });
|
|
378
|
+ var li = transform(data).children;
|
|
379
|
+ console.log(li);
|
|
380
|
+ fn(li);
|
|
381
|
+ return;
|
|
382
|
+ } else {
|
|
383
|
+ var objects = [];
|
|
384
|
+ for (var i = 0; i < data.length; i++) {
|
|
385
|
+ var object = {};
|
|
386
|
+ object.id = data[i].id;
|
|
387
|
+ object.parent = data[i].parent;
|
|
388
|
+ object.category = data[i].category;
|
|
389
|
+ object.isExpanded = true;
|
|
390
|
+ objects.push(object);
|
|
391
|
+ }
|
|
392
|
+ $scope.my_data = convertParentToChildList(objects);
|
|
393
|
+ $scope.select_treedata = angular.copy($scope.my_data);
|
|
394
|
+ }
|
|
395
|
+ if ($scope.my_data.length > 0) {
|
|
396
|
+ $scope.doing_async = false;
|
|
397
|
+ }
|
|
398
|
+ } else {
|
|
399
|
+ SweetAlert.swal({
|
|
400
|
+ title: "系统错误!",
|
|
401
|
+ text: "请刷新重试!",
|
|
402
|
+ type: "error",
|
|
403
|
+ });
|
|
404
|
+ }
|
|
405
|
+ });
|
|
406
|
+ };
|
|
407
|
+ $scope.try_async_load();
|
|
408
|
+ // --------------------
|
|
409
|
+ $scope.cancel = function () {
|
|
410
|
+ $modalInstance.dismiss("cancel");
|
|
411
|
+ };
|
|
412
|
+ // 保存
|
|
413
|
+ $scope.savercode = function (deptdata) {
|
|
414
|
+ if (
|
|
415
|
+ deptdata &&
|
|
416
|
+ deptdata.content &&
|
|
417
|
+ deptdata.category
|
|
418
|
+ ) {
|
|
419
|
+ $modalInstance.close(deptdata);
|
|
420
|
+ } else {
|
|
421
|
+ SweetAlert.swal(
|
|
422
|
+ {
|
|
423
|
+ title: "新增失败!",
|
|
424
|
+ text: "请填写必填项!",
|
|
425
|
+ type: "error",
|
|
426
|
+ confirmButtonColor: "#DD6B55",
|
|
427
|
+ },
|
|
428
|
+ function () {}
|
|
429
|
+ );
|
|
430
|
+ }
|
|
431
|
+ };
|
|
432
|
+ },
|
|
433
|
+ });
|
|
434
|
+ modalInstance.result.then(function (selectedItem) {
|
|
435
|
+ if (selectedItem.content && selectedItem.category) {
|
|
436
|
+ var fildata = {
|
|
437
|
+ incidentCategoryContent: {
|
|
438
|
+ content: selectedItem.content,
|
|
439
|
+ category: selectedItem.category,
|
|
440
|
+ },
|
|
441
|
+ };
|
|
442
|
+ api_user_data
|
|
443
|
+ .addData("incidentCategoryContent", fildata)
|
|
444
|
+ .then(function (response) {
|
|
445
|
+ if (response) {
|
|
446
|
+ if (response.status == 200) {
|
|
447
|
+ SweetAlert.swal(
|
|
448
|
+ {
|
|
449
|
+ title: "新增成功!",
|
|
450
|
+ type: "success",
|
|
451
|
+ },
|
|
452
|
+ function () {
|
|
453
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
454
|
+ }
|
|
455
|
+ );
|
|
456
|
+ } else {
|
|
457
|
+ SweetAlert.swal({
|
|
458
|
+ title: "新增失败!",
|
|
459
|
+ text: response.msg,
|
|
460
|
+ type: "error",
|
|
461
|
+ });
|
|
462
|
+ }
|
|
463
|
+ }
|
|
464
|
+ });
|
|
465
|
+ } else {
|
|
466
|
+ SweetAlert.swal(
|
|
467
|
+ {
|
|
468
|
+ title: "新增失败!",
|
|
469
|
+ text: "请填写必填项!",
|
|
470
|
+ type: "error",
|
|
471
|
+ confirmButtonColor: "#DD6B55",
|
|
472
|
+ },
|
|
473
|
+ function () {}
|
|
474
|
+ );
|
|
475
|
+ }
|
|
476
|
+ });
|
|
477
|
+ };
|
|
478
|
+
|
|
479
|
+ $scope.removeData = function () {
|
|
480
|
+ var modalInstance = $modal.open({
|
|
481
|
+ // templateUrl: 'assets/views/delete.html',
|
|
482
|
+ templateUrl: "assets/views/incident/tpl/acceptTask.tpl.html",
|
|
483
|
+ controller: function ($scope, scope, $modalInstance, api_bpm_data) {
|
|
484
|
+ var rmvList = [];
|
|
485
|
+ $scope.title = "故障现象删除";
|
|
486
|
+ $scope.connect = "确定要删除此故障现象?";
|
|
487
|
+ rmvList.push(scope.selected.items);
|
|
488
|
+ $scope.ok = function () {
|
|
489
|
+ $modalInstance.close(rmvList);
|
|
490
|
+ // }
|
|
491
|
+ };
|
|
492
|
+ $scope.cancel = function () {
|
|
493
|
+ $modalInstance.dismiss("cancel");
|
|
494
|
+ };
|
|
495
|
+ },
|
|
496
|
+ size: "sm",
|
|
497
|
+ resolve: {
|
|
498
|
+ scope: function () {
|
|
499
|
+ return $scope;
|
|
500
|
+ },
|
|
501
|
+ },
|
|
502
|
+ });
|
|
503
|
+ modalInstance.result.then(function (selectedItem) {
|
|
504
|
+ if (selectedItem) {
|
|
505
|
+ if (selectedItem.length > 0) {
|
|
506
|
+ console.log(selectedItem);
|
|
507
|
+ if (
|
|
508
|
+ selectedItem[0].children &&
|
|
509
|
+ selectedItem[0].children.length > 0
|
|
510
|
+ ) {
|
|
511
|
+ SweetAlert.swal({
|
|
512
|
+ title: "该部门存在子类部门",
|
|
513
|
+ text: "请先删除该部门子类部门!",
|
|
514
|
+ type: "error",
|
|
515
|
+ });
|
|
516
|
+ } else {
|
|
517
|
+ api_user_data
|
|
518
|
+ .rmvData("incidentCategoryContent", [selectedItem[0].id])
|
|
519
|
+ .then(function (response) {
|
|
520
|
+ if (response.status == 200) {
|
|
521
|
+ SweetAlert.swal(
|
|
522
|
+ {
|
|
523
|
+ title: "删除成功!",
|
|
524
|
+ type: "success",
|
|
525
|
+ confirmButtonColor: "#007AFF",
|
|
526
|
+ },
|
|
527
|
+ function () {
|
|
528
|
+ $scope.myData = _.reject($scope.myData, function (o) {
|
|
529
|
+ return _.includes(selectedItem, o.id);
|
|
530
|
+ });
|
|
531
|
+ $scope.selected = {
|
|
532
|
+ items: [],
|
|
533
|
+ };
|
|
534
|
+ $scope.gridOptions.totalItems =
|
|
535
|
+ $scope.gridOptions.totalItems - selectedItem.length;
|
|
536
|
+ $scope.gridApi.grid.selection.selectedCount = 0;
|
|
537
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
538
|
+ }
|
|
539
|
+ );
|
|
540
|
+ } else {
|
|
541
|
+ SweetAlert.swal({
|
|
542
|
+ title: "操作异常!",
|
|
543
|
+ text: "系统异常,请稍后重试,或者联系管理员!",
|
|
544
|
+ type: "error",
|
|
545
|
+ });
|
|
546
|
+ }
|
|
547
|
+ });
|
|
548
|
+ }
|
|
549
|
+ }
|
|
550
|
+ }
|
|
551
|
+ });
|
|
552
|
+ };
|
|
553
|
+
|
|
554
|
+ $scope.selected = {
|
|
555
|
+ items: [],
|
|
556
|
+ };
|
|
557
|
+
|
|
558
|
+ $scope.editted = {
|
|
559
|
+ items: [],
|
|
560
|
+ };
|
|
561
|
+
|
|
562
|
+ $scope.gridOptions.onRegisterApi = function (gridApi) {
|
|
563
|
+ $scope.gridApi = gridApi;
|
|
564
|
+ // gridApi.edit.on.afterCellEdit($scope,function(rowEntity, colDef, newValue, oldValue){
|
|
565
|
+ // // console.log(rowEntity);
|
|
566
|
+ // });
|
|
567
|
+ gridApi.pagination.on.paginationChanged(
|
|
568
|
+ $scope,
|
|
569
|
+ function (newPage, pageSize) {
|
|
570
|
+ var filtersData = $scope.memoryfilterData;
|
|
571
|
+ filtersData.idx = newPage - 1;
|
|
572
|
+ filtersData.sum = pageSize;
|
|
573
|
+ $scope.fileData.idx = newPage - 1;
|
|
574
|
+ $scope.fileData.sum = pageSize;
|
|
575
|
+ defaultFilterData = filtersData;
|
|
576
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
577
|
+ }
|
|
578
|
+ );
|
|
579
|
+ gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
|
|
580
|
+ scope.grid.appScope.selected.items = scope.entity;
|
|
581
|
+ });
|
|
582
|
+ };
|
|
583
|
+
|
|
584
|
+ var defaultFilterData = {
|
|
585
|
+ idx: 0,
|
|
586
|
+ sum: 10,
|
|
587
|
+ };
|
|
588
|
+
|
|
589
|
+ $scope.memoryfilterData = {
|
|
590
|
+ idx: 0,
|
|
591
|
+ sum: 10,
|
|
592
|
+ };
|
|
593
|
+ $scope.fileData = {
|
|
594
|
+ idx: 0,
|
|
595
|
+ sum: 10,
|
|
596
|
+ incidentCategoryContent: {},
|
|
597
|
+ };
|
|
598
|
+ $scope.ldloading = {};
|
|
599
|
+ $scope.refreshData = function (style, filterData) {
|
|
600
|
+ $scope.selected.items = {};
|
|
601
|
+ $scope.ldloading[style.replace("-", "_")] = true;
|
|
602
|
+ if (angular.isUndefined(filterData)) {
|
|
603
|
+ filterData = defaultFilterData;
|
|
604
|
+ }
|
|
605
|
+
|
|
606
|
+ $scope.myData = [];
|
|
607
|
+ $scope.selected = { items: [] };
|
|
608
|
+ if ($scope.gridApi) {
|
|
609
|
+ $scope.gridApi.grid.selection.selectedCount = 0;
|
|
610
|
+ }
|
|
611
|
+ filterData = angular.copy(filterData);
|
|
612
|
+ api_user_data.fetchDataList("incidentCategoryContent", filterData).then(
|
|
613
|
+ function (data) {
|
|
614
|
+ var myData = Restangular.stripRestangular(data);
|
|
615
|
+ $scope.gridOptions.totalItems = myData.totalNum;
|
|
616
|
+ $scope.myData = myData.list;
|
|
617
|
+ for (var i = 0; i < $scope.myData.length; i++) {
|
|
618
|
+ $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
|
|
619
|
+ }
|
|
620
|
+ $scope.ldloading[style.replace("-", "_")] = false;
|
|
621
|
+ },
|
|
622
|
+ function () {
|
|
623
|
+ $scope.ldloading[style.replace("-", "_")] = false;
|
|
624
|
+ }
|
|
625
|
+ );
|
|
626
|
+ };
|
|
627
|
+ $scope.refreshData2 = function (style, filterData) {
|
|
628
|
+ $scope.selected.items = {};
|
|
629
|
+ $scope.ldloading[style.replace("-", "_")] = true;
|
|
630
|
+ if (angular.isUndefined(filterData)) {
|
|
631
|
+ filterData = defaultFilterData;
|
|
632
|
+ }
|
|
633
|
+
|
|
634
|
+ $scope.myData = [];
|
|
635
|
+ $scope.selected = { items: [] };
|
|
636
|
+ if ($scope.gridApi) {
|
|
637
|
+ $scope.gridApi.grid.selection.selectedCount = 0;
|
|
638
|
+ }
|
|
639
|
+ filterData = angular.copy(filterData);
|
|
640
|
+ if (filterData.incidentCategoryContent.category) {
|
|
641
|
+ filterData.incidentCategoryContent.category =
|
|
642
|
+ filterData.incidentCategoryContent.category.id;
|
|
643
|
+ }
|
|
644
|
+ api_user_data.fetchDataList("incidentCategoryContent", filterData).then(
|
|
645
|
+ function (data) {
|
|
646
|
+ var myData = Restangular.stripRestangular(data);
|
|
647
|
+ $scope.gridOptions.totalItems = myData.totalNum;
|
|
648
|
+ $scope.myData = myData.list;
|
|
649
|
+ for (var i = 0; i < $scope.myData.length; i++) {
|
|
650
|
+ $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
|
|
651
|
+ }
|
|
652
|
+ $scope.ldloading[style.replace("-", "_")] = false;
|
|
653
|
+ },
|
|
654
|
+ function () {
|
|
655
|
+ $scope.ldloading[style.replace("-", "_")] = false;
|
|
656
|
+ }
|
|
657
|
+ );
|
|
658
|
+ };
|
|
659
|
+ // 搜索
|
|
660
|
+ $scope.searchData = function () {
|
|
661
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
662
|
+ };
|
|
663
|
+ // 清空
|
|
664
|
+ $scope.clean = function () {
|
|
665
|
+ delete $scope.fileData.incidentCategoryContent.content;
|
|
666
|
+ delete $scope.fileData.incidentCategoryContent.category;
|
|
667
|
+ $scope.getCategoryData();
|
|
668
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
669
|
+ };
|
|
670
|
+ // 获取院区下拉
|
|
671
|
+ $scope.model = {};
|
|
672
|
+ $scope.categoryData = [];
|
|
673
|
+ $scope.getCategoryData = function (s, fn) {
|
|
674
|
+ if (s) {
|
|
675
|
+ var filterKeyword = s.filterKeyword;
|
|
676
|
+ }
|
|
677
|
+ var postData = {
|
|
678
|
+ idx: 0,
|
|
679
|
+ sum: 1000,
|
|
680
|
+ };
|
|
681
|
+ if (filterKeyword) {
|
|
682
|
+ postData.incidentcategory = {
|
|
683
|
+ selectType: "pinyin_qs",
|
|
684
|
+ category: filterKeyword,
|
|
685
|
+ };
|
|
686
|
+ }
|
|
687
|
+ $scope.my_data = [];
|
|
688
|
+ $scope.doing_async = true;
|
|
689
|
+ api_bpm_data
|
|
690
|
+ .fetchDataList("incidentcategory", postData)
|
|
691
|
+ .then(function (response) {
|
|
692
|
+ if (response.status == 200) {
|
|
693
|
+ var data = response.list;
|
|
694
|
+ if (filterKeyword) {
|
|
695
|
+ data.forEach((e) => {
|
|
696
|
+ e.isExpanded = true;
|
|
697
|
+ });
|
|
698
|
+ var li = transform(data).children;
|
|
699
|
+ console.log(li);
|
|
700
|
+ fn(li);
|
|
701
|
+ return;
|
|
702
|
+ } else {
|
|
703
|
+ var objects = [];
|
|
704
|
+ for (var i = 0; i < data.length; i++) {
|
|
705
|
+ var object = {};
|
|
706
|
+ object.id = data[i].id;
|
|
707
|
+ object.parent = data[i].parent;
|
|
708
|
+ object.category = data[i].category;
|
|
709
|
+ object.isExpanded = true;
|
|
710
|
+ objects.push(object);
|
|
711
|
+ }
|
|
712
|
+ $scope.my_data = convertParentToChildList(objects);
|
|
713
|
+ $scope.categoryData = angular.copy($scope.my_data);
|
|
714
|
+ }
|
|
715
|
+ if ($scope.my_data.length > 0) {
|
|
716
|
+ $scope.doing_async = false;
|
|
717
|
+ }
|
|
718
|
+ } else {
|
|
719
|
+ SweetAlert.swal({
|
|
720
|
+ title: "系统错误!",
|
|
721
|
+ text: "请刷新重试!",
|
|
722
|
+ type: "error",
|
|
723
|
+ });
|
|
724
|
+ }
|
|
725
|
+ });
|
|
726
|
+ };
|
|
727
|
+ $scope.getCategoryData();
|
|
728
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
729
|
+ $scope.timer = $interval(function () {
|
|
730
|
+ $scope.refreshData2("expand-right", $scope.fileData);
|
|
731
|
+ }, $rootScope.refreshTime);
|
|
732
|
+ $scope.$on("$destroy", function () {
|
|
733
|
+ $interval.cancel($scope.timer);
|
|
734
|
+ });
|
|
735
|
+ },
|
|
736
|
+]);
|