调整台账

This commit is contained in:
guanj
2026-04-03 14:47:36 +08:00
parent 0b9aafc1b5
commit 3ffb11defa
5 changed files with 183 additions and 149 deletions

View File

@@ -2,6 +2,7 @@
<div class="mac-address-input" :class="{ disabled: disabled }"> <div class="mac-address-input" :class="{ disabled: disabled }">
<el-input <el-input
ref="inputRef" ref="inputRef"
placeholder="请输入设备mac地址"
v-model="macValue" v-model="macValue"
type="text" type="text"
maxlength="17" maxlength="17"
@@ -92,12 +93,10 @@ const handleKeydown = (event: KeyboardEvent) => {
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) + const newValue = macValue.value.substring(0, cursorPos - 3) + macValue.value.substring(cursorPos)
macValue.value.substring(cursorPos)
macValue.value = newValue macValue.value = newValue
// 设置光标位置 // 设置光标位置
setTimeout(() => { setTimeout(() => {
@@ -135,7 +134,7 @@ const handlePaste = (event: ClipboardEvent) => {
// 监听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, '')

View File

@@ -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] : ''

View File

@@ -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)

View File

@@ -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'

View File

@@ -170,7 +170,8 @@ queryByCode('Device_Type').then(res => {
// 版本维护 // 版本维护
const maintenance = () => { const maintenance = () => {
push({ push({
path: '/versionMaintenance' // path: '/versionMaintenance'
path: '/govern/manage/basic/version'
}) })
} }