|
@@ -17,9 +17,9 @@ export class InspectTypeConfigComponent implements OnInit {
|
17
|
17
|
tableHeight;
|
18
|
18
|
validateForm: FormGroup;
|
19
|
19
|
validateFloorForm: FormGroup;
|
20
|
|
- allFloorList: any[] = []; //当前选中的检查类型包含的所有关键字
|
|
20
|
+ allKeyword: any[] = []; //当前选中的检查类型包含的所有关键字
|
21
|
21
|
mapOfCheckedId: { [key: string]: boolean } = {};
|
22
|
|
- checkedBuilding: any = {}; //选中检查类型
|
|
22
|
+ checkedInspectType: any = {}; //选中检查类型
|
23
|
23
|
inspectTypeList: Array<any> = []; //检查类型信息
|
24
|
24
|
hosId: any; //当前选择的院区id
|
25
|
25
|
promptContent: string; //操作提示框提示信息
|
|
@@ -67,47 +67,55 @@ export class InspectTypeConfigComponent implements OnInit {
|
67
|
67
|
// 检查类型列表
|
68
|
68
|
getBuildingList() {
|
69
|
69
|
this.buildingsLoading = true;
|
|
70
|
+ let postData = {
|
|
71
|
+ idx: 0,
|
|
72
|
+ sum: 9999,
|
|
73
|
+ dictionary: {
|
|
74
|
+ key: "inspect_check_type",
|
|
75
|
+ },
|
|
76
|
+ };
|
70
|
77
|
this.mainService
|
71
|
|
- .getDictionary("list", "inspect_check_type")
|
|
78
|
+ .getFetchDataList("simple/data", "dictionary", postData)
|
72
|
79
|
.subscribe((result) => {
|
73
|
80
|
this.buildingsLoading = false;
|
74
|
|
- this.inspectTypeList = result;
|
75
|
|
- if (Object.keys(this.checkedBuilding).length) {
|
76
|
|
- result.list.forEach((item) => {
|
77
|
|
- if (item.id == this.checkedBuilding.id) {
|
78
|
|
- this.checkBuilding(item);
|
|
81
|
+ if (result.status == 200) {
|
|
82
|
+ this.inspectTypeList = result.list;
|
|
83
|
+ this.inspectTypeList.forEach((item) => {
|
|
84
|
+ if (!item.extra2) {
|
|
85
|
+ item.extra2 = "";
|
79
|
86
|
}
|
80
|
87
|
});
|
81
|
|
- } else {
|
82
|
|
- this.checkBuilding(result[0]);
|
|
88
|
+ if (Object.keys(this.checkedInspectType).length) {
|
|
89
|
+ result.list.forEach((item) => {
|
|
90
|
+ if (item.id == this.checkedInspectType.id) {
|
|
91
|
+ this.checkBuilding(item);
|
|
92
|
+ }
|
|
93
|
+ });
|
|
94
|
+ } else {
|
|
95
|
+ this.checkBuilding(result.list[0]);
|
|
96
|
+ }
|
83
|
97
|
}
|
84
|
98
|
});
|
85
|
99
|
}
|
86
|
100
|
|
87
|
101
|
// 获取选中检查类型下关键字列表
|
|
102
|
+ id: number = 0;
|
88
|
103
|
getAllFloor() {
|
89
|
|
- // 初始化的时候搜索一次,然后前端过滤
|
90
|
|
- let postData = {
|
91
|
|
- idx: 0,
|
92
|
|
- sum: 9999,
|
93
|
|
- floor: { hosId: this.hosId, buildId: this.checkedBuilding.id },
|
94
|
|
- };
|
95
|
|
- this.floorsLoading = true;
|
96
|
|
- this.mainService
|
97
|
|
- .getFetchDataList("simple/data", "floor", postData)
|
98
|
|
- .subscribe((result) => {
|
99
|
|
- this.floorsLoading = false;
|
100
|
|
- if (result.status == 200) {
|
101
|
|
- this.allFloorList = result.list;
|
102
|
|
- this.refreshStatus();
|
103
|
|
- }
|
104
|
|
- });
|
|
104
|
+ console.log(this.checkedInspectType, "baba");
|
|
105
|
+ if (this.checkedInspectType.extra2) {
|
|
106
|
+ this.allKeyword = this.checkedInspectType.extra2
|
|
107
|
+ .split(",")
|
|
108
|
+ .map((item) => ({ id: ++this.id, keyword: item }));
|
|
109
|
+ } else {
|
|
110
|
+ this.allKeyword = [];
|
|
111
|
+ }
|
|
112
|
+ this.refreshStatus();
|
105
|
113
|
}
|
106
|
114
|
|
107
|
115
|
// 选中检查类型
|
108
|
116
|
checkBuilding(data) {
|
109
|
117
|
this.positionY = this.osComponentRef1.osInstance().scroll().position.y; //内容滚动的距离
|
110
|
|
- this.checkedBuilding = data ? data : {};
|
|
118
|
+ this.checkedInspectType = data ? data : {};
|
111
|
119
|
this.mapOfCheckedId = {};
|
112
|
120
|
this.getAllFloor();
|
113
|
121
|
}
|
|
@@ -119,8 +127,8 @@ export class InspectTypeConfigComponent implements OnInit {
|
119
|
127
|
// 选中列表中关键字
|
120
|
128
|
refreshStatus(): void {
|
121
|
129
|
let arr = [];
|
122
|
|
- if (this.allFloorList.length) {
|
123
|
|
- this.isAllDisplayDataChecked = this.allFloorList.every(
|
|
130
|
+ if (this.allKeyword.length) {
|
|
131
|
+ this.isAllDisplayDataChecked = this.allKeyword.every(
|
124
|
132
|
(item) => this.mapOfCheckedId[item.id]
|
125
|
133
|
);
|
126
|
134
|
} else {
|
|
@@ -137,7 +145,7 @@ export class InspectTypeConfigComponent implements OnInit {
|
137
|
145
|
|
138
|
146
|
// 新增/编辑检查类型模态框
|
139
|
147
|
showCoopModal(type) {
|
140
|
|
- if (type == "edit" && !this.checkedBuilding.id) {
|
|
148
|
+ if (type == "edit" && !this.checkedInspectType.id) {
|
141
|
149
|
this.msg.create("warning", "请选择需要编辑的检查类型!");
|
142
|
150
|
return;
|
143
|
151
|
}
|
|
@@ -145,8 +153,8 @@ export class InspectTypeConfigComponent implements OnInit {
|
145
|
153
|
this.add = type == "add";
|
146
|
154
|
if (type == "edit") {
|
147
|
155
|
this.initForm();
|
148
|
|
- this.validateForm.controls.buildingName.setValue(
|
149
|
|
- this.checkedBuilding.name
|
|
156
|
+ this.validateForm.controls.inspectTypeName.setValue(
|
|
157
|
+ this.checkedInspectType.name
|
150
|
158
|
);
|
151
|
159
|
} else {
|
152
|
160
|
this.initForm();
|
|
@@ -157,11 +165,13 @@ export class InspectTypeConfigComponent implements OnInit {
|
157
|
165
|
showFloorModal(e, type, data?) {
|
158
|
166
|
this.floorModal = true;
|
159
|
167
|
this.addFloor = type == "add";
|
|
168
|
+ this.floorDataEdit = data;
|
160
|
169
|
if (type == "edit") {
|
161
|
170
|
this.initFormFloor();
|
162
|
|
- this.floorDataEdit = data;
|
163
|
|
- this.validateFloorForm.controls.buildId.setValue(data.buildId);
|
164
|
|
- this.validateFloorForm.controls.floorName.setValue(data.floorName);
|
|
171
|
+ this.validateFloorForm.controls.inspectTypeName.setValue(
|
|
172
|
+ this.checkedInspectType.name
|
|
173
|
+ );
|
|
174
|
+ this.validateFloorForm.controls.keyword.setValue(data.keyword);
|
165
|
175
|
} else {
|
166
|
176
|
this.initFormFloor();
|
167
|
177
|
}
|
|
@@ -181,15 +191,15 @@ export class InspectTypeConfigComponent implements OnInit {
|
181
|
191
|
// 初始化新增form表单
|
182
|
192
|
initForm() {
|
183
|
193
|
this.validateForm = this.fb.group({
|
184
|
|
- buildingName: [null, [Validators.required]],
|
|
194
|
+ inspectTypeName: [null, [Validators.required]],
|
185
|
195
|
});
|
186
|
196
|
}
|
187
|
197
|
|
188
|
198
|
// 初始化新增form表单floor
|
189
|
199
|
initFormFloor() {
|
190
|
200
|
this.validateFloorForm = this.fb.group({
|
191
|
|
- buildId: [this.checkedBuilding.id, [Validators.required]],
|
192
|
|
- floorName: [null, [Validators.required]],
|
|
201
|
+ inspectTypeName: [this.checkedInspectType.name, [Validators.required]],
|
|
202
|
+ keyword: [null, [Validators.required]],
|
193
|
203
|
});
|
194
|
204
|
}
|
195
|
205
|
|
|
@@ -203,7 +213,7 @@ export class InspectTypeConfigComponent implements OnInit {
|
203
|
213
|
this.btnLoading = true;
|
204
|
214
|
let postData;
|
205
|
215
|
let arr = this.inspectTypeList.filter(
|
206
|
|
- (item) => item.value == this.validateForm.value.buildingName
|
|
216
|
+ (item) => item.name == this.validateForm.value.inspectTypeName
|
207
|
217
|
);
|
208
|
218
|
//有重复名称
|
209
|
219
|
if (arr.length > 0) {
|
|
@@ -211,39 +221,41 @@ export class InspectTypeConfigComponent implements OnInit {
|
211
|
221
|
this.showPromptModal(
|
212
|
222
|
"新增",
|
213
|
223
|
false,
|
214
|
|
- `存在重复的检查类型名称【${this.validateForm.value.buildingName}】请修改后再保存!`
|
|
224
|
+ `存在重复的检查类型名称【${this.validateForm.value.inspectTypeName}】请修改后再保存!`
|
215
|
225
|
);
|
216
|
226
|
return;
|
217
|
227
|
}
|
218
|
228
|
if (this.add) {
|
|
229
|
+ let n = 0;
|
|
230
|
+ if (this.inspectTypeList.length > 0) {
|
|
231
|
+ let sortArr = this.inspectTypeList.map((item) => Number(item.value));
|
|
232
|
+ n = Math.max.apply(null, sortArr);
|
|
233
|
+ } else {
|
|
234
|
+ n = 0;
|
|
235
|
+ }
|
219
|
236
|
postData = {
|
220
|
|
- buildingName: this.validateForm.value.buildingName,
|
221
|
|
- deleted: false,
|
222
|
|
- hosId: this.hosId,
|
|
237
|
+ key: "inspect_check_type",
|
|
238
|
+ name: this.validateForm.value.inspectTypeName,
|
|
239
|
+ value: n + 1,
|
|
240
|
+ orders: n + 1,
|
|
241
|
+ desc: "检查类型",
|
223
|
242
|
};
|
224
|
243
|
} else {
|
225
|
244
|
postData = {
|
226
|
|
- buildingName: this.validateForm.value.buildingName,
|
227
|
|
- deleted: false,
|
228
|
|
- hosId: this.hosId,
|
229
|
|
- id: this.checkedBuilding.id,
|
|
245
|
+ extra2: this.checkedInspectType.extra2,
|
|
246
|
+ name: this.validateForm.value.inspectTypeName,
|
|
247
|
+ id: this.checkedInspectType.id,
|
230
|
248
|
};
|
231
|
249
|
}
|
232
|
|
- this.mainService
|
233
|
|
- .simplePost("addData", "building", postData)
|
234
|
|
- .subscribe((result) => {
|
235
|
|
- this.hideCoopModal();
|
236
|
|
- this.btnLoading = false;
|
237
|
|
- if (result["status"] == 200) {
|
238
|
|
- this.showPromptModal(this.add ? "新增" : "编辑", true, "");
|
239
|
|
- } else {
|
240
|
|
- this.showPromptModal(
|
241
|
|
- this.add ? "新增" : "编辑",
|
242
|
|
- false,
|
243
|
|
- result["msg"]
|
244
|
|
- );
|
245
|
|
- }
|
246
|
|
- });
|
|
250
|
+ this.mainService.upDictionary(postData).subscribe((result) => {
|
|
251
|
+ this.hideCoopModal();
|
|
252
|
+ this.btnLoading = false;
|
|
253
|
+ if (result["status"] == 200) {
|
|
254
|
+ this.showPromptModal(this.add ? "新增" : "编辑", true, "");
|
|
255
|
+ } else {
|
|
256
|
+ this.showPromptModal(this.add ? "新增" : "编辑", false, result["msg"]);
|
|
257
|
+ }
|
|
258
|
+ });
|
247
|
259
|
}
|
248
|
260
|
|
249
|
261
|
// 新增/编辑关键字提交
|
|
@@ -254,9 +266,8 @@ export class InspectTypeConfigComponent implements OnInit {
|
254
|
266
|
}
|
255
|
267
|
if (this.validateFloorForm.invalid) return;
|
256
|
268
|
this.btnLoading = true;
|
257
|
|
- let postData;
|
258
|
|
- let arr = this.allFloorList.filter(
|
259
|
|
- (item) => item.floorName == this.validateFloorForm.value.floorName
|
|
269
|
+ let arr = this.allKeyword.filter(
|
|
270
|
+ (item) => item.keyword == this.validateFloorForm.value.keyword
|
260
|
271
|
);
|
261
|
272
|
//有重复名称
|
262
|
273
|
if (arr.length > 0) {
|
|
@@ -264,52 +275,50 @@ export class InspectTypeConfigComponent implements OnInit {
|
264
|
275
|
this.showPromptModal(
|
265
|
276
|
"新增",
|
266
|
277
|
false,
|
267
|
|
- `同一个检查类型存在重复的关键字名称【${this.validateFloorForm.value.floorName}】请修改后再保存!`
|
|
278
|
+ `同一个检查类型存在重复的关键字名称【${this.validateFloorForm.value.keyword}】请修改后再保存!`
|
268
|
279
|
);
|
269
|
280
|
return;
|
270
|
281
|
}
|
271
|
282
|
if (this.addFloor) {
|
272
|
|
- postData = {
|
273
|
|
- buildId: this.validateFloorForm.value.buildId,
|
274
|
|
- floorName: this.validateFloorForm.value.floorName,
|
275
|
|
- deleted: false,
|
276
|
|
- hosId: this.hosId,
|
277
|
|
- };
|
|
283
|
+ this.allKeyword.push({
|
|
284
|
+ keyword: this.validateFloorForm.value.keyword,
|
|
285
|
+ id: ++this.id,
|
|
286
|
+ });
|
278
|
287
|
} else {
|
279
|
|
- postData = {
|
280
|
|
- buildId: this.validateFloorForm.value.buildId,
|
281
|
|
- floorName: this.validateFloorForm.value.floorName,
|
282
|
|
- deleted: false,
|
283
|
|
- hosId: this.hosId,
|
284
|
|
- id: this.floorDataEdit.id,
|
285
|
|
- };
|
|
288
|
+ this.allKeyword.forEach((item) => {
|
|
289
|
+ if (item.id === this.floorDataEdit.id) {
|
|
290
|
+ item.keyword = this.validateFloorForm.value.keyword;
|
|
291
|
+ }
|
|
292
|
+ });
|
286
|
293
|
}
|
287
|
|
- this.addFloorHandler(postData, false);
|
|
294
|
+ this.addFloorHandler();
|
288
|
295
|
}
|
289
|
296
|
|
290
|
|
- //新增关键字
|
291
|
|
- addFloorHandler(postData, flag) {
|
292
|
|
- this.mainService
|
293
|
|
- .simplePost(flag ? "addListData" : "addData", "floor", postData)
|
294
|
|
- .subscribe((result) => {
|
295
|
|
- this.hideFloorModal();
|
296
|
|
- this.generate1 && (this.generate1.delModal = false);
|
297
|
|
- this.btnLoading = false;
|
298
|
|
- if (result["status"] == 200) {
|
299
|
|
- this.showPromptModal(this.addFloor ? "新增" : "编辑", true, "");
|
300
|
|
- } else {
|
301
|
|
- this.showPromptModal(
|
302
|
|
- this.addFloor ? "新增" : "编辑",
|
303
|
|
- false,
|
304
|
|
- result["msg"]
|
305
|
|
- );
|
306
|
|
- }
|
307
|
|
- });
|
|
297
|
+ //新增关键字baba
|
|
298
|
+ addFloorHandler() {
|
|
299
|
+ let postData = {
|
|
300
|
+ id: this.checkedInspectType.id,
|
|
301
|
+ extra2: this.allKeyword.map((item) => item.keyword).toString(),
|
|
302
|
+ };
|
|
303
|
+ this.mainService.upDictionary(postData).subscribe((result) => {
|
|
304
|
+ this.hideFloorModal();
|
|
305
|
+ this.generate1 && (this.generate1.delModal = false);
|
|
306
|
+ this.btnLoading = false;
|
|
307
|
+ if (result["status"] == 200) {
|
|
308
|
+ this.showPromptModal(this.addFloor ? "新增" : "编辑", true, "");
|
|
309
|
+ } else {
|
|
310
|
+ this.showPromptModal(
|
|
311
|
+ this.addFloor ? "新增" : "编辑",
|
|
312
|
+ false,
|
|
313
|
+ result["msg"]
|
|
314
|
+ );
|
|
315
|
+ }
|
|
316
|
+ });
|
308
|
317
|
}
|
309
|
318
|
|
310
|
319
|
//删除检查类型
|
311
|
320
|
showDelModal() {
|
312
|
|
- if (!this.checkedBuilding.id) {
|
|
321
|
+ if (!this.checkedInspectType.id) {
|
313
|
322
|
this.msg.create("warning", "请选择需要删除的检查类型!");
|
314
|
323
|
return;
|
315
|
324
|
}
|
|
@@ -318,18 +327,21 @@ export class InspectTypeConfigComponent implements OnInit {
|
318
|
327
|
hideDelModal() {
|
319
|
328
|
this.delModal = false;
|
320
|
329
|
}
|
321
|
|
- // 确认删除
|
|
330
|
+ // 确认删除baba
|
322
|
331
|
confirmDel() {
|
323
|
332
|
this.btnLoading = true;
|
324
|
|
- let postData = [this.checkedBuilding["id"]];
|
325
|
|
- this.mainService.delBuildingList(postData).subscribe((result) => {
|
|
333
|
+ let postData = {
|
|
334
|
+ deleted: true,
|
|
335
|
+ id: this.checkedInspectType.id,
|
|
336
|
+ };
|
|
337
|
+ this.mainService.upDictionary(postData).subscribe((result) => {
|
326
|
338
|
this.hideDelModal();
|
327
|
339
|
this.btnLoading = false;
|
328
|
|
- if (result["status"] == 200 && !result["data"][0].msg) {
|
|
340
|
+ if (result["status"] == 200) {
|
329
|
341
|
this.showPromptModal("删除", true, "");
|
330
|
|
- this.checkedBuilding = {};
|
|
342
|
+ this.checkedInspectType = {};
|
331
|
343
|
} else {
|
332
|
|
- this.showPromptModal("删除", false, result["data"][0].msg);
|
|
344
|
+ this.showPromptModal("删除", false, "");
|
333
|
345
|
}
|
334
|
346
|
});
|
335
|
347
|
}
|
|
@@ -351,25 +363,39 @@ export class InspectTypeConfigComponent implements OnInit {
|
351
|
363
|
hideDelFloorModal() {
|
352
|
364
|
this.delFloorModal = false;
|
353
|
365
|
}
|
354
|
|
- // 确认删除
|
|
366
|
+ // 确认删除baba
|
355
|
367
|
confirmFloorDel() {
|
|
368
|
+ let allKeyword = JSON.parse(JSON.stringify(this.allKeyword));
|
356
|
369
|
this.btnLoading = true;
|
357
|
370
|
let selectedFloor = this.selectedFloor.map((item) => item.id);
|
358
|
|
- let postData = this.isDelSingle ? [this.floorDataEdit.id] : selectedFloor;
|
359
|
|
- this.mainService.delFloorList(postData).subscribe((result) => {
|
|
371
|
+ if (this.isDelSingle) {
|
|
372
|
+ allKeyword = allKeyword.filter(
|
|
373
|
+ (item) => item.id != this.floorDataEdit.id
|
|
374
|
+ );
|
|
375
|
+ } else {
|
|
376
|
+ allKeyword = allKeyword.filter(
|
|
377
|
+ (item) => !selectedFloor.includes(item.id + "")
|
|
378
|
+ );
|
|
379
|
+ }
|
|
380
|
+ let postData = {
|
|
381
|
+ id: this.checkedInspectType.id,
|
|
382
|
+ extra2: allKeyword.map((v) => v.keyword).toString(),
|
|
383
|
+ };
|
|
384
|
+ this.mainService.upDictionary(postData).subscribe((result) => {
|
360
|
385
|
this.hideDelFloorModal();
|
361
|
386
|
this.btnLoading = false;
|
362
|
|
- if (result["status"] == 200 && !result["data"][0].msg) {
|
|
387
|
+ if (result["status"] == 200) {
|
|
388
|
+ this.allKeyword = allKeyword;
|
363
|
389
|
this.showPromptModal("删除", true, "");
|
364
|
390
|
} else {
|
365
|
|
- this.showPromptModal("删除", false, result["data"][0].msg);
|
|
391
|
+ this.showPromptModal("删除", false, "");
|
366
|
392
|
}
|
367
|
393
|
});
|
368
|
394
|
}
|
369
|
395
|
// 全选
|
370
|
396
|
checkAll(value: boolean): void {
|
371
|
|
- console.log(this.allFloorList);
|
372
|
|
- this.allFloorList.forEach((item) => {
|
|
397
|
+ console.log(this.allKeyword);
|
|
398
|
+ this.allKeyword.forEach((item) => {
|
373
|
399
|
this.mapOfCheckedId[item.id] = value;
|
374
|
400
|
});
|
375
|
401
|
this.refreshStatus();
|