修改测试问题调整T相数据显示

This commit is contained in:
guanj
2026-07-02 09:54:37 +08:00
parent 51db8d0370
commit 60e7f42b04
20 changed files with 114 additions and 48 deletions

View File

@@ -153,9 +153,9 @@
</el-button>
</div>
<div class="flex justify-center items-center">
<el-tag v-if="headerPanelProps.realTimeData.show" size="small">
<!-- <el-tag v-if="headerPanelProps.realTimeData.show" size="small">
{{ headerPanelProps.realTimeData.text }}
</el-tag>
</el-tag> -->
</div>
<div class="flex items-center mr-20px">
<!-- <el-button text circle size="small" @click="emits('onReturnClick')">

View File

@@ -242,14 +242,17 @@ const onRowClick = async (row: any) => {
}
const saveDialog = async (form: any) => {
console.log(dataTrees.value)
// console.log(dataTrees.value)
// 校验表单
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
if (dataTrees.value.some(item => item.name == form.name)) {
const isDuplicate = dataTrees.value.some(
item => item.name == form.name && (dialog_title.value !== '编辑图纸' || item.kId !== form.kId)
)
if (isDuplicate) {
ElMessage.error('图纸名称不能重复!')
return
}

View File

@@ -383,10 +383,10 @@ const createCustomItem = () => {
globalStore.setIntention('none')
cacheStore.addHistory(updatedDoneJson)
console.log('globalStore111456777', globalStore)
// console.log('globalStore111456777', globalStore)
return true
} catch (error) {
console.error('创建动态图元时出错:', error)
// console.error('创建动态图元时出错:', error)
return false
}
}
@@ -513,7 +513,7 @@ const initCustomItems = async () => {
attemptCreate(attempt + 1)
}, 500)
} else {
console.log('动态图元创建成功')
// console.log('动态图元创建成功')
}
}
@@ -1419,7 +1419,7 @@ watch(
}
time.value = setTimeout(() => {
console.log('🚀 ~ globalStore:', globalStore)
// console.log('🚀 ~ globalStore:', globalStore)
if (useData.keyName == '') {
ElMessage.warning('请选择图纸!')
}

View File

@@ -105,7 +105,8 @@ import { ElForm, ElFormItem, ElTreeSelect } from 'element-plus'
import { computed, ref, watch, onMounted, reactive, nextTick, watchEffect } from 'vue'
import type { IDoneJson } from '@/components/mt-edit/store/types'
import { globalStore } from '@/components/mt-edit/store/global'
import { lineTree, targetList, eleEpdChooseTree_wx, eleEpdChooseTree_ypt } from '@/api/index'
import { lineTree, targetList, eleEpdChooseTree_wx } from '@/api/index'
import { getYptChooseTreeCache } from '@/utils/yptChooseTreeCache'
import { useDataStore } from '@/stores/menuList'
import { lineTree_wx } from '@/api/index_wx'
import { templateRef } from '@vueuse/core'
@@ -272,9 +273,11 @@ const fetchData = async () => {
return
}
if (useData.graphicDisplay == 'ypt') {
const res = await eleEpdChooseTree_ypt()
useData.settreeIndexs(res.data)
treeIndexs.value = res.data // 转换数据格式并赋值给 transformedData
const cached = getYptChooseTreeCache()
if (cached) {
useData.settreeIndexs(cached)
treeIndexs.value = cached
}
}
} catch (error) {
console.error('Error fetching data:', error)
@@ -382,7 +385,7 @@ const handleSelectUID = (uid: []) => {
}
// 单个指标绑定
if (item_title.value == '绑定指标') {
console.log(123)
// console.log(123)
selectItemSettingProps.itemJson.UIDType = true
}
}
@@ -396,7 +399,7 @@ const handleSelectUID = (uid: []) => {
.getCheckedNodes()
.map((item: any) => item.data.unit)
.filter((text: string) => text !== '' && text !== null && text !== undefined)
console.log(123)
// console.log(123)
if (is2DArray(uid)) {
if (selectItemSettingProps.itemJson) {
@@ -431,7 +434,7 @@ const handleSelectUID = (uid: []) => {
str =
names.length == 2
? names[1] + '-' + key + ':###'
: names[1] + '相' + names[2] + '-' + key + ':###'
: (names[1] == 'T' ? '' : names[1] + '相') + names[2] + '-' + key + ':###'
}
selectItemSettingProps.itemJson.props.text.val = str
}

View File

@@ -217,7 +217,7 @@ const handleOnchange = (uploadFile: UploadFile) => {
fileReader.onload = ev => {
// 读取完成,对数据进行自己的操作
const data = ev.target?.result //获取内容
console.log('🚀 ~ handleOnchange ~ data:', data)
// console.log('🚀 ~ handleOnchange ~ data:', data)
onImportYes(data)
// console.log(JSON.parse(data as string))
}
@@ -326,7 +326,7 @@ const onSaveAll = async () => {
item.sort = ind
return item
})
console.log('🚀 ~ onSaveAll ~ data:', data)
// console.log('🚀 ~ onSaveAll ~ data:', data)
let form = new FormData()
let blob = new Blob([JSON.stringify(data)], {

View File

@@ -94,7 +94,7 @@ export const leftAsideStore: ILeftAside = reactive({
},
svgDelete: (title: string, id: string) => {
const cfg = leftAsideStore.config.get(title)!.filter(m => m.id !== id)
console.log('🚀 ~ cfg:', cfg)
// console.log('🚀 ~ cfg:', cfg)
leftAsideStore.config.set(title, cfg)
}
})

View File

@@ -11,8 +11,9 @@
v-for="item in props.steadyState?.filter(k => k.lineId === corner.elementId)"
:key="item.id"
>
{{ item.statisticalName.replace(/\//g, '_') }}:
{{ item.value === 3.1415926 ? '/' : item.value + item.unit }}
<!-- {{ item.statisticalName.replace(/\//g, '_') }}: -->
{{ formatString(item.statisticalName) }}:
{{ item.value === 3.1415926 ? '/' : item.value.toFixed(2) + item.unit }}
</div>
</div>
</el-descriptions-item>
@@ -179,7 +180,27 @@ watch(
},
{ deep: true }
)
function formatString(str: string) {
// 先移除 T相_ 前缀(如果有)
let processed = str.replace(/^T相_/, '')
// 统计下划线数量
const underscoreCount = (processed.match(/_/g) || []).length
if (underscoreCount === 2) {
// 有2个_删除第0个_第1个_改成-
const parts = processed.split('_')
// parts[0] 和 parts[1] 合并删除第0个_
// 第1个_改成- 即 parts[1] 和 parts[2] 之间用 - 连接
return parts[0] + parts[1] + '-' + parts[2]
} else if (underscoreCount === 1) {
// 有1个_直接改成-
return processed.replace('_', '-')
} else {
// 没有_或其他情况返回原字符串
return processed
}
}
// 暴露方法给父组件使用
defineExpose({
showNextCorner,
@@ -190,7 +211,7 @@ defineExpose({
<style scoped lang="less">
.corner {
width: 260px;
width: 300px;
position: absolute;
}

View File

@@ -423,7 +423,7 @@ const handleResetEvent = () => {
}
}, 100)
console.log('执行复位操作完成')
// console.log('执行复位操作完成')
}
//根据 lineId 查找传输设备 ID 的函数
@@ -492,14 +492,12 @@ const setImportJson = (exportJson: IExportJson) => {
}
grid_cfg.value = gridCfg
done_json.value = importDoneJson
console.log(11111111111)
// 为图元添加点击事件
addClickEventsToElements()
// 首页初始化的时候
setTimeout(() => {
console.log(22222222222222)
done_json.value.forEach(item => {
//报警设备闪烁
if (findTransmissionDeviceIdsByKeyList(keyList.value).includes(item.id)) {
@@ -716,7 +714,7 @@ const setMqtt = async () => {
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
msgValue.value == 3.1415926 ? '暂无数据' : msgValue.value.toFixed(2) + unit
) //'B相负载电流-CP95:31'
}
})

View File

@@ -1016,7 +1016,7 @@ const setMqtt = async () => {
// 设置消息接收回调
mqttClient.value.onMessage(async (subscribe: string, message: any) => {
const msg: any = uint8ArrayToObject(message)
console.log('🚀 ~ 接受消息:', msg)
// console.log('🚀 ~ 接受消息:', msg)
list.value = [...new Set(msg.filter((item: any) => item.devStatus === 1).map((item: any) => item.lineId))]
sendColor.value = '#ff0000'
// await setImportJson(savedExportJson.value)
@@ -1027,7 +1027,7 @@ const setMqtt = async () => {
if (item.id == msgValue.id) {
item.props.text.val = item.props.text.val.replace(
/#{3}/g,
msgValue.value == 3.1415926 ? '暂无数据' : msgValue.value
msgValue.value == 3.1415926 ? '暂无数据' : msgValue.value.toFixed(2)
) //'B相负载电流-CP95:31'
}
})

View File

@@ -1030,7 +1030,7 @@ const setMqtt = async () => {
// 设置消息接收回调
mqttClient.value.onMessage(async (subscribe: string, message: any) => {
const msg: any = uint8ArrayToObject(message)
console.log('🚀 ~ 接受消息:', msg)
// console.log('🚀 ~ 接受消息:', msg)
list.value = [...new Set(msg.filter((item: any) => item.devStatus === 1).map((item: any) => item.lineId))]
sendColor.value = '#ff0000'
// await setImportJson(savedExportJson.value)
@@ -1039,7 +1039,7 @@ const setMqtt = async () => {
done_json.value.forEach(item => {
msg.forEach((msgValue: any) => {
if (item.id == msgValue.id) {
item.props.text.val = item.props.text.val.replace(/#{3}/g, msgValue.value) //'B相负载电流-CP95:31'
item.props.text.val = item.props.text.val.replace(/#{3}/g, msgValue.value.toFixed(2)) //'B相负载电流-CP95:31'
}
})
list.value.forEach((listValue: any) => {

View File

@@ -69,6 +69,10 @@ export const useDataStore = defineStore('data-store', {
modify(kId: number, val: string) {
this.dataTree.forEach((item: any) => {
if (item.kId == kId) {
item.name = val
if (this.identifying == kId) {
this.keyName = val
}
}
})
},

View File

@@ -1,8 +1,26 @@
import { leftAsideStore } from '@/export'
import demo from '/svgs/demo.svg?raw'
import { find, download, queryPage } from '@/api/index'
import { find, download, queryPage, eleEpdChooseTree_ypt } from '@/api/index'
import { useDataStore } from '@/stores/menuList'
import { ElMessage } from 'element-plus'
import { getYptChooseTreeCache, setYptChooseTreeCache } from '@/utils/yptChooseTreeCache'
const loadYptChooseTree = async () => {
const useData = useDataStore()
const cached = getYptChooseTreeCache()
if (cached) {
useData.settreeIndexs(cached)
}
try {
const res = await eleEpdChooseTree_ypt()
if (res.data) {
setYptChooseTreeCache(res.data)
useData.settreeIndexs(res.data)
}
} catch (error) {
console.error('加载云平台指标树失败:', error)
}
}
// 定义类型接口
interface ElementItem {
id: string
@@ -84,7 +102,11 @@ const loadSvg = async () => {
})
}
await getSvg()
const initTasks: Promise<unknown>[] = [getSvg()]
if (params.get('graphicDisplay') === 'ypt') {
initTasks.push(loadYptChooseTree())
}
await Promise.all(initTasks)
await useData.set('loading', false)
// const electrical_modules_files = import.meta.glob('@/assets/svgs/electrical/face/**.svg', {

View File

@@ -57,7 +57,7 @@ class MQTT {
localStorage.getItem('MQTTZUTAI') == 'null'
? 'ws://192.168.1.103:8083/mqtt'
: localStorage.getItem('MQTTZUTAI')
console.log('🚀 ~ MQTT ~ init ~ mqttUrl:', mqttUrl)
// console.log('🚀 ~ MQTT ~ init ~ mqttUrl:', mqttUrl)
this.client = mqtt.connect(mqttUrl, this.defaultOptions as IClientOptions)
this.setupEventListeners()
@@ -95,21 +95,21 @@ class MQTT {
if (!this.client) return
this.client.on('close', () => {
console.log('MQTT 连接已关闭')
// console.log('MQTT 连接已关闭')
this.isConnected = false
})
this.client.on('offline', () => {
console.log('MQTT 客户端离线')
// console.log('MQTT 客户端离线')
this.isConnected = false
})
this.client.on('reconnect', () => {
console.log(`MQTT 正在尝试重连 (${this.reconnectCount + 1}/${this.maxReconnectTimes})...`)
// console.log(`MQTT 正在尝试重连 (${this.reconnectCount + 1}/${this.maxReconnectTimes})...`)
// 检查是否超过最大重连次数
if (this.reconnectCount >= this.maxReconnectTimes) {
console.log('已达到最大重连次数,停止重连')
// console.log('已达到最大重连次数,停止重连')
this.client?.end(true)
this.client = null
return
@@ -135,7 +135,7 @@ class MQTT {
console.error('订阅失败:', error)
reject(error)
} else {
console.log('订阅成功', subscribe)
// console.log('订阅成功', subscribe)
resolve()
}
})
@@ -157,7 +157,7 @@ class MQTT {
console.error('取消订阅失败:', error)
reject(error)
} else {
console.log('取消订阅成功')
// console.log('取消订阅成功')
resolve()
}
})
@@ -197,7 +197,7 @@ class MQTT {
console.error('消息发布失败:', error)
reject(error)
} else {
console.log('消息发布成功')
// console.log('消息发布成功')
resolve()
}
})
@@ -213,7 +213,7 @@ class MQTT {
if (this.client) {
this.client.end(force, () => {
console.log('MQTT 连接已断开')
// console.log('MQTT 连接已断开')
this.isConnected = false
this.client = null
})

View File

@@ -0,0 +1,15 @@
export const YPT_ELE_EPD_CHOOSE_TREE_KEY = 'eleEpdChooseTree_ypt'
export const getYptChooseTreeCache = () => {
const cached = localStorage.getItem(YPT_ELE_EPD_CHOOSE_TREE_KEY)
if (!cached) return null
try {
return JSON.parse(cached)
} catch {
return null
}
}
export const setYptChooseTreeCache = (data: unknown) => {
localStorage.setItem(YPT_ELE_EPD_CHOOSE_TREE_KEY, JSON.stringify(data))
}

View File

@@ -251,7 +251,7 @@ onMounted(() => {
]
})
if (res) {
console.log('加载成功')
// console.log('加载成功')
}
})
</script>

View File

@@ -68,12 +68,12 @@ const export_json = ref<any>({
})
const changeRed = () => {
svgPreviewRef.value?.setItemAttrByID('demo-4Y2Eq7UPBm', 'props.fill.val', '#FF0000').then(res => {
console.log(res)
// console.log(res)
})
}
const changeGreen = () => {
svgPreviewRef.value?.setItemAttrByID('demo-4Y2Eq7UPBm', 'props.fill.val', '#00FF00').then(res => {
console.log(res)
// console.log(res)
})
}
</script>

View File

@@ -17,7 +17,7 @@ const onPreviewClick = (exportJson: IExportJson) => {
window.open(routeUrl.href, '_blank')
}
const onSaveClick = (e: IExportJson) => {
console.log(e, '这是要保存的数据')
// console.log(e, '这是要保存的数据')
}
const onSaveAll = (data: any) => {

View File

@@ -7,7 +7,7 @@ import { onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
const MtPreviewRef = ref<InstanceType<typeof MtPreview>>()
const onEventCallBack = (type: string, item_id: string) => {
console.log(type, item_id)
// console.log(type, item_id)
if (type == 'test-dialog') {
ElMessage.success(`获取到了id:${item_id}`)

View File

@@ -7,7 +7,7 @@ import { onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
const MtPreviewRef = ref<InstanceType<typeof MtPreviewYpt>>()
const onEventCallBack = (type: string, item_id: string) => {
console.log(type, item_id)
// console.log(type, item_id)
if (type == 'test-dialog') {
ElMessage.success(`获取到了id:${item_id}`)

View File

@@ -7,7 +7,7 @@ import { onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
const MtPreviewRef = ref<InstanceType<typeof MtPreviewZl>>()
const onEventCallBack = (type: string, item_id: string) => {
console.log(type, item_id)
// console.log(type, item_id)
if (type == 'test-dialog') {
ElMessage.success(`获取到了id:${item_id}`)