|
@@ -1,64 +1,151 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <el-card style="margin: 15px">
|
|
|
- <el-form ref="editform" :rules="rules" label-width="140px" :model="formmodel">
|
|
|
- <fieldset>
|
|
|
- <legend>{{ this.$t('tab.ledDevice') }}</legend>
|
|
|
-
|
|
|
- <el-row>
|
|
|
- <el-form-item :label="this.$t('deviceManage.ledUpdateDefaultProgram')">
|
|
|
- <el-radio v-model="isOnlyTime" :label="false">{{ this.$t('deviceManage.ledOnlyTime') }}</el-radio>
|
|
|
- <el-radio v-model="isOnlyTime" :label="true">{{ this.$t('deviceManage.ledAddCustom') }}</el-radio>
|
|
|
+ <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
|
|
|
+ <el-tab-pane name="s433" label="无线点阵屏"></el-tab-pane>
|
|
|
+ <el-tab-pane name="led" label="LED点阵屏"></el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ <div v-if="activeName === 's433'">
|
|
|
+ <el-form ref="myForm" :rules="rules" label-width="90px" :model="s433FormModel">
|
|
|
+ <el-row>
|
|
|
+ <el-form-item label="模式">
|
|
|
+ <el-radio-group v-model="s433FormModel.type" size="mini" prop="unit">
|
|
|
+ <el-radio :label="4">校验时间</el-radio>
|
|
|
+ <el-radio :label="0">屏参</el-radio>
|
|
|
+ <el-radio :label="1">自定义数据</el-radio>
|
|
|
+ <el-radio :label="2">调试</el-radio>
|
|
|
+ <el-radio :label="3">清空显示</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ </el-row>
|
|
|
+ <el-row v-if="s433FormModel.type === 0">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item :label="this.$t('deviceManage.ledResolutionRatio')" prop="ledStyle">
|
|
|
+ <el-input v-model="s433FormModel.ledStyle" clearable placeholder="128*32" />
|
|
|
</el-form-item>
|
|
|
- </el-row>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item :label="this.$t('deviceManage.ledFontSize')" prop="ledSize">
|
|
|
+ <el-input-number v-model="s433FormModel.ledSize" controls-position="right" :min="0" :max="60" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row v-else-if="s433FormModel.type === 1">
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="自定义数据">
|
|
|
+ <el-input v-model="s433FormModel.title" placeholder="你好世界" :maxlength="50"/>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
|
|
|
- <el-row v-if="isOnlyTime">
|
|
|
-<!-- <el-row>-->
|
|
|
- <el-col :span="18">
|
|
|
- <el-form-item :label="this.$t('deviceManage.ledAddCustom')">
|
|
|
- <el-input v-model="formmodel.addCustom" :maxlength="50" />
|
|
|
+ <div class="table-wrapper" style="padding-bottom: 10px;padding-left: 10px">
|
|
|
+ <div style="padding: 5px;">
|
|
|
+ <el-select v-model="s433FormModel.boxMac" filterable style="margin-right: 10px;">
|
|
|
+ <el-option v-for="item in boxList" :key="item.eth_mac" :label="item.name" :value="item.eth_mac">
|
|
|
+ <span style="float: left">{{ item.name }}</span>
|
|
|
+ <span style="float: right; color: #8492a6; font-size: 13px">--{{ item.eth_mac }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+<!-- <el-button :disabled="multipleSelection.length === 0 && s433FormModel.boxMac != null" type="primary" @click="clickSend(4)">校验时间</el-button>-->
|
|
|
+ <el-button :disabled="multipleSelection.length === 0 && s433FormModel.boxMac != null" type="success" @click="sendChange">批量发送</el-button>
|
|
|
+<!-- <el-button :disabled="s433FormModel.boxMac != null" type="info" @click="clickSend">清空所有显示</el-button>-->
|
|
|
+ </div>
|
|
|
+ <el-table :data="s433DeviceList" id="myTableId" stripe border style="width: 100%" ref="refTable"
|
|
|
+ @selection-change="selectFun" height="520">
|
|
|
+ <el-table-column type="selection" width="55"></el-table-column>
|
|
|
+ <el-table-column prop="name" label="设备名" min-width="130" align="center"/>
|
|
|
+ <el-table-column prop="eth_mac" label="Mac" min-width="130" align="center"/>
|
|
|
+ <!-- <el-table-column prop="send_time" label="发送时间" min-width="130" align="center" />-->
|
|
|
+ <el-table-column prop="receive_time" label="流程耗时" width="130" align="center"/>
|
|
|
+ <el-table-column prop="state" label="状态" width="140" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tag v-if="scope.row.state === 0" type="warning" disable-transitions>等待发送</el-tag>
|
|
|
+ <el-tag v-if="scope.row.state === 1" type="primary" disable-transitions>发送成功等待返回</el-tag>
|
|
|
+ <el-tag v-if="scope.row.state === 2" type="success" disable-transitions>已返回完成流程</el-tag>
|
|
|
+ <el-tag v-if="scope.row.state === -1" type="danger" disable-transitions>发送失败</el-tag>
|
|
|
+ <el-tag v-if="scope.row.state === -2" type="danger" disable-transitions>返回超时</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column style="text-align: left;" label="操作" width="120" fixed="right">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button type="success" size="mini" @click="handlerEdit(scope.$index, scope.row)">
|
|
|
+ 发送
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-if="activeName === 'led'">
|
|
|
+ <el-card style="margin: 15px">
|
|
|
+ <el-form ref="editform" :rules="rules" label-width="140px" :model="formmodel">
|
|
|
+ <fieldset>
|
|
|
+ <legend>{{ this.$t('tab.ledDevice') }}</legend>
|
|
|
+
|
|
|
+ <el-row>
|
|
|
+ <el-form-item :label="this.$t('deviceManage.ledUpdateDefaultProgram')">
|
|
|
+ <el-radio v-model="isOnlyTime" :label="false">{{ this.$t('deviceManage.ledOnlyTime') }}</el-radio>
|
|
|
+ <el-radio v-model="isOnlyTime" :label="true">{{ this.$t('deviceManage.ledAddCustom') }}</el-radio>
|
|
|
</el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
+ </el-row>
|
|
|
|
|
|
- <el-row>
|
|
|
- <el-form-item>
|
|
|
- <el-col :span="4">
|
|
|
- <el-button type="primary" @click="timing">{{ this.$t('deviceManage.ledTiming') }}</el-button>
|
|
|
+ <el-row v-if="isOnlyTime">
|
|
|
+ <!-- <el-row>-->
|
|
|
+ <el-col :span="18">
|
|
|
+ <el-form-item :label="this.$t('deviceManage.ledAddCustom')">
|
|
|
+ <el-input v-model="formmodel.addCustom" :maxlength="50"/>
|
|
|
+ </el-form-item>
|
|
|
</el-col>
|
|
|
+ </el-row>
|
|
|
|
|
|
- <el-col :span="4">
|
|
|
- <el-button type="primary" @click="updateDefaultProgram">{{ this.$t('deviceManage.ledUpdateDefaultProgram') }}</el-button>
|
|
|
- </el-col>
|
|
|
+ <el-row>
|
|
|
+ <el-form-item>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-button type="primary" @click="timing">{{ this.$t('deviceManage.ledTiming') }}</el-button>
|
|
|
+ </el-col>
|
|
|
|
|
|
- <el-col :span="4">
|
|
|
- <el-button type="primary" @click="deleteAllPrograms">{{ this.$t('deviceManage.ledRemoveAllProgram') }}</el-button>
|
|
|
- </el-col>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-button type="primary" @click="updateDefaultProgram">
|
|
|
+ {{ this.$t('deviceManage.ledUpdateDefaultProgram') }}
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
|
|
|
- <el-col :span="4">
|
|
|
- <el-button type="primary" @click="powerOn">{{ this.$t('deviceManage.ledPowerOn') }}</el-button>
|
|
|
- </el-col>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-button type="primary" @click="deleteAllPrograms">{{
|
|
|
+ this.$t('deviceManage.ledRemoveAllProgram')
|
|
|
+ }}
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
|
|
|
- <el-col :span="4">
|
|
|
- <el-button type="primary" @click="powerOff">{{ this.$t('deviceManage.ledPowerOff') }}</el-button>
|
|
|
- </el-col>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-button type="primary" @click="powerOn">{{ this.$t('deviceManage.ledPowerOn') }}</el-button>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-button type="primary" @click="powerOff">{{ this.$t('deviceManage.ledPowerOff') }}</el-button>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-button type="primary" @click="powerRestart">{{ this.$t('deviceManage.ledRestart') }}</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
+ </el-row>
|
|
|
+ </fieldset>
|
|
|
+ </el-form>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
|
|
|
- <el-col :span="4">
|
|
|
- <el-button type="primary" @click="powerRestart">{{ this.$t('deviceManage.ledRestart') }}</el-button>
|
|
|
- </el-col>
|
|
|
- </el-form-item>
|
|
|
- </el-row>
|
|
|
- </fieldset>
|
|
|
- </el-form>
|
|
|
- </el-card>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
|
|
|
+import { DEVICE_TYPE } from '@/utils/enum/DeviceTypeEnum'
|
|
|
import * as API_Led from '@/api/ncs_led'
|
|
|
+import { getCacheListByType } from '@/api/ncs_device'
|
|
|
+const DeviceUrl = domain.DeviceUrl
|
|
|
export default {
|
|
|
- name: "ledManager",
|
|
|
+ name: 'ledManager',
|
|
|
|
|
|
data() {
|
|
|
return {
|
|
@@ -66,15 +153,88 @@ export default {
|
|
|
rules: {},
|
|
|
isOnlyTime: false,
|
|
|
// addCustom: '',
|
|
|
- shop_id: this.$store.getters.partId
|
|
|
+ shop_id: this.$store.getters.partId,
|
|
|
+ activeName: 's433',
|
|
|
+ s433DeviceList: [],
|
|
|
+ boxList: [],
|
|
|
+ multipleSelection: [],
|
|
|
+ s433FormModel: {
|
|
|
+ type: 4,
|
|
|
+ ledStyle: '128*32',
|
|
|
+ ledSize: 16,
|
|
|
+ title: '你好世界',
|
|
|
+ boxMac: null,
|
|
|
+ macs: null,
|
|
|
+ partId: this.$store.getters.partId
|
|
|
+ },
|
|
|
+ boolDestroy: false
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
|
- this.isOnlyTime === false
|
|
|
+ this.API_getList()
|
|
|
+ this.API_getList2()
|
|
|
+ this.initWebSocket()
|
|
|
+ },
|
|
|
+ beforeDestroy() {
|
|
|
+ this.boolDestroy = true
|
|
|
+ this.websock.close()
|
|
|
},
|
|
|
methods: {
|
|
|
+ initWebSocket: function() {
|
|
|
+ const time = Math.round(new Date()) + "" + Math.round(Math.random()*100)
|
|
|
+ let stockbase = DeviceUrl.replace('http', 'ws')
|
|
|
+ this.websock = new WebSocket(stockbase + '/s433/listening/'+ time + '/' + this.shop_id)
|
|
|
+ this.websock.onopen = this.websocketonopen
|
|
|
+ this.websock.onerror = this.websocketonerror
|
|
|
+ this.websock.onmessage = this.websocketonmessage
|
|
|
+ this.websock.onclose = this.websocketclose
|
|
|
+ },
|
|
|
+ websocketonopen: function() {
|
|
|
+ console.log(this.$t('deviceManage.webSocketSuccess'))
|
|
|
+ },
|
|
|
+ websocketonerror: function(e) {
|
|
|
+ console.log(this.$t('deviceManage.webSocketError'))
|
|
|
+ },
|
|
|
+ websocketonmessage: function(e) {
|
|
|
+ // console.log('收到消息:', e)
|
|
|
+ const data = JSON.parse(e.data)
|
|
|
+ console.log('收到消息:', data)
|
|
|
+ if (data.status === -1) {
|
|
|
+ this.$message.error('该转换盒不在线!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const index = this.s433DeviceList.findIndex(p => p.eth_mac.toLowerCase() === data.mac.toLowerCase())
|
|
|
+ if (index === -1) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const time = (new Date()).valueOf()
|
|
|
+ const item = this.s433DeviceList[index]
|
|
|
+ if (data.status === 1) { // 发送
|
|
|
+ // this.$set(this.s433DeviceList[index], 'send_time', time)
|
|
|
+ item.send_time = time
|
|
|
+ } else if (data.status === 2) { // 有返回
|
|
|
+ item.receive_time = this.formateSeconds(item.send_time, time)
|
|
|
+ } else { // 发送失败
|
|
|
+ item.receive_time = this.formateSeconds(item.send_time, time)
|
|
|
+ }
|
|
|
+
|
|
|
+ item.state = data.status
|
|
|
+ this.$set(this.s433DeviceList, index, item)
|
|
|
+ },
|
|
|
+ websocketclose: function(e) {
|
|
|
+ console.log('connection closed')
|
|
|
+ if (!this.boolDestroy) {
|
|
|
+ const _this = this
|
|
|
+ this.$alert('连接断开,是否重连', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ callback: action => {
|
|
|
+ _this.initWebSocket()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
updateDefaultProgram() {
|
|
|
- let text;
|
|
|
+ let text
|
|
|
if (this.isOnlyTime) {
|
|
|
text = this.formmodel.addCustom
|
|
|
}
|
|
@@ -123,6 +283,56 @@ export default {
|
|
|
API_Led.removeAllProgramByShopId(params).then(r => {
|
|
|
this.$message.success(this.$t('action.saveSuccess'))
|
|
|
})
|
|
|
+ },
|
|
|
+ handleClick(e) {
|
|
|
+ if (this.activeName === 's433') {
|
|
|
+ this.API_getList()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ API_getList() {
|
|
|
+ getCacheListByType(this.shop_id, DEVICE_TYPE.S433_RECEIVER).then(res => {
|
|
|
+ res.forEach(item => {
|
|
|
+ item.state = null
|
|
|
+ item.send_time = ''
|
|
|
+ item.receive_time = ''
|
|
|
+ })
|
|
|
+ this.s433DeviceList = res
|
|
|
+ })
|
|
|
+ },
|
|
|
+ API_getList2() {
|
|
|
+ getCacheListByType(this.shop_id, DEVICE_TYPE.S433_TRANSFER_BOX).then(res => {
|
|
|
+ this.boxList = res
|
|
|
+ if (this.boxList.length > 0) {
|
|
|
+ this.s433FormModel.boxMac = this.boxList[0].eth_mac
|
|
|
+ } else {
|
|
|
+ this.$message.info('请先添加433转换盒!')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ selectFun(val) {
|
|
|
+ this.multipleSelection = val
|
|
|
+ },
|
|
|
+ handlerEdit(index, row) {
|
|
|
+ row.state = 0
|
|
|
+ row.send_time = row.receive_time = ''
|
|
|
+ this.$set(this.s433DeviceList, index, row)
|
|
|
+ this.s433FormModel.macs = row.eth_mac
|
|
|
+ this.websock.send(JSON.stringify(this.s433FormModel))
|
|
|
+ },
|
|
|
+ sendChange() {
|
|
|
+ let list = []
|
|
|
+ const _this = this
|
|
|
+ this.s433FormModel.macs = null
|
|
|
+ _this.multipleSelection.forEach(item => {
|
|
|
+ const index = _this.s433DeviceList.indexOf(item)
|
|
|
+ item.state = 0
|
|
|
+ item.send_time = item.receive_time = ''
|
|
|
+ _this.$set(_this.s433DeviceList, index, item)
|
|
|
+ list.push(item.eth_mac)
|
|
|
+ })
|
|
|
+ this.s433FormModel.macs = list.join(',')
|
|
|
+ // this.multipleSelection = []
|
|
|
+ this.websock.send(JSON.stringify(this.s433FormModel))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -130,4 +340,4 @@ export default {
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
-</style>
|
|
|
+</style>
|