在线设备录入校验
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
label-width="120px"
|
||||
:inline="true"
|
||||
ref="mainForm"
|
||||
:model="formData"
|
||||
>
|
||||
<el-form-item
|
||||
id="id100"
|
||||
@@ -112,7 +113,7 @@
|
||||
>
|
||||
<el-select
|
||||
filterable
|
||||
v-model="engineeringParam.province"
|
||||
v-model="formData.engineeringParam.province"
|
||||
:disabled="
|
||||
!((nodeLevel == 1 && pageStatus == 3) || (nodeLevel == 0 && pageStatus == 2))
|
||||
"
|
||||
@@ -137,7 +138,7 @@
|
||||
>
|
||||
<el-select
|
||||
filterable
|
||||
v-model="engineeringParam.city"
|
||||
v-model="formData.engineeringParam.city"
|
||||
:disabled="
|
||||
!((nodeLevel == 1 && pageStatus == 3) || (nodeLevel == 0 && pageStatus == 2))
|
||||
"
|
||||
@@ -160,7 +161,7 @@
|
||||
:rules="{ required: true, message: '请输入工程名称', trigger: 'blur' }"
|
||||
>
|
||||
<el-input
|
||||
v-model="engineeringParam.name"
|
||||
v-model="formData.engineeringParam.name"
|
||||
placeholder="请输入工程名称"
|
||||
:disabled="
|
||||
!((nodeLevel == 1 && pageStatus == 3) || (nodeLevel == 0 && pageStatus == 2))
|
||||
@@ -174,7 +175,7 @@
|
||||
v-if="nodeLevel > 0 || pageStatus == 2"
|
||||
>
|
||||
<el-input
|
||||
v-model="engineeringParam.description"
|
||||
v-model="formData.engineeringParam.description"
|
||||
placeholder="请输入描述"
|
||||
:disabled="
|
||||
!((nodeLevel == 1 && pageStatus == 3) || (nodeLevel == 0 && pageStatus == 2))
|
||||
@@ -192,7 +193,7 @@
|
||||
@tab-click="tabChange('deviceIndex')"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="(item, index) in projectInfoList"
|
||||
v-for="(item, index) in formData.projectInfoList"
|
||||
:key="index"
|
||||
:label="item.name ? item.name : '新建项目' + index"
|
||||
:name="index + ''"
|
||||
@@ -201,6 +202,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="项目名称:"
|
||||
:prop="'projectInfoList[' + index + '].name'"
|
||||
:rules="[
|
||||
{ required: true, message: '请输入项目名称', trigger: 'blur' }
|
||||
]"
|
||||
@@ -220,6 +222,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="地市:"
|
||||
:prop="'projectInfoList[' + index + '].area'"
|
||||
:rules="[{ required: true, message: '请输入地市', trigger: 'blur' }]"
|
||||
>
|
||||
<el-input
|
||||
@@ -237,6 +240,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="描述:"
|
||||
:prop="'projectInfoList[' + index + '].description'"
|
||||
:rules="[{ required: true, message: '请输入描述', trigger: 'blur' }]"
|
||||
>
|
||||
<el-input
|
||||
@@ -270,7 +274,7 @@
|
||||
@tab-click="tabChange('busBarIndex')"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="(busItem, bIndex) in deviceInfoList"
|
||||
v-for="(busItem, bIndex) in formData.deviceInfoList"
|
||||
:key="bIndex"
|
||||
:label="busItem.name ? busItem.name : '新建装置' + bIndex"
|
||||
:name="bIndex + ''"
|
||||
@@ -279,6 +283,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="装置名称:"
|
||||
:prop="'deviceInfoList[' + bIndex + '].name'"
|
||||
:rules="[
|
||||
{ required: true, message: '请输入装置名称', trigger: 'blur' }
|
||||
]"
|
||||
@@ -299,6 +304,7 @@
|
||||
id="id200"
|
||||
class="form-item"
|
||||
label="装置类型:"
|
||||
:prop="'deviceInfoList[' + bIndex + '].devType'"
|
||||
:rules="[
|
||||
{ required: true, message: '请选择装置类型', trigger: 'change' }
|
||||
]"
|
||||
@@ -328,6 +334,7 @@
|
||||
id="id200"
|
||||
class="form-item"
|
||||
label="装置型号:"
|
||||
:prop="'deviceInfoList[' + bIndex + '].devModel'"
|
||||
:rules="[
|
||||
{ required: true, message: '请选择装置型号', trigger: 'change' }
|
||||
]"
|
||||
@@ -357,6 +364,7 @@
|
||||
id="id200"
|
||||
class="form-item"
|
||||
label="装置接入方式:"
|
||||
:prop="'deviceInfoList[' + bIndex + '].devAccessMethod'"
|
||||
:rules="[
|
||||
{ required: true, message: '请选择装置接入方式', trigger: 'change' }
|
||||
]"
|
||||
@@ -381,6 +389,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="装置mac地址:"
|
||||
:prop="'deviceInfoList[' + bIndex + '].mac'"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请输入装置mac地址',
|
||||
@@ -404,7 +413,7 @@
|
||||
placeholder="请输入网络设备ID"
|
||||
></el-input>
|
||||
</el-form-item> -->
|
||||
<el-form-item class="form-item" label="合同号:">
|
||||
<el-form-item class="form-item" label="合同号:" :prop="'deviceInfoList[' + bIndex + '].cntractNo'">
|
||||
<el-input
|
||||
v-model="busItem.cntractNo"
|
||||
placeholder="请输入合同号"
|
||||
@@ -420,6 +429,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="所属前置机:"
|
||||
:prop="'deviceInfoList[' + bIndex + '].nodeId'"
|
||||
:rules="[
|
||||
{ required: true, message: '请选择所属前置机', trigger: 'change' }
|
||||
]"
|
||||
@@ -438,7 +448,7 @@
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item class="form-item" label="进程号:">
|
||||
<el-form-item class="form-item" label="进程号:" :prop="'deviceInfoList[' + bIndex + '].nodeProcess'">
|
||||
<el-input
|
||||
v-model="busItem.nodeProcess"
|
||||
placeholder="自动分配"
|
||||
@@ -449,6 +459,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="排序:"
|
||||
:prop="'deviceInfoList[' + bIndex + '].sort'"
|
||||
:rules="[{ required: true, message: '请输入排序', trigger: 'blur' }]"
|
||||
>
|
||||
<el-input
|
||||
@@ -482,7 +493,7 @@
|
||||
@tab-click="tabChange('lineIndex')"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="(lineItem, lIndex) in lineInfoList"
|
||||
v-for="(lineItem, lIndex) in formData.lineInfoList"
|
||||
:key="lIndex"
|
||||
:label="lineItem.name ? lineItem.name : '新建监测点' + lIndex"
|
||||
:name="lIndex + ''"
|
||||
@@ -491,6 +502,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="监测点名称:"
|
||||
:prop="'lineInfoList[' + lIndex + '].name'"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请输入监测点名称',
|
||||
@@ -512,6 +524,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="线路号:"
|
||||
:prop="'lineInfoList[' + lIndex + '].lineNo'"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请选择线路号',
|
||||
@@ -541,6 +554,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="接线方式:"
|
||||
:prop="'lineInfoList[' + lIndex + '].conType'"
|
||||
:rules="{ required: true, message: '请选择接线方式', trigger: 'blur' }"
|
||||
>
|
||||
<el-select
|
||||
@@ -566,6 +580,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="统计间隔:"
|
||||
:prop="'lineInfoList[' + lIndex + '].lineInterval'"
|
||||
:rules="{ required: true, message: '请选择统计间隔', trigger: 'blur' }"
|
||||
>
|
||||
<el-select
|
||||
@@ -591,6 +606,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="PT变比:"
|
||||
:prop="'lineInfoList[' + lIndex + '].ptRatio'"
|
||||
:rules="{ required: true, message: '请输入pt', trigger: 'blur' }"
|
||||
>
|
||||
<div style="width: 100%; display: flex; justify-content: space-between">
|
||||
@@ -636,6 +652,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="CT变比:"
|
||||
:prop="'lineInfoList[' + lIndex + '].ctRatio'"
|
||||
:rules="{ required: true, message: '请输入ct', trigger: 'blur' }"
|
||||
>
|
||||
<div style="width: 100%; display: flex; justify-content: space-between">
|
||||
@@ -679,7 +696,7 @@
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item class="form-item" label="基准容量(MVA):" :rules="{ required: true, message: '请输入基准容量', trigger: 'blur' }">
|
||||
<el-form-item class="form-item" label="基准容量(MVA):" :prop="'lineInfoList[' + lIndex + '].basicCapacity'" :rules="{ required: true, message: '请输入基准容量', trigger: 'blur' }">
|
||||
<el-input-number
|
||||
:controls="false"
|
||||
:min="0"
|
||||
@@ -698,6 +715,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="短路容量(MVA):"
|
||||
:prop="'lineInfoList[' + lIndex + '].shortCircuitCapacity'"
|
||||
:rules="{ required: true, message: '请输入短路容量', trigger: 'blur' }"
|
||||
>
|
||||
<el-input-number
|
||||
@@ -718,6 +736,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="设备容量(MW):"
|
||||
:prop="'lineInfoList[' + lIndex + '].devCapacity'"
|
||||
:rules="{ required: true, message: '请输入设备容量', trigger: 'blur' }"
|
||||
>
|
||||
<el-input-number
|
||||
@@ -738,6 +757,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="协议容量(MW):"
|
||||
:prop="'lineInfoList[' + lIndex + '].protocolCapacity'"
|
||||
:rules="{ required: true, message: '请输入协议容量', trigger: 'blur' }"
|
||||
>
|
||||
<el-input-number
|
||||
@@ -759,6 +779,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="电压等级:"
|
||||
:prop="'lineInfoList[' + lIndex + '].volGrade'"
|
||||
:rules="{ required: true, message: '请选择电压等级', trigger: 'blur' }"
|
||||
>
|
||||
<el-select
|
||||
@@ -784,6 +805,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="用户对象:"
|
||||
:prop="'lineInfoList[' + lIndex + '].monitorUser'"
|
||||
:rules="{ required: true, message: '请选择用户对象', trigger: 'blur' }"
|
||||
>
|
||||
<el-select
|
||||
@@ -809,6 +831,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="监测对象类型:"
|
||||
:prop="'lineInfoList[' + lIndex + '].monitorObj'"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请选择监测对象类型',
|
||||
@@ -838,6 +861,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="是否治理:"
|
||||
:prop="'lineInfoList[' + lIndex + '].govern'"
|
||||
:rules="{ required: true, message: '请选择是否治理', trigger: 'blur' }"
|
||||
>
|
||||
<el-select
|
||||
@@ -859,6 +883,7 @@
|
||||
<el-form-item
|
||||
class="form-item"
|
||||
label="运行状态:"
|
||||
:prop="'lineInfoList[' + lIndex + '].runStatus'"
|
||||
:rules="{ required: true, message: '请选择运行状态', trigger: 'blur' }"
|
||||
>
|
||||
<!-- (0:运行;1:检修;2:停运;3:调试;4:退运) -->
|
||||
@@ -1016,6 +1041,20 @@ const devTypeOptions2: any = ref([])
|
||||
const treeClickCount = ref(0)
|
||||
const areaTree: any = tree
|
||||
|
||||
const formData = ref({
|
||||
lineInfoList: [] as LineInfo[],
|
||||
projectInfoList:[] as ProjectInfo[],
|
||||
deviceInfoList :[] as DeviceInfo[],
|
||||
engineeringParam: {
|
||||
city: '',
|
||||
description: '',
|
||||
name: '',
|
||||
province: ''
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
const project = ref([
|
||||
{ name: '治理设备', value: '治理设备' },
|
||||
{ name: '便携式设备', value: '便携式设备' },
|
||||
@@ -1043,12 +1082,12 @@ const lineSpaceArr = ref([
|
||||
{ name: '10分钟', value: 10 }
|
||||
])
|
||||
//工程
|
||||
const engineeringParam = ref({
|
||||
city: '',
|
||||
description: '',
|
||||
name: '',
|
||||
province: ''
|
||||
})
|
||||
// const engineeringParam = ref({
|
||||
// city: '',
|
||||
// description: '',
|
||||
// name: '',
|
||||
// province: ''
|
||||
// })
|
||||
|
||||
interface ProjectInfo {
|
||||
name: string
|
||||
@@ -1056,7 +1095,7 @@ interface ProjectInfo {
|
||||
description: string
|
||||
}
|
||||
// 项目信息列表
|
||||
const projectInfoList = ref<ProjectInfo[]>([])
|
||||
//const projectInfoList = ref<ProjectInfo[]>([])
|
||||
interface DeviceInfo {
|
||||
name: string
|
||||
devModel: string
|
||||
@@ -1070,7 +1109,7 @@ interface DeviceInfo {
|
||||
nodeProcess: string
|
||||
}
|
||||
// 设备信息列表
|
||||
const deviceInfoList = ref<DeviceInfo[]>([])
|
||||
//const deviceInfoList = ref<DeviceInfo[]>([])
|
||||
interface LineInfo {
|
||||
name: string
|
||||
lineNo: number
|
||||
@@ -1092,7 +1131,7 @@ interface LineInfo {
|
||||
protocolCapacity: number
|
||||
}
|
||||
// 监测点信息列表
|
||||
const lineInfoList = ref<LineInfo[]>([])
|
||||
//const lineInfoList = ref<LineInfo[]>([])
|
||||
const arrdess: any = ref((rule: any, value: any, callback: any) => {
|
||||
let reg1 =
|
||||
/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
|
||||
@@ -1116,8 +1155,8 @@ const arrdess: any = ref((rule: any, value: any, callback: any) => {
|
||||
// 省市选择相关数据
|
||||
const provinceOptions = computed(() => areaTree)
|
||||
const cityOptions = computed(() => {
|
||||
if (engineeringParam.value.province) {
|
||||
const province = areaTree.find((item: any) => item.value === engineeringParam.value.province)
|
||||
if (formData.value.engineeringParam.province) {
|
||||
const province = areaTree.find((item: any) => item.value === formData.value.engineeringParam.province)
|
||||
return province ? province.children : []
|
||||
}
|
||||
return []
|
||||
@@ -1144,7 +1183,7 @@ const voltageLevelOptions = computed(() => {
|
||||
|
||||
// 省改变时清空市的选择
|
||||
const provinceChange = () => {
|
||||
engineeringParam.value.city = ''
|
||||
formData.value.engineeringParam.city = ''
|
||||
}
|
||||
// 临时存储所有层级的数据
|
||||
const tempAllLevelData = ref<any>({
|
||||
@@ -1204,13 +1243,13 @@ const nodeClick = (e: anyObj, data: any) => {
|
||||
// 关键修改:确保tabs展开
|
||||
setTimeout(() => {
|
||||
// 设置默认选中的tab索引
|
||||
if (nodeLevel.value >= 2 && projectInfoList.value.length > 0) {
|
||||
if (nodeLevel.value >= 2 && formData.value.projectInfoList.length > 0) {
|
||||
deviceIndex.value = '0'
|
||||
}
|
||||
if (nodeLevel.value >= 3 && deviceInfoList.value.length > 0) {
|
||||
if (nodeLevel.value >= 3 && formData.value.deviceInfoList.length > 0) {
|
||||
busBarIndex.value = '0'
|
||||
}
|
||||
if (nodeLevel.value >= 4 && lineInfoList.value.length > 0) {
|
||||
if (nodeLevel.value >= 4 && formData.value.lineInfoList.length > 0) {
|
||||
lineIndex.value = '0'
|
||||
}
|
||||
}, 100)
|
||||
@@ -1318,18 +1357,18 @@ const cleanUnnecessaryData = () => {
|
||||
switch (nodeLevel.value) {
|
||||
case 0: // 根节点
|
||||
// 清理所有数据
|
||||
projectInfoList.value = []
|
||||
deviceInfoList.value = []
|
||||
lineInfoList.value = []
|
||||
formData.value.projectInfoList = []
|
||||
formData.value.deviceInfoList = []
|
||||
formData.value.lineInfoList = []
|
||||
break
|
||||
case 1: // 工程节点
|
||||
// 清理设备和监测点数据
|
||||
deviceInfoList.value = []
|
||||
lineInfoList.value = []
|
||||
formData.value.deviceInfoList = []
|
||||
formData.value.lineInfoList = []
|
||||
break
|
||||
case 2: // 项目节点
|
||||
// 清理监测点数据
|
||||
lineInfoList.value = []
|
||||
formData.value.lineInfoList = []
|
||||
break
|
||||
case 3: // 设备节点
|
||||
// 不清理任何数据
|
||||
@@ -1377,17 +1416,17 @@ const queryNodeContent = () => {
|
||||
}
|
||||
|
||||
getInfoById(nodeData.value.id).then((res: any) => {
|
||||
Object.assign(engineeringParam.value, res.data)
|
||||
engineeringParam.value.name = res.data.engineeringName
|
||||
engineeringParam.value.description = res.data.engineeringDescription
|
||||
projectInfoList.value = res.data.projectInfoList || []
|
||||
Object.assign(formData.value.engineeringParam, res.data)
|
||||
formData.value.engineeringParam.name = res.data.engineeringName
|
||||
formData.value.engineeringParam.description = res.data.engineeringDescription
|
||||
formData.value.projectInfoList = res.data.projectInfoList || []
|
||||
|
||||
if (nodeLevel.value >= 2) {
|
||||
deviceInfoList.value = res.data.deviceInfoList || []
|
||||
formData.value.deviceInfoList = res.data.deviceInfoList || []
|
||||
}
|
||||
if (nodeLevel.value >= 3) {
|
||||
lineInfoList.value = res.data.lineInfoList || []
|
||||
lineInfoList.value.map((item: any) => {
|
||||
formData.value.lineInfoList = res.data.lineInfoList || []
|
||||
formData.value.lineInfoList.map((item: any) => {
|
||||
item.volGrade = item.volGrade + 'kV'
|
||||
})
|
||||
}
|
||||
@@ -1409,30 +1448,30 @@ const add = () => {
|
||||
switch (nodeLevel.value) {
|
||||
case 0: // 新增工程,不需要添加tab
|
||||
// 初始化工程参数
|
||||
engineeringParam.value.city = ''
|
||||
engineeringParam.value.description = ''
|
||||
engineeringParam.value.name = ''
|
||||
engineeringParam.value.province = ''
|
||||
formData.value.engineeringParam.city = ''
|
||||
formData.value.engineeringParam.description = ''
|
||||
formData.value.engineeringParam.name = ''
|
||||
formData.value.engineeringParam.province = ''
|
||||
// 清理其他层级数据
|
||||
projectInfoList.value = []
|
||||
deviceInfoList.value = []
|
||||
lineInfoList.value = []
|
||||
formData.value.projectInfoList = []
|
||||
formData.value.deviceInfoList = []
|
||||
formData.value.lineInfoList = []
|
||||
break
|
||||
case 1: // 新增项目,添加一个新的项目tab
|
||||
// 添加一个新的空项目到projectInfoList
|
||||
projectInfoList.value.push({
|
||||
formData.value.projectInfoList.push({
|
||||
name: '',
|
||||
area: '',
|
||||
description: ''
|
||||
})
|
||||
deviceIndex.value = (projectInfoList.value.length - 1).toString()
|
||||
deviceIndex.value = (formData.value.projectInfoList.length - 1).toString()
|
||||
// 清理设备和监测点数据
|
||||
deviceInfoList.value = []
|
||||
lineInfoList.value = []
|
||||
formData.value.deviceInfoList = []
|
||||
formData.value.lineInfoList = []
|
||||
break
|
||||
case 2: // 新增设备,添加一个新的设备tab
|
||||
// 添加一个新的空设备到deviceInfoList
|
||||
deviceInfoList.value.push({
|
||||
formData.value.deviceInfoList.push({
|
||||
name: '',
|
||||
devModel: '',
|
||||
devType: '',
|
||||
@@ -1444,13 +1483,13 @@ const add = () => {
|
||||
sort: 0,
|
||||
nodeProcess: ''
|
||||
})
|
||||
busBarIndex.value = (deviceInfoList.value.length - 1).toString()
|
||||
busBarIndex.value = (formData.value.deviceInfoList.length - 1).toString()
|
||||
// 清理监测点数据
|
||||
lineInfoList.value = []
|
||||
formData.value.lineInfoList = []
|
||||
break
|
||||
case 3: // 新增监测点,添加一个新的监测点tab
|
||||
// 添加一个新的空监测点到lineInfoList
|
||||
lineInfoList.value.push({
|
||||
formData.value.lineInfoList.push({
|
||||
name: '',
|
||||
lineNo: 1,
|
||||
conType: 0,
|
||||
@@ -1470,7 +1509,7 @@ const add = () => {
|
||||
devCapacity: 0,
|
||||
protocolCapacity: 0
|
||||
})
|
||||
lineIndex.value = (lineInfoList.value.length - 1).toString()
|
||||
lineIndex.value = (formData.value.lineInfoList.length - 1).toString()
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -1514,7 +1553,7 @@ const update = () => {
|
||||
*/
|
||||
const updateEngineering = (id: any) => {
|
||||
// 获取工程信息
|
||||
const engData = engineeringParam.value
|
||||
const engData = formData.value.engineeringParam
|
||||
|
||||
// 构建工程修改数据结构
|
||||
const engineeringData = {
|
||||
@@ -1539,7 +1578,7 @@ const updateEngineering = (id: any) => {
|
||||
*/
|
||||
const updateProjectFunc = (id: any) => {
|
||||
// 获取当前选中的项目信息
|
||||
const currentProject = projectInfoList.value[deviceIndex.value]
|
||||
const currentProject = formData.value.projectInfoList[deviceIndex.value]
|
||||
if (!currentProject) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
@@ -1562,7 +1601,7 @@ const updateProjectFunc = (id: any) => {
|
||||
*/
|
||||
const updateEquipmentFunc = (id: any) => {
|
||||
// 获取当前选中的设备信息
|
||||
const currentDevice = deviceInfoList.value[busBarIndex.value]
|
||||
const currentDevice = formData.value.deviceInfoList[busBarIndex.value]
|
||||
if (!currentDevice) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
@@ -1600,7 +1639,7 @@ const updateEquipmentFunc = (id: any) => {
|
||||
*/
|
||||
const updateLineFunc = (id: any) => {
|
||||
// 获取当前选中的监测点信息
|
||||
const currentLine = lineInfoList.value[lineIndex.value]
|
||||
const currentLine = formData.value.lineInfoList[lineIndex.value]
|
||||
if (!currentLine) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
@@ -1618,11 +1657,11 @@ const updateLineFunc = (id: any) => {
|
||||
// 获取设备MAC地址和设备ID
|
||||
let devMac = ''
|
||||
let devId = ''
|
||||
if (deviceInfoList.value && deviceInfoList.value[busBarIndex.value]) {
|
||||
devMac = deviceInfoList.value[busBarIndex.value].mac || ''
|
||||
if (formData.value.deviceInfoList && formData.value.deviceInfoList[busBarIndex.value]) {
|
||||
devMac = formData.value.deviceInfoList[busBarIndex.value].mac || ''
|
||||
// 如果有设备ID,也获取它
|
||||
if (deviceInfoList.value[busBarIndex.value].id) {
|
||||
devId = deviceInfoList.value[busBarIndex.value].id || ''
|
||||
if (formData.value.deviceInfoList[busBarIndex.value].id) {
|
||||
devId = formData.value.deviceInfoList[busBarIndex.value].id || ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1776,29 +1815,31 @@ const remove = () => {
|
||||
}
|
||||
// 下一步
|
||||
const next = async () => {
|
||||
await mainForm.value.validate((valid: any) => {
|
||||
if (valid) {
|
||||
// 在新增模式下(pageStatus == 2)保存当前数据并创建下一个层级的Tab
|
||||
switch (nodeLevel.value) {
|
||||
case 0: // 工程层级,下一步创建项目Tab
|
||||
// 保存当前工程信息到临时存储
|
||||
tempAllLevelData.value.engineering = { ...engineeringParam.value }
|
||||
tempAllLevelData.value.engineering = { ...formData.value.engineeringParam }
|
||||
|
||||
// 创建新的项目Tab
|
||||
projectInfoList.value.push({
|
||||
formData.value.projectInfoList.push({
|
||||
name: '',
|
||||
area: '',
|
||||
description: ''
|
||||
})
|
||||
deviceIndex.value = (projectInfoList.value.length - 1).toString()
|
||||
deviceIndex.value = (formData.value.projectInfoList.length - 1).toString()
|
||||
nextfalg.value = false
|
||||
nodeLevel.value = 1
|
||||
break
|
||||
case 1: // 项目层级,下一步创建设备Tab
|
||||
// 保存当前项目信息到临时存储
|
||||
const currentProject = { ...projectInfoList.value[deviceIndex.value] }
|
||||
const currentProject = { ...formData.value.projectInfoList[deviceIndex.value] }
|
||||
tempAllLevelData.value.projects[deviceIndex.value] = currentProject
|
||||
|
||||
// 创建新的设备Tab
|
||||
deviceInfoList.value.push({
|
||||
formData.value.deviceInfoList.push({
|
||||
name: '',
|
||||
devModel: '',
|
||||
devType: '',
|
||||
@@ -1810,17 +1851,17 @@ const next = async () => {
|
||||
sort: 0,
|
||||
nodeProcess: ''
|
||||
})
|
||||
busBarIndex.value = (deviceInfoList.value.length - 1).toString()
|
||||
busBarIndex.value = (formData.value.deviceInfoList.length - 1).toString()
|
||||
nextfalg.value = false
|
||||
nodeLevel.value = 2
|
||||
break
|
||||
case 2: // 设备层级,下一步创建监测点Tab
|
||||
// 保存当前设备信息到临时存储
|
||||
const currentDevice = { ...deviceInfoList.value[busBarIndex.value] }
|
||||
const currentDevice = { ...formData.value.deviceInfoList[busBarIndex.value] }
|
||||
tempAllLevelData.value.devices[busBarIndex.value] = currentDevice
|
||||
|
||||
// 创建新的监测点Tab
|
||||
lineInfoList.value.push({
|
||||
formData.value.lineInfoList.push({
|
||||
name: '',
|
||||
lineNo: 1,
|
||||
conType: 0,
|
||||
@@ -1840,13 +1881,13 @@ const next = async () => {
|
||||
devCapacity: 0,
|
||||
protocolCapacity: 0
|
||||
})
|
||||
lineIndex.value = (lineInfoList.value.length - 1).toString()
|
||||
lineIndex.value = (formData.value.lineInfoList.length - 1).toString()
|
||||
nextfalg.value = true
|
||||
nodeLevel.value = 3
|
||||
break
|
||||
case 3: // 监测点层级
|
||||
// 保存当前监测点信息到临时存储
|
||||
const currentLine = { ...lineInfoList.value[lineIndex.value] }
|
||||
const currentLine = { ...formData.value.lineInfoList[lineIndex.value] }
|
||||
tempAllLevelData.value.lines[lineIndex.value] = currentLine
|
||||
|
||||
nextfalg.value = true
|
||||
@@ -1854,6 +1895,9 @@ const next = async () => {
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// 撤销
|
||||
const black = () => {
|
||||
@@ -1874,7 +1918,9 @@ const black = () => {
|
||||
}
|
||||
|
||||
// 确认提交
|
||||
const onsubmit = () => {
|
||||
const onsubmit = async () => {
|
||||
await mainForm.value.validate((valid: any) => {
|
||||
if (valid) {
|
||||
if (pageStatus.value == 2) {
|
||||
// 新增
|
||||
// 检查是否是多层级新增还是单层级新增
|
||||
@@ -1909,29 +1955,33 @@ const onsubmit = () => {
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次性提交所有层级数据
|
||||
*/
|
||||
const submitAllLevelData = () => {
|
||||
const submitAllLevelData = async () => {
|
||||
let submitData: any = {}
|
||||
|
||||
await mainForm.value.validate((valid: any) => {
|
||||
if (valid) {
|
||||
// 根据当前节点层级构建相应的数据结构
|
||||
switch (nodeLevel.value) {
|
||||
case 0: // 只有工程
|
||||
submitData = {
|
||||
engineering: tempAllLevelData.value.engineering || { ...engineeringParam.value }
|
||||
engineering: tempAllLevelData.value.engineering || { ...formData.value.engineeringParam }
|
||||
}
|
||||
break
|
||||
|
||||
case 1: // 工程 + 项目
|
||||
// 工程信息
|
||||
const engineeringData = tempAllLevelData.value.engineering || { ...engineeringParam.value }
|
||||
const engineeringData = tempAllLevelData.value.engineering || { ...formData.value.engineeringParam }
|
||||
|
||||
// 项目信息
|
||||
const projectData =
|
||||
tempAllLevelData.value.projects.length > 0
|
||||
? tempAllLevelData.value.projects.find(project => project !== undefined) || {}
|
||||
: projectInfoList.value[0] || {}
|
||||
: formData.value.projectInfoList[0] || {}
|
||||
// 如果是从根节点开始新增工程和项目
|
||||
if (nodeData.value.level === 0) {
|
||||
submitData = {
|
||||
@@ -1949,19 +1999,19 @@ const submitAllLevelData = () => {
|
||||
|
||||
case 2: // 工程 + 项目 + 设备
|
||||
// 工程信息
|
||||
const engineeringData2 = tempAllLevelData.value.engineering || { ...engineeringParam.value }
|
||||
const engineeringData2 = tempAllLevelData.value.engineering || { ...formData.value.engineeringParam }
|
||||
// 项目信息
|
||||
const projectData2 =
|
||||
tempAllLevelData.value.projects.length > 0
|
||||
? tempAllLevelData.value.projects.find(project => project !== undefined) || {}
|
||||
: projectInfoList.value[0] || {}
|
||||
: formData.value.projectInfoList[0] || {}
|
||||
|
||||
// 设备信息
|
||||
let devices = []
|
||||
if (tempAllLevelData.value.devices.length > 0) {
|
||||
devices = tempAllLevelData.value.devices.filter((d: any) => d && d.name)
|
||||
} else {
|
||||
devices = deviceInfoList.value.filter((d: any) => d && d.name)
|
||||
devices = formData.value.deviceInfoList.filter((d: any) => d && d.name)
|
||||
}
|
||||
|
||||
// 如果是从根节点开始新增
|
||||
@@ -2005,20 +2055,20 @@ const submitAllLevelData = () => {
|
||||
case 3: // 工程 + 项目 + 设备 + 监测点
|
||||
case 4:
|
||||
// 工程信息
|
||||
const engineeringData3 = tempAllLevelData.value.engineering || { ...engineeringParam.value }
|
||||
const engineeringData3 = tempAllLevelData.value.engineering || { ...formData.value.engineeringParam }
|
||||
|
||||
// 项目信息
|
||||
const projectData3 =
|
||||
tempAllLevelData.value.projects.length > 0
|
||||
? tempAllLevelData.value.projects.find(project => project !== undefined) || {}
|
||||
: projectInfoList.value[0] || {}
|
||||
: formData.value.projectInfoList[0] || {}
|
||||
|
||||
// 设备信息
|
||||
let devices2: any[] = []
|
||||
if (tempAllLevelData.value.devices.length > 0) {
|
||||
devices2 = tempAllLevelData.value.devices.filter((d: any) => d && d.name)
|
||||
} else {
|
||||
devices2 = deviceInfoList.value.filter((d: any) => d && d.name)
|
||||
devices2 = formData.value.deviceInfoList.filter((d: any) => d && d.name)
|
||||
}
|
||||
|
||||
// 监测点信息
|
||||
@@ -2026,7 +2076,7 @@ const submitAllLevelData = () => {
|
||||
if (tempAllLevelData.value.lines.length > 0) {
|
||||
lines = tempAllLevelData.value.lines.filter((l: any) => l && l.name)
|
||||
} else {
|
||||
lines = lineInfoList.value.filter((l: any) => l && l.name)
|
||||
lines = formData.value.lineInfoList.filter((l: any) => l && l.name)
|
||||
}
|
||||
|
||||
// 如果是从根节点开始新增
|
||||
@@ -2201,26 +2251,30 @@ const submitAllLevelData = () => {
|
||||
}
|
||||
}, 100)
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
/**
|
||||
* 重置所有表单
|
||||
*/
|
||||
const resetAllForms = () => {
|
||||
// 清空工程表单
|
||||
engineeringParam.value.city = ''
|
||||
engineeringParam.value.description = ''
|
||||
engineeringParam.value.name = ''
|
||||
engineeringParam.value.province = ''
|
||||
formData.value.engineeringParam.city = ''
|
||||
formData.value.engineeringParam.description = ''
|
||||
formData.value.engineeringParam.name = ''
|
||||
formData.value.engineeringParam.province = ''
|
||||
|
||||
// 清空项目表单
|
||||
projectInfoList.value.forEach(project => {
|
||||
formData.value.projectInfoList.forEach(project => {
|
||||
project.name = ''
|
||||
project.area = ''
|
||||
project.description = ''
|
||||
})
|
||||
|
||||
// 清空设备表单
|
||||
deviceInfoList.value.forEach(device => {
|
||||
formData.value.deviceInfoList.forEach(device => {
|
||||
device.name = ''
|
||||
device.devModel = ''
|
||||
device.devType = ''
|
||||
@@ -2232,7 +2286,7 @@ const resetAllForms = () => {
|
||||
})
|
||||
|
||||
// 清空监测点表单
|
||||
lineInfoList.value.forEach(line => {
|
||||
formData.value.lineInfoList.forEach(line => {
|
||||
line.name = ''
|
||||
line.lineNo = 1
|
||||
line.conType = 0
|
||||
@@ -2269,10 +2323,10 @@ const submitData = () => {
|
||||
case 0: // 新增工程
|
||||
const engineering = {
|
||||
engineering: {
|
||||
city: engineeringParam.value.city,
|
||||
description: engineeringParam.value.description,
|
||||
name: engineeringParam.value.name,
|
||||
province: engineeringParam.value.province
|
||||
city: formData.value.engineeringParam.city,
|
||||
description: formData.value.engineeringParam.description,
|
||||
name: formData.value.engineeringParam.name,
|
||||
province: formData.value.engineeringParam.province
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2292,9 +2346,9 @@ const submitData = () => {
|
||||
const project = {
|
||||
engineeringIndex: nodeData.value?.id || '',
|
||||
project: {
|
||||
area: projectInfoList.value[deviceIndex.value]?.area || '',
|
||||
description: projectInfoList.value[deviceIndex.value]?.description || '',
|
||||
name: projectInfoList.value[deviceIndex.value]?.name || '',
|
||||
area: formData.value.projectInfoList[deviceIndex.value]?.area || '',
|
||||
description: formData.value.projectInfoList[deviceIndex.value]?.description || '',
|
||||
name: formData.value.projectInfoList[deviceIndex.value]?.name || '',
|
||||
engineeringId: nodeData.value?.id || ''
|
||||
}
|
||||
}
|
||||
@@ -2322,7 +2376,7 @@ const submitData = () => {
|
||||
break
|
||||
case 2: // 新增设备
|
||||
// 获取当前选中的设备信息
|
||||
const currentDevice = deviceInfoList.value[busBarIndex.value]
|
||||
const currentDevice = formData.value.deviceInfoList[busBarIndex.value]
|
||||
if (!currentDevice) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
@@ -2375,7 +2429,7 @@ const submitData = () => {
|
||||
break
|
||||
case 3: // 新增监测点
|
||||
// 获取当前选中的监测点信息
|
||||
const currentLine = lineInfoList.value[lineIndex.value]
|
||||
const currentLine = formData.value.lineInfoList[lineIndex.value]
|
||||
if (!currentLine) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
@@ -2418,7 +2472,7 @@ const submitData = () => {
|
||||
devCapacity: currentLine.devCapacity,
|
||||
protocolCapacity: currentLine.protocolCapacity,
|
||||
volGrade: volGradeValue,
|
||||
devMac: deviceInfoList.value[busBarIndex.value].mac
|
||||
devMac: formData.value.deviceInfoList[busBarIndex.value].mac
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2453,12 +2507,12 @@ const submitData = () => {
|
||||
const handleDeviceTabsEdit = (targetName: any, action: any) => {
|
||||
if (action === 'add') {
|
||||
// 新增项目
|
||||
projectInfoList.value.push({
|
||||
formData.value.projectInfoList.push({
|
||||
name: '',
|
||||
area: '',
|
||||
description: ''
|
||||
})
|
||||
deviceIndex.value = (projectInfoList.value.length - 1).toString()
|
||||
deviceIndex.value = (formData.value.projectInfoList.length - 1).toString()
|
||||
} else if (action === 'remove') {
|
||||
// 删除项目
|
||||
ElMessageBox.confirm('此操作将永久删除, 是否继续?', '提示', {
|
||||
@@ -2468,12 +2522,12 @@ const handleDeviceTabsEdit = (targetName: any, action: any) => {
|
||||
})
|
||||
.then(() => {
|
||||
// 删除项目
|
||||
if (projectInfoList.value[deviceIndex.value]?.id) {
|
||||
if (formData.value.projectInfoList[deviceIndex.value]?.id) {
|
||||
deleteProject(
|
||||
projectInfoList.value[deviceIndex.value].id,
|
||||
projectInfoList.value[deviceIndex.value].name,
|
||||
projectInfoList.value[deviceIndex.value].area,
|
||||
projectInfoList.value[deviceIndex.value].description,
|
||||
formData.value.projectInfoList[deviceIndex.value].id,
|
||||
formData.value.projectInfoList[deviceIndex.value].name,
|
||||
formData.value.projectInfoList[deviceIndex.value].area,
|
||||
formData.value.projectInfoList[deviceIndex.value].description,
|
||||
0 // 0表示删除
|
||||
).then((res: any) => {
|
||||
ElMessage({
|
||||
@@ -2481,10 +2535,10 @@ const handleDeviceTabsEdit = (targetName: any, action: any) => {
|
||||
message: res.message
|
||||
})
|
||||
// 从列表中移除
|
||||
projectInfoList.value.splice(deviceIndex.value, 1)
|
||||
formData.value.projectInfoList.splice(deviceIndex.value, 1)
|
||||
// 重新设置当前选中的tab
|
||||
deviceIndex.value = projectInfoList.value.length
|
||||
? (projectInfoList.value.length - 1).toString()
|
||||
deviceIndex.value = formData.value.projectInfoList.length
|
||||
? (formData.value.projectInfoList.length - 1).toString()
|
||||
: '0'
|
||||
// 重置相关索引
|
||||
busBarIndex.value = '0'
|
||||
@@ -2494,9 +2548,9 @@ const handleDeviceTabsEdit = (targetName: any, action: any) => {
|
||||
})
|
||||
} else {
|
||||
// 如果是新增模式下删除未保存的项目
|
||||
projectInfoList.value.splice(deviceIndex.value, 1)
|
||||
deviceIndex.value = projectInfoList.value.length
|
||||
? (projectInfoList.value.length - 1).toString()
|
||||
formData.value.projectInfoList.splice(deviceIndex.value, 1)
|
||||
deviceIndex.value = formData.value.projectInfoList.length
|
||||
? (formData.value.projectInfoList.length - 1).toString()
|
||||
: '0'
|
||||
busBarIndex.value = '0'
|
||||
lineIndex.value = '0'
|
||||
@@ -2521,7 +2575,7 @@ const handleDeviceTabsEdit = (targetName: any, action: any) => {
|
||||
const handleBusBarTabsEdit = (targetName: any, action: any) => {
|
||||
if (action === 'add') {
|
||||
// 新增设备
|
||||
deviceInfoList.value.push({
|
||||
formData.value.deviceInfoList.push({
|
||||
name: '',
|
||||
devModel: '',
|
||||
devType: '',
|
||||
@@ -2533,7 +2587,7 @@ const handleBusBarTabsEdit = (targetName: any, action: any) => {
|
||||
sort: 0,
|
||||
nodeProcess: ''
|
||||
})
|
||||
busBarIndex.value = (deviceInfoList.value.length - 1).toString()
|
||||
busBarIndex.value = (formData.value.deviceInfoList.length - 1).toString()
|
||||
} else if (action === 'remove') {
|
||||
// 删除设备
|
||||
ElMessageBox.confirm('此操作将永久删除, 是否继续?', '提示', {
|
||||
@@ -2543,17 +2597,17 @@ const handleBusBarTabsEdit = (targetName: any, action: any) => {
|
||||
})
|
||||
.then(() => {
|
||||
// 如果是编辑现有设备
|
||||
if (deviceInfoList.value[busBarIndex.value]?.id) {
|
||||
deleteEquipment(deviceInfoList.value[busBarIndex.value].id).then((res: any) => {
|
||||
if (formData.value.deviceInfoList[busBarIndex.value]?.id) {
|
||||
deleteEquipment(formData.value.deviceInfoList[busBarIndex.value].id).then((res: any) => {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: res.message
|
||||
})
|
||||
// 从列表中移除
|
||||
deviceInfoList.value.splice(busBarIndex.value, 1)
|
||||
formData.value.deviceInfoList.splice(busBarIndex.value, 1)
|
||||
// 重新设置当前选中的tab
|
||||
busBarIndex.value = deviceInfoList.value.length
|
||||
? (deviceInfoList.value.length - 1).toString()
|
||||
busBarIndex.value = formData.value.deviceInfoList.length
|
||||
? (formData.value.deviceInfoList.length - 1).toString()
|
||||
: '0'
|
||||
lineIndex.value = '0'
|
||||
pageStatus.value = 1
|
||||
@@ -2561,8 +2615,8 @@ const handleBusBarTabsEdit = (targetName: any, action: any) => {
|
||||
})
|
||||
} else {
|
||||
// 如果是新增模式下删除未保存的设备
|
||||
deviceInfoList.value.splice(busBarIndex.value, 1)
|
||||
busBarIndex.value = deviceInfoList.value.length ? (deviceInfoList.value.length - 1).toString() : '0'
|
||||
formData.value.deviceInfoList.splice(busBarIndex.value, 1)
|
||||
busBarIndex.value = formData.value.deviceInfoList.length ? (formData.value.deviceInfoList.length - 1).toString() : '0'
|
||||
lineIndex.value = '0'
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
@@ -2585,7 +2639,7 @@ const handleBusBarTabsEdit = (targetName: any, action: any) => {
|
||||
const handleLineTabsEdit = (targetName: any, action: any) => {
|
||||
if (action === 'add') {
|
||||
// 新增监测点
|
||||
lineInfoList.value.push({
|
||||
formData.value.lineInfoList.push({
|
||||
name: '',
|
||||
lineNo: 1,
|
||||
conType: 0,
|
||||
@@ -2605,7 +2659,7 @@ const handleLineTabsEdit = (targetName: any, action: any) => {
|
||||
devCapacity: 0,
|
||||
protocolCapacity: 0
|
||||
})
|
||||
lineIndex.value = (lineInfoList.value.length - 1).toString()
|
||||
lineIndex.value = (formData.value.lineInfoList.length - 1).toString()
|
||||
} else if (action === 'remove') {
|
||||
// 删除监测点
|
||||
ElMessageBox.confirm('此操作将永久删除, 是否继续?', '提示', {
|
||||
@@ -2615,23 +2669,23 @@ const handleLineTabsEdit = (targetName: any, action: any) => {
|
||||
})
|
||||
.then(() => {
|
||||
// 如果是编辑现有监测点
|
||||
if (lineInfoList.value[lineIndex.value]?.lineId) {
|
||||
deleteLine(lineInfoList.value[lineIndex.value].lineId).then((res: any) => {
|
||||
if (formData.value.lineInfoList[lineIndex.value]?.lineId) {
|
||||
deleteLine(formData.value.lineInfoList[lineIndex.value].lineId).then((res: any) => {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: res.message
|
||||
})
|
||||
// 从列表中移除
|
||||
lineInfoList.value.splice(lineIndex.value, 1)
|
||||
formData.value.lineInfoList.splice(lineIndex.value, 1)
|
||||
// 重新设置当前选中的tab
|
||||
lineIndex.value = lineInfoList.value.length ? (lineInfoList.value.length - 1).toString() : '0'
|
||||
lineIndex.value = formData.value.lineInfoList.length ? (formData.value.lineInfoList.length - 1).toString() : '0'
|
||||
pageStatus.value = 1
|
||||
treedata()
|
||||
})
|
||||
} else {
|
||||
// 如果是新增模式下删除未保存的监测点
|
||||
lineInfoList.value.splice(lineIndex.value, 1)
|
||||
lineIndex.value = lineInfoList.value.length ? (lineInfoList.value.length - 1).toString() : '0'
|
||||
formData.value.lineInfoList.splice(lineIndex.value, 1)
|
||||
lineIndex.value = formData.value.lineInfoList.length ? (formData.value.lineInfoList.length - 1).toString() : '0'
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功'
|
||||
|
||||
Reference in New Issue
Block a user