|
@@ -0,0 +1,239 @@
|
|
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 { MainService } from "../../services/main.service";
|
|
6
|
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
|
|
7
|
+import { ToolService } from "../../services/tool.service";
|
|
8
|
+import { Subject } from "rxjs";
|
|
9
|
+import { debounceTime } from "rxjs/operators";
|
|
10
|
+import { QRCodeConfigurationService } from './qrcode-configuration.service';
|
|
11
|
+
|
|
12
|
+@Component({
|
|
13
|
+ selector: "app-qrcode-configuration",
|
|
14
|
+ templateUrl: "./qrcode-configuration.component.html",
|
|
15
|
+ styleUrls: ["./qrcode-configuration.component.less"],
|
|
16
|
+})
|
|
17
|
+export class QRCodeConfigurationComponent implements OnInit {
|
|
18
|
+ @ViewChild("osComponentRef1", {
|
|
19
|
+ read: OverlayScrollbarsComponent,
|
|
20
|
+ static: false,
|
|
21
|
+ })
|
|
22
|
+ osComponentRef1: OverlayScrollbarsComponent;
|
|
23
|
+ constructor(
|
|
24
|
+ private fb: FormBuilder,
|
|
25
|
+ private route: ActivatedRoute,
|
|
26
|
+ private mainService: MainService,
|
|
27
|
+ private tool: ToolService,
|
|
28
|
+ private qrCodeConfigurationService: QRCodeConfigurationService,
|
|
29
|
+ ) {}
|
|
30
|
+
|
|
31
|
+ listOfData: any[] = []; //表格数据
|
|
32
|
+
|
|
33
|
+ modal: boolean = false; //新增/编辑模态框
|
|
34
|
+ add: boolean; //true:新增;false:编辑
|
|
35
|
+ validateForm: FormGroup; //新增/编辑表单
|
|
36
|
+ coopId: number; //表格中执行操作的id
|
|
37
|
+ department: any; //所属科室
|
|
38
|
+ hosId: 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
|
+
|
|
52
|
+ // 初始化增删改按钮
|
|
53
|
+ coopBtns: any = {};
|
|
54
|
+
|
|
55
|
+ ngOnInit() {
|
|
56
|
+ //防抖
|
|
57
|
+ this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
58
|
+ this.getOtherTasktype(v[0]);
|
|
59
|
+ });
|
|
60
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
61
|
+ this.initForm();
|
|
62
|
+ this.hosId = this.tool.getCurrentHospital().id;
|
|
63
|
+ this.getList(true);
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ // 搜索
|
|
67
|
+ search() {
|
|
68
|
+ this.getList(true);
|
|
69
|
+ }
|
|
70
|
+ // 表格数据
|
|
71
|
+ loading1 = false;
|
|
72
|
+ getList(isResetPageIndex = false) {
|
|
73
|
+ isResetPageIndex && (this.pageIndex = 1);
|
|
74
|
+ let data = {
|
|
75
|
+ pageIndex: this.pageIndex,
|
|
76
|
+ pageSize: this.pageSize,
|
|
77
|
+ hosId: this.hosId,
|
|
78
|
+ };
|
|
79
|
+ this.loading1 = true;
|
|
80
|
+ this.qrCodeConfigurationService
|
|
81
|
+ .query(data)
|
|
82
|
+ .subscribe((result) => {
|
|
83
|
+ this.loading1 = false;
|
|
84
|
+ result.list = result.list || [];
|
|
85
|
+ this.listOfData = result.list;
|
|
86
|
+ this.listLength = result.totalNum;
|
|
87
|
+ });
|
|
88
|
+ }
|
|
89
|
+
|
|
90
|
+ // 获取任务类型列表-其他临床服务
|
|
91
|
+ getOtherTasktype(keywords = '') {
|
|
92
|
+ let hosId = this.tool.getCurrentHospital().id;
|
|
93
|
+ this.isLoading = true;
|
|
94
|
+ this.qrCodeConfigurationService.queryOtherTasktype({
|
|
95
|
+ hosId,
|
|
96
|
+ keywords,
|
|
97
|
+ }).subscribe((res) => {
|
|
98
|
+ this.isLoading = false;
|
|
99
|
+ this.deptList = res.list || [];
|
|
100
|
+ });
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ // 新增弹框
|
|
104
|
+ showModal() {
|
|
105
|
+ this.add = true;
|
|
106
|
+ this.modal = true;
|
|
107
|
+ this.initForm();
|
|
108
|
+ }
|
|
109
|
+ hideModal() {
|
|
110
|
+ this.modal = false;
|
|
111
|
+ this.initForm();
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+ // 初始化新增form表单
|
|
115
|
+ initForm() {
|
|
116
|
+ if (this.add) {
|
|
117
|
+ this.deptList = [];
|
|
118
|
+ }
|
|
119
|
+ this.validateForm = this.fb.group({
|
|
120
|
+ name: ['', [Validators.required]],
|
|
121
|
+ deptId: [null, [Validators.required]],
|
|
122
|
+ });
|
|
123
|
+ }
|
|
124
|
+ // 表单提交
|
|
125
|
+ submitForm(): void {
|
|
126
|
+ for (const i in this.validateForm.controls) {
|
|
127
|
+ this.validateForm.controls[i].markAsDirty({ onlySelf: true });
|
|
128
|
+ this.validateForm.controls[i].updateValueAndValidity();
|
|
129
|
+ }
|
|
130
|
+ if (this.validateForm.invalid) return;
|
|
131
|
+ this.btnLoading = true;
|
|
132
|
+ if(this.add){
|
|
133
|
+ this.qrCodeConfigurationService
|
|
134
|
+ .add({
|
|
135
|
+ name: this.validateForm.value.name,
|
|
136
|
+ deptId: this.validateForm.value.deptId,
|
|
137
|
+ hosId: this.hosId,
|
|
138
|
+ })
|
|
139
|
+ .subscribe((data) => {
|
|
140
|
+ this.btnLoading = false;
|
|
141
|
+ this.hideModal();
|
|
142
|
+ this.initForm();
|
|
143
|
+ if (data.status == 200) {
|
|
144
|
+ this.showPromptModal(this.add ? "新增" : "编辑", true, "");
|
|
145
|
+ } else {
|
|
146
|
+ this.showPromptModal(this.add ? "新增" : "编辑", false, data.msg);
|
|
147
|
+ }
|
|
148
|
+ });
|
|
149
|
+ }else{
|
|
150
|
+ this.qrCodeConfigurationService
|
|
151
|
+ .update({
|
|
152
|
+ name: this.validateForm.value.name,
|
|
153
|
+ deptId: this.validateForm.value.deptId,
|
|
154
|
+ coopData: this.coopData,
|
|
155
|
+ })
|
|
156
|
+ .subscribe((data) => {
|
|
157
|
+ this.btnLoading = false;
|
|
158
|
+ this.hideModal();
|
|
159
|
+ this.initForm();
|
|
160
|
+ if (data.status == 200) {
|
|
161
|
+ this.showPromptModal(this.add ? "新增" : "编辑", true, "");
|
|
162
|
+ } else {
|
|
163
|
+ this.showPromptModal(this.add ? "新增" : "编辑", false, data.msg);
|
|
164
|
+ }
|
|
165
|
+ });
|
|
166
|
+ }
|
|
167
|
+ }
|
|
168
|
+
|
|
169
|
+ // 编辑
|
|
170
|
+ maskFlag: any = false;
|
|
171
|
+ coopData = {};
|
|
172
|
+ edit(data) {
|
|
173
|
+ this.validateForm.controls.name.setValue(data.name);
|
|
174
|
+ this.validateForm.controls.deptId.setValue(data.deptId);
|
|
175
|
+ this.modal = true;
|
|
176
|
+ this.add = false;
|
|
177
|
+ this.coopId = data.id;
|
|
178
|
+ this.coopData = data;
|
|
179
|
+ this.getOtherTasktype();
|
|
180
|
+ }
|
|
181
|
+
|
|
182
|
+ // 删除
|
|
183
|
+ delModal: boolean = false; //删除模态框
|
|
184
|
+ del(data) {
|
|
185
|
+ this.coopId = data.id;
|
|
186
|
+ this.delModal = true;
|
|
187
|
+ }
|
|
188
|
+ // 确认删除
|
|
189
|
+ confirmDel() {
|
|
190
|
+ this.btnLoading = true;
|
|
191
|
+ this.qrCodeConfigurationService
|
|
192
|
+ .delete({
|
|
193
|
+ id: this.coopId
|
|
194
|
+ })
|
|
195
|
+ .subscribe((data) => {
|
|
196
|
+ this.btnLoading = false;
|
|
197
|
+ this.hideDelModal();
|
|
198
|
+ if (data.status == 200) {
|
|
199
|
+ if (this.listOfData.length == 1 && this.pageIndex == Math.ceil(this.listLength / this.pageSize)) {
|
|
200
|
+ this.listLength--;
|
|
201
|
+ this.pageIndex = Math.ceil(this.listLength / this.pageSize);
|
|
202
|
+ }
|
|
203
|
+ this.showPromptModal("删除", true, "");
|
|
204
|
+ } else {
|
|
205
|
+ this.showPromptModal("删除", false, data.msg);
|
|
206
|
+ }
|
|
207
|
+ });
|
|
208
|
+ }
|
|
209
|
+
|
|
210
|
+ // 关闭删除模态框
|
|
211
|
+ hideDelModal() {
|
|
212
|
+ this.delModal = false;
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
216
|
+ showPromptModal(con, success, promptInfo?) {
|
|
217
|
+ this.promptModalShow = false;
|
|
218
|
+ this.promptContent = con;
|
|
219
|
+ this.ifSuccess = success;
|
|
220
|
+ this.promptInfo = promptInfo;
|
|
221
|
+ setTimeout(() => {
|
|
222
|
+ this.promptModalShow = true;
|
|
223
|
+ }, 100);
|
|
224
|
+ this.getList(true);
|
|
225
|
+ }
|
|
226
|
+
|
|
227
|
+ // 边输边搜节流阀
|
|
228
|
+ isLoading = false;
|
|
229
|
+ changeInp(e) {
|
|
230
|
+ this.changeInpSubject.next([e]);
|
|
231
|
+ }
|
|
232
|
+
|
|
233
|
+ // 打开任务类型
|
|
234
|
+ openOtherTasktype(e){
|
|
235
|
+ if(e){
|
|
236
|
+ this.getOtherTasktype();
|
|
237
|
+ }
|
|
238
|
+ }
|
|
239
|
+}
|