import { AfterViewInit, Component, TemplateRef, ViewChild } from '@angular/core'; import { DialogService } from '@app/core/services/dialog.service'; import { HttpService } from '@app/core/services/http.service'; import { I18nService } from '@app/core/services/i18n.service'; import { ToastService } from '@app/core/services/toast.service'; import { CrudComponent } from '@app/routes/.templates/crud/crud.component'; @Component({ selector: 'app-wcs-managetask', templateUrl: './monitortask.component.html', styleUrls: ['./monitortask.component.scss'], queries: { _template: new ViewChild('$crud'), _stateColumn: new ViewChild('$state') } }) export class MonitortaskComponent implements AfterViewInit { private _template: CrudComponent; private _stateColumn: TemplateRef; private _defination: any; //private _colorful: boolean; constructor( private _dialogService: DialogService, private _httpService: HttpService, private _i18nService: I18nService, private _toastService: ToastService ) { } ngAfterViewInit(): void { setTimeout(() => { this._defination = [ { id: 'state', template: this._stateColumn, style: { width: '24px', paddingRight: '24px', lineHeight: 1, cursor: 'default' } }, { id: 'barcode', header: 'routes.wcs.monitortask.Barcode', filter: { field: 'text' },//右侧查询时候 决定是否出现在查询项中 //editor: { field: 'text', required: true }//编辑选项可用时 弹出编辑窗口 这个属性决定是否出现在编辑项中 }, { id: 'fid', header: 'routes.wcs.monitortask.TaskCode', filter: { field: 'text' }, }, { id: 'taskKind', header: 'routes.wcs.monitortask.TaskType', }, { id: 'id', header: 'routes.wcs.monitortask.MonitorID', filter: { field: 'text' } }, { id: 'deviceIndex', header: 'routes.wcs.monitortask.DeviceCode', filter: { field: 'text' } }, { id: 'deviceName', header: 'routes.wcs.monitortask.DeviceName' }, { id: 'ordername', header: 'routes.wcs.monitortask.OrderName' }, { id: 'deviceStatus', header: 'routes.wcs.monitortask.StatusName', filter: { order: 1, field: 'select', range: [{ id: 0, name: this._i18nService.translate('routes.wcs.monitortask.waiting') }, { id: 1, name: this._i18nService.translate('routes.wcs.monitortask.send') }, { id: 2, name: this._i18nService.translate('routes.wcs.monitortask.running') }] } }, { id: 'aheadDetect', header: 'routes.wcs.monitortask.NoRunCase' }, { id: 'startZ', header: 'routes.wcs.monitortask.StartRollerZ', filter: { field: 'text' }, }, { id: 'startX', header: 'routes.wcs.monitortask.StartRollerX' }, { id: 'startY', header: 'routes.wcs.monitortask.StartRollerY' }, { id: 'endZ', header: 'routes.wcs.monitortask.EndRollerZ', filter: { field: 'text' }, }, { id: 'endX', header: 'routes.wcs.monitortask.EndRollerX' }, { id: 'endY', header: 'routes.wcs.monitortask.EndRollerY' }, { id: 'startTime', header: 'routes.wcs.monitortask.StartTime' }, { id: 'useAwayFork', header: 'routes.wcs.monitortask.useAwayFork' } //,{ // id: 'status',//数据源还在 只是不显示了 // header: 'routes.wcs.monitortask.Status' // } ]; }); }; public get defination() { return this._defination; } /* public get colorful() { return this._colorful; }; public set colorful(value: boolean) { this._colorful = value; }; public dyeing = (row: any) => { debugger; if (this.colorful) { switch (row.status) { case '0': return 'app-foreground-secondary'; case '1': return 'app-foreground-accent'; case '2': return 'app-foreground-primary'; default: return 'app-foreground-warn'; } } return null; } */ public error = (e: any) => { switch (e.status) { case 422: this._toastService.show(this._i18nService.translate('shared.notification.fail')); return true; default: return true; } } public async delete(e?: any): Promise { if (await this._dialogService.confirm(this._i18nService.translate('shared.notification.confirm'))) { const data: any = { id: e.id, action: 900, device: e.deviceIndex }; const res = await this._httpService.post(`monitortask`, data).catch(async err => { switch (err.status) { case 409: this._toastService.show(this._i18nService.translate(`routes.wcs.monitortask.TaskCodeIsError`)); break; case 410: this._toastService.show(this._i18nService.translate(`routes.wcs.monitortask.TaskStatusIsRuning`)); break; case 422: this._toastService.show(this._i18nService.translate('routes.wcs.monitortask.SystemError')); break; default: break; } }) !== undefined; if (res) { this._toastService.show(this._i18nService.translate('shared.notification.success')); this._template.refresh(); } } } public async complete(e?: any): Promise { if (await this._dialogService.confirm(this._i18nService.translate('shared.notification.confirm'))) { const data: any = { id: e.id, action: 999, device: e.deviceIndex }; const res = await this._httpService.post(`monitortask`, data).catch(async err => { switch (err.status) { case 409: this._toastService.show(this._i18nService.translate(`routes.wcs.monitortask.TaskCodeIsError`)); break; case 410: this._toastService.show(this._i18nService.translate(`routes.wcs.monitortask.TaskStatusIsRuning`)); break; case 422: this._toastService.show(this._i18nService.translate('routes.wcs.monitortask.SystemError')); break; default: break; } }) !== undefined; if (res) { this._toastService.show(this._i18nService.translate('shared.notification.success')); this._template.refresh(); } } } public async replay(e?: any): Promise { if (await this._dialogService.confirm(this._i18nService.translate('shared.notification.confirm'))) { const data: any = { id: e.id, action: 920, device: e.deviceIndex }; const res = await this._httpService.post(`monitortask`, data).catch(async err => { switch (err.status) { case 409: this._toastService.show(this._i18nService.translate(`routes.wcs.monitortask.TaskCodeIsError`)); break; case 410: this._toastService.show(this._i18nService.translate(`routes.wcs.monitortask.TaskStatusIsRuning`)); break; case 422: this._toastService.show(this._i18nService.translate('routes.wcs.monitortask.SystemError')); break; default: break; } }) !== undefined; if (res) { this._toastService.show(this._i18nService.translate('shared.notification.success')); this._template.refresh(); } } } }