import { Component, Injector, ViewChild, OnInit } from '@angular/core'; import { appModuleAnimation } from '@shared/animations/routerTransition'; import { AppComponentBase } from '@shared/common/app-component-base'; import { SubAppServiceProxy, SubAppDto, RackTypeServiceProxy, WaferAreaServiceProxy } from '@shared/service-proxies/service-proxies'; import { Table } from 'primeng/components/table/table'; import * as _ from 'lodash'; import { LazyLoadEvent } from 'primeng/api'; import { Paginator } from 'primeng/primeng'; import { FileDownloadService } from '@shared/utils/file-download.service'; import { SelfHttp } from '@app/shared/common/utils/selfHttp.service'; import { WaferHttp } from '@app/shared/common/utils/waferhttp.service'; import { WaferAreaLookupTableModalComponent } from '@app/shared/lookup/waferAreaLookup/waferArea-lookup-table-modal.component'; import { WaferAreaSerarchInputDto } from '../waferarea/waferarea.model'; import { GetWaferForViewDto, WaferSendOutDto } from '../wafersendout/wafersendout.model'; import { WaferReceiveDto } from './waferreceive.module'; @Component({ templateUrl: './waferreceive.component.html', animations: [appModuleAnimation()] }) export class WaferReceiveComponent extends AppComponentBase implements OnInit { @ViewChild('dataTable') dataTable: Table; @ViewChild('paginator') paginator: Paginator; @ViewChild('waferAreaLookupTableModal') waferAreaLookupTableModal: WaferAreaLookupTableModalComponent; advancedFiltersAreShown = false; //Filters filterText = ''; code = ''; controllot = ''; waferAreaSerarchInputDto = new WaferAreaSerarchInputDto(); selectWafers: Array = new Array(); waferReceive: WaferReceiveDto = new WaferReceiveDto(); fromCode: string; toCode: string; selectArea: string; checklocation: string; userName: string; location: string; constructor( injector: Injector, private _waferAreaService: WaferAreaServiceProxy, private _fileDownloadService: FileDownloadService, private waferHttp: WaferHttp ) { super(injector); } ngOnInit(): void { } getAll(): void { let data = { filter: this.filterText }; if (this.filterText === '') { // this.message.error('扫入资料不能为空!'); // return; this.waferHttp.get('api/WaferTraceManage/WaferReceiveSelect', {toArea: this.location}, res => { //this.primengTableHelper.records = JSON.parse(res.result); this.primengTableHelper.records = res; this.selectWafers = res; if (res.length > 0) { this.userName = res[0].USERNAME; } else { this.message.error('扫入资料无收料信息!'); } } ); } else { this.waferHttp.get('api/WaferTraceManage/WaferCancelSendOutSelect', data, res => { //this.primengTableHelper.records = JSON.parse(res.result); this.primengTableHelper.records = res; this.selectWafers = res; if (res.length > 0) { this.userName = res[0].USERNAME; } else { this.message.error('扫入资料无收料信息!'); } }); } } receiveConfirm() { if (this.selectWafers.length === 0) { this.message.error('请选择Wafer!'); return; } if (!this.location) { this.message.error('请选择收料区段!'); return; } let checkLocation = this.selectWafers.map(a => a.TOAREA); let flag = false; checkLocation.forEach(a => { if (a !== this.location) { flag = true; return; } }); if (flag) { this.message.error('所选Wafer中有区段不一致!请确认!'); return; } this.waferReceive.waferList = this.selectWafers.map(a => a.WAFERID); this.waferReceive.location = this.location; this.waferReceive.userId = this.appSession.getShownLoginName(); let self = this; self.message.confirm('当前选中Wafer' + this.selectWafers.length + '片(共' + this.primengTableHelper.records.length + '片),确定收料吗?', isConfirmed => { if (isConfirmed) { this.receive(); } } ); } receive() { this.waferHttp.post('api/WaferTraceManage/WaferReceive', this.waferReceive, res => { this.notify.info(this.l('收料成功!')); this.filterText = ''; this.primengTableHelper.records = []; } ); } openSelectAreaModal() { this.waferAreaLookupTableModal.code = this.location; this.waferAreaLookupTableModal.show(); } setAreaNull() { this.location = ''; } getNewArea() { this.location = this.waferAreaLookupTableModal.code; } }