|
@@ -1,5 +1,6 @@
|
|
|
import { Component, inject } from '@angular/core';
|
|
|
import { NZ_MODAL_DATA } from 'ng-zorro-antd/modal';
|
|
|
+import { NzSelectOptionInterface } from 'ng-zorro-antd/select';
|
|
|
import { horizontalInOut } from '../../../common.animation';
|
|
|
import { KnowledgeService } from '../../../services/knowledge.service';
|
|
|
import { CommonNzModule } from './../../../common.nz.module';
|
|
@@ -27,13 +28,23 @@ export class RiskItemPickerModalComponent {
|
|
|
readonly nzModalData: RiskItemPickerModalData = inject(NZ_MODAL_DATA);
|
|
|
category?: number;
|
|
|
type?: number;
|
|
|
- filteredCategories: Knowledge.RiskCategoryDto[] = [];
|
|
|
+ filteredCategories: NzSelectOptionInterface[] = [];
|
|
|
filteredItems: Knowledge.RiskItem[] = [];
|
|
|
selectedItems: Knowledge.RiskItem[] = [];
|
|
|
searchText = '';
|
|
|
constructor(private knowledge: KnowledgeService) {}
|
|
|
|
|
|
ngOnInit() {
|
|
|
+ this.typeOptions = this.types.map(t => ({
|
|
|
+ label: t.value,
|
|
|
+ value: t.id,
|
|
|
+ disabled: !this.items.some(p => p.type === t.id),
|
|
|
+ }));
|
|
|
+ this.categoryOptions = this.categories.map(c => ({
|
|
|
+ label: c.value,
|
|
|
+ value: c.id,
|
|
|
+ disabled: !this.items.some(p => p.category === c.id),
|
|
|
+ }));
|
|
|
if (this.nzModalData.checkItemIds.length > 0) {
|
|
|
this.selectedItems = this.items.filter(p => this.nzModalData.checkItemIds.includes(p.id));
|
|
|
}
|
|
@@ -53,7 +64,11 @@ export class RiskItemPickerModalComponent {
|
|
|
this.setFilteredItems();
|
|
|
return;
|
|
|
}
|
|
|
- this.filteredCategories = typeDto.categories;
|
|
|
+ this.filteredCategories = typeDto.categories.map(c => ({
|
|
|
+ label: c.value,
|
|
|
+ value: c.id,
|
|
|
+ disabled: !this.items.some(p => p.category === c.id),
|
|
|
+ }));
|
|
|
this.setFilteredItems();
|
|
|
}
|
|
|
onCategoryChange(value: number) {
|
|
@@ -92,7 +107,7 @@ export class RiskItemPickerModalComponent {
|
|
|
if (this.filteredItems.length === 0) {
|
|
|
return true;
|
|
|
}
|
|
|
- if (!this.category && !this.type && !this.searchText) {
|
|
|
+ if (this.isTotalSelecting && !this.category && !this.type && !this.searchText) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
@@ -157,12 +172,19 @@ export class RiskItemPickerModalComponent {
|
|
|
get types() {
|
|
|
return this.nzModalData.types;
|
|
|
}
|
|
|
+ typeOptions: NzSelectOptionInterface[] = [];
|
|
|
+ categoryOptions: NzSelectOptionInterface[] = [];
|
|
|
+
|
|
|
get categories() {
|
|
|
return this.nzModalData.categories;
|
|
|
}
|
|
|
get currentCategory() {
|
|
|
return this.categories.find(c => c.id === this.category);
|
|
|
}
|
|
|
+ get isTotalSelecting() {
|
|
|
+ // 列出系统中所有风险条目时 (不允许全选)
|
|
|
+ return this.filteredItems.length === this.knowledge.riskItems().length;
|
|
|
+ }
|
|
|
// get categoryTypeIsStation() {
|
|
|
// return this.currentCategory?.name === '车站';
|
|
|
// }
|