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.
 
 
 

119 lines
5.5 KiB

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-devicestatus',
templateUrl: './devicestatus.component.html',
styleUrls: ['./devicestatus.component.scss'],
queries: {
_template: new ViewChild('$crud'),
_idEditor: new ViewChild('$id'),
_deviceNameEditor: new ViewChild('$deviceName'),
_manTaskReserveEditor: new ViewChild('$manTaskReserve'),
_lockedStateEditor: new ViewChild('$lockedState'),
_errorCodeEditor: new ViewChild('$errorCode')
}
})
export class DevicestatusComponent implements AfterViewInit {
private _template: CrudComponent;
private _idEditor: TemplateRef<any>;
private _deviceNameEditor: TemplateRef<any>;
private _lockedStateEditor: TemplateRef<any>;
private _manTaskReserveEditor: TemplateRef<any>;
private _errorCodeEditor: TemplateRef<any>;
private _defination: any;
constructor(
//private _dialogService: DialogService,
private _httpService: HttpService,
private _i18nService: I18nService,
private _toastService: ToastService
) { }
ngAfterViewInit(): void {
setTimeout(() => {
//查询多个
/* const res: any = await this._httpService.join(
this._httpService.get('historytaskquery/taskkind'),
this._httpService.get('historytaskquery/controlTaskKind')
);
const taskkind: any = res[0];
const controlTaskKind: any = res[1]; */
//const taskkind:any=await this._httpService.get('historytaskquery/taskkind');
this._defination = [
{
id: 'id',
header: 'routes.wcs.devicestatus.deviceIndex',
filter: { order: 1, field: 'text' },
editor: { field: 'text', required: true, template: this._idEditor }
}, {
id: 'deviceName',
header: 'routes.wcs.devicestatus.deviceName',
editor: { field: 'text', required: true, template: this._deviceNameEditor },
sortable: false
}, {
id: 'deviceKindIndex',
header: 'routes.wcs.devicestatus.deviceKindIndex',
sortable: false
}, {
id: 'deviceKindName',
header: 'routes.wcs.devicestatus.deviceKindName',
sortable: false
}, {
id: 'lockedState',
header: 'routes.wcs.devicestatus.lockedState',
//-1 禁用; 0 空闲; 1有任务;
filter: { order: 2, field: 'select', range: [{ id: -1, name: this._i18nService.translate('routes.wcs.devicestatus.Forbidden') }, { id: 0, name: this._i18nService.translate('routes.wcs.devicestatus.ready') }, { id: 1, name: this._i18nService.translate('routes.wcs.devicestatus.running') }] },
editor: { template: this._lockedStateEditor },
sortable: false
}, {
id: 'errorCode',
header: 'routes.wcs.devicestatus.errorCode',
editor: { template: this._errorCodeEditor },
sortable: false,
filter: { order: 3, field: 'select', range: [{ id: 0, name: this._i18nService.translate('routes.wcs.devicestatus.normal') }, { id: 1, name: this._i18nService.translate('routes.wcs.devicestatus.error') }] },
//editor: { field: 'select', range: [{ id: 0, name: "空闲" }], default: "", required: true }
}, {
id: 'manTaskReserve',
header: 'routes.wcs.devicestatus.manTaskReserve',
filter: { order: 4, field: 'select', range: [{ id: 0, name: this._i18nService.translate('routes.wcs.devicestatus.ready') }, { id: 1, name: this._i18nService.translate('routes.wcs.devicestatus.ReserveLock') }] },
editor: { template: this._manTaskReserveEditor },
sortable: false
}, {
id: 'haveGoods',
header: 'routes.wcs.devicestatus.haveGoods',
sortable: false,
editor: { field: 'select', range: [{ id: 0, name: this._i18nService.translate('routes.wcs.devicestatus.LogicInexist') }, { id: 1, name: this._i18nService.translate('routes.wcs.devicestatus.LogicExist') }], required: true }
}
];
});
}
public get defination() {
return this._defination;
}
public error = (e: any) => {
switch (e.status) {
/* case 409:
this._toastService.show(this._i18nService.translate(`routes.basic.user.error.conflict.${e.error}`));
return false;
case 410:
this._toastService.show(this._i18nService.translate(`routes.basic.user.error.gone.${e.error}`));
return true; */
case 422:
this._toastService.show(this._i18nService.translate('shared.notification.fail'));
return true;
default:
return true;
}
}
}