| | |
| | | <div class="app">
|
| | | <!--面包屑导航区域-->
|
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
|
| | | <router-link to="/home" tag="el-button" type="text">{{ $t('langHome') }}</router-link>
|
| | | <el-button type="text">设备管理</el-button>
|
| | | <router-link to="/Electrical/Parameter" tag="el-button" type="text">Parameter</router-link>
|
| | | <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>
|
| | | <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') }}</router-link>
|
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') }}</router-link>
|
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') }}</router-link>
|
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') }}</router-link>
|
| | | <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') }}</router-link>
|
| | | </el-breadcrumb>
|
| | | <div>State</div>
|
| | |
|
| | |
|
| | | <el-form label-width="100px" style="display: flex;flex-wrap: wrap;" :model="messagepack.data">
|
| | | <div id="btn_div">
|
| | | <el-button type="primary" @click="send()">Distribute</el-button>
|
| | | <!-- <button @click="send()">测试发送</button> -->
|
| | | </div>
|
| | |
|
| | | <div class="kuai_div" v-for="item in this.record.xyData" :key="item.name">
|
| | | <el-input style="width: 280px;" class="in_mc" v-model="item.name"></el-input>
|
| | | <el-input v-model="item.value" style="width: 80px;"></el-input>
|
| | | <el-input v-model.number="item.value" style="width: 80px;"></el-input>
|
| | | </div>
|
| | |
|
| | |
|
| | |
| | | </template>
|
| | |
|
| | | <script >
|
| | |
|
| | | import LanguageMixin from '../../lang/LanguageMixin'
|
| | | let socket;
|
| | | export default {
|
| | | name: "State",
|
| | | mixins: [LanguageMixin],
|
| | | data () {
|
| | | return {
|
| | | activeButton: '',
|
| | | record: {
|
| | | params: [0, 0, 0, 0, 0, 0, 0, 0, 0,],
|
| | | params: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,],
|
| | | xyData: [
|
| | | { name: 'D01.State', value: 0 },
|
| | | { name: 'D02.State', value: 0 },
|
| | |
| | | { name: 'D05.State', value: 0 },
|
| | | { name: 'D06.State', value: 0 },
|
| | | ],
|
| | | canshu: [
|
| | | 'D01.State',
|
| | | 'D02.State',
|
| | | 'B01.State',
|
| | | 'B02.State',
|
| | | 'A01.State',
|
| | | 'A02.State',
|
| | | 'D03.State',
|
| | | 'D04.State',
|
| | | 'D05.State',
|
| | | 'D06.State',
|
| | | ],
|
| | | // canshu: [
|
| | | // 'D01.State',
|
| | | // 'D02.State',
|
| | | // 'B01.State',
|
| | | // 'B02.State',
|
| | | // 'A01.State',
|
| | | // 'A02.State',
|
| | | // 'D03.State',
|
| | | // 'D04.State',
|
| | | // 'D05.State',
|
| | | // 'D06.State',
|
| | | // ],
|
| | |
|
| | | },
|
| | |
|
| | |
| | | this.init();
|
| | | },
|
| | | methods: {
|
| | | onButtonClick() {
|
| | | this.isButtonClicked = true; // 将按钮颜色设置为蓝色
|
| | | setTimeout(() => {
|
| | | this.isButtonClicked = false; // 重置按钮颜色
|
| | | }, 500); // 这里的500毫秒是根据您希望按钮颜色持续多长时间来定的,可以根据需求进行调整
|
| | | },
|
| | | init () {
|
| | | let viewname = "State";
|
| | |
|
| | |
| | | //console.log("收到数据====" + msg.data);
|
| | | let obj = JSON.parse(msg.data);
|
| | | this.record.params[0] = obj.sta[0];
|
| | | for (let a = 0; a <= this.record.params.length - 1; a++) {
|
| | | //this.record.xyData[a] = [this.record.params[0][a], this.record.canshu[a]];
|
| | | this.record.xyData[a] = { name: this.record.canshu[a], value: this.record.params[0][a] };
|
| | | //将读取到的PLC的数据,与定义的xyData,组合成新的数组
|
| | | for (let a = 0; a <= this.record.xyData[0].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.$forceUpdate();
|
| | | console.log(this.record.xyData);
|
| | | //console.log(this.record.params[0])
|
| | | // console.log(this.records.canshu);
|
| | |
|
| | | }.bind(this);
|
| | | //关闭事件
|
| | |
| | | }
|
| | | },
|
| | | send () {
|
| | | this.messagepack.data = { taskname: "前端到后台" };
|
| | | socket?.send(JSON.stringify(this.messagepack)); // 将组装好的json发送给服务端,由服务端进行转发
|
| | | }
|
| | | this.messagepack.data = this.record.xyData.map((item) => parseInt(item.value)); // 转换为整数数组
|
| | | console.log(this.messagepack);
|
| | | socket?.send(JSON.stringify(this.messagepack));
|
| | | },
|
| | |
|
| | | }
|
| | |
|
| | |
| | | #btn_div .el-button {
|
| | | float: right;
|
| | | }
|
| | | .blue-button {
|
| | | background-color: skyblue;
|
| | | }
|
| | | </style>
|