|
@@ -1,48 +1,54 @@
|
1
|
|
-import { Component, OnInit, ViewChild } from '@angular/core';
|
2
|
|
-import { MainService } from '../../services/main.service';
|
3
|
|
-import { Router } from "@angular/router"
|
4
|
|
-import { OverlayScrollbarsComponent } from 'overlayscrollbars-ngx';
|
|
1
|
+import { Component, OnInit, ViewChild } from "@angular/core";
|
|
2
|
+import { MainService } from "../../services/main.service";
|
|
3
|
+import { Router } from "@angular/router";
|
|
4
|
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
|
5
|
5
|
|
6
|
6
|
@Component({
|
7
|
|
- selector: 'app-pharmacy',
|
8
|
|
- templateUrl: './pharmacy.component.html',
|
9
|
|
- styleUrls: ['./pharmacy.component.less']
|
|
7
|
+ selector: "app-pharmacy",
|
|
8
|
+ templateUrl: "./pharmacy.component.html",
|
|
9
|
+ styleUrls: ["./pharmacy.component.less"],
|
10
|
10
|
})
|
11
|
11
|
export class PharmacyComponent implements OnInit {
|
12
|
|
- @ViewChild('osComponentRef1', { read: OverlayScrollbarsComponent, static: false })
|
|
12
|
+ @ViewChild("osComponentRef1", {
|
|
13
|
+ read: OverlayScrollbarsComponent,
|
|
14
|
+ static: false,
|
|
15
|
+ })
|
13
|
16
|
osComponentRef1: OverlayScrollbarsComponent;
|
14
|
|
- @ViewChild('osComponentRef2', { read: OverlayScrollbarsComponent, static: false })
|
|
17
|
+ @ViewChild("osComponentRef2", {
|
|
18
|
+ read: OverlayScrollbarsComponent,
|
|
19
|
+ static: false,
|
|
20
|
+ })
|
15
|
21
|
osComponentRef2: OverlayScrollbarsComponent;
|
16
|
|
- @ViewChild('osComponentRef3', { read: OverlayScrollbarsComponent, static: false })
|
|
22
|
+ @ViewChild("osComponentRef3", {
|
|
23
|
+ read: OverlayScrollbarsComponent,
|
|
24
|
+ static: false,
|
|
25
|
+ })
|
17
|
26
|
osComponentRef3: OverlayScrollbarsComponent;
|
18
|
|
- constructor(
|
19
|
|
- private mainService: MainService,
|
20
|
|
- public router: Router
|
21
|
|
- ) { }
|
|
27
|
+ constructor(private mainService: MainService, public router: Router) {}
|
22
|
28
|
//打印二维码数据
|
23
|
29
|
codes = [];
|
24
|
30
|
// 登录切换效果
|
25
|
31
|
loginFlag = false;
|
26
|
32
|
// 打印二维码
|
27
|
|
- printPharmacyList = [];//数据列表
|
28
|
|
- printPharmacyIdx = 0;//页码
|
29
|
|
- printPharmacyFlag = false;//是否查看更多
|
30
|
|
- printPharmacySearchKey = '';//搜索的内容
|
31
|
|
- printPharmacyLoad = false;//按钮的loading
|
|
33
|
+ printPharmacyList = []; //数据列表
|
|
34
|
+ printPharmacyIdx = 0; //页码
|
|
35
|
+ printPharmacyFlag = false; //是否查看更多
|
|
36
|
+ printPharmacySearchKey = ""; //搜索的内容
|
|
37
|
+ printPharmacyLoad = false; //按钮的loading
|
32
|
38
|
// 待配送列表
|
33
|
39
|
waitPharmacyList = [];
|
34
|
40
|
waitPharmacyIdx = 0;
|
35
|
41
|
waitPharmacyFlag = false;
|
36
|
|
- waitPharmacySearchKey = '';
|
|
42
|
+ waitPharmacySearchKey = "";
|
37
|
43
|
waitPharmacyLoad = false;
|
38
|
44
|
// 已配送列表
|
39
|
45
|
pharmacyList = [];
|
40
|
46
|
pharmacyIdx = 0;
|
41
|
47
|
pharmacyFlag = false;
|
42
|
|
- pharmacySearchKey = '';
|
|
48
|
+ pharmacySearchKey = "";
|
43
|
49
|
pharmacyLoad = false;
|
44
|
50
|
//当前登录人所属科室
|
45
|
|
- currentDept = '';
|
|
51
|
+ currentDept = "";
|
46
|
52
|
|
47
|
53
|
ngOnInit() {
|
48
|
54
|
// 打印二维码列表
|
|
@@ -52,9 +58,9 @@ export class PharmacyComponent implements OnInit {
|
52
|
58
|
// 已配送列表
|
53
|
59
|
this.getPharmacyList(this.pharmacyIdx, 3, this.pharmacySearchKey);
|
54
|
60
|
//当前登录人所属科室
|
55
|
|
- this.currentDept = JSON.parse(localStorage.getItem('user')).user.dept.dept;
|
|
61
|
+ this.currentDept = JSON.parse(localStorage.getItem("user")).user.dept.dept;
|
56
|
62
|
|
57
|
|
- this.initRole()
|
|
63
|
+ this.initRole();
|
58
|
64
|
}
|
59
|
65
|
// 药房端药房列表查询、搜索
|
60
|
66
|
// 1为pc待打印状态、2为pc待配送、3为pc已配送
|
|
@@ -64,7 +70,7 @@ export class PharmacyComponent implements OnInit {
|
64
|
70
|
loading3 = false;
|
65
|
71
|
getPharmacyList(idx, type, searchKey) {
|
66
|
72
|
let launch = {
|
67
|
|
- id: JSON.parse(localStorage.getItem('user')).user.dept.id
|
|
73
|
+ id: JSON.parse(localStorage.getItem("user")).user.dept.id,
|
68
|
74
|
};
|
69
|
75
|
switch (type) {
|
70
|
76
|
case 1:
|
|
@@ -77,59 +83,67 @@ export class PharmacyComponent implements OnInit {
|
77
|
83
|
this.loading3 = true;
|
78
|
84
|
break;
|
79
|
85
|
}
|
80
|
|
- this.mainService.getPharmacyList(idx, type, searchKey, launch).subscribe(result => {
|
81
|
|
- switch (type) {
|
82
|
|
- case 1:
|
83
|
|
- this.loading1 = false;
|
84
|
|
- break;
|
85
|
|
- case 2:
|
86
|
|
- this.loading2 = false;
|
87
|
|
- break;
|
88
|
|
- case 3:
|
89
|
|
- this.loading3 = false;
|
90
|
|
- break;
|
91
|
|
- }
|
92
|
|
- if (result['status'] == 200) {
|
|
86
|
+ this.mainService
|
|
87
|
+ .getPharmacyList(idx, type, searchKey, launch)
|
|
88
|
+ .subscribe((result) => {
|
93
|
89
|
switch (type) {
|
94
|
90
|
case 1:
|
95
|
|
- // 隐藏按钮的loading
|
96
|
|
- this.printPharmacyLoad = false;
|
97
|
|
- // 查看更多,是否显示
|
98
|
|
- if (result['list'].length < 10) {
|
99
|
|
- this.printPharmacyFlag = false;
|
100
|
|
- } else if (result['list'].length === 0 && idx === 0) {
|
101
|
|
- this.printPharmacyFlag = false;
|
102
|
|
- } else {
|
103
|
|
- this.printPharmacyFlag = true;
|
104
|
|
- }
|
105
|
|
- // 列表数据合并
|
106
|
|
- this.printPharmacyList = [...this.printPharmacyList, ...result['list']];
|
|
91
|
+ this.loading1 = false;
|
107
|
92
|
break;
|
108
|
93
|
case 2:
|
109
|
|
- this.waitPharmacyLoad = false;
|
110
|
|
- if (result['list'].length < 10) {
|
111
|
|
- this.waitPharmacyFlag = false;
|
112
|
|
- } else if (result['list'].length === 0 && idx === 0) {
|
113
|
|
- this.waitPharmacyFlag = false;
|
114
|
|
- } else {
|
115
|
|
- this.waitPharmacyFlag = true;
|
116
|
|
- }
|
117
|
|
- this.waitPharmacyList = [...this.waitPharmacyList, ...result['list']];
|
|
94
|
+ this.loading2 = false;
|
118
|
95
|
break;
|
119
|
96
|
case 3:
|
120
|
|
- this.pharmacyLoad = false;
|
121
|
|
- if (result['list'].length < 10) {
|
122
|
|
- this.pharmacyFlag = false;
|
123
|
|
- } else if (result['list'].length === 0 && idx === 0) {
|
124
|
|
- this.pharmacyFlag = false;
|
125
|
|
- } else {
|
126
|
|
- this.pharmacyFlag = true;
|
127
|
|
- }
|
128
|
|
- this.pharmacyList = [...this.pharmacyList, ...result['list']];
|
|
97
|
+ this.loading3 = false;
|
129
|
98
|
break;
|
130
|
99
|
}
|
131
|
|
- }
|
132
|
|
- })
|
|
100
|
+ if (result["status"] == 200) {
|
|
101
|
+ switch (type) {
|
|
102
|
+ case 1:
|
|
103
|
+ // 隐藏按钮的loading
|
|
104
|
+ this.printPharmacyLoad = false;
|
|
105
|
+ // 查看更多,是否显示
|
|
106
|
+ if (result["list"].length < 10) {
|
|
107
|
+ this.printPharmacyFlag = false;
|
|
108
|
+ } else if (result["list"].length === 0 && idx === 0) {
|
|
109
|
+ this.printPharmacyFlag = false;
|
|
110
|
+ } else {
|
|
111
|
+ this.printPharmacyFlag = true;
|
|
112
|
+ }
|
|
113
|
+ // 列表数据合并
|
|
114
|
+ this.printPharmacyList = [
|
|
115
|
+ ...this.printPharmacyList,
|
|
116
|
+ ...result["list"],
|
|
117
|
+ ];
|
|
118
|
+ break;
|
|
119
|
+ case 2:
|
|
120
|
+ this.waitPharmacyLoad = false;
|
|
121
|
+ if (result["list"].length < 10) {
|
|
122
|
+ this.waitPharmacyFlag = false;
|
|
123
|
+ } else if (result["list"].length === 0 && idx === 0) {
|
|
124
|
+ this.waitPharmacyFlag = false;
|
|
125
|
+ } else {
|
|
126
|
+ this.waitPharmacyFlag = true;
|
|
127
|
+ }
|
|
128
|
+ this.waitPharmacyList = [
|
|
129
|
+ ...this.waitPharmacyList,
|
|
130
|
+ ...result["list"],
|
|
131
|
+ ];
|
|
132
|
+ break;
|
|
133
|
+ case 3:
|
|
134
|
+ this.pharmacyLoad = false;
|
|
135
|
+ if (result["list"].length < 10) {
|
|
136
|
+ this.pharmacyFlag = false;
|
|
137
|
+ } else if (result["list"].length === 0 && idx === 0) {
|
|
138
|
+ this.pharmacyFlag = false;
|
|
139
|
+ } else {
|
|
140
|
+ this.pharmacyFlag = true;
|
|
141
|
+ }
|
|
142
|
+ this.pharmacyList = [...this.pharmacyList, ...result["list"]];
|
|
143
|
+ break;
|
|
144
|
+ }
|
|
145
|
+ }
|
|
146
|
+ });
|
133
|
147
|
}
|
134
|
148
|
// 加载更多
|
135
|
149
|
loadMore(type) {
|
|
@@ -137,12 +151,20 @@ export class PharmacyComponent implements OnInit {
|
137
|
151
|
case 1:
|
138
|
152
|
this.printPharmacyIdx++;
|
139
|
153
|
this.printPharmacyLoad = true;
|
140
|
|
- this.getPharmacyList(this.printPharmacyIdx, type, this.printPharmacySearchKey);
|
|
154
|
+ this.getPharmacyList(
|
|
155
|
+ this.printPharmacyIdx,
|
|
156
|
+ type,
|
|
157
|
+ this.printPharmacySearchKey
|
|
158
|
+ );
|
141
|
159
|
break;
|
142
|
160
|
case 2:
|
143
|
161
|
this.waitPharmacyIdx++;
|
144
|
162
|
this.waitPharmacyLoad = true;
|
145
|
|
- this.getPharmacyList(this.waitPharmacyIdx, type, this.waitPharmacySearchKey);
|
|
163
|
+ this.getPharmacyList(
|
|
164
|
+ this.waitPharmacyIdx,
|
|
165
|
+ type,
|
|
166
|
+ this.waitPharmacySearchKey
|
|
167
|
+ );
|
146
|
168
|
break;
|
147
|
169
|
case 3:
|
148
|
170
|
this.pharmacyIdx++;
|
|
@@ -155,33 +177,48 @@ export class PharmacyComponent implements OnInit {
|
155
|
177
|
searchKeyHandle(type) {
|
156
|
178
|
switch (type) {
|
157
|
179
|
case 1:
|
158
|
|
- this.printPharmacyIdx = 0;//页码重置
|
159
|
|
- this.printPharmacyList = [];//列表重置
|
160
|
|
- this.getPharmacyList(this.printPharmacyIdx, type, this.printPharmacySearchKey);
|
|
180
|
+ this.printPharmacyIdx = 0; //页码重置
|
|
181
|
+ this.printPharmacyList = []; //列表重置
|
|
182
|
+ this.getPharmacyList(
|
|
183
|
+ this.printPharmacyIdx,
|
|
184
|
+ type,
|
|
185
|
+ this.printPharmacySearchKey
|
|
186
|
+ );
|
161
|
187
|
break;
|
162
|
188
|
case 2:
|
163
|
|
- this.waitPharmacyIdx = 0;//页码重置
|
164
|
|
- this.waitPharmacyList = [];//列表重置
|
165
|
|
- this.getPharmacyList(this.waitPharmacyIdx, type, this.waitPharmacySearchKey);
|
|
189
|
+ this.waitPharmacyIdx = 0; //页码重置
|
|
190
|
+ this.waitPharmacyList = []; //列表重置
|
|
191
|
+ this.getPharmacyList(
|
|
192
|
+ this.waitPharmacyIdx,
|
|
193
|
+ type,
|
|
194
|
+ this.waitPharmacySearchKey
|
|
195
|
+ );
|
166
|
196
|
break;
|
167
|
197
|
case 3:
|
168
|
|
- this.pharmacyIdx = 0;//页码重置
|
169
|
|
- this.pharmacyList = [];//列表重置
|
|
198
|
+ this.pharmacyIdx = 0; //页码重置
|
|
199
|
+ this.pharmacyList = []; //列表重置
|
170
|
200
|
this.getPharmacyList(this.pharmacyIdx, type, this.pharmacySearchKey);
|
171
|
201
|
break;
|
172
|
202
|
}
|
173
|
203
|
}
|
174
|
204
|
// 退出
|
175
|
205
|
logOut(): void {
|
176
|
|
- this.mainService.logOut().subscribe(data => {
|
|
206
|
+ // 假退出
|
|
207
|
+ localStorage.removeItem("user");
|
|
208
|
+ localStorage.removeItem("menu");
|
|
209
|
+ localStorage.removeItem("phones");
|
|
210
|
+ localStorage.removeItem("index");
|
|
211
|
+ this.router.navigateByUrl("login");
|
|
212
|
+ // 假退出
|
|
213
|
+ this.mainService.logOut().subscribe((data) => {
|
177
|
214
|
if (data.status == 200) {
|
178
|
|
- localStorage.removeItem('user')
|
179
|
|
- localStorage.removeItem('menu')
|
180
|
|
- localStorage.removeItem('phones')
|
181
|
|
- localStorage.removeItem('index')
|
182
|
|
- this.router.navigateByUrl('login');
|
|
215
|
+ localStorage.removeItem("user");
|
|
216
|
+ localStorage.removeItem("menu");
|
|
217
|
+ localStorage.removeItem("phones");
|
|
218
|
+ localStorage.removeItem("index");
|
|
219
|
+ this.router.navigateByUrl("login");
|
183
|
220
|
}
|
184
|
|
- })
|
|
221
|
+ });
|
185
|
222
|
}
|
186
|
223
|
// 退出按钮切换效果
|
187
|
224
|
toggleLogin() {
|
|
@@ -190,62 +227,65 @@ export class PharmacyComponent implements OnInit {
|
190
|
227
|
//打印二维码
|
191
|
228
|
print(id?) {
|
192
|
229
|
let arr = [];
|
193
|
|
- if (typeof id === 'number' && id > 0) {//单个二维码
|
|
230
|
+ if (typeof id === "number" && id > 0) {
|
|
231
|
+ //单个二维码
|
194
|
232
|
arr.push(id);
|
195
|
|
- } else {//批量二维码
|
196
|
|
- arr = this.printPharmacyList.map(item => item.id);
|
|
233
|
+ } else {
|
|
234
|
+ //批量二维码
|
|
235
|
+ arr = this.printPharmacyList.map((item) => item.id);
|
197
|
236
|
}
|
198
|
|
- this.mainService.printRequisition(arr).subscribe(data => {
|
199
|
|
- if (data['status'] == 200) {
|
200
|
|
- this.codes = data['data'];
|
|
237
|
+ this.mainService.printRequisition(arr).subscribe((data) => {
|
|
238
|
+ if (data["status"] == 200) {
|
|
239
|
+ this.codes = data["data"];
|
201
|
240
|
setTimeout(function () {
|
202
|
241
|
const printContent = document.getElementById("report");
|
203
|
|
- const WindowPrt = window.open('', '', 'width=700,height=900');
|
|
242
|
+ const WindowPrt = window.open("", "", "width=700,height=900");
|
204
|
243
|
WindowPrt.document.write(printContent.innerHTML);
|
205
|
244
|
WindowPrt.print();
|
206
|
245
|
WindowPrt.close();
|
207
|
246
|
}, 100);
|
208
|
247
|
// 待打印变为待配药接口
|
209
|
|
- let loginName = JSON.parse(localStorage.getItem('user')).user.name;
|
210
|
|
- this.mainService.changeToDispensing(arr, loginName).subscribe(data => {
|
211
|
|
- if (data['state'] == 200) {
|
212
|
|
- this.printPharmacyList = [];
|
213
|
|
- this.waitPharmacyList = [];
|
214
|
|
- // 打印二维码列表
|
215
|
|
- this.getPharmacyList(0, 1, this.printPharmacySearchKey);
|
216
|
|
- // 待配送列表
|
217
|
|
- this.getPharmacyList(0, 2, this.waitPharmacySearchKey);
|
218
|
|
- }
|
219
|
|
- })
|
|
248
|
+ let loginName = JSON.parse(localStorage.getItem("user")).user.name;
|
|
249
|
+ this.mainService
|
|
250
|
+ .changeToDispensing(arr, loginName)
|
|
251
|
+ .subscribe((data) => {
|
|
252
|
+ if (data["state"] == 200) {
|
|
253
|
+ this.printPharmacyList = [];
|
|
254
|
+ this.waitPharmacyList = [];
|
|
255
|
+ // 打印二维码列表
|
|
256
|
+ this.getPharmacyList(0, 1, this.printPharmacySearchKey);
|
|
257
|
+ // 待配送列表
|
|
258
|
+ this.getPharmacyList(0, 2, this.waitPharmacySearchKey);
|
|
259
|
+ }
|
|
260
|
+ });
|
220
|
261
|
}
|
221
|
|
- })
|
|
262
|
+ });
|
222
|
263
|
}
|
223
|
264
|
|
224
|
265
|
//补打二维码
|
225
|
266
|
replenishPrint(id?) {
|
226
|
267
|
let arr = [];
|
227
|
|
- if (typeof id === 'number' && id > 0) {//单个二维码
|
|
268
|
+ if (typeof id === "number" && id > 0) {
|
|
269
|
+ //单个二维码
|
228
|
270
|
arr.push(id);
|
229
|
|
- } else {//批量二维码
|
230
|
|
- arr = this.printPharmacyList.map(item => item.id);
|
|
271
|
+ } else {
|
|
272
|
+ //批量二维码
|
|
273
|
+ arr = this.printPharmacyList.map((item) => item.id);
|
231
|
274
|
}
|
232
|
|
- this.mainService.printRequisition(arr).subscribe(data => {
|
233
|
|
- if (data['status'] == 200) {
|
234
|
|
- this.codes = data['data'];
|
|
275
|
+ this.mainService.printRequisition(arr).subscribe((data) => {
|
|
276
|
+ if (data["status"] == 200) {
|
|
277
|
+ this.codes = data["data"];
|
235
|
278
|
setTimeout(function () {
|
236
|
279
|
const printContent = document.getElementById("report");
|
237
|
|
- const WindowPrt = window.open('', '', 'width=700,height=900');
|
|
280
|
+ const WindowPrt = window.open("", "", "width=700,height=900");
|
238
|
281
|
WindowPrt.document.write(printContent.innerHTML);
|
239
|
282
|
WindowPrt.print();
|
240
|
283
|
WindowPrt.close();
|
241
|
284
|
}, 100);
|
242
|
285
|
}
|
243
|
|
- })
|
|
286
|
+ });
|
244
|
287
|
}
|
245
|
288
|
|
246
|
|
-
|
247
|
|
-
|
248
|
|
-
|
249
|
289
|
// 右侧菜单
|
250
|
290
|
showLastItems: boolean = false;
|
251
|
291
|
// 下拉
|
|
@@ -258,13 +298,12 @@ export class PharmacyComponent implements OnInit {
|
258
|
298
|
this.showLastItems = false;
|
259
|
299
|
}
|
260
|
300
|
|
261
|
|
-
|
262
|
|
- mainRole: boolean = false;//回到系统管理权限
|
|
301
|
+ mainRole: boolean = false; //回到系统管理权限
|
263
|
302
|
initRole() {
|
264
|
303
|
// let roles = JSON.parse(localStorage.getItem('user')).user.role;
|
265
|
|
- let menus = JSON.parse(localStorage.getItem('menu'));
|
266
|
|
- let that = this
|
267
|
|
- console.log("菜单数量" + menus.length)
|
|
304
|
+ let menus = JSON.parse(localStorage.getItem("menu"));
|
|
305
|
+ let that = this;
|
|
306
|
+ console.log("菜单数量" + menus.length);
|
268
|
307
|
if (menus.length >= 2) {
|
269
|
308
|
that.mainRole = true;
|
270
|
309
|
return;
|
|
@@ -272,13 +311,13 @@ export class PharmacyComponent implements OnInit {
|
272
|
311
|
}
|
273
|
312
|
|
274
|
313
|
// 切换右侧菜单Tab
|
275
|
|
- fixedTab: string = '';
|
|
314
|
+ fixedTab: string = "";
|
276
|
315
|
checkFixedTab(type: string) {
|
277
|
|
- if (type == 'toSystem') {
|
278
|
|
- this.router.navigateByUrl('main');
|
|
316
|
+ if (type == "toSystem") {
|
|
317
|
+ this.router.navigateByUrl("main");
|
279
|
318
|
}
|
280
|
319
|
if (this.fixedTab == type) {
|
281
|
|
- this.fixedTab = ''
|
|
320
|
+ this.fixedTab = "";
|
282
|
321
|
} else {
|
283
|
322
|
this.fixedTab = type;
|
284
|
323
|
}
|