|
@@ -0,0 +1,493 @@
|
|
1
|
+"use strict";
|
|
2
|
+/**
|
|
3
|
+ * controller for User Profile Example
|
|
4
|
+ */
|
|
5
|
+app.controller("hospitalCtrl", [
|
|
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
|
+ function (
|
|
19
|
+ $rootScope,
|
|
20
|
+ $scope,
|
|
21
|
+ $state,
|
|
22
|
+ $timeout,
|
|
23
|
+ $interval,
|
|
24
|
+ $modal,
|
|
25
|
+ SweetAlert,
|
|
26
|
+ i18nService,
|
|
27
|
+ uiGridConstants,
|
|
28
|
+ uiGridGroupingConstants,
|
|
29
|
+ Restangular,
|
|
30
|
+ api_user_data
|
|
31
|
+ ) {
|
|
32
|
+ $scope.langs = i18nService.getAllLangs();
|
|
33
|
+ $scope.lang = "zh-cn";
|
|
34
|
+ i18nService.setCurrentLang($scope.lang);
|
|
35
|
+ var loginUser = $rootScope.user;
|
|
36
|
+ $scope.xinzeng = false;
|
|
37
|
+ $scope.shanchu = false;
|
|
38
|
+ $scope.bianji = false;
|
|
39
|
+ for (var i = 0; i < loginUser.menu.length; i++) {
|
|
40
|
+ if (loginUser.menu[i].link == "hospital_add") {
|
|
41
|
+ $scope.xinzeng = true;
|
|
42
|
+ }
|
|
43
|
+ if (loginUser.menu[i].link == "hospital_del") {
|
|
44
|
+ $scope.shanchu = true;
|
|
45
|
+ }
|
|
46
|
+ if (loginUser.menu[i].link == "hospital_edit") {
|
|
47
|
+ $scope.bianji = true;
|
|
48
|
+ }
|
|
49
|
+ }
|
|
50
|
+ $scope.gridOptions = {};
|
|
51
|
+ $scope.gridOptions.data = "myData";
|
|
52
|
+ $scope.gridOptions.enableColumnResizing = true;
|
|
53
|
+ $scope.gridOptions.enableFiltering = true;
|
|
54
|
+ $scope.gridOptions.enableGridMenu = true;
|
|
55
|
+ $scope.gridOptions.enableRowSelection = true;
|
|
56
|
+ $scope.gridOptions.showGridFooter = true;
|
|
57
|
+ $scope.gridOptions.showColumnFooter = false;
|
|
58
|
+ $scope.gridOptions.fastWatch = true;
|
|
59
|
+ $scope.gridOptions.useExternalFiltering = true;
|
|
60
|
+ $scope.gridOptions.useExternalPagination = true;
|
|
61
|
+ $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
|
|
62
|
+ $scope.gridOptions.paginationPageSize = 10;
|
|
63
|
+ $scope.gridOptions.multiSelect = false;
|
|
64
|
+
|
|
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>';
|
|
67
|
+
|
|
68
|
+ $scope.gridOptions.rowIdentity = function (row) {
|
|
69
|
+ return row.id;
|
|
70
|
+ };
|
|
71
|
+ $scope.gridOptions.getRowIdentity = function (row) {
|
|
72
|
+ return row.id;
|
|
73
|
+ };
|
|
74
|
+
|
|
75
|
+ $scope.gridOptions.columnDefs = [
|
|
76
|
+ {
|
|
77
|
+ name: "item",
|
|
78
|
+ displayName: "序号",
|
|
79
|
+ width: 50,
|
|
80
|
+ enableFiltering: false,
|
|
81
|
+ },
|
|
82
|
+ {
|
|
83
|
+ name: "hosName",
|
|
84
|
+ displayName: "院区名称",
|
|
85
|
+ width: "35%",
|
|
86
|
+ enableFiltering: false,
|
|
87
|
+ },
|
|
88
|
+ {
|
|
89
|
+ name: "hosNo",
|
|
90
|
+ displayName: "院区编码",
|
|
91
|
+ width: "35%",
|
|
92
|
+ enableFiltering: false,
|
|
93
|
+ },
|
|
94
|
+ {
|
|
95
|
+ name: "操作",
|
|
96
|
+ cellTemplate:
|
|
97
|
+ '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
|
|
98
|
+ '<a ng-click="grid.appScope.saveData(row.entity)" ng-show="grid.appScope.bianji" class="bianjifont">编辑</a>' +
|
|
99
|
+ '<a ng-click="grid.appScope.removeData(row.entity)" ng-show="grid.appScope.shanchu" class="bianjifont">删除</a>' +
|
|
100
|
+ "</div></div>",
|
|
101
|
+ enableFiltering: false,
|
|
102
|
+ },
|
|
103
|
+ ];
|
|
104
|
+ $scope.transferDept = function (data) {
|
|
105
|
+ if (data) {
|
|
106
|
+ return data;
|
|
107
|
+ } else {
|
|
108
|
+ return "无";
|
|
109
|
+ }
|
|
110
|
+ };
|
|
111
|
+ // // 区域
|
|
112
|
+ // $scope.getArea = function () {
|
|
113
|
+ // var fildata = {
|
|
114
|
+ // "idx": 0,
|
|
115
|
+ // "sum": 1000
|
|
116
|
+ // };
|
|
117
|
+ // api_user_data.fetchDataList('area', fildata).then(function (res) {
|
|
118
|
+ // $scope.areaData=res.list;
|
|
119
|
+ // })
|
|
120
|
+ // }
|
|
121
|
+ // $scope.getArea();
|
|
122
|
+ // // 选择区域带出地点
|
|
123
|
+ // $scope.changeArea=function(item){
|
|
124
|
+ // $scope.getPlace(item.id)
|
|
125
|
+ // }
|
|
126
|
+ // // 地点
|
|
127
|
+ // $scope.getPlace = function (areaId) {
|
|
128
|
+ // var fildata = {
|
|
129
|
+ // "idx": 0,
|
|
130
|
+ // "sum": 1000,
|
|
131
|
+ // place: {area: {id: areaId}},
|
|
132
|
+ // };
|
|
133
|
+ // api_user_data.fetchDataList('place', fildata).then(function (res) {
|
|
134
|
+ // $scope.placeData=res.list;
|
|
135
|
+ // })
|
|
136
|
+ // }
|
|
137
|
+ // 编辑
|
|
138
|
+ $scope.saveData = function (selectdata) {
|
|
139
|
+ console.log(selectdata);
|
|
140
|
+ var modalInstance = $modal.open({
|
|
141
|
+ templateUrl: "assets/views/system/tpl/hospitalchange.html",
|
|
142
|
+ controller: function ($scope, scope, $modalInstance, api_user_data) {
|
|
143
|
+ $scope.hospital = {};
|
|
144
|
+ $scope.hospital = selectdata;
|
|
145
|
+ $scope.title = "院区编辑";
|
|
146
|
+ $scope.cancel = function () {
|
|
147
|
+ $modalInstance.dismiss("cancel");
|
|
148
|
+ };
|
|
149
|
+ $scope.savercode = function (hospital) {
|
|
150
|
+ if (hospital && hospital.hosName && hospital.hosNo) {
|
|
151
|
+ var fildata = {
|
|
152
|
+ branch: {
|
|
153
|
+ id: hospital.id,
|
|
154
|
+ hosName: hospital.hosName,
|
|
155
|
+ hosNo: hospital.hosNo,
|
|
156
|
+ deleteFlag: 0,
|
|
157
|
+ },
|
|
158
|
+ };
|
|
159
|
+ api_user_data
|
|
160
|
+ .updData("branch", fildata)
|
|
161
|
+ .then(function (response) {
|
|
162
|
+ if (response) {
|
|
163
|
+ if (response.status == 200) {
|
|
164
|
+ SweetAlert.swal(
|
|
165
|
+ {
|
|
166
|
+ title: "修改成功!",
|
|
167
|
+ type: "success",
|
|
168
|
+ },
|
|
169
|
+ function () {
|
|
170
|
+ scope.refreshData("expand-right", scope.fileData);
|
|
171
|
+ }
|
|
172
|
+ );
|
|
173
|
+ } else if (response.status == 500) {
|
|
174
|
+ SweetAlert.swal(
|
|
175
|
+ {
|
|
176
|
+ title: "修改失败!",
|
|
177
|
+ text: "该院区已存在",
|
|
178
|
+ type: "error",
|
|
179
|
+ },
|
|
180
|
+ function () {
|
|
181
|
+ scope.refreshData("expand-right", scope.fileData);
|
|
182
|
+ }
|
|
183
|
+ );
|
|
184
|
+ } else {
|
|
185
|
+ SweetAlert.swal(
|
|
186
|
+ {
|
|
187
|
+ title: "修改失败!",
|
|
188
|
+ type: "error",
|
|
189
|
+ },
|
|
190
|
+ function () {
|
|
191
|
+ scope.refreshData("expand-right", scope.fileData);
|
|
192
|
+ }
|
|
193
|
+ );
|
|
194
|
+ }
|
|
195
|
+ $modalInstance.close();
|
|
196
|
+ } else {
|
|
197
|
+ SweetAlert.swal(
|
|
198
|
+ {
|
|
199
|
+ title: "修改失败!",
|
|
200
|
+ type: "error",
|
|
201
|
+ },
|
|
202
|
+ function () {
|
|
203
|
+ scope.refreshData("expand-right", scope.fileData);
|
|
204
|
+ }
|
|
205
|
+ );
|
|
206
|
+ }
|
|
207
|
+ });
|
|
208
|
+ } else {
|
|
209
|
+ SweetAlert.swal(
|
|
210
|
+ {
|
|
211
|
+ title: "修改失败!",
|
|
212
|
+ text: "请填写必填项!",
|
|
213
|
+ type: "error",
|
|
214
|
+ confirmButtonColor: "#DD6B55",
|
|
215
|
+ },
|
|
216
|
+ function () {}
|
|
217
|
+ );
|
|
218
|
+ }
|
|
219
|
+ };
|
|
220
|
+ },
|
|
221
|
+ resolve: {
|
|
222
|
+ scope: function () {
|
|
223
|
+ return $scope;
|
|
224
|
+ },
|
|
225
|
+ },
|
|
226
|
+ });
|
|
227
|
+ };
|
|
228
|
+ // 新增
|
|
229
|
+ $scope.addData = function () {
|
|
230
|
+ var modalInstance = $modal.open({
|
|
231
|
+ templateUrl: "assets/views/system/tpl/hospitalchange.html",
|
|
232
|
+ controller: function ($scope, $modalInstance, api_user_data) {
|
|
233
|
+ $scope.title = "院区新增";
|
|
234
|
+ $scope.cancel = function () {
|
|
235
|
+ $modalInstance.dismiss("cancel");
|
|
236
|
+ };
|
|
237
|
+ $scope.hospital = { hosName: "", hosNo: "" };
|
|
238
|
+ $scope.savercode = function (hospital) {
|
|
239
|
+ if (hospital && hospital.hosName && hospital.hosNo) {
|
|
240
|
+ $modalInstance.close(hospital);
|
|
241
|
+ } else {
|
|
242
|
+ SweetAlert.swal(
|
|
243
|
+ {
|
|
244
|
+ title: "新增失败!",
|
|
245
|
+ text: "请填写必填项!",
|
|
246
|
+ type: "error",
|
|
247
|
+ confirmButtonColor: "#DD6B55",
|
|
248
|
+ },
|
|
249
|
+ function () {}
|
|
250
|
+ );
|
|
251
|
+ }
|
|
252
|
+ };
|
|
253
|
+ },
|
|
254
|
+ });
|
|
255
|
+ modalInstance.result.then(function (selectedItem) {
|
|
256
|
+ if (selectedItem.hosName && selectedItem.hosNo) {
|
|
257
|
+ var fildata = {
|
|
258
|
+ branch: {
|
|
259
|
+ hosName: selectedItem.hosName,
|
|
260
|
+ hosNo: selectedItem.hosNo,
|
|
261
|
+ deleteFlag: 0,
|
|
262
|
+ },
|
|
263
|
+ };
|
|
264
|
+ api_user_data.addData("branch", fildata).then(function (response) {
|
|
265
|
+ if (response) {
|
|
266
|
+ if (response.status == 200) {
|
|
267
|
+ SweetAlert.swal(
|
|
268
|
+ {
|
|
269
|
+ title: "新增成功!",
|
|
270
|
+ type: "success",
|
|
271
|
+ },
|
|
272
|
+ function () {
|
|
273
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
274
|
+ }
|
|
275
|
+ );
|
|
276
|
+ } else {
|
|
277
|
+ SweetAlert.swal({
|
|
278
|
+ title: "新增失败!",
|
|
279
|
+ text: response.msg,
|
|
280
|
+ type: "error",
|
|
281
|
+ });
|
|
282
|
+ }
|
|
283
|
+ }
|
|
284
|
+ });
|
|
285
|
+ } else {
|
|
286
|
+ SweetAlert.swal(
|
|
287
|
+ {
|
|
288
|
+ title: "新增失败!",
|
|
289
|
+ text: "请填写必填项!",
|
|
290
|
+ type: "error",
|
|
291
|
+ confirmButtonColor: "#DD6B55",
|
|
292
|
+ },
|
|
293
|
+ function () {}
|
|
294
|
+ );
|
|
295
|
+ }
|
|
296
|
+ });
|
|
297
|
+ };
|
|
298
|
+ // 删除
|
|
299
|
+ $scope.removeData = function (rmData) {
|
|
300
|
+ var modalInstance = $modal.open({
|
|
301
|
+ templateUrl: "assets/views/incident/tpl/acceptTask.tpl.html",
|
|
302
|
+ controller: function ($scope, scope, $modalInstance, api_bpm_data) {
|
|
303
|
+ var rmvList = [];
|
|
304
|
+ $scope.title = "院区删除";
|
|
305
|
+ $scope.connect = "确定要删除此院区?";
|
|
306
|
+ rmvList.push(rmData);
|
|
307
|
+ $scope.ok = function () {
|
|
308
|
+ $modalInstance.close(rmvList);
|
|
309
|
+ };
|
|
310
|
+ $scope.cancel = function () {
|
|
311
|
+ $modalInstance.dismiss("cancel");
|
|
312
|
+ };
|
|
313
|
+ },
|
|
314
|
+ size: "sm",
|
|
315
|
+ resolve: {
|
|
316
|
+ scope: function () {
|
|
317
|
+ return $scope;
|
|
318
|
+ },
|
|
319
|
+ },
|
|
320
|
+ });
|
|
321
|
+ modalInstance.result.then(function (selectedItem) {
|
|
322
|
+ if (selectedItem) {
|
|
323
|
+ if (selectedItem.length > 0) {
|
|
324
|
+ console.log(selectedItem);
|
|
325
|
+ api_user_data
|
|
326
|
+ .rmvData("branch", [selectedItem[0].id])
|
|
327
|
+ .then(function (response) {
|
|
328
|
+ if (response.status == 200) {
|
|
329
|
+ SweetAlert.swal(
|
|
330
|
+ {
|
|
331
|
+ title: "删除成功!",
|
|
332
|
+ type: "success",
|
|
333
|
+ confirmButtonColor: "#007AFF",
|
|
334
|
+ },
|
|
335
|
+ function () {
|
|
336
|
+ $scope.myData = _.reject($scope.myData, function (o) {
|
|
337
|
+ return _.includes(selectedItem, o.id);
|
|
338
|
+ });
|
|
339
|
+ $scope.selected = {
|
|
340
|
+ items: [],
|
|
341
|
+ };
|
|
342
|
+ $scope.gridOptions.totalItems =
|
|
343
|
+ $scope.gridOptions.totalItems - selectedItem.length;
|
|
344
|
+ $scope.gridApi.grid.selection.selectedCount = 0;
|
|
345
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
346
|
+ }
|
|
347
|
+ );
|
|
348
|
+ } else {
|
|
349
|
+ SweetAlert.swal({
|
|
350
|
+ title: "操作异常!",
|
|
351
|
+ text: "系统异常,请稍后重试,或者联系管理员!",
|
|
352
|
+ type: "error",
|
|
353
|
+ });
|
|
354
|
+ }
|
|
355
|
+ });
|
|
356
|
+ }
|
|
357
|
+ }
|
|
358
|
+ });
|
|
359
|
+ };
|
|
360
|
+
|
|
361
|
+ $scope.selected = {
|
|
362
|
+ items: [],
|
|
363
|
+ };
|
|
364
|
+
|
|
365
|
+ $scope.editted = {
|
|
366
|
+ items: [],
|
|
367
|
+ };
|
|
368
|
+
|
|
369
|
+ $scope.gridOptions.onRegisterApi = function (gridApi) {
|
|
370
|
+ $scope.gridApi = gridApi;
|
|
371
|
+ gridApi.pagination.on.paginationChanged(
|
|
372
|
+ $scope,
|
|
373
|
+ function (newPage, pageSize) {
|
|
374
|
+ var filtersData = $scope.memoryfilterData;
|
|
375
|
+ filtersData.idx = newPage - 1;
|
|
376
|
+ filtersData.sum = pageSize;
|
|
377
|
+ $scope.fileData.idx = newPage - 1;
|
|
378
|
+ $scope.fileData.sum = pageSize;
|
|
379
|
+ defaultFilterData = filtersData;
|
|
380
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
381
|
+ }
|
|
382
|
+ );
|
|
383
|
+ gridApi.selection.on.rowSelectionChanged($scope, function (scope) {
|
|
384
|
+ scope.grid.appScope.selected.items = scope.entity;
|
|
385
|
+ });
|
|
386
|
+ };
|
|
387
|
+
|
|
388
|
+ var defaultFilterData = {
|
|
389
|
+ idx: 0,
|
|
390
|
+ sum: 10,
|
|
391
|
+ };
|
|
392
|
+
|
|
393
|
+ $scope.memoryfilterData = {
|
|
394
|
+ idx: 0,
|
|
395
|
+ sum: 10,
|
|
396
|
+ };
|
|
397
|
+ $scope.fileData = {
|
|
398
|
+ idx: 0,
|
|
399
|
+ sum: 10,
|
|
400
|
+ branch: {},
|
|
401
|
+ };
|
|
402
|
+ $scope.ldloading = {};
|
|
403
|
+ $scope.refreshData = function (style, filterData) {
|
|
404
|
+ $scope.selected.items = {};
|
|
405
|
+ $scope.ldloading[style.replace("-", "_")] = true;
|
|
406
|
+ if (angular.isUndefined(filterData)) {
|
|
407
|
+ filterData = defaultFilterData;
|
|
408
|
+ }
|
|
409
|
+
|
|
410
|
+ $scope.myData = [];
|
|
411
|
+ $scope.selected = { items: [] };
|
|
412
|
+ if ($scope.gridApi) {
|
|
413
|
+ $scope.gridApi.grid.selection.selectedCount = 0;
|
|
414
|
+ }
|
|
415
|
+ api_user_data.fetchDataList("branch", filterData).then(
|
|
416
|
+ function (data) {
|
|
417
|
+ var myData = Restangular.stripRestangular(data);
|
|
418
|
+ $scope.gridOptions.totalItems = myData.totalNum;
|
|
419
|
+ $scope.myData = myData.list;
|
|
420
|
+ for (var i = 0; i < $scope.myData.length; i++) {
|
|
421
|
+ $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
|
|
422
|
+ }
|
|
423
|
+ $scope.ldloading[style.replace("-", "_")] = false;
|
|
424
|
+ },
|
|
425
|
+ function () {
|
|
426
|
+ $scope.ldloading[style.replace("-", "_")] = false;
|
|
427
|
+ }
|
|
428
|
+ );
|
|
429
|
+ };
|
|
430
|
+ $scope.refreshData2 = function (style, filterData) {
|
|
431
|
+ $scope.selected.items = {};
|
|
432
|
+ $scope.ldloading[style.replace("-", "_")] = true;
|
|
433
|
+ if (angular.isUndefined(filterData)) {
|
|
434
|
+ filterData = defaultFilterData;
|
|
435
|
+ }
|
|
436
|
+
|
|
437
|
+ // $scope.myData = [];
|
|
438
|
+ $scope.selected = { items: [] };
|
|
439
|
+ if ($scope.gridApi) {
|
|
440
|
+ $scope.gridApi.grid.selection.selectedCount = 0;
|
|
441
|
+ }
|
|
442
|
+ api_user_data.fetchDataList("branch", filterData).then(
|
|
443
|
+ function (data) {
|
|
444
|
+ var myData = Restangular.stripRestangular(data);
|
|
445
|
+ $scope.gridOptions.totalItems = myData.totalNum;
|
|
446
|
+ $scope.myData = myData.list;
|
|
447
|
+ for (var i = 0; i < $scope.myData.length; i++) {
|
|
448
|
+ $scope.myData[i]["item"] = i + 1 + filterData.idx * filterData.sum;
|
|
449
|
+ }
|
|
450
|
+ $scope.ldloading[style.replace("-", "_")] = false;
|
|
451
|
+ },
|
|
452
|
+ function () {
|
|
453
|
+ $scope.ldloading[style.replace("-", "_")] = false;
|
|
454
|
+ }
|
|
455
|
+ );
|
|
456
|
+ };
|
|
457
|
+ // 搜索
|
|
458
|
+ $scope.searchData = function () {
|
|
459
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
460
|
+ };
|
|
461
|
+ // 清空
|
|
462
|
+ $scope.clean = function () {
|
|
463
|
+ delete $scope.fileData.branch.dept;
|
|
464
|
+ delete $scope.fileData.branch.address;
|
|
465
|
+ delete $scope.fileData.branch.phone;
|
|
466
|
+ delete $scope.fileData.branch.parent;
|
|
467
|
+ delete $scope.fileData.branch.area;
|
|
468
|
+ delete $scope.fileData.branch.place;
|
|
469
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
470
|
+ };
|
|
471
|
+ // 获取单位下拉
|
|
472
|
+ $scope.model = {};
|
|
473
|
+ $scope.deptData = {};
|
|
474
|
+ // $scope.getDeptData=function(){
|
|
475
|
+ // var data={
|
|
476
|
+ // "idx":0,
|
|
477
|
+ // "sum":1000
|
|
478
|
+ // }
|
|
479
|
+ // api_user_data.fetchDataList('branch',data).then(function(res){
|
|
480
|
+ // $scope.deptData=res.list;
|
|
481
|
+ // // console.log($scope.deptData)
|
|
482
|
+ // })
|
|
483
|
+ // }
|
|
484
|
+ // $scope.getDeptData();
|
|
485
|
+ $scope.refreshData("expand-right", $scope.fileData);
|
|
486
|
+ $scope.timer = $interval(function () {
|
|
487
|
+ $scope.refreshData2("expand-right", $scope.fileData);
|
|
488
|
+ }, $rootScope.refreshTime);
|
|
489
|
+ $scope.$on("$destroy", function () {
|
|
490
|
+ $interval.cancel($scope.timer);
|
|
491
|
+ });
|
|
492
|
+ },
|
|
493
|
+]);
|