|
@@ -62,7 +62,8 @@ app.controller("responsibilityDeptlistCtrl", [
|
62
|
62
|
$scope.gridOptions.paginationPageSize = 10;
|
63
|
63
|
$scope.gridOptions.multiSelect = false;
|
64
|
64
|
|
65
|
|
- $scope.gridOptions.rowTemplate= "<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>";
|
|
65
|
+ $scope.gridOptions.rowTemplate =
|
|
66
|
+ '<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>';
|
66
|
67
|
|
67
|
68
|
$scope.gridOptions.rowIdentity = function (row) {
|
68
|
69
|
return row.id;
|
|
@@ -85,14 +86,10 @@ app.controller("responsibilityDeptlistCtrl", [
|
85
|
86
|
enableFiltering: false,
|
86
|
87
|
},
|
87
|
88
|
{
|
88
|
|
- name: "parent.dept",
|
89
|
|
- displayName: "单位",
|
|
89
|
+ name: "branchName",
|
|
90
|
+ displayName: "院区",
|
90
|
91
|
width: "20%",
|
91
|
92
|
enableFiltering: false,
|
92
|
|
- cellTemplate:
|
93
|
|
- "<div>" +
|
94
|
|
- '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{grid.appScope.transferDept(row.entity.parent.dept)}}</div>' +
|
95
|
|
- "</div>",
|
96
|
93
|
},
|
97
|
94
|
{
|
98
|
95
|
name: "phone",
|
|
@@ -100,16 +97,6 @@ app.controller("responsibilityDeptlistCtrl", [
|
100
|
97
|
width: "20%",
|
101
|
98
|
enableFiltering: false,
|
102
|
99
|
},
|
103
|
|
- {
|
104
|
|
- name: "area",
|
105
|
|
- displayName: "区域地点",
|
106
|
|
- width: "20%",
|
107
|
|
- enableFiltering: false,
|
108
|
|
- cellTemplate:
|
109
|
|
- "<div>" +
|
110
|
|
- '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{row.entity.place.area.area+""+row.entity.place.place}}</div>' +
|
111
|
|
- "</div>",
|
112
|
|
- },
|
113
|
100
|
{
|
114
|
101
|
name: "操作",
|
115
|
102
|
cellTemplate:
|
|
@@ -128,94 +115,46 @@ app.controller("responsibilityDeptlistCtrl", [
|
128
|
115
|
return "无";
|
129
|
116
|
}
|
130
|
117
|
};
|
131
|
|
- // 区域
|
132
|
|
- $scope.getArea = function () {
|
133
|
|
- var fildata = {
|
134
|
|
- idx: 0,
|
135
|
|
- sum: 1000,
|
136
|
|
- };
|
137
|
|
- api_user_data.fetchDataList("area", fildata).then(function (res) {
|
138
|
|
- $scope.areaData = res.list;
|
139
|
|
- });
|
140
|
|
- };
|
141
|
|
- $scope.getArea();
|
142
|
|
- // 选择区域带出地点
|
143
|
|
- $scope.changeArea = function (item) {
|
144
|
|
- $scope.getPlace(item.id);
|
145
|
|
- };
|
146
|
|
- // 地点
|
147
|
|
- $scope.getPlace = function (areaId) {
|
148
|
|
- var fildata = {
|
149
|
|
- idx: 0,
|
150
|
|
- sum: 1000,
|
151
|
|
- place: { area: { id: areaId } },
|
152
|
|
- };
|
153
|
|
- api_user_data.fetchDataList("place", fildata).then(function (res) {
|
154
|
|
- $scope.placeData = res.list;
|
155
|
|
- });
|
156
|
|
- };
|
157
|
118
|
$scope.saveData = function (selectdata) {
|
158
|
119
|
console.log(selectdata);
|
159
|
120
|
var modalInstance = $modal.open({
|
160
|
|
- templateUrl: "assets/views/system/tpl/deptchange.html",
|
|
121
|
+ templateUrl: "assets/views/system/tpl/responsibilityDeptchange.html",
|
161
|
122
|
controller: function ($scope, scope, $modalInstance, api_user_data) {
|
162
|
|
- $scope.deptdata = {};
|
163
|
|
- $scope.deptdata = selectdata;
|
164
|
|
- $scope.areaData = scope.areaData;
|
165
|
|
- $scope.deptchoice = {};
|
166
|
|
- $scope.title = "部门修改";
|
167
|
|
- var filterData = { idx: 0, sum: 100 };
|
|
123
|
+ $scope.deptdata = {
|
|
124
|
+ id: selectdata.id,
|
|
125
|
+ dept: selectdata.dept,
|
|
126
|
+ phone: selectdata.phone,
|
|
127
|
+ branch: { id: selectdata.branch, hosName: selectdata.branchName },
|
|
128
|
+ };
|
|
129
|
+ $scope.branchList = [];
|
|
130
|
+ $scope.title = "责任部门修改";
|
168
|
131
|
api_user_data
|
169
|
|
- .fetchDataList("department", filterData)
|
|
132
|
+ .fetchDataList("branch", { idx: 0, sum: 100 })
|
170
|
133
|
.then(function (data) {
|
171
|
|
- $scope.deptchoice = Restangular.stripRestangular(data).list;
|
|
134
|
+ $scope.branchList = Restangular.stripRestangular(data).list;
|
172
|
135
|
});
|
173
|
136
|
$scope.cancel = function () {
|
174
|
137
|
$modalInstance.dismiss("cancel");
|
175
|
138
|
};
|
176
|
|
-
|
177
|
|
- $scope.changeArea = function (item) {
|
178
|
|
- var postData = {
|
179
|
|
- idx: 0,
|
180
|
|
- sum: 1000,
|
181
|
|
- };
|
182
|
|
- if (item) {
|
183
|
|
- postData.place = { area: { id: item.id } };
|
184
|
|
- }
|
185
|
|
- api_user_data
|
186
|
|
- .fetchDataList("place", postData)
|
187
|
|
- .then(function (data) {
|
188
|
|
- $scope.placeData = Restangular.stripRestangular(data).list;
|
189
|
|
- });
|
190
|
|
- };
|
191
|
|
- $scope.changeArea(selectdata.area);
|
|
139
|
+ // 保存
|
192
|
140
|
$scope.savercode = function (deptdata) {
|
193
|
141
|
if (
|
194
|
142
|
deptdata &&
|
195
|
143
|
deptdata.dept &&
|
196
|
144
|
deptdata.phone &&
|
197
|
|
- deptdata.area &&
|
198
|
|
- deptdata.place
|
|
145
|
+ deptdata.branch
|
199
|
146
|
) {
|
200
|
147
|
var fildata = {
|
201
|
|
- department: {
|
|
148
|
+ dutyDepartment: {
|
202
|
149
|
id: deptdata.id,
|
203
|
|
- area: { id: deptdata.area.id },
|
204
|
|
- place: {
|
205
|
|
- id: deptdata.place.id,
|
206
|
|
- area: { id: deptdata.area.id },
|
207
|
|
- },
|
208
|
150
|
deleteFlag: 0,
|
209
|
151
|
phone: deptdata.phone,
|
210
|
152
|
dept: deptdata.dept,
|
|
153
|
+ branch: deptdata.branch.id,
|
211
|
154
|
},
|
212
|
155
|
};
|
213
|
|
- if (deptdata.parent) {
|
214
|
|
- fildata.department.parent = { id: deptdata.parent.id };
|
215
|
|
- }
|
216
|
|
- // console.log(fildata)
|
217
|
156
|
api_user_data
|
218
|
|
- .updData("department", fildata)
|
|
157
|
+ .updData("dutyDepartment", fildata)
|
219
|
158
|
.then(function (response) {
|
220
|
159
|
if (response) {
|
221
|
160
|
if (response.status == 200) {
|
|
@@ -286,31 +225,29 @@ app.controller("responsibilityDeptlistCtrl", [
|
286
|
225
|
|
287
|
226
|
$scope.addData = function () {
|
288
|
227
|
var modalInstance = $modal.open({
|
289
|
|
- templateUrl: "assets/views/system/tpl/deptchange.html",
|
|
228
|
+ templateUrl: "assets/views/system/tpl/responsibilityDeptchange.html",
|
290
|
229
|
controller: function ($scope, $modalInstance, api_user_data) {
|
291
|
|
- var filterData = { idx: 0, sum: 100 };
|
292
|
|
- $scope.title = "部门新增";
|
|
230
|
+ $scope.deptdata = {
|
|
231
|
+ dept: "",
|
|
232
|
+ phone: "",
|
|
233
|
+ branch: "",
|
|
234
|
+ };
|
|
235
|
+ $scope.title = "责任部门新增";
|
293
|
236
|
api_user_data
|
294
|
|
- .fetchDataList("department", filterData)
|
|
237
|
+ .fetchDataList("branch", { idx: 0, sum: 100 })
|
295
|
238
|
.then(function (data) {
|
296
|
|
- $scope.deptchoice = Restangular.stripRestangular(data).list;
|
|
239
|
+ $scope.branchList = Restangular.stripRestangular(data).list;
|
297
|
240
|
});
|
298
|
|
- api_user_data.fetchDataList("area", filterData).then(function (data) {
|
299
|
|
- $scope.areaData = Restangular.stripRestangular(data).list;
|
300
|
|
- });
|
301
|
|
- // api_wechatfile.getDictionary('department').then(function(data) {
|
302
|
|
- // $scope.deptchoice = Restangular.stripRestangular(data).list;
|
303
|
|
- // })
|
304
|
241
|
$scope.cancel = function () {
|
305
|
242
|
$modalInstance.dismiss("cancel");
|
306
|
243
|
};
|
|
244
|
+ // 保存
|
307
|
245
|
$scope.savercode = function (deptdata) {
|
308
|
246
|
if (
|
309
|
247
|
deptdata &&
|
310
|
248
|
deptdata.dept &&
|
311
|
249
|
deptdata.phone &&
|
312
|
|
- deptdata.area &&
|
313
|
|
- deptdata.place
|
|
250
|
+ deptdata.branch
|
314
|
251
|
) {
|
315
|
252
|
$modalInstance.close(deptdata);
|
316
|
253
|
} else {
|
|
@@ -325,50 +262,19 @@ app.controller("responsibilityDeptlistCtrl", [
|
325
|
262
|
);
|
326
|
263
|
}
|
327
|
264
|
};
|
328
|
|
- $scope.changeArea = function (item) {
|
329
|
|
- var postData = {
|
330
|
|
- idx: 0,
|
331
|
|
- place: { area: { id: item.id } },
|
332
|
|
- sum: 1000,
|
333
|
|
- };
|
334
|
|
- api_user_data
|
335
|
|
- .fetchDataList("place", postData)
|
336
|
|
- .then(function (data) {
|
337
|
|
- $scope.placeData = Restangular.stripRestangular(data).list;
|
338
|
|
- });
|
339
|
|
- };
|
340
|
265
|
},
|
341
|
266
|
});
|
342
|
267
|
modalInstance.result.then(function (selectedItem) {
|
343
|
|
- if (
|
344
|
|
- selectedItem.dept &&
|
345
|
|
- selectedItem.phone &&
|
346
|
|
- selectedItem.area &&
|
347
|
|
- selectedItem.place
|
348
|
|
- ) {
|
349
|
|
- // angular.forEach($scope.myData,function(item){
|
350
|
|
- // if(item.dept==selectedItem.parent.dept){
|
351
|
|
- // selectedItem.parent.id=item.id;
|
352
|
|
- // }
|
353
|
|
- // })
|
354
|
|
-
|
|
268
|
+ if (selectedItem.dept && selectedItem.phone && selectedItem.branch) {
|
355
|
269
|
var fildata = {
|
356
|
|
- department: {
|
|
270
|
+ dutyDepartment: {
|
357
|
271
|
phone: selectedItem.phone,
|
358
|
|
- area: { id: selectedItem.area.id },
|
359
|
|
- place: {
|
360
|
|
- id: selectedItem.place.id,
|
361
|
|
- area: { id: selectedItem.area.id },
|
362
|
|
- },
|
363
|
272
|
dept: selectedItem.dept,
|
|
273
|
+ branch: selectedItem.branch.id,
|
364
|
274
|
},
|
365
|
275
|
};
|
366
|
|
- if (selectedItem.parent) {
|
367
|
|
- fildata.department.parent = { id: selectedItem.parent.id };
|
368
|
|
- }
|
369
|
|
- // console.log(fildata)
|
370
|
276
|
api_user_data
|
371
|
|
- .addData("department", fildata)
|
|
277
|
+ .addData("dutyDepartment", fildata)
|
372
|
278
|
.then(function (response) {
|
373
|
279
|
if (response) {
|
374
|
280
|
if (response.status == 200) {
|
|
@@ -432,7 +338,7 @@ app.controller("responsibilityDeptlistCtrl", [
|
432
|
338
|
if (selectedItem) {
|
433
|
339
|
if (selectedItem.length > 0) {
|
434
|
340
|
console.log(selectedItem);
|
435
|
|
- if (selectedItem[0].children.length > 0) {
|
|
341
|
+ if (selectedItem[0].children && selectedItem[0].children.length > 0) {
|
436
|
342
|
SweetAlert.swal({
|
437
|
343
|
title: "该部门存在子类部门",
|
438
|
344
|
text: "请先删除该部门子类部门!",
|
|
@@ -440,7 +346,7 @@ app.controller("responsibilityDeptlistCtrl", [
|
440
|
346
|
});
|
441
|
347
|
} else {
|
442
|
348
|
api_user_data
|
443
|
|
- .rmvData("department", [selectedItem[0].id])
|
|
349
|
+ .rmvData("dutyDepartment", [selectedItem[0].id])
|
444
|
350
|
.then(function (response) {
|
445
|
351
|
if (response.status == 200) {
|
446
|
352
|
SweetAlert.swal(
|
|
@@ -476,33 +382,6 @@ app.controller("responsibilityDeptlistCtrl", [
|
476
|
382
|
});
|
477
|
383
|
};
|
478
|
384
|
|
479
|
|
- // $scope.removeData = function() {
|
480
|
|
- // var rmvList = [$scope.selected.items.id]
|
481
|
|
- // if (rmvList.length > 0) {
|
482
|
|
- // api_user_data.rmvData('department', rmvList).then(function(response) {
|
483
|
|
- // if (response.status == 200) {
|
484
|
|
- // SweetAlert.swal({
|
485
|
|
- // title: "删除成功!",
|
486
|
|
- // type: "success",
|
487
|
|
- // confirmButtonColor: "#007AFF"
|
488
|
|
- // }, function() {
|
489
|
|
- // $scope.myData = _.reject($scope.myData, function(o) { return _.includes(rmvList, o.id); });
|
490
|
|
- // $scope.selected = {
|
491
|
|
- // items: []
|
492
|
|
- // };
|
493
|
|
- // });
|
494
|
|
-
|
495
|
|
- // } else {
|
496
|
|
- // SweetAlert.swal({
|
497
|
|
- // title: "操作异常!",
|
498
|
|
- // text: "系统异常,请稍后重试,或者联系管理员!",
|
499
|
|
- // type: "error"
|
500
|
|
- // });
|
501
|
|
- // }
|
502
|
|
- // })
|
503
|
|
- // }
|
504
|
|
- // }
|
505
|
|
-
|
506
|
385
|
$scope.selected = {
|
507
|
386
|
items: [],
|
508
|
387
|
};
|
|
@@ -545,7 +424,7 @@ app.controller("responsibilityDeptlistCtrl", [
|
545
|
424
|
$scope.fileData = {
|
546
|
425
|
idx: 0,
|
547
|
426
|
sum: 10,
|
548
|
|
- department: {},
|
|
427
|
+ dutyDepartment: {},
|
549
|
428
|
};
|
550
|
429
|
$scope.ldloading = {};
|
551
|
430
|
$scope.refreshData = function (style, filterData) {
|
|
@@ -560,7 +439,11 @@ app.controller("responsibilityDeptlistCtrl", [
|
560
|
439
|
if ($scope.gridApi) {
|
561
|
440
|
$scope.gridApi.grid.selection.selectedCount = 0;
|
562
|
441
|
}
|
563
|
|
- api_user_data.fetchDataList("department", filterData).then(
|
|
442
|
+ filterData = angular.copy(filterData);
|
|
443
|
+ if(filterData.dutyDepartment.branch){
|
|
444
|
+ filterData.dutyDepartment.branch = filterData.dutyDepartment.branch.id;
|
|
445
|
+ }
|
|
446
|
+ api_user_data.fetchDataList("dutyDepartment", filterData).then(
|
564
|
447
|
function (data) {
|
565
|
448
|
var myData = Restangular.stripRestangular(data);
|
566
|
449
|
$scope.gridOptions.totalItems = myData.totalNum;
|
|
@@ -587,7 +470,11 @@ app.controller("responsibilityDeptlistCtrl", [
|
587
|
470
|
if ($scope.gridApi) {
|
588
|
471
|
$scope.gridApi.grid.selection.selectedCount = 0;
|
589
|
472
|
}
|
590
|
|
- api_user_data.fetchDataList("department", filterData).then(
|
|
473
|
+ filterData = angular.copy(filterData);
|
|
474
|
+ if(filterData.dutyDepartment.branch){
|
|
475
|
+ filterData.dutyDepartment.branch = filterData.dutyDepartment.branch.id;
|
|
476
|
+ }
|
|
477
|
+ api_user_data.fetchDataList("dutyDepartment", filterData).then(
|
591
|
478
|
function (data) {
|
592
|
479
|
var myData = Restangular.stripRestangular(data);
|
593
|
480
|
$scope.gridOptions.totalItems = myData.totalNum;
|
|
@@ -608,25 +495,21 @@ app.controller("responsibilityDeptlistCtrl", [
|
608
|
495
|
};
|
609
|
496
|
// 清空
|
610
|
497
|
$scope.clean = function () {
|
611
|
|
- delete $scope.fileData.department.dept;
|
612
|
|
- delete $scope.fileData.department.address;
|
613
|
|
- delete $scope.fileData.department.phone;
|
614
|
|
- delete $scope.fileData.department.parent;
|
615
|
|
- delete $scope.fileData.department.area;
|
616
|
|
- delete $scope.fileData.department.place;
|
|
498
|
+ delete $scope.fileData.dutyDepartment.dept;
|
|
499
|
+ delete $scope.fileData.dutyDepartment.phone;
|
|
500
|
+ delete $scope.fileData.dutyDepartment.branch;
|
617
|
501
|
$scope.refreshData("expand-right", $scope.fileData);
|
618
|
502
|
};
|
619
|
|
- // 获取单位下拉
|
|
503
|
+ // 获取院区下拉
|
620
|
504
|
$scope.model = {};
|
621
|
|
- $scope.deptData = {};
|
|
505
|
+ $scope.branchData = [];
|
622
|
506
|
$scope.getDeptData = function () {
|
623
|
507
|
var data = {
|
624
|
508
|
idx: 0,
|
625
|
509
|
sum: 1000,
|
626
|
510
|
};
|
627
|
|
- api_user_data.fetchDataList("department", data).then(function (res) {
|
628
|
|
- $scope.deptData = res.list;
|
629
|
|
- // console.log($scope.deptData)
|
|
511
|
+ api_user_data.fetchDataList("branch", data).then(function (res) {
|
|
512
|
+ $scope.branchData = res.list;
|
630
|
513
|
});
|
631
|
514
|
};
|
632
|
515
|
$scope.getDeptData();
|