车辆对接
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
<nz-select [(ngModel)]="value" (ngModelChange)="change($event)" *ngIf="dictList">
|
||||
<nz-select [(ngModel)]="value" (ngModelChange)="change($event)" *ngIf="dictList" [nzMode]="mode? mode:'default'">
|
||||
<nz-option [nzValue]="item.value" [nzLabel]="item.label" *ngFor="let item of dictList"></nz-option>
|
||||
</nz-select>
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DictSelectComponent } from './dict-select.component';
|
||||
|
||||
describe('DictSelectComponent', () => {
|
||||
let component: DictSelectComponent;
|
||||
let fixture: ComponentFixture<DictSelectComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ DictSelectComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DictSelectComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Author: your name
|
||||
* @Date: 2021-12-13 10:41:19
|
||||
* @LastEditTime: 2021-12-13 10:41:57
|
||||
* @Date: 2021-12-16 20:41:23
|
||||
* @LastEditTime: 2021-12-16 20:41:42
|
||||
* @LastEditors: your name
|
||||
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
* @FilePath: \tms-obc-web\src\app\shared\components\dict-select\index.ts
|
||||
|
||||
Reference in New Issue
Block a user