新增批量导出导入功能
优化画图软件
This commit is contained in:
@@ -6,10 +6,12 @@
|
||||
@mouseup="onMouseUp"
|
||||
@mouseleave="onMouseUp"
|
||||
@wheel="onMouseWheel"
|
||||
style="height: 100vh; overflow: hidden"
|
||||
>
|
||||
<div
|
||||
v-loading="useData.loading"
|
||||
:style="canvasStyle"
|
||||
style="overflow: hidden"
|
||||
:class="`canvasArea ${isDragging ? 'cursor-grabbing' : mtPreviewProps.canDrag ? 'cursor-grab' : ''} `"
|
||||
>
|
||||
<!-- <el-button type="primary" class="backBtn" @click="onBack" v-if="!useData.display">返回</el-button> -->
|
||||
@@ -512,6 +514,7 @@ const setImportJson = (exportJson: IExportJson) => {
|
||||
if (exportJson == null) {
|
||||
setDoneJson(useData.dataTree[0].kId)
|
||||
publish(useData.dataTree[0])
|
||||
singlePublish(useData.dataTree[0])
|
||||
} else {
|
||||
executeOperations()
|
||||
}
|
||||
@@ -523,6 +526,7 @@ const setImportJson = (exportJson: IExportJson) => {
|
||||
if (newVal === false) {
|
||||
// 当loading变为true时执行操作
|
||||
if (exportJson == null) {
|
||||
singlePublish(useData.dataTree[0])
|
||||
setDoneJson(useData.dataTree[0].kId)
|
||||
publish(useData.dataTree[0])
|
||||
} else {
|
||||
@@ -676,7 +680,7 @@ const init = async () => {
|
||||
}, 100)
|
||||
}
|
||||
const timer = ref()
|
||||
|
||||
const list: any = ref([])
|
||||
// 连接mqtt
|
||||
const mqttClient = ref()
|
||||
const setMqtt = async () => {
|
||||
@@ -687,20 +691,50 @@ const setMqtt = async () => {
|
||||
await mqttClient.value.init()
|
||||
|
||||
// 订阅主题
|
||||
await mqttClient.value.subscribe('/zl/rtData/#')
|
||||
await mqttClient.value.subscribe('/zl/TemperData/#') //实时数据
|
||||
await mqttClient.value.subscribe('/zl/csConfigRtData/#') //指标
|
||||
|
||||
// 设置消息接收回调
|
||||
mqttClient.value.onMessage((subscribe: string, message: any) => {
|
||||
const msg: any = uint8ArrayToObject(message)
|
||||
// console.log('🚀 ~ setMqtt ~ msg:', msg)
|
||||
console.log('🚀 ~ setMqtt ~ msg:', msg)
|
||||
|
||||
if (subscribe.split('/')[2] === 'rtData') {
|
||||
// 指标数据
|
||||
|
||||
// await setImportJson(savedExportJson.value)
|
||||
|
||||
setTimeout(() => {
|
||||
if (done_json.value) {
|
||||
// list.value = [
|
||||
// ...new Set(msg.filter((item: any) => item.devStatus === 1).map((item: any) => item.lineId))
|
||||
// ]
|
||||
done_json.value?.forEach(item => {
|
||||
msg.forEach((msgValue: any) => {
|
||||
if (item.id == msgValue.id) {
|
||||
const unit = item?.unit && Array.isArray(item.unit) ? item.unit[0] : ''
|
||||
item.props.text.val = item.props.text.val.replace(
|
||||
/#{3}/g,
|
||||
msgValue.value == 3.1415926 ? '暂无数据' : msgValue.value + unit
|
||||
) //'B相负载电流-CP95:31'
|
||||
}
|
||||
})
|
||||
// list.value.forEach((listValue: any) => {
|
||||
// if (listValue == item.lineId && item.type == 'svg') {
|
||||
// item.props.fill.val = '#ff0000'
|
||||
// // item.common_animations.val = 'flash'
|
||||
// }
|
||||
// })
|
||||
})
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
if (subscribe.split('/')[2] === 'csConfigRtData') {
|
||||
// 指标数据
|
||||
dataList.value = JSON.parse(msg.message)
|
||||
//console.log('🚀 ~ setMqtt ~ dataList:', dataList.value)
|
||||
// keyList.value = JSON.parse(list.path).canvasCfg.lineList
|
||||
}
|
||||
if (subscribe.split('/')[2] === 'TemperData') {
|
||||
} else if (subscribe.split('/')[2] === 'TemperData') {
|
||||
// 表格数据
|
||||
tableData.value = []
|
||||
tableData.value = JSON.parse(msg.message)
|
||||
@@ -726,6 +760,25 @@ const setMqtt = async () => {
|
||||
console.error('MQTT 初始化失败:', error)
|
||||
}
|
||||
}
|
||||
const singlePublish = async (id: string) => {
|
||||
console.log(123)
|
||||
|
||||
if (mqttClient.value) {
|
||||
await mqttClient.value.subscribe('zl/askRtData/' + storedSelectedId)
|
||||
// 发送消息
|
||||
await mqttClient.value.publish('/zl/askRtData/' + storedSelectedId, '{}')
|
||||
if (timer.value) {
|
||||
clearInterval(timer.value)
|
||||
timer.value = null
|
||||
}
|
||||
timer.value = setInterval(
|
||||
() => {
|
||||
mqttClient.value.publish('/zl/askRtData/' + storedSelectedId, '{}')
|
||||
},
|
||||
3 * 60 * 1000
|
||||
)
|
||||
}
|
||||
}
|
||||
const publish = async (list: any) => {
|
||||
console.log('🚀 ~ publish ~ list:', JSON.parse(list.path).canvasCfg.lineList)
|
||||
if (mqttClient.value) {
|
||||
|
||||
Reference in New Issue
Block a user