|
@@ -0,0 +1,309 @@
|
|
1
|
+import { Component, OnInit, Input } from "@angular/core";
|
|
2
|
+import { Subject } from 'rxjs';
|
|
3
|
+import { debounceTime } from 'rxjs/operators';
|
|
4
|
+import { Validators, FormGroup, FormBuilder } from '@angular/forms';
|
|
5
|
+import { ToolService } from 'src/app/services/tool.service';
|
|
6
|
+import { NzMessageService } from 'ng-zorro-antd';
|
|
7
|
+import { MainService } from 'src/app/services/main.service';
|
|
8
|
+
|
|
9
|
+@Component({
|
|
10
|
+ selector: "app-configuration-inspect-inspects",
|
|
11
|
+ templateUrl: "./configuration-inspect-inspects.component.html",
|
|
12
|
+ styleUrls: ["./configuration-inspect-inspects.component.less"],
|
|
13
|
+})
|
|
14
|
+export class ConfigurationInspectInspectsComponent implements OnInit {
|
|
15
|
+ constructor(
|
|
16
|
+ private mainService: MainService,
|
|
17
|
+ private fb: FormBuilder,
|
|
18
|
+ private tool: ToolService,
|
|
19
|
+ private message: NzMessageService,
|
|
20
|
+ ) {}
|
|
21
|
+
|
|
22
|
+ coopData: any = {}; //当前操作列
|
|
23
|
+ hosId: any = this.tool.getCurrentHospital().id;
|
|
24
|
+
|
|
25
|
+ searchTimerSubject = new Subject();
|
|
26
|
+
|
|
27
|
+ ngOnInit() {
|
|
28
|
+ this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
29
|
+ let fun = v[0];
|
|
30
|
+ fun.call(this, v[1]);
|
|
31
|
+ });
|
|
32
|
+ setTimeout(() => {
|
|
33
|
+ this.tableWechatHeight = document.querySelector('#wechatTable').clientHeight - document.querySelector('#wechatTable .list-template__top').clientHeight - 8 - document.querySelector('#wechatTable .thead').clientHeight;
|
|
34
|
+ }, 0)
|
|
35
|
+ this.getTypes();
|
|
36
|
+ this.getList();
|
|
37
|
+ }
|
|
38
|
+
|
|
39
|
+ // 新增弹框
|
|
40
|
+ modelName = ""; //模态框名称
|
|
41
|
+ modalWechat: boolean = false; //新增/编辑模态框
|
|
42
|
+ add: boolean; //true:新增;false:编辑
|
|
43
|
+ addWechatModal() {
|
|
44
|
+ this.modelName = "新增";
|
|
45
|
+ this.add = true; //新增
|
|
46
|
+ this.modalWechat = true;
|
|
47
|
+ this.initWechatForm();
|
|
48
|
+ }
|
|
49
|
+ //关闭新增/编辑弹框
|
|
50
|
+ hideWechatModal() {
|
|
51
|
+ this.modalWechat = false;
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ // 编辑
|
|
55
|
+ editWechat(data) {
|
|
56
|
+ console.log(data);
|
|
57
|
+ this.modelName = "编辑";
|
|
58
|
+ this.add = false;
|
|
59
|
+ this.modalWechat = true;
|
|
60
|
+ this.initWechatForm();
|
|
61
|
+ this.coopData = data;
|
|
62
|
+ this.validateForm.controls.orders.setValue(data.orders);
|
|
63
|
+ this.validateForm.controls.name.setValue(data.name);
|
|
64
|
+ this.validateForm.controls.extra4.setValue(data.extra4DTO ? data.extra4DTO.id : null);
|
|
65
|
+ this.validateForm.controls.extra5.setValue(data.extra5DTO ? data.extra5DTO.id : null);
|
|
66
|
+
|
|
67
|
+ data.extra4DTO && (this.deptList = [data.extra4DTO]);
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ // 新增/编辑表单提交
|
|
71
|
+ btnLoading: boolean = false; //提交按钮loading状态
|
|
72
|
+ submitWechatForm(): void {
|
|
73
|
+ for (const i in this.validateForm.controls) {
|
|
74
|
+ this.validateForm.controls[i].markAsDirty();
|
|
75
|
+ this.validateForm.controls[i].updateValueAndValidity();
|
|
76
|
+ }
|
|
77
|
+ if (this.validateForm.invalid) {
|
|
78
|
+ return;
|
|
79
|
+ }
|
|
80
|
+ console.log(this.validateForm.value);
|
|
81
|
+ this.btnLoading = true;
|
|
82
|
+ let postData:any = {};
|
|
83
|
+
|
|
84
|
+ let arr = this.dataList.filter(
|
|
85
|
+ (item) => item.name == this.validateForm.value.name && item.id != this.coopData.id
|
|
86
|
+ );
|
|
87
|
+
|
|
88
|
+ //有重复名称
|
|
89
|
+ if (arr.length > 0) {
|
|
90
|
+ this.btnLoading = false;
|
|
91
|
+ this.showPromptModal(
|
|
92
|
+ this.add ? "新增" : "编辑",
|
|
93
|
+ false,
|
|
94
|
+ `存在重复的检查项目名称【${this.validateForm.value.name}】请修改后再保存!`
|
|
95
|
+ );
|
|
96
|
+ return;
|
|
97
|
+ }
|
|
98
|
+
|
|
99
|
+ if (this.add) {
|
|
100
|
+ //增加
|
|
101
|
+ let n = 0;
|
|
102
|
+ if (this.dataList.length > 0) {
|
|
103
|
+ let sortArr = this.dataList.map((item) => Number(item.value));
|
|
104
|
+ n = Math.max.apply(null, sortArr);
|
|
105
|
+ } else {
|
|
106
|
+ n = 0;
|
|
107
|
+ }
|
|
108
|
+ postData = {
|
|
109
|
+ // dictionary: {
|
|
110
|
+ key: "inspect_check_type",
|
|
111
|
+ value: n + 1,
|
|
112
|
+ desc: "检查项目",
|
|
113
|
+ orders: this.validateForm.value.orders,
|
|
114
|
+ name: this.validateForm.value.name,
|
|
115
|
+ extra4: this.validateForm.value.extra4,
|
|
116
|
+ extra5: this.validateForm.value.extra5,
|
|
117
|
+ // }
|
|
118
|
+ };
|
|
119
|
+ } else {
|
|
120
|
+ //编辑
|
|
121
|
+ postData = {
|
|
122
|
+ // dictionary: {
|
|
123
|
+ ...this.coopData,
|
|
124
|
+ ...{
|
|
125
|
+ orders: this.validateForm.value.orders,
|
|
126
|
+ name: this.validateForm.value.name,
|
|
127
|
+ extra4: this.validateForm.value.extra4,
|
|
128
|
+ extra5: this.validateForm.value.extra5,
|
|
129
|
+ }
|
|
130
|
+ // }
|
|
131
|
+ };
|
|
132
|
+ }
|
|
133
|
+ this.mainService
|
|
134
|
+ .simplePost("addData", "dictionary", postData)
|
|
135
|
+ .subscribe((result) => {
|
|
136
|
+ this.btnLoading = false;
|
|
137
|
+ this.hideWechatModal();
|
|
138
|
+ let msg = "";
|
|
139
|
+ if (this.add) {
|
|
140
|
+ msg = "新增";
|
|
141
|
+ } else {
|
|
142
|
+ msg = "修改";
|
|
143
|
+ }
|
|
144
|
+ if (result.status == 200) {
|
|
145
|
+ this.showPromptModal(msg, true, '');
|
|
146
|
+ } else {
|
|
147
|
+ this.showPromptModal(msg, false, result.msg);
|
|
148
|
+ }
|
|
149
|
+ });
|
|
150
|
+ }
|
|
151
|
+
|
|
152
|
+ // 初始化新增form表单
|
|
153
|
+ validateForm: FormGroup; //新增/编辑表单
|
|
154
|
+ initWechatForm() {
|
|
155
|
+ this.validateForm = this.fb.group({
|
|
156
|
+ orders: [null, [Validators.required]],
|
|
157
|
+ name: [null, [Validators.required]],
|
|
158
|
+ extra4: [null, [Validators.required]],
|
|
159
|
+ extra5: [null, [Validators.required]],
|
|
160
|
+ });
|
|
161
|
+ }
|
|
162
|
+
|
|
163
|
+ // 重置
|
|
164
|
+ queryData: any = {}
|
|
165
|
+ reset(){
|
|
166
|
+ this.queryData = {};
|
|
167
|
+ this.getList();
|
|
168
|
+ }
|
|
169
|
+
|
|
170
|
+ // 获取列表
|
|
171
|
+ loading1:boolean = false;
|
|
172
|
+ dataList: any[] = []; //表格数据
|
|
173
|
+ tableWechatHeight:number = 0;
|
|
174
|
+ getList() {
|
|
175
|
+ let data = {
|
|
176
|
+ idx: 0,
|
|
177
|
+ sum: 9999,
|
|
178
|
+ dictionary: {
|
|
179
|
+ key: "inspect_check_type",
|
|
180
|
+ name: this.queryData.name,
|
|
181
|
+ extra4: this.queryData.extra4,
|
|
182
|
+ extra5: this.queryData.extra5,
|
|
183
|
+ },
|
|
184
|
+ };
|
|
185
|
+ this.loading1 = true;
|
|
186
|
+ this.mainService
|
|
187
|
+ .getFetchDataList("simple/data", "dictionary", data)
|
|
188
|
+ .subscribe((data) => {
|
|
189
|
+ this.loading1 = false;
|
|
190
|
+ if (data.status == 200) {
|
|
191
|
+ this.dataList = data.list || [];
|
|
192
|
+ }else{
|
|
193
|
+ this.message.error(data.msg || "请求数据失败");
|
|
194
|
+ }
|
|
195
|
+ });
|
|
196
|
+ }
|
|
197
|
+
|
|
198
|
+ // 防抖
|
|
199
|
+ isLoading = false;
|
|
200
|
+ isSelecting:boolean = false; // 是否在选中状态
|
|
201
|
+ searchTimer(fun, e) {
|
|
202
|
+ if (this.isSelecting) {
|
|
203
|
+ this.isSelecting = false; // 重置标志
|
|
204
|
+ return; // 跳过处理
|
|
205
|
+ }
|
|
206
|
+ this.isLoading = true;
|
|
207
|
+ this.searchTimerSubject.next([fun, e]);
|
|
208
|
+ }
|
|
209
|
+
|
|
210
|
+ // 设置标志
|
|
211
|
+ setIsSelecting(flag){
|
|
212
|
+ this.isSelecting = flag; // 设置标志
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ openChangeDept(flag){
|
|
216
|
+ flag && this.setIsSelecting(false);
|
|
217
|
+ flag && this.getDeptList();
|
|
218
|
+ }
|
|
219
|
+
|
|
220
|
+ // 科室搜索
|
|
221
|
+ changeDeptInp(e) {
|
|
222
|
+ this.searchTimer(this.getDeptList, e);
|
|
223
|
+ }
|
|
224
|
+
|
|
225
|
+ // 获取检查科室
|
|
226
|
+ deptList: any = [];
|
|
227
|
+ getDeptList(e = undefined) {
|
|
228
|
+ let postData = {
|
|
229
|
+ idx: 0,
|
|
230
|
+ sum: 20,
|
|
231
|
+ department: {
|
|
232
|
+ searchType: 1,// 简单查询
|
|
233
|
+ hospital: { id: this.hosId },
|
|
234
|
+ dept: e,
|
|
235
|
+ }
|
|
236
|
+ };
|
|
237
|
+ this.isLoading = true;
|
|
238
|
+ this.mainService
|
|
239
|
+ .getFetchDataList("simple/data", "department", postData)
|
|
240
|
+ .subscribe((data) => {
|
|
241
|
+ this.isLoading = false;
|
|
242
|
+ this.deptList = data.list || [];
|
|
243
|
+ });
|
|
244
|
+ }
|
|
245
|
+
|
|
246
|
+ // 获取检查类型
|
|
247
|
+ typeList: any = [];
|
|
248
|
+ getTypes() {
|
|
249
|
+ this.mainService.getDictionary('list', 'inspect_check_item').subscribe((data) => {
|
|
250
|
+ this.isLoading = false;
|
|
251
|
+ this.typeList = data || [];
|
|
252
|
+ });
|
|
253
|
+ }
|
|
254
|
+
|
|
255
|
+ delModal: boolean = false; //删除模态框
|
|
256
|
+ tipsMsg1: string; //提示框信息
|
|
257
|
+ tipsMsg2: string; //操作后信息
|
|
258
|
+ confirmDelType: string; //确认的类型(启用/停用,删除)
|
|
259
|
+ showDelModal(
|
|
260
|
+ data,
|
|
261
|
+ tipsMsg1: string,
|
|
262
|
+ tipsMsg2: string,
|
|
263
|
+ type: string,
|
|
264
|
+ ) {
|
|
265
|
+ this.confirmDelType = type;
|
|
266
|
+ this.delModal = true;
|
|
267
|
+ this.coopData = data;
|
|
268
|
+ this.tipsMsg1 = tipsMsg1;
|
|
269
|
+ this.tipsMsg2 = tipsMsg2;
|
|
270
|
+ }
|
|
271
|
+ // 隐藏删除框
|
|
272
|
+ hideDelModal() {
|
|
273
|
+ this.delModal = false;
|
|
274
|
+ }
|
|
275
|
+ // 确认删除
|
|
276
|
+ confirmDel() {
|
|
277
|
+ this.btnLoading = true;
|
|
278
|
+ if (this.confirmDelType === "del") {
|
|
279
|
+ //删除
|
|
280
|
+ this.mainService
|
|
281
|
+ .simplePost("rmvData", "dictionary", [this.coopData.id])
|
|
282
|
+ .subscribe((data) => {
|
|
283
|
+ this.btnLoading = false;
|
|
284
|
+ this.delModal = false;
|
|
285
|
+ if (data.status == 200) {
|
|
286
|
+ this.showPromptModal(this.tipsMsg2, true, "");
|
|
287
|
+ } else {
|
|
288
|
+ this.showPromptModal(this.tipsMsg2, false, data.msg);
|
|
289
|
+ }
|
|
290
|
+ });
|
|
291
|
+ }
|
|
292
|
+ }
|
|
293
|
+
|
|
294
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
295
|
+ promptContent: string; //操作提示框提示信息
|
|
296
|
+ ifSuccess: boolean; //操作成功/失败
|
|
297
|
+ promptInfo: string; //操作结果提示信息
|
|
298
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
299
|
+ showPromptModal(con, success, promptInfo?) {
|
|
300
|
+ this.promptModalShow = false;
|
|
301
|
+ this.promptContent = con;
|
|
302
|
+ this.ifSuccess = success;
|
|
303
|
+ this.promptInfo = promptInfo;
|
|
304
|
+ setTimeout(() => {
|
|
305
|
+ this.promptModalShow = true;
|
|
306
|
+ }, 100);
|
|
307
|
+ this.getList();
|
|
308
|
+ }
|
|
309
|
+}
|