调整台账
This commit is contained in:
@@ -1,35 +1,36 @@
|
||||
<template>
|
||||
<div class="mac-address-input" :class="{ disabled: disabled }">
|
||||
<el-input
|
||||
ref="inputRef"
|
||||
v-model="macValue"
|
||||
type="text"
|
||||
maxlength="17"
|
||||
:disabled="disabled"
|
||||
@input="handleInput"
|
||||
@keydown="handleKeydown"
|
||||
@focus="handleFocus"
|
||||
@blur="handleBlur"
|
||||
@paste="handlePaste"
|
||||
/>
|
||||
</div>
|
||||
<div class="mac-address-input" :class="{ disabled: disabled }">
|
||||
<el-input
|
||||
ref="inputRef"
|
||||
placeholder="请输入设备mac地址"
|
||||
v-model="macValue"
|
||||
type="text"
|
||||
maxlength="17"
|
||||
:disabled="disabled"
|
||||
@input="handleInput"
|
||||
@keydown="handleKeydown"
|
||||
@focus="handleFocus"
|
||||
@blur="handleBlur"
|
||||
@paste="handlePaste"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
interface Props {
|
||||
modelValue?: string
|
||||
disabled?: boolean
|
||||
modelValue?: string
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: string): void
|
||||
(e: 'update:modelValue', value: string): void
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: '',
|
||||
disabled: false
|
||||
modelValue: '',
|
||||
disabled: false
|
||||
})
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
@@ -42,35 +43,35 @@ const macValue = ref<string>('')
|
||||
|
||||
// 解析传入的MAC地址
|
||||
const parseMacAddress = (mac: string): string => {
|
||||
if (!mac) return ''
|
||||
|
||||
// 移除非十六进制字符并转为大写
|
||||
const cleanMac = mac.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
|
||||
// 按每2个字符分割并用冒号连接
|
||||
let result = ''
|
||||
for (let i = 0; i < cleanMac.length; i += 2) {
|
||||
if (i > 0) result += ':'
|
||||
result += cleanMac.substr(i, 2)
|
||||
}
|
||||
return result.substring(0, 17) // 最多17个字符 (12个数字+5个冒号)
|
||||
if (!mac) return ''
|
||||
|
||||
// 移除非十六进制字符并转为大写
|
||||
const cleanMac = mac.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
|
||||
// 按每2个字符分割并用冒号连接
|
||||
let result = ''
|
||||
for (let i = 0; i < cleanMac.length; i += 2) {
|
||||
if (i > 0) result += ':'
|
||||
result += cleanMac.substr(i, 2)
|
||||
}
|
||||
return result.substring(0, 17) // 最多17个字符 (12个数字+5个冒号)
|
||||
}
|
||||
|
||||
// 格式化MAC地址 - 改进版
|
||||
const formatMac = (value: string): string => {
|
||||
// 移除所有冒号
|
||||
const cleanValue = value.replace(/:/g, '')
|
||||
// 只保留十六进制字符并转为大写
|
||||
const hexOnly = cleanValue.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
|
||||
// 按每两个字符添加冒号,最多6段
|
||||
let formatted = ''
|
||||
for (let i = 0; i < Math.min(hexOnly.length, 12); i += 2) {
|
||||
if (i > 0) formatted += ':'
|
||||
formatted += hexOnly.substr(i, 2)
|
||||
}
|
||||
|
||||
return formatted
|
||||
// 移除所有冒号
|
||||
const cleanValue = value.replace(/:/g, '')
|
||||
// 只保留十六进制字符并转为大写
|
||||
const hexOnly = cleanValue.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
|
||||
// 按每两个字符添加冒号,最多6段
|
||||
let formatted = ''
|
||||
for (let i = 0; i < Math.min(hexOnly.length, 12); i += 2) {
|
||||
if (i > 0) formatted += ':'
|
||||
formatted += hexOnly.substr(i, 2)
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
// 当前聚焦的输入框索引
|
||||
@@ -78,88 +79,86 @@ const focusedIndex = ref<number | null>(null)
|
||||
|
||||
// 处理输入事件
|
||||
const handleInput = (value: string) => {
|
||||
const formatted = formatMac(value)
|
||||
macValue.value = formatted
|
||||
// 发出不带冒号的纯净值
|
||||
emit('update:modelValue', formatted.replace(/:/g, ''))
|
||||
const formatted = formatMac(value)
|
||||
macValue.value = formatted
|
||||
// 发出不带冒号的纯净值
|
||||
emit('update:modelValue', formatted.replace(/:/g, ''))
|
||||
}
|
||||
|
||||
// 处理键盘事件
|
||||
const handleKeydown = (event: KeyboardEvent) => {
|
||||
const target = event.target as HTMLInputElement
|
||||
|
||||
// 处理退格键
|
||||
if (event.key === 'Backspace') {
|
||||
// 处理在冒号前删除的情况
|
||||
const cursorPos = target.selectionStart || 0
|
||||
if (cursorPos > 0 && macValue.value[cursorPos - 1] === ':' &&
|
||||
target.selectionStart === target.selectionEnd) {
|
||||
event.preventDefault()
|
||||
// 删除冒号前的两个字符
|
||||
const newValue = macValue.value.substring(0, cursorPos - 3) +
|
||||
macValue.value.substring(cursorPos)
|
||||
macValue.value = newValue
|
||||
// 设置光标位置
|
||||
setTimeout(() => {
|
||||
if (target.setSelectionRange) {
|
||||
target.setSelectionRange(cursorPos - 3, cursorPos - 3)
|
||||
const target = event.target as HTMLInputElement
|
||||
|
||||
// 处理退格键
|
||||
if (event.key === 'Backspace') {
|
||||
// 处理在冒号前删除的情况
|
||||
const cursorPos = target.selectionStart || 0
|
||||
if (cursorPos > 0 && macValue.value[cursorPos - 1] === ':' && target.selectionStart === target.selectionEnd) {
|
||||
event.preventDefault()
|
||||
// 删除冒号前的两个字符
|
||||
const newValue = macValue.value.substring(0, cursorPos - 3) + macValue.value.substring(cursorPos)
|
||||
macValue.value = newValue
|
||||
// 设置光标位置
|
||||
setTimeout(() => {
|
||||
if (target.setSelectionRange) {
|
||||
target.setSelectionRange(cursorPos - 3, cursorPos - 3)
|
||||
}
|
||||
}, 0)
|
||||
emit('update:modelValue', newValue.replace(/:/g, ''))
|
||||
}
|
||||
}, 0)
|
||||
emit('update:modelValue', newValue.replace(/:/g, ''))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理焦点事件
|
||||
const handleFocus = () => {
|
||||
focusedIndex.value = 0
|
||||
focusedIndex.value = 0
|
||||
}
|
||||
|
||||
// 处理失焦事件
|
||||
const handleBlur = () => {
|
||||
focusedIndex.value = null
|
||||
focusedIndex.value = null
|
||||
}
|
||||
|
||||
// 处理粘贴事件
|
||||
const handlePaste = (event: ClipboardEvent) => {
|
||||
event.preventDefault()
|
||||
const pastedText = event.clipboardData?.getData('text') || ''
|
||||
|
||||
// 清理粘贴的文本
|
||||
const cleanPastedText = pastedText.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
const formatted = formatMac(cleanPastedText)
|
||||
macValue.value = formatted
|
||||
emit('update:modelValue', formatted.replace(/:/g, ''))
|
||||
event.preventDefault()
|
||||
const pastedText = event.clipboardData?.getData('text') || ''
|
||||
|
||||
// 清理粘贴的文本
|
||||
const cleanPastedText = pastedText.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
const formatted = formatMac(cleanPastedText)
|
||||
macValue.value = formatted
|
||||
emit('update:modelValue', formatted.replace(/:/g, ''))
|
||||
}
|
||||
|
||||
// 监听modelValue变化
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
const cleanNewVal = (newVal || '').replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
const currentCleanValue = macValue.value.replace(/:/g, '')
|
||||
|
||||
if (cleanNewVal !== currentCleanValue) {
|
||||
macValue.value = parseMacAddress(cleanNewVal)
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
() => props.modelValue,
|
||||
newVal => {
|
||||
const cleanNewVal = (newVal || '').replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
const currentCleanValue = macValue.value.replace(/:/g, '')
|
||||
|
||||
if (cleanNewVal !== currentCleanValue) {
|
||||
macValue.value = parseMacAddress(cleanNewVal)
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.mac-address-input {
|
||||
width: 100%;
|
||||
|
||||
&.disabled {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
:deep(.el-input__wrapper) {
|
||||
input {
|
||||
text-transform: uppercase;
|
||||
font-family: inherit; // 使用继承的字体而不是等宽字体
|
||||
width: 100%;
|
||||
|
||||
&.disabled {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
:deep(.el-input__wrapper) {
|
||||
input {
|
||||
text-transform: uppercase;
|
||||
font-family: inherit; // 使用继承的字体而不是等宽字体
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -193,7 +193,10 @@
|
||||
</el-form-item>
|
||||
|
||||
<!--项目-->
|
||||
<div style="width: 100%" v-if="nodeLevel > 0 || pageStatus == 2">
|
||||
<div
|
||||
style="width: 100%"
|
||||
v-if="(nodeLevel > 0 || pageStatus == 2) && formData.projectInfoList.length > 0"
|
||||
>
|
||||
<el-tabs
|
||||
v-model="deviceIndex"
|
||||
type="card"
|
||||
@@ -333,7 +336,11 @@
|
||||
<!--设备-->
|
||||
<div
|
||||
style="width: 100%"
|
||||
v-if="(nodeLevel > 1 || pageStatus == 2) && (nodeLevel >= 2 || pageStatus == 2)"
|
||||
v-if="
|
||||
(nodeLevel > 1 || pageStatus == 2) &&
|
||||
(nodeLevel >= 2 || pageStatus == 2) &&
|
||||
formData.deviceInfoList.length > 0
|
||||
"
|
||||
>
|
||||
<el-tabs
|
||||
v-model="busBarIndex"
|
||||
@@ -656,7 +663,11 @@
|
||||
<!--监测点-->
|
||||
<div
|
||||
style="width: 100%"
|
||||
v-if="(nodeLevel > 2 || pageStatus == 2) && (nodeLevel >= 3 || pageStatus == 2)"
|
||||
v-if="
|
||||
(nodeLevel > 2 || pageStatus == 2) &&
|
||||
(nodeLevel >= 3 || pageStatus == 2) &&
|
||||
formData.lineInfoList.length > 0
|
||||
"
|
||||
>
|
||||
<el-tabs
|
||||
type="card"
|
||||
@@ -703,7 +714,7 @@
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请选择线路号',
|
||||
trigger: 'blur'
|
||||
trigger: 'change'
|
||||
}"
|
||||
>
|
||||
<el-select
|
||||
@@ -731,7 +742,11 @@
|
||||
class="form-item"
|
||||
label="接线方式:"
|
||||
:prop="'lineInfoList[' + lIndex + '].conType'"
|
||||
:rules="{ required: true, message: '请选择接线方式', trigger: 'blur' }"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请选择接线方式',
|
||||
trigger: 'change'
|
||||
}"
|
||||
>
|
||||
<el-select
|
||||
clearable
|
||||
@@ -758,7 +773,11 @@
|
||||
class="form-item"
|
||||
label="统计间隔:"
|
||||
:prop="'lineInfoList[' + lIndex + '].lineInterval'"
|
||||
:rules="{ required: true, message: '请选择统计间隔', trigger: 'blur' }"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请选择统计间隔',
|
||||
trigger: 'change'
|
||||
}"
|
||||
>
|
||||
<el-select
|
||||
clearable
|
||||
@@ -975,7 +994,11 @@
|
||||
class="form-item"
|
||||
label="电压等级:"
|
||||
:prop="'lineInfoList[' + lIndex + '].volGrade'"
|
||||
:rules="{ required: true, message: '请选择电压等级', trigger: 'blur' }"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请选择电压等级',
|
||||
trigger: 'change'
|
||||
}"
|
||||
>
|
||||
<el-select
|
||||
clearable
|
||||
@@ -1027,7 +1050,7 @@
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请选择监测对象类型',
|
||||
trigger: 'blur'
|
||||
trigger: 'change'
|
||||
}"
|
||||
>
|
||||
<el-select
|
||||
@@ -1058,7 +1081,7 @@
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请选择监测位置',
|
||||
trigger: 'blur'
|
||||
trigger: 'change'
|
||||
}"
|
||||
>
|
||||
<el-select
|
||||
@@ -1113,7 +1136,11 @@
|
||||
class="form-item"
|
||||
label="运行状态:"
|
||||
:prop="'lineInfoList[' + lIndex + '].runStatus'"
|
||||
:rules="{ required: true, message: '请选择运行状态', trigger: 'blur' }"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请选择运行状态',
|
||||
trigger: 'change'
|
||||
}"
|
||||
>
|
||||
<!-- (0:运行;1:检修;2:停运;3:调试;4:退运) -->
|
||||
<el-select
|
||||
@@ -1351,7 +1378,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item class="form-item" label="通讯状态:">
|
||||
<el-form-item class="form-item" label="运行状态:">
|
||||
<!-- (0:运行;1:检修;2:停运;3:调试;4:退运) -->
|
||||
<el-select
|
||||
clearable
|
||||
@@ -1360,8 +1387,11 @@
|
||||
placeholder="请选择通讯状态"
|
||||
:disabled="true"
|
||||
>
|
||||
<el-option label="离线" :value="1" />
|
||||
<el-option label="在线" :value="2" />
|
||||
<el-option label="运行" :value="0" />
|
||||
<el-option label="检修" :value="1" />
|
||||
<el-option label="停运" :value="2" />
|
||||
<el-option label="调试" :value="3" />
|
||||
<el-option label="退运" :value="4" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
@@ -1476,6 +1506,7 @@ const loading = ref(false)
|
||||
const nextfalg = ref(false)
|
||||
const dictData = useDictData()
|
||||
const nodeLevel = ref(0)
|
||||
const nodeLevelCopy = ref(0)
|
||||
const pageStatus = ref(1)
|
||||
const titleList: any = ref([])
|
||||
const nodeData: any = ref([])
|
||||
@@ -1941,7 +1972,7 @@ const add = () => {
|
||||
return
|
||||
}
|
||||
pageStatus.value = 2
|
||||
|
||||
nodeLevelCopy.value = nodeLevel.value
|
||||
// 根据当前节点层级添加对应的tab页
|
||||
switch (nodeLevel.value) {
|
||||
case 0: // 新增工程,不需要添加tab
|
||||
@@ -2243,8 +2274,8 @@ const remove = () => {
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
switch (nodeLevel.value) {
|
||||
case 1:
|
||||
switch (nodeData.value.level) {
|
||||
case 0:
|
||||
let data = {
|
||||
id: nodeData.value.id,
|
||||
status: '0'
|
||||
@@ -2262,7 +2293,7 @@ const remove = () => {
|
||||
})
|
||||
|
||||
break
|
||||
case 2: // 项目层级
|
||||
case 1: // 项目层级
|
||||
// 删除项目后选中工程节点
|
||||
const engineeringId = nodeData.value.pids ? nodeData.value.pids.split(',')[1] : null
|
||||
deleteProject(nodeData.value.id, '', '', '', 0, '', '').then((res: any) => {
|
||||
@@ -2282,7 +2313,7 @@ const remove = () => {
|
||||
})
|
||||
|
||||
break
|
||||
case 3: // 设备层级
|
||||
case 2: // 设备层级
|
||||
// 删除设备后选中项目节点
|
||||
const projectId = nodeData.value.pids ? nodeData.value.pids.split(',')[2] : null
|
||||
deleteEquipment(nodeData.value.id).then((res: any) => {
|
||||
@@ -2302,7 +2333,7 @@ const remove = () => {
|
||||
})
|
||||
|
||||
break
|
||||
case 4: // 监测点层级
|
||||
case 3: // 监测点层级
|
||||
const deviceId = nodeData.value.pids ? nodeData.value.pids.split(',')[3] : null
|
||||
|
||||
deleteLine(nodeData.value.id).then((res: any) => {
|
||||
@@ -2502,21 +2533,21 @@ const submitAllLevelData = async () => {
|
||||
const engineeringData = tempAllLevelData.value.engineering || { ...formData.value.engineeringParam }
|
||||
|
||||
// 项目信息
|
||||
const projectData =
|
||||
const projectData: any =
|
||||
tempAllLevelData.value.projects.length > 0
|
||||
? tempAllLevelData.value.projects.find(project => project !== undefined) || {}
|
||||
: formData.value.projectInfoList[0] || {}
|
||||
// 如果是从根节点开始新增工程和项目
|
||||
if (nodeData.value.level === 0) {
|
||||
if (nodeData.value.level === -1) {
|
||||
submitData = {
|
||||
engineering: engineeringData,
|
||||
project: projectData
|
||||
project: { ...projectData, topoIds: [projectData.topoId] }
|
||||
}
|
||||
} else {
|
||||
// 如果是从工程节点开始新增项目
|
||||
submitData = {
|
||||
engineeringIndex: nodeData.value?.id || '',
|
||||
project: projectData
|
||||
project: { ...projectData, topoIds: [projectData.topoId] }
|
||||
}
|
||||
}
|
||||
break
|
||||
@@ -2541,10 +2572,10 @@ const submitAllLevelData = async () => {
|
||||
}
|
||||
|
||||
// 如果是从根节点开始新增
|
||||
if (nodeData.value.level === 0) {
|
||||
if (nodeData.value.level === -1) {
|
||||
submitData = {
|
||||
engineering: engineeringData2,
|
||||
project: projectData2,
|
||||
project: { ...projectData2, topoIds: [projectData2.topoId] },
|
||||
device: devices.map((device: any) => ({
|
||||
...device,
|
||||
ndid: device.mac ? device.mac.replace(/:/g, '') : ''
|
||||
@@ -2552,10 +2583,10 @@ const submitAllLevelData = async () => {
|
||||
}
|
||||
}
|
||||
// 如果是从工程节点开始新增
|
||||
else if (nodeData.value.level === 1) {
|
||||
else if (nodeData.value.level === 0) {
|
||||
submitData = {
|
||||
engineeringIndex: nodeData.value?.id || '',
|
||||
project: projectData2,
|
||||
project: { ...projectData2, topoIds: [projectData2.topoId] },
|
||||
device: devices.map((device: any) => ({
|
||||
...device,
|
||||
ndid: device.mac ? device.mac.replace(/:/g, '') : ''
|
||||
@@ -2563,7 +2594,7 @@ const submitAllLevelData = async () => {
|
||||
}
|
||||
}
|
||||
// 如果是从项目节点开始新增
|
||||
else if (nodeData.value.level === 2) {
|
||||
else if (nodeData.value.level === 1) {
|
||||
const pidsArray = nodeData.value?.pids ? nodeData.value.pids.split(',') : []
|
||||
const engineeringId = pidsArray.length >= 2 ? pidsArray[1] : ''
|
||||
|
||||
@@ -2578,8 +2609,8 @@ const submitAllLevelData = async () => {
|
||||
}
|
||||
break
|
||||
|
||||
case 3: // 工程 + 项目 + 设备 + 监测点
|
||||
case 4:
|
||||
// case 3: // 工程 + 项目 + 设备 + 监测点
|
||||
case 3:
|
||||
// 工程信息
|
||||
const engineeringData3 = tempAllLevelData.value.engineering || {
|
||||
...formData.value.engineeringParam
|
||||
@@ -2608,10 +2639,10 @@ const submitAllLevelData = async () => {
|
||||
}
|
||||
|
||||
// 如果是从根节点开始新增
|
||||
if (nodeData.value.level === 0) {
|
||||
if (nodeData.value.level === -1) {
|
||||
submitData = {
|
||||
engineering: engineeringData3,
|
||||
project: projectData3,
|
||||
project: { ...projectData3, topoIds: [projectData3.topoId] },
|
||||
device: devices2.map((device: any) => ({
|
||||
...device,
|
||||
ndid: device.mac ? device.mac.replace(/:/g, '') : ''
|
||||
@@ -2638,7 +2669,7 @@ const submitAllLevelData = async () => {
|
||||
}
|
||||
}
|
||||
// 如果是从工程节点开始新增
|
||||
else if (nodeData.value.level === 1) {
|
||||
else if (nodeData.value.level === 0) {
|
||||
submitData = {
|
||||
engineeringIndex: nodeData.value?.id || '',
|
||||
project: projectData3,
|
||||
@@ -2668,7 +2699,7 @@ const submitAllLevelData = async () => {
|
||||
}
|
||||
}
|
||||
// 如果是从项目节点开始新增
|
||||
else if (nodeData.value.level === 2) {
|
||||
else if (nodeData.value.level === 1) {
|
||||
const pidsArray = nodeData.value?.pids ? nodeData.value.pids.split(',') : []
|
||||
const engineeringId = pidsArray.length >= 2 ? pidsArray[1] : ''
|
||||
|
||||
@@ -2701,7 +2732,7 @@ const submitAllLevelData = async () => {
|
||||
}
|
||||
}
|
||||
// 如果是从设备节点开始新增
|
||||
else if (nodeData.value.level === 3) {
|
||||
else if (nodeData.value.level === 2) {
|
||||
const pidsArray2 = nodeData.value?.pids ? nodeData.value.pids.split(',') : []
|
||||
const engineeringId2 = pidsArray2.length >= 2 ? pidsArray2[1] : ''
|
||||
const projectId = pidsArray2.length >= 3 ? pidsArray2[2] : ''
|
||||
|
||||
@@ -746,26 +746,28 @@ const mqttMessage = ref<any>({})
|
||||
const status: any = ref()
|
||||
function parseStringToObject(str: string) {
|
||||
const content = str.replace(/^{|}$/g, '')
|
||||
const pairs = content.split(',')
|
||||
const result: any = {}
|
||||
pairs.forEach(pair => {
|
||||
const [key, value] = pair.split(':')
|
||||
// 尝试将数字转换为Number类型
|
||||
result[key.trim()] = isNaN(Number(value)) ? value.trim() : Number(value)
|
||||
})
|
||||
|
||||
// 正则匹配:key:value 格式,支持 value 里带 : / 等字符
|
||||
const regex = /([^,:]+):([^,]+)(?=,|$)/g
|
||||
let match
|
||||
|
||||
while ((match = regex.exec(content)) !== null) {
|
||||
const key = match[1].trim()
|
||||
const value = match[2].trim()
|
||||
// 数字自动转 Number
|
||||
result[key] = isNaN(Number(value)) ? value : Number(value)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
mqttRef.value.on('message', (topic: any, message: any) => {
|
||||
// console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))))
|
||||
|
||||
let str = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
|
||||
|
||||
let regex = /fileName:(.*?),allStep/
|
||||
let regex1 = /allStep:(.*?),nowStep/
|
||||
let regex2 = /nowStep:(.*?),userId/
|
||||
let regex3 = /userId:(.*?)}/
|
||||
|
||||
mqttMessage.value = parseStringToObject(str)
|
||||
if (adminInfo.id != mqttMessage.value.userId) return
|
||||
|
||||
// console.log("🚀 ~ str.match(regex3)[1]:", str.match(regex3)[1])
|
||||
status.value = parseInt(Number((mqttMessage.value.nowStep / mqttMessage.value.allStep) * 100))
|
||||
fileRef.value.setStatus(mqttMessage.value)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<div :class="downLoading ? 'all_disabled' : ''">
|
||||
<el-dialog v-model.trim="dialogVisible" title="文件信息" width="50%" @closed="handleClose">
|
||||
<div v-loading="loading">
|
||||
|
||||
<div
|
||||
class="download_progress"
|
||||
v-if="mqttFileName.includes(fileNameInfoMation) && status != 0 && status != 100"
|
||||
@@ -57,7 +58,7 @@ import {
|
||||
getFileServiceFileOrDir,
|
||||
downLoadDeviceFile,
|
||||
downLoadDeviceFilePath
|
||||
} from '@/api/cs-device-boot/fileService.ts'
|
||||
} from '@/api/cs-device-boot/fileService'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useAdminInfo } from '@/stores/adminInfo'
|
||||
import { downLoadFile } from '@/api/cs-system-boot/manage.ts'
|
||||
|
||||
@@ -170,7 +170,8 @@ queryByCode('Device_Type').then(res => {
|
||||
// 版本维护
|
||||
const maintenance = () => {
|
||||
push({
|
||||
path: '/versionMaintenance'
|
||||
// path: '/versionMaintenance'
|
||||
path: '/govern/manage/basic/version'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user