|
@@ -0,0 +1,283 @@
|
|
1
|
+import { Component, OnInit } from "@angular/core";
|
|
2
|
+import { ActivatedRoute, Router } from "@angular/router";
|
|
3
|
+import { FormBuilder, Validators, FormGroup } from "@angular/forms";
|
|
4
|
+
|
|
5
|
+import { MainService } from "../../services/main.service";
|
|
6
|
+import { ToolService } from "../../services/tool.service";
|
|
7
|
+import { NzMessageService } from 'ng-zorro-antd';
|
|
8
|
+import { Subject } from 'rxjs';
|
|
9
|
+import { debounceTime } from 'rxjs/operators';
|
|
10
|
+import { format } from 'date-fns';
|
|
11
|
+@Component({
|
|
12
|
+ selector: "app-inspection-batch",
|
|
13
|
+ templateUrl: "./inspection-batch.component.html",
|
|
14
|
+ styleUrls: ["./inspection-batch.component.less"],
|
|
15
|
+})
|
|
16
|
+export class InspectionBatchComponent implements OnInit {
|
|
17
|
+ constructor(
|
|
18
|
+ private fb: FormBuilder,
|
|
19
|
+ private mainService: MainService,
|
|
20
|
+ private route: ActivatedRoute,
|
|
21
|
+ private router: Router,
|
|
22
|
+ private tool: ToolService,
|
|
23
|
+ private message: NzMessageService,
|
|
24
|
+ ) {}
|
|
25
|
+
|
|
26
|
+ listOfData: any[] = []; //表格数据
|
|
27
|
+ pageIndex: number = 1; //表格当前页码
|
|
28
|
+ pageSize: number = 10; //表格每页展示条数
|
|
29
|
+ listLength: number = 10; //表格总数据量
|
|
30
|
+ modal: boolean = false; //新增/编辑模态框
|
|
31
|
+ add: boolean; //true:新增;false:编辑
|
|
32
|
+ validateForm: FormGroup; //新增/编辑表单
|
|
33
|
+ coopData: any; //当前操作列
|
|
34
|
+ currentHospital; //当前院区
|
|
35
|
+
|
|
36
|
+ btnLoading: boolean = false; //提交按钮loading状态
|
|
37
|
+
|
|
38
|
+ promptContent: string; //操作提示框提示信息
|
|
39
|
+ ifSuccess: boolean; //操作成功/失败
|
|
40
|
+ promptInfo: string; //操作结果提示信息
|
|
41
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
42
|
+ nextSchemeName = ""; //下一个开启的方案名称
|
|
43
|
+ modelName = ""; //模态框名称
|
|
44
|
+
|
|
45
|
+ changeInpSubject = new Subject(); //防抖
|
|
46
|
+ showDropdown:boolean = false;
|
|
47
|
+
|
|
48
|
+ ngOnInit() {
|
|
49
|
+ //防抖
|
|
50
|
+ this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
51
|
+ if(v[1] === 'incidentPlan'){
|
|
52
|
+ this.getIncidentPlans(v[0], v[2]);
|
|
53
|
+ }
|
|
54
|
+ });
|
|
55
|
+ this.currentHospital = this.tool.getCurrentHospital();
|
|
56
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
57
|
+ this.getList(1);
|
|
58
|
+ this.getIncidentPlans('search', '');
|
|
59
|
+ this.getStatus();
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ // 初始化增删改按钮
|
|
63
|
+ coopBtns: any = {};
|
|
64
|
+
|
|
65
|
+ // 批量关联科室
|
|
66
|
+ inspectionAddressDepartmentPromptModalShow = false; //标本历史记录弹窗开关
|
|
67
|
+ showInspectionAddressDepartment() {
|
|
68
|
+ this.inspectionAddressDepartmentPromptModalShow = true;
|
|
69
|
+ }
|
|
70
|
+ // 关闭弹窗
|
|
71
|
+ closeModelInspectionAddressDepartment(e) {
|
|
72
|
+ this.inspectionAddressDepartmentPromptModalShow = JSON.parse(e).show;
|
|
73
|
+ }
|
|
74
|
+ // 确认弹窗
|
|
75
|
+ checkedDepIdsModel = [];
|
|
76
|
+ confirmModelInspectionAddressDepartment(checkedDepIds) {
|
|
77
|
+ this.inspectionAddressDepartmentPromptModalShow = true;
|
|
78
|
+ this.checkedDepIdsModel = checkedDepIds;
|
|
79
|
+ console.log(checkedDepIds)
|
|
80
|
+ this.showInspectionAddressTag();
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ // 批量关联科室-标签
|
|
84
|
+ inspectionAddressTagPromptModalShow = false; //标本历史记录弹窗开关
|
|
85
|
+ showInspectionAddressTag() {
|
|
86
|
+ this.inspectionAddressTagPromptModalShow = true;
|
|
87
|
+ }
|
|
88
|
+ // 关闭弹窗
|
|
89
|
+ closeModelInspectionAddressTag(e) {
|
|
90
|
+ this.inspectionAddressTagPromptModalShow = JSON.parse(e).show;
|
|
91
|
+ }
|
|
92
|
+ // 确认弹窗
|
|
93
|
+ maskFlag: any = false;
|
|
94
|
+ confirmModelInspectionAddressTag(tags) {
|
|
95
|
+ this.maskFlag = this.message.loading("正在加载中..", {
|
|
96
|
+ nzDuration: 0,
|
|
97
|
+ }).messageId;
|
|
98
|
+ this.inspectionAddressTagPromptModalShow = true;
|
|
99
|
+ console.log(this.checkedDepIdsModel, tags);
|
|
100
|
+ let postData:any = {
|
|
101
|
+ deptIds: this.checkedDepIdsModel.toString(),
|
|
102
|
+ hosId: this.currentHospital.id,
|
|
103
|
+ tagIds: tags.toString(),
|
|
104
|
+ };
|
|
105
|
+ console.log(postData);
|
|
106
|
+ this.btnLoading = true;
|
|
107
|
+ this.mainService
|
|
108
|
+ .inspectionPost("batchBindFormNode", postData)
|
|
109
|
+ .subscribe((result) => {
|
|
110
|
+ this.message.remove(this.maskFlag);
|
|
111
|
+ this.maskFlag = false;
|
|
112
|
+ this.btnLoading = false;
|
|
113
|
+ if (result.status == 200) {
|
|
114
|
+ this.inspectionAddressDepartmentPromptModalShow = false;
|
|
115
|
+ this.inspectionAddressTagPromptModalShow = false;
|
|
116
|
+ this.showPromptModal('操作', true, '');
|
|
117
|
+ } else if (result.status == 501) {
|
|
118
|
+ this.inspectionAddressDepartmentPromptModalShow = false;
|
|
119
|
+ this.inspectionAddressTagPromptModalShow = false;
|
|
120
|
+ this.showPromptModal('操作', true, result.msg);
|
|
121
|
+ } else {
|
|
122
|
+ this.showPromptModal('操作', false, result.msg);
|
|
123
|
+ }
|
|
124
|
+ });
|
|
125
|
+ }
|
|
126
|
+
|
|
127
|
+ // 搜索
|
|
128
|
+ search() {
|
|
129
|
+ this.getList(0);
|
|
130
|
+ }
|
|
131
|
+ // 重置
|
|
132
|
+ reset() {
|
|
133
|
+ this.dateRange = [];
|
|
134
|
+ this.changeDate();
|
|
135
|
+ this.searchDto = {};
|
|
136
|
+ this.getList(1);
|
|
137
|
+ }
|
|
138
|
+
|
|
139
|
+ // 表格数据
|
|
140
|
+ searchDto: any = {};
|
|
141
|
+ loading1 = false;
|
|
142
|
+ getList(type) {
|
|
143
|
+ if (type == 1) {
|
|
144
|
+ this.pageIndex = 1;
|
|
145
|
+ }
|
|
146
|
+ let data:any = {
|
|
147
|
+ idx: this.pageIndex - 1,
|
|
148
|
+ sum: this.pageSize,
|
|
149
|
+ inspectionBatch: {
|
|
150
|
+ hosId: this.currentHospital.id,
|
|
151
|
+ inspectionId: this.searchDto.inspectionId || undefined,
|
|
152
|
+ status: this.searchDto.statusId ? { id: this.searchDto.statusId } : undefined,
|
|
153
|
+ },
|
|
154
|
+ };
|
|
155
|
+ if (this.startDate && this.endDate) {
|
|
156
|
+ data.inspectionBatch.addTimeStart = this.startDate;
|
|
157
|
+ data.inspectionBatch.addTimeEnd = this.endDate;
|
|
158
|
+ }
|
|
159
|
+ this.loading1 = true;
|
|
160
|
+ this.mainService
|
|
161
|
+ .getFetchDataList("simple/data", "inspectionBatch", data)
|
|
162
|
+ .subscribe((data) => {
|
|
163
|
+ this.loading1 = false;
|
|
164
|
+ if (data.status == 200) {
|
|
165
|
+ this.listOfData = data.list;
|
|
166
|
+ this.listLength = data.totalNum;
|
|
167
|
+ }else{
|
|
168
|
+ this.message.error(data.msg || "请求数据失败");
|
|
169
|
+ }
|
|
170
|
+ });
|
|
171
|
+ }
|
|
172
|
+
|
|
173
|
+ // 边输边搜节流阀
|
|
174
|
+ isLoading = false;
|
|
175
|
+ changeInp(type, model, e) {
|
|
176
|
+ this.isLoading = true;
|
|
177
|
+ this.changeInpSubject.next([type, model, e]);
|
|
178
|
+ }
|
|
179
|
+
|
|
180
|
+ // 获取巡检计划
|
|
181
|
+ incidentPlanSearchList: any = [];
|
|
182
|
+ getIncidentPlans(type, keyword, init = false) {
|
|
183
|
+ let postData = {
|
|
184
|
+ inspection: {
|
|
185
|
+ name: keyword,
|
|
186
|
+ hosId: this.currentHospital.id,
|
|
187
|
+ },
|
|
188
|
+ idx: 0,
|
|
189
|
+ sum: 20,
|
|
190
|
+ };
|
|
191
|
+ this.mainService
|
|
192
|
+ .getFetchDataList("data", "inspection", postData)
|
|
193
|
+ .subscribe((data) => {
|
|
194
|
+ this.incidentPlanSearchList = data.list;
|
|
195
|
+ this.isLoading = false;
|
|
196
|
+ });
|
|
197
|
+ }
|
|
198
|
+
|
|
199
|
+ // 获取状态
|
|
200
|
+ statusSearchList: any = [];
|
|
201
|
+ getStatus() {
|
|
202
|
+ this.mainService
|
|
203
|
+ .getDictionary('list', 'inspection_batch_status')
|
|
204
|
+ .subscribe((data) => {
|
|
205
|
+ this.statusSearchList = data || [];
|
|
206
|
+ });
|
|
207
|
+ }
|
|
208
|
+
|
|
209
|
+ dateRange: any = []; //时间范围
|
|
210
|
+ onCalendarChangeDate(dateArr){
|
|
211
|
+ console.log(dateArr)
|
|
212
|
+ if(dateArr.length == 2){
|
|
213
|
+ let dateStart = new Date(dateArr[0]);
|
|
214
|
+ let dateEnd = new Date(dateArr[1]);
|
|
215
|
+ dateStart.setHours(0,0,0);
|
|
216
|
+ dateEnd.setHours(23,59,59);
|
|
217
|
+ this.dateRange = [dateStart,dateEnd];
|
|
218
|
+ }
|
|
219
|
+ }
|
|
220
|
+
|
|
221
|
+ // 日期选择
|
|
222
|
+ startDate: string; //发起时间开始
|
|
223
|
+ endDate: string; //发起时间结束
|
|
224
|
+ changeDate(result?): void {
|
|
225
|
+ if (!result) {
|
|
226
|
+ this.startDate = this.endDate = "";
|
|
227
|
+ return;
|
|
228
|
+ }
|
|
229
|
+ this.startDate = format(result[0], 'yyyy-MM-dd HH:mm:ss');
|
|
230
|
+ this.endDate = format(result[1], 'yyyy-MM-dd HH:mm:ss');
|
|
231
|
+ }
|
|
232
|
+
|
|
233
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
234
|
+ showPromptModal(con, success, promptInfo?) {
|
|
235
|
+ this.promptModalShow = false;
|
|
236
|
+ this.promptContent = con;
|
|
237
|
+ this.ifSuccess = success;
|
|
238
|
+ this.promptInfo = promptInfo;
|
|
239
|
+ setTimeout(() => {
|
|
240
|
+ this.promptModalShow = true;
|
|
241
|
+ }, 100);
|
|
242
|
+ this.getList(0);
|
|
243
|
+ }
|
|
244
|
+
|
|
245
|
+ delModal: boolean = false; //删除模态框
|
|
246
|
+ tipsMsg1: string; //提示框信息
|
|
247
|
+ tipsMsg2: string; //操作后信息
|
|
248
|
+ confirmDelType: string; //确认的类型(启用/停用,删除)
|
|
249
|
+ showDelModal(
|
|
250
|
+ data,
|
|
251
|
+ tipsMsg1: string,
|
|
252
|
+ tipsMsg2: string,
|
|
253
|
+ type: string,
|
|
254
|
+ ) {
|
|
255
|
+ this.confirmDelType = type;
|
|
256
|
+ this.delModal = true;
|
|
257
|
+ this.coopData = data;
|
|
258
|
+ this.tipsMsg1 = tipsMsg1;
|
|
259
|
+ this.tipsMsg2 = tipsMsg2;
|
|
260
|
+ }
|
|
261
|
+ // 隐藏删除框
|
|
262
|
+ hideDelModal() {
|
|
263
|
+ this.delModal = false;
|
|
264
|
+ }
|
|
265
|
+ // 确认删除
|
|
266
|
+ confirmDel() {
|
|
267
|
+ this.btnLoading = true;
|
|
268
|
+ if (this.confirmDelType === "del") {
|
|
269
|
+ //删除
|
|
270
|
+ this.mainService
|
|
271
|
+ .simplePost("rmvData", "inspectionBatch", [this.coopData.id])
|
|
272
|
+ .subscribe((data) => {
|
|
273
|
+ this.btnLoading = false;
|
|
274
|
+ this.delModal = false;
|
|
275
|
+ if (data.status == 200) {
|
|
276
|
+ this.showPromptModal(this.tipsMsg2, true, "");
|
|
277
|
+ } else {
|
|
278
|
+ this.showPromptModal(this.tipsMsg2, false, data.msg);
|
|
279
|
+ }
|
|
280
|
+ });
|
|
281
|
+ }
|
|
282
|
+ }
|
|
283
|
+}
|