车辆对接
This commit is contained in:
@ -22,17 +22,24 @@ export class DictSelectComponent implements OnInit, ControlValueAccessor {
|
||||
private onTouchedFn?: () => void;
|
||||
|
||||
defaultUrl = `/api/mdc/pbc/dictItems/getDictValue`;
|
||||
@Input() value: string = ''; // 默认选中值
|
||||
@Input() value: any = '' || []; // 默认选中值
|
||||
@Input() url: string = ''; // 获取字典数据的地址
|
||||
@Input() params = {};// 请求参数
|
||||
|
||||
dictList: any[] = [];
|
||||
@Input() containsAllLable = true; // 是否包含全部这一选项
|
||||
@Input() mode: 'multiple' | 'tags' | 'default' = 'default';
|
||||
|
||||
|
||||
constructor(public service: DictSelectService, public cdr: ChangeDetectorRef) { }
|
||||
|
||||
writeValue(geo: string): void {
|
||||
if (geo == null) {
|
||||
this.value = '';
|
||||
if (this.mode === 'multiple' || this.mode === 'tags') {
|
||||
this.value = [];
|
||||
} else {
|
||||
this.value = '';
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.value = geo;
|
||||
@ -45,11 +52,10 @@ export class DictSelectComponent implements OnInit, ControlValueAccessor {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
this.service.getDictList(this.url || this.defaultUrl, this.params).subscribe(res => {
|
||||
if (res) {
|
||||
this.dictList = res || [];
|
||||
if (this.dictList.length > 0) {
|
||||
if (this.dictList.length > 0 && this.containsAllLable) {
|
||||
const obj = { label: '全部', value: '' };
|
||||
this.dictList.unshift(obj);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user