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.
 
 
 

320 lines
12 KiB

import { Component } from '@angular/core';
import { FormGroup, Validators, FormBuilder } from '@angular/forms';
import { MatDialogRef } from '@angular/material/dialog';
import { HttpService } from '@app/core/services/http.service';
import { ToastService } from '@app/core/services/toast.service';
import { I18nService } from '@app/core/services/i18n.service';
import { DialogService } from '@app/core/services/dialog.service';
@Component({
selector: 'app-wcs-handcommand-handcommandedit',
templateUrl: './handcommandedit.component.html',
styleUrls: ['./handcommandedit.component.scss']
})
export class HandcommandeditComponent {
private _form: FormGroup;
private _devicelist: any[];
private _orderlist: any[];
private _arrowlocation: any[];
private _beginDevice: any[]; // HSYL 增加起点设备,给环穿取送货指令用
public _z: any[];
public _x: any[];
public _y: any[];
public _f: any[];
public _pallettype: any[];
public xhide: boolean = true; // 显示XYZ参数
public fhide: boolean = true; // 显示货叉参数
public phide: boolean = true; // 显示托盘类型
public beginhide: boolean = true; // 显示起点设备
private _arrowLocationList: any[];
private _beginhideList: any[];
constructor(
private _dialogService: DialogService,
private _formBuilder: FormBuilder,
private _httpService: HttpService,
private _toastService: ToastService,
private _i18nService: I18nService,
private _dialogRef: MatDialogRef<HandcommandeditComponent>
) {
this._form = this._formBuilder.group({
devicelist: [null, [Validators.required]],
pallettype: [null, [Validators.required]],
orderlist: [null, [Validators.required]],
arrowlocation: [null, [Validators.required]],
z: [null, [Validators.required]],
x: [null, [Validators.required]],
y: [null, [Validators.required]],
f: [null, [Validators.required]],
beginDevice:[null,[Validators.required]] //对应HTML定义的控件名称
});
this.Init();
this._orderlist = [{ id: "-1", name: "" }];
this._arrowlocation = [{ id: "-1", name: "" }];
this._beginDevice = [{ id: "-1", name: "" }]; // 初始化赋值
this._z = [{ id: "0", name: "" }];
this._x = [{ id: "0", name: "" }];
this._y = [{ id: "0", name: "" }];
this._f = [{ id: "0", name: "" }];
}
async Init(): Promise<void> {
let res: any = await this._httpService.get('handcommand/devicelist');
this._devicelist = res.items;
}
public async deviceSelected(e: any): Promise<void> {
if (e) {
const value = e.value;
let res: any = null;
//debugger
res = await this._httpService.join(
this._httpService.get(`handcommand/order?device=${value}`),
this._httpService.get(`handcommand/arrowlocation?device=${value}`),
this._httpService.get(`handcommand/Fork?device=${value}`))
//debugger
this._orderlist = res[0].items; // 命令返回数组值
this._arrowlocation = res[1].items; // 目标地址返回数组值
this._beginDevice = res[1].items; // 控件变化事件,前端显示赋值
this._f = res[2].items; // 货叉返回数组值
this._arrowLocationList = this._arrowlocation;//暂存一下 在指令改变时 重新赋值用
this._beginhideList = this._beginDevice;//暂存一下 在指令改变时 重新赋值用
// debugger;
// 增加环穿类型 13、14
if (this._devicelist.find(item => item.id == e.value).devicekind == "2"||this._devicelist.find(item => item.id == e.value).devicekind == "4"||this._devicelist.find(item => item.id == e.value).devicekind == "13"||this._devicelist.find(item => item.id == e.value).devicekind == "14") {
this.xhide = false; // 显示XYZ参数
this.phide =true; // 显示托盘类型
// this.fhide = false;
}
else {
this.xhide = true;
this.phide =true;
// this.fhide = true;
}
if(res[2].items.length !=0){
if(res[2].items[0].forkS == "2"){
this.fhide = true;
}else{
this.fhide = false;
}
}else{
this.fhide = false;
}
if (this._devicelist.find(item => item.id == e.value).devicekind == "1") {
this._arrowlocation.push({ id: "-1", name: "立库货位" });
}
// HSYL 环穿 穿梭车显示起点选项d
if(this._devicelist.find(item => item.id == e.value).devicekind == "14"|| this._devicelist.find(item => item.id == e.value).devicekind == "13"){
this.beginhide = true; // html 设置标签 *ngIf="beginhide"
// this._beginDevice = res[1].items; // 目标地址返回数组值
}else{
this.beginhide = false;
}
}
}
public async arrowlocationSelected(e: any, edevice: any): Promise<void> {
if (e) {
const value = e.value;
if (value == -1) {//立库货位
this.xhide = true;
let res: any = await this._httpService.get(`handcommand/zxy?device=${edevice.value}`);
if (res) {
this._z = res.items;
}
}
else {
this.xhide = false;//将zxy隐藏
// this.fhide = false;
}
}
}
public async orderSelected(edevice: any, e: any): Promise<void> {
if (e && edevice) {
if (this._devicelist.find(item => item.id == edevice.value).devicekind == "2") {
if (e.value != "6") {
//king kun 正装反转需要带目标位置改这
this._arrowlocation = [{ id: "0", name: "0" }];
}
else {
this._arrowlocation = this._arrowLocationList;
}
//console.log( this._beginDevice+"sssssssssssssvvvv")
}
//debugger
// 不是环穿设备 _beginDevice 赋值0
if (this._devicelist.find(item => item.id == edevice.value).devicekind != "13"&& this._devicelist.find(item => item.id == edevice.value).devicekind != "14") {
this._beginDevice = [{ id: "0", name: "0" }];
}
// debugger
if (this._devicelist.find(item => item.id == edevice.value).devicekind == "13"|| this._devicelist.find(item => item.id == edevice.value).devicekind == "14") {
if (e.value == "1") {
//zb 取送货指令需要带目标位置改这 ,赋值给控件
this._beginDevice = this._beginhideList;
}
else {
// 其他指令,赋值0
this._beginDevice = [{ id: "0", name: "0" }];
}
//console.log( this._beginDevice+"sssssssssssss")
//this.form.controls.arrowlocation.setValue("0", "")
}
}
}
public async zSelected(e: any, ez: any): Promise<void> {
if (e && ez) {
let res: any = await this._httpService.get(`handcommand/zxy?device=${e.value}&z=${ez.value}`);
if (res) {
this._x = res.items;
}
}
}
public async xSelected(e: any, ez: any, ex: any): Promise<void> {
if (e && ez && ex) {
let res: any = await this._httpService.get(`handcommand/zxy?device=${e.value}&z=${ez.value}&x=${ex.value}`);
if (res) {
this._y = res.items;
}
}
}
public async fSelected(e: any): Promise<void> {
if (e) {
let res: any = await this._httpService.get(`handcommand/Fork?device=${e.value}`);
this._f = res.items;
if (this._f.find(item => item.id == "2")) {
// this.fhide = true;
if(res){
this._f = res.items;
}
}
// else{
// this.fhide = false;
// }
}
}
// public async ySelected(e: any): Promise<void> {
// if (e) {
// const value = e.value;
// // res = await this._httpService.get(`handcommand/arrowlocation?device=${value}`);
// // if (res) {
// // this._arrowlocation = res.items;
// // //this._orderlist = res[0].items;
// // //this._arrowlocation = res[1].items;
// // }
// if (value == -1) {//立库货位
// this.xhide = true;
// }
// else {
// this.xhide = false;//将zxy隐藏
// }
// }
// }
public get form() {
return this._form;
};
public get devicelist() {
return this._devicelist;
};
public get orderlist() {
return this._orderlist;
};
public get arrowlocation() {
return this._arrowlocation;
};
public get beginDevice() {
return this._beginDevice;
};
public get z() {
return this._z;
};
public get x() {
return this._x;
};
public get y() {
return this._y;
};
public get f() {
return this._f;
};
public get pallettype() {
return this._pallettype;
};
// console.log();
public save = async () => {
if (await this._dialogService.confirm(this._i18nService.translate('shared.notification.confirm'))) {
const data: any = {
id: this.form.controls.devicelist.value,
order: this.form.controls.orderlist.value,
pallettype: this.form.controls.pallettype.value==null ? "0":this.form.controls.pallettype.value,
arrowlocation: this.form.controls.arrowlocation.value,
z: this.form.controls.z.value == null ? "0" : this.form.controls.z.value,
x: this.form.controls.x.value == null ? "0" : this.form.controls.x.value,
y: this.form.controls.y.value == null ? "0" : this.form.controls.y.value,
f: this.form.controls.f.value == null ? "0" : this.form.controls.f.value,
beginDevice: this.form.controls.beginDevice.value==null ?"0":this.form.controls.beginDevice.value
};
// var f = this.form.controls.f.value;
// // var length = f.length;
// //add for JXYN
// debugger;
// if (f==0) {
// this._toastService.show(this._i18nService.translate(`routes.wcs.handcommand.SB`));
// this._dialogRef.close(false);
// }
const res = await this._httpService.post(`handcommand`, data).catch(async err => {
switch (err.status) {
case 407:
this._toastService.show(this._i18nService.translate(`routes.wcs.handcommand.SB2`));
break;
case 408:
this._toastService.show(this._i18nService.translate(`routes.wcs.autocommand.palletTypeeerror`));
break;
case 409:
this._toastService.show(this._i18nService.translate(`routes.wcs.handcommand.systemerror`));
break;
case 410:
this._toastService.show(this._i18nService.translate(`routes.wcs.handcommand.systemerror`));
break;
case 422:
this._toastService.show(this._i18nService.translate('routes.wcs.handcommand.error'));
break;
case 423:
this._toastService.show(this._i18nService.translate(`routes.wcs.handcommand.SB`));
break;
default:
break;
}
}) !== undefined;
if (res) {
this._toastService.show(this._i18nService.translate('shared.notification.success'));
this._dialogRef.close(true);
}
}
}
}