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.
224 lines
7.4 KiB
224 lines
7.4 KiB
5 months ago
|
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: './managetask.component.html',
|
||
|
styleUrls: ['./managetask.component.scss'],
|
||
|
queries: {
|
||
|
_template: new ViewChild('$crud'), // 从crud模板产生的子类
|
||
|
_stateColumn: new ViewChild('$state') // 从crud模板产生的子类
|
||
|
|
||
|
}
|
||
|
})
|
||
|
export class ManagetaskComponent implements AfterViewInit {
|
||
|
|
||
|
private _template: CrudComponent;
|
||
|
private _defination: any;
|
||
|
private _stateColumn: TemplateRef<any>;
|
||
|
|
||
|
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.managetask.Barcode',
|
||
|
filter: { field: 'text' },//右侧查询时候 决定是否出现在查询项中
|
||
|
//editor: { field: 'text', required: true }//编辑选项可用时 弹出编辑窗口 这个属性决定是否出现在编辑项中
|
||
|
}, {
|
||
|
id: 'id', // 模版元素字段名:id
|
||
|
header: 'routes.wcs.managetask.TaskCode', // 显示文字,在zh-CN.json中定义
|
||
|
filter: { field: 'text' },
|
||
|
}, {
|
||
|
id: 'relativeControlID',
|
||
|
header: 'routes.wcs.managetask.relativeControlID',
|
||
|
filter: { field: 'text' },
|
||
|
},
|
||
|
{
|
||
|
id: 'taskKind',
|
||
|
header: 'routes.wcs.managetask.Taskkind',
|
||
|
//filter: { field: 'text' },
|
||
|
}, {
|
||
|
id: 'controlTaskKind',
|
||
|
header: 'routes.wcs.managetask.ControlTaskKind',
|
||
|
//filter: { field: 'text' },
|
||
|
} , {
|
||
|
id: 'froutename',
|
||
|
header: 'routes.wcs.managetask.froutename',
|
||
|
// filter: { field: 'text' },
|
||
|
},
|
||
|
{
|
||
|
id: 'startDevice',
|
||
|
header: 'routes.wcs.managetask.StartDevice',
|
||
|
filter: { field: 'text' },
|
||
|
}, {
|
||
|
id: 'startCell',
|
||
|
header: 'routes.wcs.managetask.StartCell',
|
||
|
filter: { field: 'text' },
|
||
|
}, {
|
||
|
id: 'endDevice',
|
||
|
header: 'routes.wcs.managetask.EndDevice',
|
||
|
filter: { field: 'text' },
|
||
|
}, {
|
||
|
id: 'endCell',
|
||
|
header: 'routes.wcs.managetask.EndCell',
|
||
|
filter: { field: 'text' },
|
||
|
}, {
|
||
|
id: 'taskStatus',
|
||
|
header: 'routes.wcs.managetask.TaskStatus',
|
||
|
filter: { order: 1, field: 'select', range: [{ id: 0, name: this._i18nService.translate('routes.wcs.managetask.waiting') }, { id: 1, name: this._i18nService.translate('routes.wcs.managetask.running') }] }
|
||
|
}, {
|
||
|
id: 'fIntoStepOK',
|
||
|
header: 'routes.wcs.managetask.FIntoStepOK',
|
||
|
//filter: { field: 'text' },
|
||
|
}, {
|
||
|
id: 'startTime',
|
||
|
header: 'routes.wcs.managetask.startTime',
|
||
|
//filter: { field: 'text' },
|
||
|
}, {
|
||
|
id: 'currentDevice',
|
||
|
header: 'routes.wcs.managetask.CurrentDevice',
|
||
|
filter: { field: 'text' },
|
||
|
}, {
|
||
|
id: 'errorInfo',
|
||
|
header: 'routes.wcs.managetask.ErrorInfo',
|
||
|
//filter: { field: 'text' },
|
||
|
}, {
|
||
|
id: 'ftaskLevel',
|
||
|
header: 'routes.wcs.managetask.FtaskLevel',
|
||
|
//filter: { field: 'text' },
|
||
|
}
|
||
|
, {
|
||
|
id: 'useAwayFork',
|
||
|
header: 'routes.wcs.managetask.useAwayFork',
|
||
|
//filter: { field: 'text' },
|
||
|
}
|
||
|
// , {
|
||
|
// id: 'frgvuseawayfork',
|
||
|
// header: 'routes.wcs.managetask.frgvuseawayfork',
|
||
|
// // filter: { field: 'text' },
|
||
|
// }
|
||
|
|
||
|
// , {
|
||
|
// id: 'rgvrelativecontorlid',
|
||
|
// header: 'routes.wcs.managetask.rgvrelativecontorlid',
|
||
|
// filter: { field: 'text' },
|
||
|
// }
|
||
|
, {
|
||
|
id: 'palletType',
|
||
|
header: 'routes.wcs.managetask.palletType',
|
||
|
filter: { field: 'text' },
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
// ,{
|
||
|
// id: 'statusCode',
|
||
|
// header: 'routes.wcs.managetask.TaskStatusCode',
|
||
|
// //filter: { field: 'text' },
|
||
|
// }
|
||
|
];
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public async delete(e?: any): Promise<void> {
|
||
|
if (await this._dialogService.confirm(this._i18nService.translate('shared.notification.confirm'))) {
|
||
|
const data: any = {
|
||
|
id: e.id,
|
||
|
action: 900,
|
||
|
kind: e.taskKind
|
||
|
};
|
||
|
// 调用http接口向服务端发送请求
|
||
|
const res = await this._httpService.post(`managetask`, data).catch(async err => {
|
||
|
// 根据返回错误码,在界面显示提示信息
|
||
|
switch (err.status) {
|
||
|
case 409:
|
||
|
this._toastService.show(this._i18nService.translate(`routes.wcs.managetask.TaskCodeIsError`));
|
||
|
break;
|
||
|
case 410:
|
||
|
this._toastService.show(this._i18nService.translate(`routes.wcs.managetask.TaskStatusIsRuning`));
|
||
|
break;
|
||
|
case 422:
|
||
|
this._toastService.show(this._i18nService.translate('routes.wcs.managetask.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<void> {
|
||
|
if (await this._dialogService.confirm(this._i18nService.translate('shared.notification.confirm'))) {
|
||
|
const data: any = {
|
||
|
id: e.id,
|
||
|
action: 999,
|
||
|
kind: e.taskKind
|
||
|
};
|
||
|
// 调用http接口向服务端发送请求
|
||
|
const res = await this._httpService.post(`managetask`, data).catch(async err => {
|
||
|
// 根据返回错误码,在界面显示提示信息
|
||
|
switch (err.status) {
|
||
|
case 409:
|
||
|
this._toastService.show(this._i18nService.translate(`routes.wcs.managetask.TaskCodeIsError`));
|
||
|
break;
|
||
|
case 410:
|
||
|
this._toastService.show(this._i18nService.translate(`routes.wcs.managetask.TaskStatusIsRuning`));
|
||
|
break;
|
||
|
case 422:
|
||
|
this._toastService.show(this._i18nService.translate('routes.wcs.managetask.SystemError'));
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}) !== undefined;
|
||
|
if (res) {
|
||
|
// 返回成功,提示操作成功
|
||
|
this._toastService.show(this._i18nService.translate('shared.notification.success'));
|
||
|
this._template.refresh();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|