Vue.component("watch-crn-card", {
template: `
{{ item.crnNo }}号堆垛机
自动
作业中
故障
离线
{{ item.crnNo }}
{{ item.workNo }}
{{ item.mode }}
{{ item.status }}
{{ item.sourceLocNo }}
{{ item.locNo }}
{{ item.loading }}
{{ item.bay }}
{{ item.lev }}
{{ item.forkOffset }}
{{ item.liftPos }}
{{ item.walkPos }}
{{ item.xspeed }}
{{ item.yspeed }}
{{ item.zspeed }}
{{ item.xdistance }}
{{ item.ydistance }}
{{ item.xDuration }}
{{ item.yduration }}
{{ item.warnCode }}
{{ item.alarm }}
`,
props: ["param"],
data() {
return {
crnList: [],
activeNames: "",
searchCrnNo: "",
showControl: false,
controlParam: {
crnNo: "",
sourceLocNo: "",
targetLocNo: "",
},
pageSize: 25,
currentPage: 1,
};
},
created() {
setInterval(() => {
this.getCrnStateInfo();
}, 1000);
},
computed: {
displayCrnList() {
const start = (this.currentPage - 1) * this.pageSize;
const end = start + this.pageSize;
return this.crnList.slice(start, end);
}
},
watch: {
param: {
handler(newVal, oldVal) {
if (newVal.crnNo != 0) {
this.activeNames = newVal.crnNo;
const idx = this.crnList.findIndex(i => i.crnNo == newVal.crnNo);
if (idx >= 0) { this.currentPage = Math.floor(idx / this.pageSize) + 1; }
}
},
deep: true, // 深度监听嵌套属性
immediate: true, // 立即触发一次(可选)
},
},
methods: {
handlePageChange(page) {
this.currentPage = page;
},
handleSizeChange(size) {
this.pageSize = size;
this.currentPage = 1;
},
getCrnStateInfo() {
let that = this;
$.ajax({
url: baseUrl + "/crn/table/crn/state",
headers: {
token: localStorage.getItem("token"),
},
method: "post",
success: (res) => {
// 堆垛机信息表获取
if (res.code == 200) {
let list = res.data;
if (that.searchCrnNo == "") {
that.crnList = list;
} else {
let tmp = [];
list.forEach((item) => {
if (item.crnNo == that.searchCrnNo) {
tmp.push(item);
}
});
that.crnList = tmp;
that.currentPage = 1;
}
}
},
});
},
openControl() {
this.showControl = !this.showControl;
},
controlCommandTransport() {
let that = this;
//取放货
$.ajax({
url: baseUrl + "/crn/command/take",
headers: {
token: localStorage.getItem("token"),
},
contentType: "application/json",
method: "post",
data: JSON.stringify(that.controlParam),
success: (res) => {
if (res.code == 200) {
that.$message({
message: res.msg,
type: "success",
});
} else {
that.$message({
message: res.msg,
type: "warning",
});
}
},
});
},
controlCommandMove() {
let that = this;
$.ajax({
url: baseUrl + "/crn/command/move",
headers: {
token: localStorage.getItem("token"),
},
contentType: "application/json",
method: "post",
data: JSON.stringify(that.controlParam),
success: (res) => {
if (res.code == 200) {
that.$message({
message: res.msg,
type: "success",
});
} else {
that.$message({
message: res.msg,
type: "warning",
});
}
},
});
},
controlCommandTaskComplete() {
let that = this;
$.ajax({
url: baseUrl + "/crn/command/taskComplete",
headers: {
token: localStorage.getItem("token"),
},
contentType: "application/json",
method: "post",
data: JSON.stringify(that.controlParam),
success: (res) => {
if (res.code == 200) {
that.$message({
message: res.msg,
type: "success",
});
} else {
that.$message({
message: res.msg,
type: "warning",
});
}
},
});
},
},
});