前置管理

This commit is contained in:
sjl
2025-10-17 09:55:43 +08:00
parent d9def45a8b
commit 1211277a0d
6 changed files with 825 additions and 102 deletions

View File

@@ -69,6 +69,7 @@
label-width="120px"
:inline="true"
ref="mainForm"
>
<el-form-item
id="id100"
@@ -97,14 +98,15 @@
class="form-item"
label="省:"
v-if="nodeLevel > 0 || pageStatus == 2"
:rules="[{ required: true, message: '请选择省', trigger: 'change' }]"
prop="'engineeringParam.province'"
:rules="{ required: true, message: '请选择省', trigger: 'change' }"
>
<el-select
filterable
v-model="engineeringParam.province"
:disabled="!((nodeLevel == 1 && pageStatus == 3) || (nodeLevel == 0 && pageStatus == 2))"
placeholder="请选择省"
@change="provinceChange"
filterable
v-model="engineeringParam.province"
:disabled="!((nodeLevel == 1 && pageStatus == 3) || (nodeLevel == 0 && pageStatus == 2))"
placeholder="请选择省"
@change="provinceChange"
>
<el-option
v-for="item in provinceOptions"
@@ -120,7 +122,8 @@
class="form-item"
label="市:"
v-if="(nodeLevel > 0 || pageStatus == 2)"
:rules="[{ required: true, message: '请选择市', trigger: 'change' }]"
:prop="'engineeringParam.city'"
:rules="{ required: true, message: '请选择市', trigger: 'change' }"
>
<el-select
filterable
@@ -141,7 +144,8 @@
class="form-item"
label="工程名称:"
v-if="nodeLevel > 0 || pageStatus == 2"
:rules="[{ required: true, message: '请输入工程名称', trigger: 'blur' }]"
:prop="'name'"
:rules="{ required: true, message: '请输入工程名称', trigger: 'blur' }"
>
<el-input
v-model="engineeringParam.name"
@@ -166,7 +170,8 @@
<el-tabs
v-model="deviceIndex"
type="card"
:editable="pageStatus != 1"
:addable="false"
:closable="pageStatus != 1"
@edit="handleDeviceTabsEdit"
@tab-click="tabChange('deviceIndex')"
>
@@ -180,6 +185,7 @@
<el-form-item
class="form-item"
label="项目名称:"
:prop="'projectInfoList.' + index + '.name'"
:rules="[{ required: true, message: '请输入项目名称', trigger: 'blur' }]"
>
<el-input
@@ -216,11 +222,12 @@
</div>
<!--设备-->
<div style="width: 100%" v-if="nodeLevel > 1 || pageStatus == 2">
<div style="width: 100%" v-if="(nodeLevel > 1 || pageStatus == 2) && (nodeLevel >= 2 || pageStatus == 2)">
<el-tabs
v-model="busBarIndex"
type="card"
:editable="pageStatus != 1"
:addable="false"
:closable="pageStatus != 1"
@edit="handleBusBarTabsEdit"
@tab-click="tabChange('busBarIndex')"
>
@@ -366,11 +373,12 @@
</div>
<!--监测点-->
<div style="width: 100%" v-if="nodeLevel > 2 || pageStatus == 2">
<div style="width: 100%" v-if="(nodeLevel > 2 || pageStatus == 2) && (nodeLevel >= 3 || pageStatus == 2)">
<el-tabs
type="card"
v-model="lineIndex"
:editable="pageStatus != 1"
:addable="false"
:closable="pageStatus != 1"
@edit="handleLineTabsEdit"
@tab-click="tabChange('lineIndex')"
>
@@ -714,12 +722,10 @@ const nodeDataList=ref()
const nodeEventList=ref()
const nodeClick = (e: anyObj, data: any) => {
console.log(e, data)
nodeDataList.value = data
nodeEventList.value = e
treeClickCount.value++
if (treeClickCount.value > 2) return
if (treeClickCount.value > 2) return
if (treeClickCount.value == 1) {
if (pageStatus.value == 2 || pageStatus.value == 3) {
if (pageStatus.value == 3 || pageStatus.value == 2) {
@@ -749,12 +755,54 @@ const nodeClick = (e: anyObj, data: any) => {
}else if(nodeData.value.level == 4){ //监测点
nodeLevel.value = 4
}
// 根据节点层级清理不需要的数据
cleanUnnecessaryData()
/**不是根节点请求数据 */
queryNodeContent()
treeClickCount.value = 0
}
/**
* 根据当前节点层级清理不需要的数据
*/
const cleanUnnecessaryData = () => {
// 根据当前节点层级清理不需要的数据
switch(nodeLevel.value) {
case 0: // 根节点
// 清理所有数据
projectInfoList.value = []
deviceInfoList.value = []
lineInfoList.value = []
break
case 1: // 工程节点
// 清理设备和监测点数据
deviceInfoList.value = []
lineInfoList.value = []
break
case 2: // 项目节点
// 清理监测点数据
lineInfoList.value = []
break
case 3: // 设备节点
// 不清理任何数据
break
case 4: // 监测点节点
// 不清理任何数据
break
}
// 重置tab索引
if (nodeLevel.value < 2) {
deviceIndex.value = '0'
}
if (nodeLevel.value < 3) {
busBarIndex.value = '0'
}
if (nodeLevel.value < 4) {
lineIndex.value = '0'
}
}
const getparentsNode = (node: any) => {
// 检查node是否存在以及是否有parent属性
if (!node || !node.parent) {
@@ -818,6 +866,10 @@ const add = () => {
engineeringParam.value.description = ''
engineeringParam.value.name = ''
engineeringParam.value.province = ''
// 清理其他层级数据
projectInfoList.value = []
deviceInfoList.value = []
lineInfoList.value = []
break
case 1: // 新增项目添加一个新的项目tab
// 添加一个新的空项目到projectInfoList
@@ -827,6 +879,9 @@ const add = () => {
description: ''
})
deviceIndex.value = (projectInfoList.value.length - 1).toString()
// 清理设备和监测点数据
deviceInfoList.value = []
lineInfoList.value = []
break
case 2: // 新增设备添加一个新的设备tab
// 添加一个新的空设备到deviceInfoList
@@ -842,6 +897,8 @@ const add = () => {
sort: 0
})
busBarIndex.value = (deviceInfoList.value.length - 1).toString()
// 清理监测点数据
lineInfoList.value = []
break
case 3: // 新增监测点添加一个新的监测点tab
// 添加一个新的空监测点到lineInfoList
@@ -943,7 +1000,7 @@ const updateProjectFunc = (id: any) => {
message: '修改项目成功'
})
pageStatus.value = 1
TerminalRef.value.info()
treedata()
})
}
/**
@@ -1037,7 +1094,7 @@ const updateLineFunc = (id: any) => {
message: '修改监测点成功'
})
pageStatus.value = 1
TerminalRef.value.info()
treedata()
})
}
@@ -1088,14 +1145,13 @@ const remove = () => {
case 2: // 项目层级
// 删除项目后选中工程节点
const engineeringId = nodeData.value.pids ? nodeData.value.pids.split(',')[1] : null
console.log(engineeringId)
deleteProject(nodeData.value.id,'','','', 0).then((res: any) => {
ElMessage({
type: 'success',
message: res.message
})
reaseStatus()
console.log('engineeringId',engineeringId)
if (engineeringId) {
setTimeout(() => {
treedata(engineeringId)
@@ -1159,74 +1215,85 @@ const remove = () => {
}
// 下一步
const next = async () => {
// 在新增模式下pageStatus == 2保存当前数据并创建下一个层级的Tab
switch (nodeLevel.value) {
case 0: // 工程层级下一步创建项目Tab
// 保存当前工程信息到临时存储
tempAllLevelData.value.engineering = { ...engineeringParam.value }
// 创建新的项目Tab
projectInfoList.value.push({
name: '',
area: '',
description: '',
})
deviceIndex.value = (projectInfoList.value.length - 1).toString()
nextfalg.value = false
nodeLevel.value = 1
break
case 1: // 项目层级下一步创建设备Tab
// 保存当前项目信息到临时存储
const currentProject = { ...projectInfoList.value[deviceIndex.value] }
tempAllLevelData.value.projects[deviceIndex.value] = currentProject
// 创建新的设备Tab
deviceInfoList.value.push({
name: '',
devModel: '',
devType: '',
devAccessMethod: 'CLD',
mac: '',
ndid: '',
nodeId: '',
cntractNo: '',
sort: 0
})
busBarIndex.value = (deviceInfoList.value.length - 1).toString()
nextfalg.value = false
nodeLevel.value = 2
break
case 2: // 设备层级下一步创建监测点Tab
// 保存当前设备信息到临时存储
const currentDevice = { ...deviceInfoList.value[busBarIndex.value] }
tempAllLevelData.value.devices[busBarIndex.value] = currentDevice
// 创建新的监测点Tab
lineInfoList.value.push({
name: '',
lineNo: 1,
conType: 0,
lineInterval: 1,
ptRatio: 0,
pt2Ratio: 0,
ctRatio: 0,
ct2Ratio: 0,
volGrade: '',
devMac: '',
})
lineIndex.value = (lineInfoList.value.length - 1).toString()
nextfalg.value = false
nodeLevel.value = 3
break
case 3: // 监测点层级
// 保存当前监测点信息到临时存储
const currentLine = { ...lineInfoList.value[lineIndex.value] }
tempAllLevelData.value.lines[lineIndex.value] = currentLine
nextfalg.value = true
nodeLevel.value = 4
break
}
console.log('mainForm',mainForm.value.validate)
await mainForm.value?.validate((valid: boolean) => {
console.log('valid', valid)
if (valid) {
}
})
}
const executeNextStep = () => {
// 在新增模式下pageStatus == 2保存当前数据并创建下一个层级的Tab
switch (nodeLevel.value) {
case 0: // 工程层级下一步创建项目Tab
// 保存当前工程信息到临时存储
tempAllLevelData.value.engineering = { ...engineeringParam.value }
// 创建新的项目Tab
projectInfoList.value.push({
name: '',
area: '',
description: '',
})
deviceIndex.value = (projectInfoList.value.length - 1).toString()
nextfalg.value = false
nodeLevel.value = 1
break
case 1: // 项目层级下一步创建设备Tab
// 保存当前项目信息到临时存储
const currentProject = { ...projectInfoList.value[deviceIndex.value] }
tempAllLevelData.value.projects[deviceIndex.value] = currentProject
// 创建新的设备Tab
deviceInfoList.value.push({
name: '',
devModel: '',
devType: '',
devAccessMethod: 'CLD',
mac: '',
ndid: '',
nodeId: '',
cntractNo: '',
sort: 0
})
busBarIndex.value = (deviceInfoList.value.length - 1).toString()
nextfalg.value = false
nodeLevel.value = 2
break
case 2: // 设备层级下一步创建监测点Tab
// 保存当前设备信息到临时存储
const currentDevice = { ...deviceInfoList.value[busBarIndex.value] }
tempAllLevelData.value.devices[busBarIndex.value] = currentDevice
// 创建新的监测点Tab
lineInfoList.value.push({
name: '',
lineNo: 1,
conType: 0,
lineInterval: 1,
ptRatio: 0,
pt2Ratio: 0,
ctRatio: 0,
ct2Ratio: 0,
volGrade: '',
devMac: '',
})
lineIndex.value = (lineInfoList.value.length - 1).toString()
nextfalg.value = false
nodeLevel.value = 3
break
case 3: // 监测点层级
// 保存当前监测点信息到临时存储
const currentLine = { ...lineInfoList.value[lineIndex.value] }
tempAllLevelData.value.lines[lineIndex.value] = currentLine
nextfalg.value = true
nodeLevel.value = 4
break
}
}
// 撤销
@@ -1823,8 +1890,8 @@ const handleDeviceTabsEdit = (targetName: any, action: any) => {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 如果是编辑现有项目
if (pageStatus.value === 3 && projectInfoList.value[deviceIndex.value]?.id) {
// 删除项目
if (projectInfoList.value[deviceIndex.value]?.id) {
deleteProject(
projectInfoList.value[deviceIndex.value].id,
projectInfoList.value[deviceIndex.value].name,
@@ -1845,7 +1912,8 @@ const handleDeviceTabsEdit = (targetName: any, action: any) => {
// 重置相关索引
busBarIndex.value = '0'
lineIndex.value = '0'
TerminalRef.value.info()
pageStatus.value = 1
treedata()
})
} else {
// 如果是新增模式下删除未保存的项目
@@ -1895,7 +1963,7 @@ const handleBusBarTabsEdit = (targetName: any, action: any) => {
type: 'warning'
}).then(() => {
// 如果是编辑现有设备
if (pageStatus.value === 3 && deviceInfoList.value[busBarIndex.value]?.id) {
if ( deviceInfoList.value[busBarIndex.value]?.id) {
deleteEquipment(deviceInfoList.value[busBarIndex.value].id).then((res: any) => {
ElMessage({
type: 'success',
@@ -1908,7 +1976,8 @@ const handleBusBarTabsEdit = (targetName: any, action: any) => {
? (deviceInfoList.value.length - 1).toString()
: '0'
lineIndex.value = '0'
TerminalRef.value.info()
pageStatus.value = 1
treedata()
})
} else {
// 如果是新增模式下删除未保存的设备
@@ -1958,8 +2027,8 @@ const handleLineTabsEdit = (targetName: any, action: any) => {
type: 'warning'
}).then(() => {
// 如果是编辑现有监测点
if (pageStatus.value === 3 && lineInfoList.value[lineIndex.value]?.id) {
deleteLine(lineInfoList.value[lineIndex.value].id).then((res: any) => {
if (lineInfoList.value[lineIndex.value]?.lineId) {
deleteLine(lineInfoList.value[lineIndex.value].lineId).then((res: any) => {
ElMessage({
type: 'success',
message: res.message
@@ -1970,7 +2039,8 @@ const handleLineTabsEdit = (targetName: any, action: any) => {
lineIndex.value = lineInfoList.value.length
? (lineInfoList.value.length - 1).toString()
: '0'
TerminalRef.value.info()
pageStatus.value = 1
treedata()
})
} else {
// 如果是新增模式下删除未保存的监测点
@@ -1991,6 +2061,7 @@ const handleLineTabsEdit = (targetName: any, action: any) => {
})
}
}
const tabChange = (type: string) => {
if (type == 'deviceIndex') {
busBarIndex.value = '0'
@@ -2006,6 +2077,9 @@ const treedata = (selectedNodeId?: string) => {
} else {
TerminalRef.value.info();
}
titleList.value = []
titleList.value.unshift('在线设备')
}
/**
* 重置初始状态