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 { WaferSendOutDto, GetWaferForViewDto } from './wafersendout.model'; @Component({ templateUrl: './wafersendout.component.html', animations: [appModuleAnimation()] }) export class WaferSendOutComponent extends AppComponentBase implements OnInit { @ViewChild('dataTable') dataTable: Table; @ViewChild('paginator') paginator: Paginator; @ViewChild('waferAreaLookupTableModal') waferAreaLookupTableModal: WaferAreaLookupTableModalComponent; @ViewChild('waferToAreaLookupTableModal') waferToAreaLookupTableModal: WaferAreaLookupTableModalComponent; advancedFiltersAreShown = false; //Filters filterText = ''; code = ''; controllot = ''; waferAreaSerarchInputDto = new WaferAreaSerarchInputDto(); selectWafers: Array = new Array(); waferSendOut: WaferSendOutDto = new WaferSendOutDto(); fromCode: string; toCode: string; selectArea: string; checklocation: 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/WaferSendOutSelect', data, res => { this.primengTableHelper.records = res; this.selectWafers = res; if (res.length > 0) { this.checklocation = res[0].LOCATION; } else { this.message.error('扫入资料无发料信息!'); } }); } sendOutConfirm() { if (this.selectWafers.length === 0) { this.message.error('请选择Wafer!'); return; } this.waferSendOut.waferList = this.selectWafers.map(a => a.WAFERID); this.waferSendOut.fromArea = this.fromCode; this.waferSendOut.controllot = this.selectWafers[0].CONTROLLOTID; this.waferSendOut.userId = this.appSession.getShownLoginName(); let self = this; //判断是否GS if (this.fromCode === 'GS') { this.waferHttp.getString('api/WaferTraceManage/GetProdLine', {Controllot : this.selectWafers[0].CONTROLLOTID} , res => { this.waferSendOut.toArea = res; console.log(this.waferSendOut.toArea, 500); if (this.waferSendOut.toArea === null ) { console.log(this.waferSendOut.toArea, this.toCode, 600); if (this.toCode) { this.waferSendOut.toArea = this.toCode; } else { this.message.error('请选择区段!'); return; } } console.log(this.waferSendOut.toArea, 800); }); } else if (this.fromCode === '' || this.toCode === '' || typeof(this.fromCode ) === 'undefined' || typeof(this.toCode) === 'undefined') { this.message.error('请选择区段!'); return; } let checklocations = this.selectWafers.map(a => a.LOCATION); for (let i = 0; i < checklocations.length; i++) { if (checklocations[i] !== this.fromCode) { this.message.error('发料所选择区段【' + this.fromCode + '】与Wafer所在区域【' + checklocations[i] + '】不一致,不能执行发料。请选择正确的发料区段。'); return; } } self.message.confirm('当前选中Wafer' + this.selectWafers.length + '片(共' + this.primengTableHelper.records.length + '片),确定发料吗?', isConfirmed => { if (isConfirmed) { this.sendOut(); } } ); } sendOut() { this.waferHttp.post('api/WaferTraceManage/WaferSendOut', this.waferSendOut, res => { this.notify.info(this.l('发料成功!')); this.filterText = ''; this.primengTableHelper.records = []; } ); } getProdLine() { this.waferHttp.getString('api/WaferTraceManage/GetProdLine', {Controllot : this.selectWafers[0].CONTROLLOTID} , res => { this.waferSendOut.toArea = res; console.log(this.waferSendOut.toArea, 800); }); } openSelectFromAreaModal() { this.waferAreaLookupTableModal.code = this.fromCode; this.waferAreaLookupTableModal.show(); this.selectArea = 'from'; } openSelectToAreaModal(fromCode) { this.waferToAreaLookupTableModal.code = this.toCode; this.waferToAreaLookupTableModal.showToAreaByFromArea(fromCode); this.selectArea = 'to'; } setFromAreaNull() { this.fromCode = ''; this.toCode = ''; } setToAreaNull() { this.toCode = ''; } getNewArea() { if (this.selectArea === 'from') { this.fromCode = this.waferAreaLookupTableModal.code; this.toCode = ''; } else if ( this.selectArea === 'to') { this.toCode = this.waferToAreaLookupTableModal.code; } } }