Compare commits

..

1 Commits

Author SHA1 Message Date
cxc
cc46a48feb websocket 2023-02-27 10:28:04 +08:00
3 changed files with 126 additions and 150 deletions

View File

@ -162,7 +162,7 @@
<template slot-scope="scope">
{{
scope.row.deviceType
? deviceTypeList.find(v => v.value == scope.row.deviceType)
? deviceTypeList.find((v) => v.value == scope.row.deviceType)
.label
: ''
}}
@ -177,25 +177,8 @@
<el-table-column align="center" prop="version" label="可升级软件版本">
</el-table-column>
<el-table-column align="center" label="升级状态">
<!-- <template slot-scope="scope">
<template slot-scope="scope">
{{ scope.row.isUpdate == 0 ? '已' : '可' }}升级
</template> -->
<template #default="{row}">
<el-progress
v-if="row.updateStatus == '1'"
type="circle"
:width="40"
:stroke-width="2"
status="success"
:percentage="100"
></el-progress>
<el-progress
v-else
type="circle"
:width="40"
:stroke-width="2"
:percentage="0"
></el-progress>
</template>
</el-table-column>
<el-table-column align="center" label="上次升级时间">
@ -286,7 +269,7 @@ import {
OTAUpdate,
OTAUpdates,
getNodeOTAHistory,
nodeOTAHistoryExport
nodeOTAHistoryExport,
} from '@/api/firmware/firmwareupdate';
import { select as projectSelect } from '@/api/hardware/project';
import { select as productSelect } from '@/api/hardware/product';
@ -296,7 +279,7 @@ import { userSelect } from '@/api/system/user';
export default {
name: 'FirmwareUpdate',
components: {
Region
Region,
},
data() {
return {
@ -307,7 +290,7 @@ export default {
queryProjectSelectList: [],
isUpdateList: [
{ label: '已升级', value: 0 },
{ label: '可升级', value: 1 }
{ label: '可升级', value: 1 },
],
value: '',
options: '',
@ -320,14 +303,14 @@ export default {
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10
pageSize: 10,
},
deviceTypeList: [
{ label: '锐能设备', value: 'rn' },
{ label: '铁塔设备', value: 'tt' }
{ label: '铁塔设备', value: 'tt' },
],
nodeOTAHistoryDialog: false,
nodeOTAHistoryData: []
nodeOTAHistoryData: [],
};
},
created() {
@ -352,12 +335,12 @@ export default {
this.$confirm('是否确认导出所有节点升级记录?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
type: 'warning',
})
.then(function() {
.then(function () {
return nodeOTAHistoryExport();
})
.then(response => {
.then((response) => {
this.download(response.msg);
});
},
@ -404,12 +387,12 @@ export default {
this.$confirm(`是否确认升级${deviceId}?`, '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
type: 'warning',
})
.then(() => {
this.OTAUpdate([{ productId, nodeId, deviceId }]);
})
.catch(res => {});
.catch((res) => {});
},
handleOTAUpdate() {
if (this.ids.length) {
@ -418,18 +401,18 @@ export default {
});
const h = this.$createElement;
this.$confirm(
`是否确认批量升级\r\n${snap.map(v => v.deviceId).join(',\r\n')}?`,
`是否确认批量升级\r\n${snap.map((v) => v.deviceId).join(',\r\n')}?`,
'警告',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
type: 'warning',
}
)
.then(() => {
this.OTAUpdate(snap);
})
.catch(res => {});
.catch((res) => {});
} else {
let snap = Object.assign({}, this.queryParams);
delete snap.pageNum;
@ -437,12 +420,12 @@ export default {
this.$confirm(`是否确认批量升级?`, '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
type: 'warning',
})
.then(() => {
this.OTAUpdates(snap);
})
.catch(res => {});
.catch((res) => {});
}
},
@ -475,18 +458,14 @@ export default {
this.ids = selection;
},
getList() {
list(this.queryParams).then(response => {
list(this.queryParams).then((response) => {
this.tableData = response.rows;
this.total = response.total;
});
},
handleUpdate() {}
}
handleUpdate() {},
},
};
</script>
<style scoped>
::v-deep .el-progress__text {
font-size: 16px !important;
}
</style>
<style></style>

View File

@ -10,7 +10,7 @@
<span>设备SN{{ info.deviceId }}</span>
<el-divider class="mt10 mb10"></el-divider>
<span
>设备类型{{
>设备类型{{
info.deviceType
? this.deviceTypeList.find(v => v.value == info.deviceType).label
: ''
@ -83,7 +83,7 @@
type="danger"
size="mini"
@click="handleCommand(item, 1)"
>设备重置
>设备重置
</el-button>
</div>
</el-col>
@ -128,8 +128,8 @@
<el-col :span="12">
<div class="tr">
<span style="margin-right: 20px">{{
signalUpdateTime | formatDate
}}</span>
signalUpdateTime | formatDate
}}</span>
<el-button
v-if="
v.key == '01305001' ||
@ -141,7 +141,7 @@
plain
size="mini"
@click="open(v)"
>点击输入
>点击输入
</el-button>
<el-dropdown
v-else-if="v.key == '01308001'"
@ -168,7 +168,7 @@
plain
size="mini"
@click="openDialog(info.deviceId, v.key)"
>历史性能
>历史性能
</el-button>
</div>
</el-col>
@ -196,7 +196,7 @@
<!-- :picker-options="pickerOptions" -->
</el-date-picker>
<span style="margin-left: 20px"
><el-button type="primary" @click="getNewData">查询</el-button></span
><el-button type="primary" @click="getNewData">查询</el-button></span
>
<div ref="echa" style="width: 100%; height: 600px"></div>
</el-dialog>
@ -204,10 +204,10 @@
</template>
<script>
import { getKeyHistory, info, updateValue } from '@/api/hardware/device'
import { getProvinceByCode } from '@/api/hardware/province'
import { handleOffsetAndRange } from '../../../utils/offsetMap'
import ReconnectingWebSocket from 'reconnecting-websocket'
import { getKeyHistory, info, updateValue } from '@/api/hardware/device';
import { getProvinceByCode } from '@/api/hardware/province';
import { handleOffsetAndRange } from '../../../utils/offsetMap';
import ReconnectingWebSocket from 'reconnecting-websocket';
export default {
name: 'DeviceDetail',
@ -248,49 +248,49 @@ export default {
{ label: '锐能设备', value: 'rn' },
{ label: '铁塔设备', value: 'tt' }
]
}
};
},
watch: {
selectDate() {
if (!this.selectDate) {
this.selectDate = ''
this.selectDate = '';
}
}
},
computed: {
// 过充 单体过充阈值
overcharge() {
let a = this.signal.find(item => item.keyCN == '单体过充阈值')
return a ? a.valueCN - 0 : null
let a = this.signal.find(item => item.keyCN == '单体过充阈值');
return a ? a.valueCN - 0 : null;
},
// 过放 单体过放阈值
overdischarge() {
let a = this.signal.find(item => item.keyCN == '单体过放阈值')
return a ? a.valueCN - 0 : null
let a = this.signal.find(item => item.keyCN == '单体过放阈值');
return a ? a.valueCN - 0 : null;
},
// 过压 单体过压阈值
overVoltage() {
let a = this.signal.find(item => item.keyCN == '单体过压阈值')
return a ? a.valueCN - 0 : null
let a = this.signal.find(item => item.keyCN == '单体过压阈值');
return a ? a.valueCN - 0 : null;
},
// 欠压 单体欠压阈值
underVoltage() {
let a = this.signal.find(item => item.keyCN == '单体欠压阈值')
return a ? a.valueCN - 0 : null
let a = this.signal.find(item => item.keyCN == '单体欠压阈值');
return a ? a.valueCN - 0 : null;
}
},
created() {
let { id } = this.$route.query
let { id } = this.$route.query;
if (!id) {
this.msgError('无设备ID')
this.$router.go(-1)
return
this.msgError('无设备ID');
this.$router.go(-1);
return;
}
this.id = id
this.getDetail()
this.id = id;
this.getDetail();
},
mounted() {
this.initWebsocket()
this.initWebsocket();
},
methods: {
handleOffsetAndRange,
@ -301,30 +301,29 @@ export default {
type: 'warning'
})
.then(() => {
item.value = command
let query = this.info
query['signal'] = item
item.value = command;
let query = this.info;
query['signal'] = item;
updateValue(query).then(({ code, data, message }) => {
if (200 == code) {
this.msgSuccess(message)
this.getDetail()
this.msgSuccess(message);
this.getDetail();
} else {
this.msgError(message)
this.msgError(message);
}
})
})
.catch(() => {
});
})
.catch(() => {});
// this.$message('click on item ' + command);
},
open(item) {
let keyVla = ''
let keyVla = '';
if (item.key == '01305001') {
keyVla = '数值20-3600'
keyVla = '数值20-3600';
} else if (item.key == '01306001') {
keyVla = '字符串'
keyVla = '字符串';
} else {
keyVla = '数值20-600'
keyVla = '数值20-600';
}
this.$prompt(`请输入${keyVla}`, '提示', {
confirmButtonText: '确定',
@ -333,68 +332,67 @@ export default {
inputErrorMessage: '校验失败'
})
.then(({ value }) => {
item.value = value
let query = this.info
query['signal'] = item
item.value = value;
let query = this.info;
query['signal'] = item;
updateValue(query).then(({ code, data, message }) => {
if (200 == code) {
this.msgSuccess(message)
this.getDetail()
this.msgSuccess(message);
this.getDetail();
} else {
this.msgError(message)
this.msgError(message);
}
})
});
})
.catch(() => {
// this.msgInfo('取消输入');
})
});
},
getDetail() {
info(this.id).then(async({ code, msg, info }) => {
info(this.id).then(async ({ code, msg, info }) => {
if (200 == code) {
info.proName = await this.getProvinceByCode(info.proCode)
info.cityName = await this.getProvinceByCode(info.cityCode)
info.disName = await this.getProvinceByCode(info.disCode)
this.info = info
info.proName = await this.getProvinceByCode(info.proCode);
info.cityName = await this.getProvinceByCode(info.cityCode);
info.disName = await this.getProvinceByCode(info.disCode);
this.info = info;
if (info.deviceSignal) {
let deviceSignal = JSON.parse(info.deviceSignal.signalJsonTurn)
this.signal = deviceSignal?.signal
this.defaultSignal = info.defaultSignal
let deviceSignal = JSON.parse(info.deviceSignal.signalJsonTurn);
this.signal = deviceSignal.signal;
this.defaultSignal = info.defaultSignal;
// console.log(info.deviceSignal.signalJsonTurn);
// console.log(this.signal);
// let a = deviceSignal.signal.find(
// item => item.keyCN == '单体过充阈值'
// );
// console.log(a.valueCN);
this.signalUpdateTime = info.deviceSignal.updateTime
this.signalUpdateTime = info.deviceSignal.updateTime;
}
} else {
this.msgError(msg)
this.msgError(msg);
}
})
});
},
getProvinceByCode(code) {
return new Promise((resolve, reject) => {
getProvinceByCode(code)
.then(({ code, msg, data }) => {
if (code == 200) {
resolve(data?.cityName)
resolve(data.cityName);
} else {
this.$message.error(msg)
reject({ msg, code })
this.$message.error(msg);
reject({ msg, code });
}
})
.catch(error => {
reject(error)
})
})
reject(error);
});
});
},
openDialog(deviceId, key) {
this.dialogVisible = true
this.queryParams.deviceId = deviceId
this.queryParams.key = key
this.getChartData()
this.dialogVisible = true;
this.queryParams.deviceId = deviceId;
this.queryParams.key = key;
this.getChartData();
},
// getDay(mss) {
@ -406,33 +404,33 @@ export default {
// },
getNewData() {
if (this.selectDate == '') return this.$message.info('请选择日期')
if (this.selectDate == '') return this.$message.info('请选择日期');
// let a = new Date(this.selectDate[0]).getTime();
// let b = new Date(this.selectDate[1]).getTime();
// const minTime = b - a;
// const flag = this.getDay(minTime);
this.queryParams.startTime = this.selectDate[0]
this.queryParams.endTime = this.selectDate[1]
this.getChartData()
this.queryParams.startTime = this.selectDate[0];
this.queryParams.endTime = this.selectDate[1];
this.getChartData();
},
getChartData() {
getKeyHistory(this.queryParams).then(data => {
this.$nextTick(() => {
this.initChart(data)
})
})
this.initChart(data);
});
});
},
initChart(data) {
var echarts = require('echarts')
this.centerChart = echarts.init(this.$refs.echa)
let months = []
let nums = []
var echarts = require('echarts');
this.centerChart = echarts.init(this.$refs.echa);
let months = [];
let nums = [];
data.map(item => {
for (const k in item) {
months.push(k)
nums.push(item[k])
months.push(k);
nums.push(item[k]);
}
})
});
let option = {
tooltip: {
trigger: 'axis'
@ -443,27 +441,27 @@ export default {
dataView: {
readOnly: true,
optionToContent: function(opt) {
let axisData = opt.xAxis[0].data //坐标数据
let series = opt.series //折线图数据
let tdHeads = '<td>序号</td><td>时间</td>' //表头
let tdBodys = '' //数据
let axisData = opt.xAxis[0].data; //坐标数据
let series = opt.series; //折线图数据
let tdHeads = '<td>序号</td><td>时间</td>'; //表头
let tdBodys = ''; //数据
series.forEach(function(item) {
//组装表头
tdHeads += `<td style="text-align:center">${item.name}</td>`
})
let table = `<table style="width:100%;text-align: center"><tbody><tr>${tdHeads} </tr>`
tdHeads += `<td style="text-align:center">${item.name}</td>`;
});
let table = `<table style="width:100%;text-align: center"><tbody><tr>${tdHeads} </tr>`;
for (let i = 0, l = axisData.length; i < l; i++) {
for (let j = 0; j < series.length; j++) {
//组装表数据
tdBodys += `<td>${series[j].data[i]}</td>`
tdBodys += `<td>${series[j].data[i]}</td>`;
}
table += `<tr><td>${i + 1}</td><td >${
axisData[i]
}</td>${tdBodys}</tr>`
tdBodys = ''
}</td>${tdBodys}</tr>`;
tdBodys = '';
}
table += '</tbody></table>'
return table
table += '</tbody></table>';
return table;
}
},
// restore: {},
@ -475,7 +473,7 @@ export default {
type: 'category',
boundaryGap: false,
data: months.map(function(str) {
return str.replace(' ', '\n')
return str.replace(' ', '\n');
})
},
yAxis: {
@ -492,21 +490,21 @@ export default {
}
}
]
}
this.centerChart.setOption(option)
};
this.centerChart.setOption(option);
},
initWebsocket() {
const wsBaseUrl =
process.env.NODE_ENV === 'development'
? '192.168.110.10:8080'
: `${window.location.host}:8080`
this.websocket = new ReconnectingWebSocket(`ws://${wsBaseUrl}/ws`)
: `${window.location.host}/${process.env.VUE_APP_BASE_API}`;
this.websocket = new ReconnectingWebSocket(`ws://${wsBaseUrl}/ws`);
this.websocket.addEventListener('message', e => {
this.$message.success(e.data)
})
this.$message.success(e.data);
});
}
}
}
};
</script>
<style lang="scss" scoped>

View File

@ -39,9 +39,8 @@ module.exports = {
// target: `http://47.115.73.110:8080`,
// target: `http://121.37.250.170:8080`,
// target: `http://192.168.0.129:8080`,
target: `http://120.79.217.22:81/api`,
// target: `http://192.168.0.131:8080`,
// target: `http://192.168.110.10:8080`,
target: `http://192.168.110.10:8080`,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''