ZengTao
2023-09-06 3879216b974b6a54232dd03017e0695186cea092
CanadaMes-ui/src/views/home/index.vue
@@ -102,9 +102,11 @@
.el-table th {
    padding: 8px 0;
}
.el-table__empty-block{
    min-height: 41px;
}
.el-table__empty-text{
    line-height: 41px;
}
@@ -124,7 +126,7 @@
                    <el-table-column prop="glassId" label="Coming out glass ID"></el-table-column>
                    <el-table-column :width="250" prop="cage" label="The Grille number being used"></el-table-column>
                    <el-table-column prop="orderId" label="Order Nmuber"></el-table-column>
                    <el-table-column prop="glasswidth" label="Length and width"></el-table-column>
                    <el-table-column prop="lengthwidth" label="Length and width"></el-table-column>
                    <el-table-column prop="coating" label="coating"></el-table-column>
                    <el-table-column label="Operate">
                        <el-button type="primary" style="padding: 4px 10px;font-size: 12px;">end task</el-button>
@@ -134,7 +136,7 @@
                    <el-table-column prop="glassId" label="Incoming glass ID"></el-table-column>
                    <el-table-column :width="250" prop="cage" label="The Grille number being used"></el-table-column>
                    <el-table-column prop="orderId" label="Order Nmuber"></el-table-column>
                    <el-table-column prop="glasswidth" label="Length and width"></el-table-column>
                    <el-table-column prop="lengthwidth" label="Length and width"></el-table-column>
                    <el-table-column prop="coating" label="coating"></el-table-column>
                    <el-table-column label="Operate">
                        <el-button type="primary" style="padding: 4px 10px;font-size: 12px;">end task</el-button>
@@ -205,8 +207,9 @@
import { home, home2, loadtask, InsertOrder, Addglassid } from "../../api/home";
let socket;
export default {
    name: "Home",
    data() {
        return {
            dialogFormVisible: false,
@@ -234,8 +237,68 @@
    },
    created() {
        this.load();
        this.init();
    },
    methods: {
        init() {
            let viewname = "Home";
            if (typeof (WebSocket) == "undefined") {
                console.log("您的浏览器不支持WebSocket");
            } else {
                //console.log("您的浏览器支持WebSocket");
                let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
                if (socket != null) {
                    socket.close();
                    socket = null;
                }
                // 开启一个websocket服务
                socket = new WebSocket(socketUrl);
                //打开事件
                socket.onopen = function () {
                    console.log("websocket已打开");
                };
                //  浏览器端收消息,获得从服务端发送过来的文本消息
                socket.onmessage = function (msg) {
                    //console.log("收到数据====" + msg.data);
                    let obj = JSON.parse(msg.data);
                    //this.$set(this.record.params, 0, obj.params[0]);
                    this.car1 = 116 + 18.88 * obj.params[0][0];
                    this.car2 = 187 + 18.8 * obj.params[0][1];
                    this.tableData=obj.tableData[0];
                    this.cagelist1=obj.cagelist1[0];
                    this.cagelist2=obj.cagelist2[0];
                    this.cagelist3=obj.cagelist3[0];
                    this.cagelist4=obj.cagelist4[0];
                    this.tasklist1=obj.tasklist1[0];
                    this.tasklist2=obj.tasklist2[0];
                    // for (let a = 0; a <= this.record.params.length - 1; a++) {
                    //     // this.record.xyData[a] = [this.record.canshu[a], this.record.params[0][a]];
                    //     // this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a] };
                    //     // this.record.xyData[a].value = this.record.params[0][a];
                    //     this.car1=this.record.params[0][a];
                    //     console.log(this.record.params[0][a]);
                    // }
                    this.$forceUpdate();
                }.bind(this);
                //关闭事件
                socket.onclose = function () {
                    console.log("websocket已关闭");
                };
                //发生了错误事件
                socket.onerror = function () {
                    console.log("websocket发生了错误");
                }
            }
        },
        load() {
            home().then(res => {
                this.tableData = res.data.list;
@@ -255,8 +318,7 @@
            });
            loadtask(this.task2).then(res => {
                this.tasklist2 = res.data.list;
                this.car1 = 116 + 18.88 * 20;
                this.car2 = 187 + 18.8 * 30;
            });
        },
        //根据格子状态修改颜色
@@ -314,8 +376,9 @@
                });
            }
        },
        endtask(){
        endtask(type,shelfrack) {
            alert(type);
            alert(shelfrack);
        }
    }
};