| | |
| | | <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">Electrical</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> |
| | | </el-breadcrumb> |
| | | <div>Alarm</div> |
| | | <!-- <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[1]"> |
| | | <el-input v-model="item[1]" style="width: 240px;" class="in_mc"></el-input> |
| | | <el-switch v-model="item[0]" active-value="0" inactive-value="1"></el-switch> |
| | | </div> |
| | | </el-form> --> |
| | | |
| | | <el-table :data="localizedRoles" style="width: 100%;" height="590"> |
| | | <el-table-column prop="id" label="id" width="80"> |
| | | <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') }}</router-link> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') }}</router-link> --> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') }}</router-link> |
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ $t('Servo Manual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | <div>{{ $t('Alarm') }}</div> |
| | | <div class="block"> |
| | | <span class="demonstration">{{ $t('shijian') }}:</span> |
| | | <el-date-picker v-model="shijian1" type="datetime" :placeholder="$t('Pick a day')" align="right" |
| | | :picker-options="pickerOptions"> |
| | | </el-date-picker> |
| | | ~ |
| | | <el-date-picker v-model="shijian2" type="datetime" :placeholder="$t('Pick a day')" align="right" |
| | | :picker-options="pickerOptions"> |
| | | </el-date-picker> |
| | | |
| | | <el-button type="primary" @click="selectTime()">{{ $t('Search') }}</el-button> |
| | | </div> |
| | | |
| | | <el-table :data="localizedRoles" style="width: 100%;" height="550"> |
| | | <el-table-column prop="id" :label="$t('alarmid')" width="80"> |
| | | </el-table-column> |
| | | <el-table-column prop="content" label="content"> |
| | | <el-table-column prop="content" :label="$t('alacontent')"> |
| | | </el-table-column> |
| | | <el-table-column prop="timeon" label="time-on"> |
| | | <el-table-column prop="timeon" :label="$t('time-on')"> |
| | | </el-table-column> |
| | | <el-table-column prop="endTime" label="End Time"> |
| | | <el-table-column prop="endTime" :label="$t('End-Time')"> |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | </template> |
| | | |
| | | <script > |
| | | import { setAll } from "../../api/alarm"; |
| | | import { setAll, setTime } from "../../api/alarm"; |
| | | |
| | | import moment from 'moment'; |
| | | //setTime |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | let socket; |
| | | export default { |
| | |
| | | data: "1", |
| | | pageSize: 10 |
| | | }, |
| | | pickerOptions: { |
| | | |
| | | disabledDate (time) { |
| | | return time.getTime() > Date.now(); |
| | | }, |
| | | shortcuts: [{ |
| | | |
| | | text: this.$t('today'), |
| | | onClick (picker) { |
| | | picker.$emit('pick', new Date()); |
| | | } |
| | | }, |
| | | { |
| | | text: this.$t('yesterday'), |
| | | onClick (picker) { |
| | | const date = new Date(); |
| | | date.setTime(date.getTime() - 3600 * 1000 * 24); |
| | | picker.$emit('pick', date); |
| | | } |
| | | }, |
| | | { |
| | | text: this.$t('week'), |
| | | onClick (picker) { |
| | | const date = new Date(); |
| | | date.setTime(date.getTime() - 3600 * 1000 * 24 * 7); |
| | | picker.$emit('pick', date); |
| | | } |
| | | }] |
| | | }, |
| | | shijian1: "", |
| | | shijian2: "", |
| | | } |
| | | }, |
| | | created () { |
| | | this.init(); |
| | | this.load(); |
| | | |
| | | |
| | | }, |
| | | // created () { |
| | | // this.init(); |
| | | |
| | | |
| | | // if (this.shijian1 == "" || this.shijian2 == "") { |
| | | // //查询当天报警信息 |
| | | // this.load(); |
| | | // } |
| | | // else { |
| | | // //根据时间查询报警信息 |
| | | // this.selectTime(); |
| | | // } |
| | | |
| | | // }, |
| | | activated(){ |
| | | |
| | | this.init(); |
| | | if (this.shijian1 == "" || this.shijian2 == "") { |
| | | //查询当天报警信息 |
| | | this.load(); |
| | | } |
| | | else { |
| | | //根据时间查询报警信息 |
| | | this.selectTime(); |
| | | } |
| | | |
| | | }, |
| | | methods: { |
| | | |
| | | load () { |
| | |
| | | } else { |
| | | this.localizedRoles = [...this.roles]; |
| | | } |
| | | console.log(this.localizedRoles); |
| | | //console.log(this.localizedRoles); |
| | | }); |
| | | |
| | | }, |
| | | selectTime () { |
| | | |
| | | //moment需要单独安转依赖,npm install moment |
| | | let sj1 = moment(this.shijian1).format('YYYY-MM-DD%20HH:mm'); |
| | | let sj2 = moment(this.shijian2).format('YYYY-MM-DD%20HH:mm') |
| | | //调用setTime方法给roles赋值 |
| | | setTime(sj1, sj2).then(res => { |
| | | this.roles = res.data.list; |
| | | //table中的内容进行语言转换 |
| | | const language = this.$i18n.locale; |
| | | if (language === 'zh-CN') { |
| | | this.replaceChineseWithEnglish(); |
| | | } else { |
| | | this.localizedRoles = [...this.roles]; |
| | | } |
| | | }); |
| | | }, |
| | | //语言转换 |
| | | replaceChineseWithEnglish () { |
| | | const translation = this.$t('translation'); |
| | | this.localizedRoles = this.roles.map(role => ({ |
| | |
| | | }; |
| | | // 浏览器端收消息,获得从服务端发送过来的文本消息 |
| | | socket.onmessage = function (msg) { |
| | | |
| | | //console.log("收到数据====" + msg.data); |
| | | let obj = JSON.parse(msg.data); |
| | | |
| | | this.record.params[0] = obj.arm; |
| | | //每次请求更新数据 |
| | | this.load(); |
| | | if (this.shijian1 == "" || this.shijian2 == "") { |
| | | this.load(); |
| | | } |
| | | else { |
| | | this.selectTime(); |
| | | } |
| | | this.$forceUpdate(); |
| | | }.bind(this); |
| | | //关闭事件 |
| | |
| | | socket.onerror = function () { |
| | | console.log("websocket发生了错误"); |
| | | } |
| | | this.$router.afterEach(function(){ |
| | | socket.close(); |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | send () { |
| | | this.messagepack.data = { taskname: "前端到后台" }; |
| | | socket?.send(JSON.stringify(this.messagepack)); // 将组装好的json发送给服务端,由服务端进行转发 |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | </script> |
| | | |
| | | |
| | | <style> |
| | | <style > |
| | | .kuai_div { |
| | | /* width: 30%; */ |
| | | margin-bottom: 30px; |