固定资产项目前端文件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

91 lines
2.0 KiB

import {
ChangeDetectorRef,
Component,
EventEmitter,
Input,
OnInit,
Output,
TemplateRef,
ViewChild,
forwardRef,
} from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
import { NzSafeAny } from 'ng-zorro-antd/core/types'
import { NzModalService } from 'ng-zorro-antd/modal'
import { ApiService } from 'app/services'
import { NzMessageService } from 'ng-zorro-antd/message'
import { SharedModule } from 'app/shared/shared.module'
import { Utils } from 'app/utils'
import { NzFormatEmitEvent, NzTreeNode } from 'ng-zorro-antd/tree'
import { NzTreeSelectComponent } from 'ng-zorro-antd/tree-select'
import { MAX_PAGE_SIZE } from 'app/constants'
@Component({
selector: 'app-warehouse-select',
standalone: true,
imports: [SharedModule],
templateUrl: './warehouse-select.component.html',
styleUrl: './warehouse-select.component.less',
providers: [
{
provide: NG_VALUE_ACCESSOR,
multi: true,
useExisting: forwardRef(() => WarehouseSelectComponent),
},
],
})
export class WarehouseSelectComponent {
constructor(private api: ApiService) {}
@Input() placeholder: string = '请选择'
@Input() modalTitle: string = '选择'
@Input() radio: boolean = false
@Output() onSelected = new EventEmitter<NzSafeAny>()
@ViewChild('el') el!: NzTreeSelectComponent
originData: NzSafeAny[] = []
value?: string
disabled = false
ngOnInit(): void {
this.api.getBasicWarehousePage({ pageSize: MAX_PAGE_SIZE, pageNum: 1 }).subscribe((res) => {
this.originData = res.body.rows
})
}
onModelChange(v: NzSafeAny) {
const item = this.originData.find((f) => f.maintenanceVendorId === v)
this.onSelected.emit(item)
this.onChange(v)
}
onTouched = () => {}
onChange(v: NzSafeAny[]) {}
writeValue(v: NzSafeAny): void {
this.value = v
}
registerOnChange(fn: any): void {
this.onChange = fn
}
registerOnTouched(fn: any): void {
this.onTouched = fn
}
setDisabledState?(isDisabled: boolean): void {
this.disabled = isDisabled
}
}