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