设备保护

This commit is contained in:
白菜
2025-10-28 18:15:10 +08:00
parent 3766b2c0fa
commit 567ddf85a5
2 changed files with 129 additions and 48 deletions

View File

@ -76,3 +76,12 @@ export function getDevicePointList({siteId,deviceId,deviceCategory,parentId,page
method: 'get', method: 'get',
}) })
} }
//获取设备类型下面的所有设备列表
export function getDeviceListBySiteAndCategory({siteId, deviceCategory}) {
return request({
url: `/ems/siteConfig/getDeviceListBySiteAndCategory?siteId=${siteId}&deviceCategory=${deviceCategory}`,
method: 'get',
})
}

View File

@ -40,6 +40,17 @@
> >
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="处理方案描述" prop="description">
<el-input
v-model="formData.description"
type="textarea"
:rows="2"
placeholder="请输入"
clearable
:style="{ width: '50%' }"
>
</el-input>
</el-form-item>
<el-form-item label="是否告警" prop="isAlert"> <el-form-item label="是否告警" prop="isAlert">
<el-checkbox <el-checkbox
v-model="formData.isAlert" v-model="formData.isAlert"
@ -96,17 +107,12 @@
:key="'protectionSettings' + index" :key="'protectionSettings' + index"
> >
<div> <div>
<el-select <el-cascader
v-model="item.deviceCategory" v-model="item.deviceId"
placeholder="请选择设备类型" :show-all-levels="false"
> :options="childOptions"
<el-option @change="(v)=>handleChange(v,'protectionSettings',index)"
v-for="(value, key) in deviceCategoryList" ></el-cascader>
:key="key + 'deviceCategoryList'"
:label="value.name"
:value="value.code"
></el-option>
</el-select>
</div> </div>
<div> <div>
<el-autocomplete <el-autocomplete
@ -214,17 +220,12 @@
:key="'protectionPlan' + index" :key="'protectionPlan' + index"
> >
<div> <div>
<el-select <el-cascader
v-model="item.deviceCategory" v-model="item.deviceId"
placeholder="请选择设备类型" :show-all-levels="false"
> :options="childOptions"
<el-option @change="(v)=>handleChange(v,'protectionPlan',index)"
v-for="(value, key) in deviceCategoryList" ></el-cascader>
:key="key + 'deviceCategoryList'"
:label="value.name"
:value="value.code"
></el-option>
</el-select>
</div> </div>
<div> <div>
<el-autocomplete <el-autocomplete
@ -272,6 +273,7 @@ import {
updateDevice, updateDevice,
addDevice, addDevice,
getParentDeviceId, getParentDeviceId,
getDeviceListBySiteAndCategory
} from "@/api/ems/site"; } from "@/api/ems/site";
import { getAllDeviceCategory, pointFuzzyQuery } from "@/api/ems/search"; import { getAllDeviceCategory, pointFuzzyQuery } from "@/api/ems/search";
export default { export default {
@ -302,6 +304,7 @@ export default {
}; };
return { return {
loading: 0, loading: 0,
childOptions:[],
protectionSettings: [], protectionSettings: [],
protectionPlan: [], protectionPlan: [],
dialogTableVisible: false, dialogTableVisible: false,
@ -314,6 +317,7 @@ export default {
faultLevel: 1, //告警等级 faultLevel: 1, //告警等级
faultDelaySeconds: "", //故障延时 faultDelaySeconds: "", //故障延时
releaseDelaySeconds: "", //释放延时 releaseDelaySeconds: "", //释放延时
description:'',//方案描述
}, },
rules: { rules: {
siteId: [ siteId: [
@ -351,8 +355,8 @@ export default {
handler(newVal) { handler(newVal) {
//打开弹窗 //打开弹窗
if (newVal) { if (newVal) {
this.getZdList();
this.getDeviceCategoryList(); this.getDeviceCategoryList();
this.getZdList();
} }
}, },
immediate: true, immediate: true,
@ -385,19 +389,25 @@ export default {
addRow(type) { addRow(type) {
if (type === "protectionSettings") { if (type === "protectionSettings") {
this.protectionSettings.push({ this.protectionSettings.push({
deviceCategory: "", deviceId:'',//设备ID
point: "", deviceCategory: "",//设备类型 英文
faultValue: "", categoryName:'',//设备类型名称 中文
releaseValue: "", point: "",//点位 英文
faultOperator: "", pointName:"",//点位 中文
releaseOperator: "", faultValue: "",//故障值
relation: "", releaseValue: "",//释放值
faultOperator: "",//故障值比较关系
releaseOperator: "",//释放值比较关系
relationNext: "",//与下一个点位的关系
}); });
} else { } else {
this.protectionPlan.push({ this.protectionPlan.push({
deviceCategory: "", deviceId:"",
deviceCategory: "",//设备类型 英文
categoryName:'',//设备类型名称 中文
point: "", point: "",
value: "", pointName:"",
value: "",//设置值
}); });
} }
}, },
@ -406,6 +416,7 @@ export default {
this[type].splice(index, 1); this[type].splice(index, 1);
}, },
// 设备保护前提、设备保护方案点位选择 // 设备保护前提、设备保护方案点位选择
querySearchAsync(query, cb, index, type) { querySearchAsync(query, cb, index, type) {
console.log("查询数据", query, index); console.log("查询数据", query, index);
@ -429,17 +440,63 @@ export default {
); );
}); });
}, },
// 点位选择
handleSelect(data, index, type) { handleSelect(data, index, type) {
console.log("点位选择", data, "index=", index);
this[type][index].point = data.value; this[type][index].point = data.value;
this[type][index].pointName = data.value;
}, },
// 切换站点 // 获取设备类别-不区分站点
changeType() { getDeviceCategoryList() {
console.log("切换站点"); this.loading += 1;
this.protectionSettings.forEach((item) => (item.point = "")); getAllDeviceCategory()
this.protectionPlan.forEach((item) => (item.point = "")); .then((response) => {
const data = (response?.data || []).filter(item => ['PCS','STACK'].includes(item.code));
this.childOptions=[]
data.forEach((item) => {
this.childOptions.push({
value: item.code,
label: item.name,
children:[]
})
})
console.log('获取设备类型',data,this.childOptions)
})
.finally(() => {
this.loading -= 1;
});
}, },
//获取设备列表-区分站点
getDeviceList(deviceCategory){
this.$nextTick(()=>{
getDeviceListBySiteAndCategory({siteId:this.formData.siteId,deviceCategory}).then((response) => {
const data = response?.data || []
console.log('设置设备列表',this.childOptions)
this.childOptions.find(item=>item.value === deviceCategory).children=data.map(item => {
return {
label: item.deviceName,
value: item.id,
}
})
})
})
},
//更新站点下面的设备列表
updateSiteDeviceList(){
this.childOptions.forEach(item => {
item.children = []
})
this.getDeviceList('PCS')
this.getDeviceList('STACK')
},
//选中设备类型、设备
handleChange([deviceCategory,deviceId],type,index){
this[type][index].deviceId = deviceId;
this[type][index].deviceCategory = deviceCategory;
this[type][index].categoryName = this.childOptions.find(i=>i.value === deviceCategory).label;
console.log('设置选中设备类型、设备',this[type][index])
},
//获取站点列表 //获取站点列表
getZdList() { getZdList() {
this.loading += 1; this.loading += 1;
@ -451,17 +508,29 @@ export default {
this.loading -= 1; this.loading -= 1;
}); });
}, },
// 获取设备类别 // 切换站点
getDeviceCategoryList() { // 重新获取设备列表
this.loading += 1; // 清空选中的设备、点位信息
getAllDeviceCategory() changeType() {
.then((response) => { //获取当前站点下的pcs和bms
this.deviceCategoryList = response?.data || []; this.updateSiteDeviceList()
}) this.protectionSettings.forEach((item) => {
.finally(() => { item.point = ""
this.loading -= 1; item.pointName = ""
}); item.deviceId=''
item.categoryName=''
item.deviceCategory=''
});
this.protectionPlan.forEach((item) => {
item.point = ""
item.pointName = ""
item.deviceId=''
item.categoryName=''
item.deviceCategory=''
});
}, },
saveDialog() { saveDialog() {
this.$refs.addTempForm.validate((valid) => { this.$refs.addTempForm.validate((valid) => {
if (!valid) return; if (!valid) return;
@ -535,6 +604,9 @@ export default {
faultDelaySeconds: "", //故障延时 faultDelaySeconds: "", //故障延时
releaseDelaySeconds: "", //释放延时 releaseDelaySeconds: "", //释放延时
}; };
for(let key in this.formData) {
this.formData[key] = key === 'isAlert' ? 0 : key === 'faultLevel' ? 1 : ''
}
this.$refs.addTempForm.resetFields(); this.$refs.addTempForm.resetFields();
this.dialogTableVisible = false; this.dialogTableVisible = false;
}, },