wu
2023-09-05 adb18df8a106d6a45241ded8805c9abf3ec58e91
CanadaMes-ui/src/views/Electrical/Action.vue
@@ -8,21 +8,15 @@
      <router-link to="/Electrical/Action" tag="el-button" type="text">Action</router-link>
      <router-link to="/Electrical/Sign" tag="el-button" type="text">Sign</router-link>
      <router-link to="/Electrical/State" tag="el-button" type="text">State</router-link>
      <router-link to="/Electrical/alarm" tag="el-button" type="text">Alarm</router-link>
    </el-breadcrumb>
    <div>Action</div>
    <el-form label-width="100px" style="display: flex;flex-wrap: wrap;" :model="{ records }">
      <div class="kuai_sb" v-for="item in records" :key="item.id">
        <el-input v-model="item.mingcheng" style="width: 280px;" class="in_mc"></el-input>
        <!-- <el-input v-model="item.zhuangtai" style="width: 80px;"></el-input> -->
        <el-switch v-model="item.zhuangtai" active-color="#13ce66" active-value="1" inactive-value="2"></el-switch>
    <el-form label-width="100px" style="display: flex;flex-wrap: wrap;" :model="{ messagepack }">
      <div class="kuai_div" v-for="item in this.record.xyData" :key="item.name">
        <el-input v-model="item.name" style="width: 240px;" class="in_mc"></el-input>
        <!-- <el-input v-model="item[0]" style="width: 80px;"></el-input> -->
        <el-switch v-model="item.value" active-value="0" inactive-value="1"></el-switch>
      </div>
      <div class="kuai_div">
  <el-input style="width: 280px;" class="in_mc" value="conveyor Velocity(Auto SLOW)"></el-input>
  <el-input v-for="(param, index) in record.params[0]" :key="index" v-model="record.params[0][index]" style="width: 80px;"></el-input>
</div>
<button @click="send()">测试发送</button>
    </el-form>
@@ -30,34 +24,69 @@
</template>
<script >
let socket;
export default {
  name: "Action",
  name: "action",
  data () {
    return {
      records: [
        { id: 1, mingcheng: 'conveyor Velocity(Auto SLOW)', zhuangtai: "1" },
        { id: 2, mingcheng: 'B01 B02 TRAVEL POS Velocity AUTO', zhuangtai: "2" },
        { id: 3, mingcheng: 'B01 B02 TRAVEL JOG Velocity', zhuangtai: "2" },
        { id: 4, mingcheng: 'conveyor Velocity(Manual)', zhuangtai: "1" }
      record: {
        params: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        canshu: [
          'D01 VFD conveyor',
          'D02 VFD conveyor',
          'D03 VFD conveyor',
          'D04 VFD conveyor',
          'D05 VFD conveyor',
          'D06 VFD conveyor',
          'A01 VFD conveyor',
          'A02 VFD conveyor',
          'B01 VFD conveyor',
          'B02 VFD conveyor',
          'A01 SERVE TURN JOG+',
          'A02 SERVE TURN JOG-',
          'A01 SERVE TRAVEL JOG+',
          'A02 SERVE TRAVEL JOG-',
          'B01 SERVE TRAVEL JOG+',
          'B02 SERVE TRAVEL JOG-',
          'A01 SERVE TURN POS',
          'A02 SERVE TURN POS',
          'A01 SERVE TRAVEL POS',
          'A02 SERVE TRAVEL POS',
          'B01 SERVE TRAVEL POS',
          'B02 SERVE TRAVEL POS',
          'B01 YV TURN',
          'B01 YV UP DOWN',
          'B02 YV TURN',
          'B02 YV UP DOWN',
      ],
        xyData: [
          { name: 'D01 VFD conveyor', value: 0 },
          { name: "D02 VFD conveyor", value: 0 },
          { name: "D03 VFD conveyor", value: 0 },
          { name: "D04 VFD conveyor", value: 0 },
          { name: "B01 B02 TRAVEL JOG Velocity", value: 0 },
          { name: "conveyor Velocity(Manual)", value: 0 },
        ],
      },
      messagepack: {
        data: { taskname: "" }
      },
      record: {
      params: [0,0,0,0,0,0]
      queryInfo: {
        data: "1",
        pageSize: 10
    },
    }
  },
  created () {
    this.init();
    //console.log(this.records);
  },
  methods: {
    init () {
      let viewname = "talkvue";
      let viewname = "Action";
      if (typeof (WebSocket) == "undefined") {
        console.log("您的浏览器不支持WebSocket");
@@ -77,10 +106,23 @@
        };
        //  浏览器端收消息,获得从服务端发送过来的文本消息
        socket.onmessage = function (msg) {
  console.log("收到数据====" + msg.data);
          //console.log("收到数据====" + msg.data);
  let obj = JSON.parse(msg.data);
  this.$set(this.record.params, 0, obj.params[0]);
  console.log( this.record.params[0])
          this.record.params[0] = obj.acion[0].join(",");
          this.record.params[0] = this.record.params[0].split(",");
          for (let a = 0; a <= this.record.params.length - 1; a++) {
            // if (!this.record.xyData[a]) {
            //   this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a] };
            // } else {
            //   this.record.xyData[a].value = this.record.params[0][a];
            // }
            this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a] };
          }
          console.log(this.record.xyData)
          this.$forceUpdate();
}.bind(this);
        //关闭事件
        socket.onclose = function () {
@@ -91,6 +133,7 @@
          console.log("websocket发生了错误");
        }
      }
    },
    send () {
      this.messagepack.data = { taskname: "前端到后台" };
@@ -107,10 +150,11 @@
</script>
<style>
.kuai_sb {
  width: 30%;
  margin-bottom: 15px;
.kuai_div {
  /* width: 30%; */
  margin-bottom: 30px;
}
.el-input {