|
@@ -0,0 +1,361 @@
|
|
1
|
+import { Component, OnInit, ViewChild } from "@angular/core";
|
|
2
|
+import { ActivatedRoute } from "@angular/router";
|
|
3
|
+import { FormBuilder, Validators, FormGroup } from "@angular/forms";
|
|
4
|
+
|
|
5
|
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
|
|
6
|
+import { ToolService } from "../../services/tool.service";
|
|
7
|
+import { Subject } from "rxjs";
|
|
8
|
+import { debounceTime } from "rxjs/operators";
|
|
9
|
+import { QuickOrderAcceptanceService } from './quick-order-acceptance.service';
|
|
10
|
+
|
|
11
|
+@Component({
|
|
12
|
+ selector: "app-quick-order-acceptance",
|
|
13
|
+ templateUrl: "./quick-order-acceptance.component.html",
|
|
14
|
+ styleUrls: ["./quick-order-acceptance.component.less"],
|
|
15
|
+})
|
|
16
|
+export class QuickOrderAcceptanceComponent implements OnInit {
|
|
17
|
+ @ViewChild("osComponentRef1", {
|
|
18
|
+ read: OverlayScrollbarsComponent,
|
|
19
|
+ static: false,
|
|
20
|
+ })
|
|
21
|
+ osComponentRef1: OverlayScrollbarsComponent;
|
|
22
|
+ constructor(
|
|
23
|
+ private fb: FormBuilder,
|
|
24
|
+ private route: ActivatedRoute,
|
|
25
|
+ private tool: ToolService,
|
|
26
|
+ private quickOrderAcceptanceService: QuickOrderAcceptanceService,
|
|
27
|
+ ) {}
|
|
28
|
+
|
|
29
|
+ listOfData: any[] = []; //表格数据
|
|
30
|
+
|
|
31
|
+ modal: boolean = false; //新增/编辑模态框
|
|
32
|
+ add: boolean; //true:新增;false:编辑
|
|
33
|
+ validateForm: FormGroup; //新增/编辑表单
|
|
34
|
+ coopId: number; //表格中执行操作的id
|
|
35
|
+ department: any; //所属科室
|
|
36
|
+ hosId: any; //院区(搜索)
|
|
37
|
+ typeList: Array<any>; //快捷类型
|
|
38
|
+ taskTypeList: Array<any>; //所有任务类型
|
|
39
|
+ deptList: Array<any>; //所有科室
|
|
40
|
+ pageIndex: number = 1; //页码
|
|
41
|
+ listLength: number = 10; //总条数
|
|
42
|
+ pageSize: number = 10; //每页条数
|
|
43
|
+
|
|
44
|
+ promptContent: string; //操作提示框提示信息
|
|
45
|
+ ifSuccess: boolean; //操作成功/失败
|
|
46
|
+ promptInfo: string; //操作结果提示信息
|
|
47
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
48
|
+
|
|
49
|
+ btnLoading: boolean = false; //提交按钮loading状态
|
|
50
|
+ changeInpSubject = new Subject(); //防抖
|
|
51
|
+ changeInpDeptSubject = new Subject(); //防抖
|
|
52
|
+
|
|
53
|
+ // 初始化增删改按钮
|
|
54
|
+ coopBtns: any = {};
|
|
55
|
+
|
|
56
|
+ ngOnInit() {
|
|
57
|
+ //防抖
|
|
58
|
+ this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
59
|
+ this.getTasktype(v[0]);
|
|
60
|
+ });
|
|
61
|
+ //防抖
|
|
62
|
+ this.changeInpDeptSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
63
|
+ this.getDept(v[0]);
|
|
64
|
+ });
|
|
65
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
66
|
+ this.initForm();
|
|
67
|
+ this.hosId = this.tool.getCurrentHospital().id;
|
|
68
|
+ this.getList(true);
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ // 搜索
|
|
72
|
+ search() {
|
|
73
|
+ this.getList(true);
|
|
74
|
+ }
|
|
75
|
+ // 表格数据
|
|
76
|
+ loading1 = false;
|
|
77
|
+ getList(isResetPageIndex = false) {
|
|
78
|
+ isResetPageIndex && (this.pageIndex = 1);
|
|
79
|
+ let data = {
|
|
80
|
+ pageIndex: this.pageIndex,
|
|
81
|
+ pageSize: this.pageSize,
|
|
82
|
+ hosId: this.hosId,
|
|
83
|
+ };
|
|
84
|
+ this.loading1 = true;
|
|
85
|
+ this.mapOfCheckedId = {};
|
|
86
|
+ this.checkedDepIds = [];
|
|
87
|
+ this.isAllDisplayDataChecked = false;
|
|
88
|
+ this.quickOrderAcceptanceService
|
|
89
|
+ .query(data)
|
|
90
|
+ .subscribe((result) => {
|
|
91
|
+ this.loading1 = false;
|
|
92
|
+ result.list = result.list || [];
|
|
93
|
+ result.list.forEach(v => {
|
|
94
|
+ v.taskNames = v.taskTypeList.map(v => v.taskName).toString();
|
|
95
|
+ v.deptNames = v.deptList.map(v => v.dept).toString();
|
|
96
|
+ })
|
|
97
|
+ this.listOfData = result.list;
|
|
98
|
+ this.listLength = result.totalNum;
|
|
99
|
+ });
|
|
100
|
+ }
|
|
101
|
+
|
|
102
|
+ // 获取任务类型列表
|
|
103
|
+ getTasktype(keywords = '') {
|
|
104
|
+ let hosId = this.tool.getCurrentHospital().id;
|
|
105
|
+ this.isLoading = true;
|
|
106
|
+ this.quickOrderAcceptanceService.queryTasktype({
|
|
107
|
+ hosId,
|
|
108
|
+ keywords,
|
|
109
|
+ }).subscribe((res) => {
|
|
110
|
+ this.isLoading = false;
|
|
111
|
+ this.taskTypeList = res.list || [];
|
|
112
|
+ });
|
|
113
|
+ }
|
|
114
|
+
|
|
115
|
+ // 获取科室列表
|
|
116
|
+ getDept(keywords = '') {
|
|
117
|
+ let hosId = this.tool.getCurrentHospital().id;
|
|
118
|
+ this.isLoading = true;
|
|
119
|
+ this.quickOrderAcceptanceService.queryDept({
|
|
120
|
+ hosId,
|
|
121
|
+ keywords,
|
|
122
|
+ }).subscribe((res) => {
|
|
123
|
+ this.isLoading = false;
|
|
124
|
+ this.deptList = res.list || [];
|
|
125
|
+ });
|
|
126
|
+ }
|
|
127
|
+
|
|
128
|
+ // 获取快捷类型
|
|
129
|
+ getTypeList() {
|
|
130
|
+ this.isLoading = true;
|
|
131
|
+ this.quickOrderAcceptanceService.getDictionary("receiveRuleType").subscribe((res) => {
|
|
132
|
+ this.isLoading = false;
|
|
133
|
+ this.typeList = res || [];
|
|
134
|
+ });
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ // 新增弹框
|
|
138
|
+ showModal() {
|
|
139
|
+ this.add = true;
|
|
140
|
+ this.modal = true;
|
|
141
|
+ this.initForm();
|
|
142
|
+ }
|
|
143
|
+ hideModal() {
|
|
144
|
+ this.modal = false;
|
|
145
|
+ this.initForm();
|
|
146
|
+ }
|
|
147
|
+
|
|
148
|
+ // 初始化新增form表单
|
|
149
|
+ initForm() {
|
|
150
|
+ if (this.add) {
|
|
151
|
+ this.typeList = [];
|
|
152
|
+ this.taskTypeList = [];
|
|
153
|
+ this.deptList = [];
|
|
154
|
+ }
|
|
155
|
+ this.validateForm = this.fb.group({
|
|
156
|
+ title: ['', [Validators.required]],
|
|
157
|
+ taskTypeIds: [null, [Validators.required]],
|
|
158
|
+ deptIds: [null, [Validators.required]],
|
|
159
|
+ type: [null, [Validators.required]],
|
|
160
|
+ });
|
|
161
|
+ }
|
|
162
|
+ // 表单提交
|
|
163
|
+ submitForm(): void {
|
|
164
|
+ for (const i in this.validateForm.controls) {
|
|
165
|
+ this.validateForm.controls[i].markAsDirty({ onlySelf: true });
|
|
166
|
+ this.validateForm.controls[i].updateValueAndValidity();
|
|
167
|
+ }
|
|
168
|
+ if (this.validateForm.invalid) return;
|
|
169
|
+ this.btnLoading = true;
|
|
170
|
+ if(this.add){
|
|
171
|
+ this.quickOrderAcceptanceService
|
|
172
|
+ .add({
|
|
173
|
+ title: this.validateForm.value.title,
|
|
174
|
+ taskTypeIds: this.validateForm.value.taskTypeIds,
|
|
175
|
+ deptIds: this.validateForm.value.deptIds,
|
|
176
|
+ type: {id: this.validateForm.value.type},
|
|
177
|
+ hosId: this.hosId,
|
|
178
|
+ })
|
|
179
|
+ .subscribe((data) => {
|
|
180
|
+ this.btnLoading = false;
|
|
181
|
+ this.hideModal();
|
|
182
|
+ this.initForm();
|
|
183
|
+ if (data.status == 200) {
|
|
184
|
+ this.showPromptModal(this.add ? "新增" : "编辑", true, "");
|
|
185
|
+ } else {
|
|
186
|
+ this.showPromptModal(this.add ? "新增" : "编辑", false, data.msg);
|
|
187
|
+ }
|
|
188
|
+ });
|
|
189
|
+ }else{
|
|
190
|
+ this.quickOrderAcceptanceService
|
|
191
|
+ .update({
|
|
192
|
+ title: this.validateForm.value.title,
|
|
193
|
+ taskTypeIds: this.validateForm.value.taskTypeIds,
|
|
194
|
+ deptIds: this.validateForm.value.deptIds,
|
|
195
|
+ type: {id: this.validateForm.value.type},
|
|
196
|
+ coopData: this.coopData,
|
|
197
|
+ })
|
|
198
|
+ .subscribe((data) => {
|
|
199
|
+ this.btnLoading = false;
|
|
200
|
+ this.hideModal();
|
|
201
|
+ this.initForm();
|
|
202
|
+ if (data.status == 200) {
|
|
203
|
+ this.showPromptModal(this.add ? "新增" : "编辑", true, "");
|
|
204
|
+ } else {
|
|
205
|
+ this.showPromptModal(this.add ? "新增" : "编辑", false, data.msg);
|
|
206
|
+ }
|
|
207
|
+ });
|
|
208
|
+ }
|
|
209
|
+ }
|
|
210
|
+
|
|
211
|
+ // 选中表格中科室
|
|
212
|
+ mapOfCheckedId: { [key: string]: boolean } = {};
|
|
213
|
+ checkedDepIds = []; //已选中科室id
|
|
214
|
+ refreshStatus(): void {
|
|
215
|
+ this.isAllDisplayDataChecked = this.listOfData.every(
|
|
216
|
+ (item) => this.mapOfCheckedId[item.id]
|
|
217
|
+ );
|
|
218
|
+ let arr = [];
|
|
219
|
+ for (var k in this.mapOfCheckedId) {
|
|
220
|
+ if (this.mapOfCheckedId[k]) {
|
|
221
|
+ arr.push(Number(k));
|
|
222
|
+ }
|
|
223
|
+ }
|
|
224
|
+ this.checkedDepIds = arr;
|
|
225
|
+ console.log(this.checkedDepIds);
|
|
226
|
+ }
|
|
227
|
+
|
|
228
|
+ //表格整行选中
|
|
229
|
+ selectedListData(id) {
|
|
230
|
+ this.mapOfCheckedId[id] = !this.mapOfCheckedId[id];
|
|
231
|
+ this.refreshStatus();
|
|
232
|
+ }
|
|
233
|
+
|
|
234
|
+ // 全选
|
|
235
|
+ isAllDisplayDataChecked = false; //当前页是否全选
|
|
236
|
+ checkAll(value: boolean): void {
|
|
237
|
+ this.listOfData.forEach((item) => (this.mapOfCheckedId[item.id] = value));
|
|
238
|
+ this.refreshStatus();
|
|
239
|
+ }
|
|
240
|
+
|
|
241
|
+ // 打印
|
|
242
|
+ codes = []; //二维码
|
|
243
|
+ printLoading: boolean = false; //批量打印按钮loading状态
|
|
244
|
+ print(e, batch, id?) {
|
|
245
|
+ e.stopPropagation();
|
|
246
|
+ this.printLoading = true;
|
|
247
|
+ this.quickOrderAcceptanceService
|
|
248
|
+ .print({
|
|
249
|
+ ids: batch ? this.checkedDepIds.toString() : id.toString()
|
|
250
|
+ })
|
|
251
|
+ .subscribe((data) => {
|
|
252
|
+ this.codes = data.data;
|
|
253
|
+ this.printLoading = false;
|
|
254
|
+ setTimeout(() => {
|
|
255
|
+ const printContent = document.getElementById("report");
|
|
256
|
+ const WindowPrt = window.open("", "", "width=700,height=900");
|
|
257
|
+ WindowPrt.document.write(printContent.innerHTML);
|
|
258
|
+ WindowPrt.document.close();
|
|
259
|
+ WindowPrt.focus();
|
|
260
|
+ WindowPrt.print();
|
|
261
|
+ WindowPrt.close();
|
|
262
|
+ }, 100);
|
|
263
|
+ });
|
|
264
|
+ }
|
|
265
|
+
|
|
266
|
+ // 编辑
|
|
267
|
+ maskFlag: any = false;
|
|
268
|
+ coopData = {};
|
|
269
|
+ edit(data) {
|
|
270
|
+ this.validateForm.controls.title.setValue(data.title);
|
|
271
|
+ this.validateForm.controls.type.setValue(data.type ? data.type.id : null);
|
|
272
|
+ this.validateForm.controls.taskTypeIds.setValue(data.taskTypeList ? data.taskTypeList.map(v => v.id) : null);
|
|
273
|
+ this.validateForm.controls.deptIds.setValue(data.deptList ? data.deptList.map(v => v.id) : null);
|
|
274
|
+ this.modal = true;
|
|
275
|
+ this.add = false;
|
|
276
|
+ this.coopId = data.id;
|
|
277
|
+ this.coopData = data;
|
|
278
|
+ this.getTasktype();
|
|
279
|
+ this.getDept();
|
|
280
|
+ this.getTypeList();
|
|
281
|
+ }
|
|
282
|
+
|
|
283
|
+ // 删除
|
|
284
|
+ delModal: boolean = false; //删除模态框
|
|
285
|
+ del(data) {
|
|
286
|
+ this.coopId = data.id;
|
|
287
|
+ this.delModal = true;
|
|
288
|
+ }
|
|
289
|
+ // 确认删除
|
|
290
|
+ confirmDel() {
|
|
291
|
+ this.btnLoading = true;
|
|
292
|
+ this.quickOrderAcceptanceService
|
|
293
|
+ .delete({
|
|
294
|
+ id: this.coopId
|
|
295
|
+ })
|
|
296
|
+ .subscribe((data) => {
|
|
297
|
+ this.btnLoading = false;
|
|
298
|
+ this.hideDelModal();
|
|
299
|
+ if (data.status == 200) {
|
|
300
|
+ if (this.listOfData.length == 1 && this.pageIndex == Math.ceil(this.listLength / this.pageSize)) {
|
|
301
|
+ this.listLength--;
|
|
302
|
+ this.pageIndex = Math.ceil(this.listLength / this.pageSize);
|
|
303
|
+ }
|
|
304
|
+ this.showPromptModal("删除", true, "");
|
|
305
|
+ } else {
|
|
306
|
+ this.showPromptModal("删除", false, data.msg);
|
|
307
|
+ }
|
|
308
|
+ });
|
|
309
|
+ }
|
|
310
|
+
|
|
311
|
+ // 关闭删除模态框
|
|
312
|
+ hideDelModal() {
|
|
313
|
+ this.delModal = false;
|
|
314
|
+ }
|
|
315
|
+
|
|
316
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
317
|
+ showPromptModal(con, success, promptInfo?) {
|
|
318
|
+ this.promptModalShow = false;
|
|
319
|
+ this.promptContent = con;
|
|
320
|
+ this.ifSuccess = success;
|
|
321
|
+ this.promptInfo = promptInfo;
|
|
322
|
+ setTimeout(() => {
|
|
323
|
+ this.promptModalShow = true;
|
|
324
|
+ }, 100);
|
|
325
|
+ this.getList(true);
|
|
326
|
+ }
|
|
327
|
+
|
|
328
|
+ // 边输边搜节流阀
|
|
329
|
+ isLoading = false;
|
|
330
|
+ changeInp(e) {
|
|
331
|
+ this.changeInpSubject.next([e]);
|
|
332
|
+ }
|
|
333
|
+
|
|
334
|
+ // 边输边搜节流阀
|
|
335
|
+ changeDeptInp(e) {
|
|
336
|
+ this.changeInpDeptSubject.next([e]);
|
|
337
|
+ }
|
|
338
|
+
|
|
339
|
+ // 打开任务类型
|
|
340
|
+ openTasktype(e){
|
|
341
|
+ if(e){
|
|
342
|
+ this.getTasktype();
|
|
343
|
+ }
|
|
344
|
+ }
|
|
345
|
+
|
|
346
|
+ // 打开科室
|
|
347
|
+ openDept(e){
|
|
348
|
+ if(e){
|
|
349
|
+ this.getDept();
|
|
350
|
+ }
|
|
351
|
+ }
|
|
352
|
+
|
|
353
|
+ // 打开班次
|
|
354
|
+ openSchedule(e){
|
|
355
|
+ if(e){
|
|
356
|
+ this.getTypeList();
|
|
357
|
+ }
|
|
358
|
+ }
|
|
359
|
+}
|
|
360
|
+
|
|
361
|
+
|