|
@@ -1,12 +1,10 @@
|
1
|
1
|
import { Component, OnInit } from "@angular/core";
|
2
|
|
-import { ActivatedRoute, Router } from "@angular/router";
|
|
2
|
+import { ActivatedRoute } from "@angular/router";
|
3
|
3
|
import { FormBuilder, Validators, FormGroup } from "@angular/forms";
|
4
|
4
|
|
5
|
5
|
import { MainService } from "../../services/main.service";
|
6
|
6
|
import { ToolService } from "../../services/tool.service";
|
7
|
7
|
import { NzMessageService } from 'ng-zorro-antd';
|
8
|
|
-import { Subject } from 'rxjs';
|
9
|
|
-import { debounceTime } from 'rxjs/operators';
|
10
|
8
|
@Component({
|
11
|
9
|
selector: "app-tripartite-company",
|
12
|
10
|
templateUrl: "./tripartite-company.component.html",
|
|
@@ -17,7 +15,6 @@ export class TripartiteCompanyComponent implements OnInit {
|
17
|
15
|
private fb: FormBuilder,
|
18
|
16
|
private mainService: MainService,
|
19
|
17
|
private route: ActivatedRoute,
|
20
|
|
- private router: Router,
|
21
|
18
|
private tool: ToolService,
|
22
|
19
|
private message: NzMessageService,
|
23
|
20
|
) {}
|
|
@@ -41,29 +38,13 @@ export class TripartiteCompanyComponent implements OnInit {
|
41
|
38
|
nextSchemeName = ""; //下一个开启的方案名称
|
42
|
39
|
modelName = ""; //模态框名称
|
43
|
40
|
|
44
|
|
- changeInpSubject = new Subject(); //防抖
|
45
|
41
|
showDropdown:boolean = false;
|
46
|
42
|
|
47
|
43
|
ngOnInit() {
|
48
|
|
- //防抖
|
49
|
|
- this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
|
50
|
|
- if(v[1] === 'department'){
|
51
|
|
- this.getDeparts(v[0], v[2]);
|
52
|
|
- } else if(v[1] === 'building'){
|
53
|
|
- this.getBuildings(v[0], v[2]);
|
54
|
|
- } else if(v[1] === 'floor'){
|
55
|
|
- this.getFloors(v[0], v[2], this.validateForm.value.buildId);
|
56
|
|
- }
|
57
|
|
- });
|
58
|
44
|
this.currentHospital = this.tool.getCurrentHospital();
|
59
|
45
|
this.coopBtns = this.tool.initCoopBtns(this.route);
|
60
|
46
|
this.getList(1);
|
61
|
|
- this.getDeparts('search', '');
|
62
|
|
- this.getDeparts('add', '');
|
63
|
|
- this.getTags('add', '');
|
64
|
|
- this.getBuildings('add', '');
|
65
|
|
- this.getBuildings('search', '');
|
66
|
|
- this.getDispatchMethods();
|
|
47
|
+ this.getCompanyType();
|
67
|
48
|
}
|
68
|
49
|
|
69
|
50
|
// 初始化增删改按钮
|
|
@@ -91,6 +72,7 @@ export class TripartiteCompanyComponent implements OnInit {
|
91
|
72
|
sum: this.pageSize,
|
92
|
73
|
company: {
|
93
|
74
|
hosId: this.currentHospital.id,
|
|
75
|
+ busiType: { key: 'company_busi_type', value: '2' },
|
94
|
76
|
...this.searchDto,
|
95
|
77
|
},
|
96
|
78
|
};
|
|
@@ -123,245 +105,23 @@ export class TripartiteCompanyComponent implements OnInit {
|
123
|
105
|
|
124
|
106
|
// 初始化新增form表单
|
125
|
107
|
initForm() {
|
126
|
|
- this.floorList = [];
|
127
|
108
|
this.validateForm = this.fb.group({
|
128
|
109
|
name: ['', [Validators.required, Validators.pattern(/\S/)]],
|
129
|
|
- deptId: [null, [Validators.required]],
|
130
|
|
- buildId: [null, [Validators.required]],
|
131
|
|
- floorId: [null, [Validators.required]],
|
132
|
|
- tagIds: [[], [Validators.required]],
|
133
|
|
- signType: [null, [Validators.required]],
|
|
110
|
+ nickName: ['', [Validators.required]],
|
|
111
|
+ companyTypeIds: [this.companyTypeList.map(v => ({ label: v.name, value: v.id, checked: false })), [Validators.required]],
|
|
112
|
+ contacts: [''],
|
|
113
|
+ mphone: [''],
|
134
|
114
|
});
|
135
|
115
|
}
|
136
|
116
|
|
137
|
|
- // 边输边搜节流阀
|
138
|
|
- isLoading = false;
|
139
|
|
- changeInp(type, model, e) {
|
|
117
|
+ //获取公司分类
|
|
118
|
+ isLoading:boolean = false;
|
|
119
|
+ companyTypeList:any[] = [];
|
|
120
|
+ getCompanyType() {
|
140
|
121
|
this.isLoading = true;
|
141
|
|
- this.changeInpSubject.next([type, model, e]);
|
142
|
|
- }
|
143
|
|
-
|
144
|
|
- // 获取所有科室
|
145
|
|
- departmentAddList: any = []; //所有所属科室
|
146
|
|
- departmentSearchList: any = []; //所有所属科室(搜索)
|
147
|
|
- getDeparts(type, keyword, init = false) {
|
148
|
|
- let postData:any = {
|
149
|
|
- department: {
|
150
|
|
- // searchType: 1,// 简单查询
|
151
|
|
- dept: keyword,
|
152
|
|
- cascadeHosId: this.currentHospital.id,
|
153
|
|
- },
|
154
|
|
- idx: 0,
|
155
|
|
- sum: 20,
|
156
|
|
- };
|
157
|
|
- if(type === 'add'){
|
158
|
|
- postData.department.bussType = 'inspection';
|
159
|
|
- }
|
160
|
|
- this.mainService
|
161
|
|
- .getFetchDataList("data", "department", postData)
|
162
|
|
- .subscribe((data) => {
|
163
|
|
- if (type == "search") {
|
164
|
|
- this.departmentSearchList = data.list;
|
165
|
|
- } else if (type == "add") {
|
166
|
|
- this.departmentAddList = data.list;
|
167
|
|
- }
|
168
|
|
-
|
169
|
|
- this.isLoading = false;
|
170
|
|
-
|
171
|
|
- if(init && this.coopData && this.coopData.departmentDTO){
|
172
|
|
- let deptId = this.coopData.departmentDTO.id;
|
173
|
|
- let flag = this.departmentAddList.some(v => v.id == deptId);
|
174
|
|
- if(!flag){
|
175
|
|
- this.departmentAddList.unshift(this.coopData.departmentDTO)
|
176
|
|
- }
|
177
|
|
- this.validateForm.controls.deptId.setValue(this.coopData.departmentDTO.id);
|
178
|
|
- }
|
179
|
|
- });
|
180
|
|
- }
|
181
|
|
-
|
182
|
|
- // 获取标签
|
183
|
|
- tagList: any = [];
|
184
|
|
- tagListCopy: any = [];
|
185
|
|
- getTags(type, keyword) {
|
186
|
|
- let postData = {
|
187
|
|
- tag: {
|
188
|
|
- hosId: this.currentHospital.id,
|
189
|
|
- modelType: { value: 'inspection' },
|
190
|
|
- },
|
191
|
|
- idx: 0,
|
192
|
|
- sum: 50,
|
193
|
|
- };
|
194
|
|
- this.mainService
|
195
|
|
- .getFetchDataList("simple/data", "tag", postData)
|
196
|
|
- .subscribe((data) => {
|
197
|
|
- this.tagList = data.list;
|
198
|
|
- this.tagListCopy = JSON.parse(JSON.stringify(this.tagList));
|
199
|
|
- this.isLoading = false;
|
200
|
|
- });
|
201
|
|
- }
|
202
|
|
-
|
203
|
|
- // 获取楼栋
|
204
|
|
- buildingAddList: any = [];
|
205
|
|
- buildingSearchList: any = [];
|
206
|
|
- getBuildings(type, keyword, init = false) {
|
207
|
|
- let postData = {
|
208
|
|
- building: {
|
209
|
|
- simpleQuery: true,
|
210
|
|
- buildingName: keyword,
|
211
|
|
- cascadeHosId: this.currentHospital.id,
|
212
|
|
- },
|
213
|
|
- idx: 0,
|
214
|
|
- sum: 20,
|
215
|
|
- };
|
216
|
|
- this.mainService
|
217
|
|
- .getFetchDataList("simple/data", "building", postData)
|
218
|
|
- .subscribe((data) => {
|
219
|
|
- if (type == "search") {
|
220
|
|
- this.buildingSearchList = data.list;
|
221
|
|
- } else if (type == "add") {
|
222
|
|
- this.buildingAddList = data.list;
|
223
|
|
- }
|
224
|
|
- this.isLoading = false;
|
225
|
|
-
|
226
|
|
- if(init && this.coopData && this.coopData.buildingDTO){
|
227
|
|
- let buildId = this.coopData.buildingDTO.id;
|
228
|
|
- let flag = this.buildingAddList.some(v => v.id == buildId);
|
229
|
|
- if(!flag){
|
230
|
|
- this.buildingAddList.unshift(this.coopData.buildingDTO)
|
231
|
|
- }
|
232
|
|
- this.validateForm.controls.buildId.setValue(this.coopData.buildingDTO.id);
|
233
|
|
- } else if (this.deptDto && this.deptDto.building){
|
234
|
|
- let buildId = this.deptDto.building.id;
|
235
|
|
- let flag = this.buildingAddList.some(v => v.id == buildId);
|
236
|
|
- if(!flag){
|
237
|
|
- this.buildingAddList.unshift(this.deptDto.building)
|
238
|
|
- }
|
239
|
|
- this.validateForm.controls.buildId.setValue(this.deptDto.building.id);
|
240
|
|
- }
|
241
|
|
- });
|
242
|
|
- }
|
243
|
|
-
|
244
|
|
- // 修改关联科室
|
245
|
|
- deptDto:any = null;
|
246
|
|
- changeDepartment(deptId){
|
247
|
|
- if(this.add){
|
248
|
|
- console.log(deptId)
|
249
|
|
- this.deptDto = this.departmentAddList.find(v => v.id == deptId);
|
250
|
|
- console.log(this.deptDto);
|
251
|
|
- if(this.deptDto && this.deptDto.dept && !this.validateForm.value.name){
|
252
|
|
- this.validateForm.controls.name.setValue(this.deptDto.dept);
|
253
|
|
- }
|
254
|
|
-
|
255
|
|
- if(this.deptDto && this.deptDto.building){
|
256
|
|
- this.getBuildings('add', '');
|
257
|
|
- }
|
258
|
|
-
|
259
|
|
- if(this.deptDto && this.deptDto.floor){
|
260
|
|
- this.noChangeBuilding = true;
|
261
|
|
- this.getFloors('add', '', this.deptDto.building.id, false, true);
|
262
|
|
- }
|
263
|
|
- }
|
264
|
|
- }
|
265
|
|
-
|
266
|
|
- // 修改楼栋
|
267
|
|
- noChangeBuilding:boolean = false;
|
268
|
|
- changeBuilding(buildId?){
|
269
|
|
- console.log(buildId)
|
270
|
|
- if(!this.noChangeBuilding){
|
271
|
|
- this.validateForm.controls.floorId.setValue(null);
|
272
|
|
- this.getFloors('add', '', this.validateForm.value.buildId);
|
273
|
|
- }
|
274
|
|
- this.noChangeBuilding = false;
|
275
|
|
- }
|
276
|
|
-
|
277
|
|
- // 获取楼层
|
278
|
|
- floorList: any = [];
|
279
|
|
- getFloors(type, keyword, buildId, init = false, isNoChangeBuilding = false) {
|
280
|
|
- console.log(isNoChangeBuilding)
|
281
|
|
- if(!buildId){
|
282
|
|
- this.floorList = [];
|
283
|
|
- return;
|
284
|
|
- }
|
285
|
|
- let postData = {
|
286
|
|
- floor: {
|
287
|
|
- floorName: keyword,
|
288
|
|
- buildId,
|
289
|
|
- // hosId: this.currentHospital.id,
|
290
|
|
- },
|
291
|
|
- idx: 0,
|
292
|
|
- sum: 20,
|
293
|
|
- };
|
294
|
|
- this.mainService
|
295
|
|
- .getFetchDataList("simple/data", "floor", postData)
|
296
|
|
- .subscribe((data) => {
|
297
|
|
- this.floorList = data.list;
|
298
|
|
- this.isLoading = false;
|
299
|
|
-
|
300
|
|
- if(init && this.coopData && this.coopData.floorDTO){
|
301
|
|
- let floorId = this.coopData.floorDTO.id;
|
302
|
|
- let flag = this.floorList.some(v => v.id == floorId);
|
303
|
|
- if(!flag){
|
304
|
|
- this.floorList.unshift(this.coopData.floorDTO)
|
305
|
|
- }
|
306
|
|
- this.validateForm.controls.floorId.setValue(this.coopData.floorDTO.id);
|
307
|
|
- } else if (isNoChangeBuilding && this.deptDto && this.deptDto.floor){
|
308
|
|
- let floorId = this.deptDto.floor.id;
|
309
|
|
- let flag = this.floorList.some(v => v.id == floorId);
|
310
|
|
- if(!flag){
|
311
|
|
- this.floorList.unshift(this.deptDto.floor)
|
312
|
|
- }
|
313
|
|
- this.validateForm.controls.floorId.setValue(this.deptDto.floor.id);
|
314
|
|
- }
|
315
|
|
- });
|
316
|
|
- }
|
317
|
|
-
|
318
|
|
- // 选择标签
|
319
|
|
- changeTags(tags){
|
320
|
|
- if(tags.length){
|
321
|
|
- let flag = tags.every(v => {
|
322
|
|
- return this.tagListCopy.map(vv => vv.name).includes(v);
|
323
|
|
- })
|
324
|
|
-
|
325
|
|
- if(flag){
|
326
|
|
- return;
|
327
|
|
- }
|
328
|
|
-
|
329
|
|
- let tagName = tags[tags.length - 1];
|
330
|
|
- let postData = {
|
331
|
|
- tag: {
|
332
|
|
- name: tagName,
|
333
|
|
- hosId: this.currentHospital.id,
|
334
|
|
- modelType: { value: 'inspection' },
|
335
|
|
- }
|
336
|
|
- }
|
337
|
|
- this.isLoading = true;
|
338
|
|
- this.mainService
|
339
|
|
- .coopData("addData", "tag", postData)
|
340
|
|
- .subscribe((result) => {
|
341
|
|
- this.isLoading = false;
|
342
|
|
- console.log(result);
|
343
|
|
- if(result.status == 200){
|
344
|
|
- this.tagListCopy.unshift(result.data)
|
345
|
|
- console.log(this.tagListCopy);
|
346
|
|
- } else if (result.status == 10001){
|
347
|
|
- // 名称重复
|
348
|
|
- this.tagListCopy.unshift(result.data)
|
349
|
|
- console.log(this.tagListCopy);
|
350
|
|
- } else {
|
351
|
|
- tags.pop();
|
352
|
|
- this.message.warning(result.msg || '请求数据失败')
|
353
|
|
- }
|
354
|
|
- });
|
355
|
|
- }
|
356
|
|
- }
|
357
|
|
-
|
358
|
|
- //获取填写方式
|
359
|
|
- dispatchMethods:any[] = [];
|
360
|
|
- getDispatchMethods() {
|
361
|
|
- this.isLoading = true;
|
362
|
|
- this.mainService.getDictionary("list", "inspection_node_sign_type").subscribe((data) => {
|
|
122
|
+ this.mainService.getDictionary("list", "company_type").subscribe((data) => {
|
363
|
123
|
this.isLoading = false;
|
364
|
|
- this.dispatchMethods = data || [];
|
|
124
|
+ this.companyTypeList = data || [];
|
365
|
125
|
});
|
366
|
126
|
}
|
367
|
127
|
|
|
@@ -376,28 +136,20 @@ export class TripartiteCompanyComponent implements OnInit {
|
376
|
136
|
}
|
377
|
137
|
|
378
|
138
|
console.log(this.validateForm.value)
|
379
|
|
- console.log(this.tagListCopy);
|
380
|
139
|
|
381
|
140
|
this.btnLoading = true;
|
382
|
141
|
let postData:any = {};
|
383
|
142
|
|
384
|
|
- let tagNames = this.validateForm.value.tagIds;
|
385
|
|
- let tags = this.tagListCopy;
|
386
|
|
- let tagIds = tagNames.map(name =>{
|
387
|
|
- return tags.find(v => v.name === name).id;
|
388
|
|
- })
|
389
|
|
-
|
390
|
143
|
if (this.add) {
|
391
|
144
|
//增加
|
392
|
145
|
postData = {
|
393
|
146
|
company: {
|
394
|
147
|
name: this.validateForm.value.name,
|
395
|
|
- deptId: this.validateForm.value.deptId,
|
396
|
|
- buildId: this.validateForm.value.buildId,
|
397
|
|
- floorId: this.validateForm.value.floorId,
|
398
|
|
- tagIds: tagIds.toString(),
|
399
|
|
- signType: this.dispatchMethods.find(v => v.value === this.validateForm.value.signType),
|
400
|
|
- hosId: this.currentHospital.id,
|
|
148
|
+ nickName: this.validateForm.value.nickName,
|
|
149
|
+ companyTypeIds: this.validateForm.value.companyTypeIds.filter(v => v.checked).map(v => v.value).toString(),
|
|
150
|
+ contacts: this.validateForm.value.contacts,
|
|
151
|
+ mphone: this.validateForm.value.mphone,
|
|
152
|
+ busiType: { key: 'company_busi_type', value: '2' },
|
401
|
153
|
}
|
402
|
154
|
};
|
403
|
155
|
} else {
|
|
@@ -407,15 +159,16 @@ export class TripartiteCompanyComponent implements OnInit {
|
407
|
159
|
...this.coopData,
|
408
|
160
|
...{
|
409
|
161
|
name: this.validateForm.value.name,
|
410
|
|
- deptId: this.validateForm.value.deptId,
|
411
|
|
- buildId: this.validateForm.value.buildId,
|
412
|
|
- floorId: this.validateForm.value.floorId,
|
413
|
|
- tagIds: tagIds.toString(),
|
414
|
|
- signType: this.dispatchMethods.find(v => v.value === this.validateForm.value.signType),
|
|
162
|
+ nickName: this.validateForm.value.nickName,
|
|
163
|
+ companyTypeIds: this.validateForm.value.companyTypeIds.filter(v => v.checked).map(v => v.value).toString(),
|
|
164
|
+ contacts: this.validateForm.value.contacts,
|
|
165
|
+ mphone: this.validateForm.value.mphone,
|
|
166
|
+ busiType: { key: 'company_busi_type', value: '2' },
|
415
|
167
|
}
|
416
|
168
|
}
|
417
|
169
|
};
|
418
|
170
|
}
|
|
171
|
+ console.log(postData);
|
419
|
172
|
this.mainService
|
420
|
173
|
.coopData("addData", "company", postData)
|
421
|
174
|
.subscribe((result) => {
|
|
@@ -429,8 +182,6 @@ export class TripartiteCompanyComponent implements OnInit {
|
429
|
182
|
}
|
430
|
183
|
if (result.status == 200) {
|
431
|
184
|
this.showPromptModal(msg, true, "");
|
432
|
|
- } else if (result.status == 10001) {
|
433
|
|
- this.showPromptModal(msg, false, "关联科室重复");
|
434
|
185
|
} else {
|
435
|
186
|
this.showPromptModal(msg, false, result.msg);
|
436
|
187
|
}
|
|
@@ -446,10 +197,11 @@ export class TripartiteCompanyComponent implements OnInit {
|
446
|
197
|
this.add = false;
|
447
|
198
|
this.modal = true;
|
448
|
199
|
this.coopData = data;
|
449
|
|
- this.validateForm.controls.name.setValue(data.name); //名称
|
450
|
|
- this.validateForm.controls.deptId.setValue(data.deptId);
|
451
|
|
- this.validateForm.controls.tagIds.setValue(data.tagIdsList.map(v => v.name));
|
452
|
|
- this.validateForm.controls.signType.setValue(data.signType.value);
|
|
200
|
+ this.validateForm.controls.name.setValue(data.name);
|
|
201
|
+ this.validateForm.controls.nickName.setValue(data.nickName);
|
|
202
|
+ this.validateForm.controls.companyTypeIds.setValue(this.companyTypeList.map(v => ({label: v.name, value: v.id, checked: data.companyTypeIds.includes(v.id)})));
|
|
203
|
+ this.validateForm.controls.contacts.setValue(data.contacts);
|
|
204
|
+ this.validateForm.controls.mphone.setValue(data.mphone);
|
453
|
205
|
|
454
|
206
|
if(data.deptId){
|
455
|
207
|
this.getDeparts('add', '', true);
|