Files
admin-govern/src/views/govern/device/planData/components/popup.vue

544 lines
19 KiB
Vue
Raw Normal View History

2024-06-24 14:38:42 +08:00
<template>
2024-12-25 10:53:07 +08:00
<el-dialog v-model.trim="dialogVisible" :title="title" draggable
2024-11-19 10:39:46 +08:00
:style="{ width: popupType == 0 || popupType == 1 ? '500px' : '1100px' }">
2024-07-12 16:55:10 +08:00
<!-- 新增方案数据 -->
2024-11-19 10:39:46 +08:00
<el-form :model="form" scroll-to-error label-width="140px" :rules="rules1" ref="ruleFormRef1" class="form-one"
v-if="popupType == 0 || popupType == 1">
2024-07-12 16:55:10 +08:00
<el-form-item label="方案名称:" prop="itemName">
2024-12-25 10:53:07 +08:00
<el-input maxlength="32" show-word-limit v-model.trim="form.itemName" placeholder="请输入方案名称" />
2024-07-12 16:55:10 +08:00
</el-form-item>
<el-form-item label="方案描述:" prop="describe">
2024-12-25 10:53:07 +08:00
<el-input maxlength="300" show-word-limit type="textarea" v-model.trim="form.describe"
2024-12-13 14:36:23 +08:00
placeholder="请输入方案描述" />
2024-07-12 16:55:10 +08:00
</el-form-item>
2024-06-24 14:38:42 +08:00
</el-form>
2024-07-12 16:55:10 +08:00
<!-- 测试项信息&数据绑定页面 -->
2024-12-25 10:53:07 +08:00
<el-tabs type="border-card" v-model.trim="activeName" v-if="popupType != 0 && popupType != 1">
<el-tab-pane label="测试项信息" :name="0" v-if="openType == 'tree'">
2024-11-19 10:39:46 +08:00
<el-form :model="form1" ref="ruleFormRef2" scroll-to-error class="form-two" label-width="140px"
:rules="rules2">
2024-06-24 14:38:42 +08:00
<el-form-item label="测试项名称:" prop="itemName">
2024-12-25 10:53:07 +08:00
<el-input maxlength="32" show-word-limit v-model.trim="form1.itemName" placeholder="请输入测试项名称" />
2024-06-24 14:38:42 +08:00
</el-form-item>
<el-form-item label="测量间隔:" prop="statisticalInterval">
2024-12-25 10:53:07 +08:00
<el-select v-model.trim="form1.statisticalInterval" placeholder="请选择测量间隔" clearable
2024-11-19 10:39:46 +08:00
style="width: 100%">
<el-option v-for="(item, index) in statisticalIntervalList" :key="index" :label="item.name"
:value="item.id"></el-option>
2024-06-24 14:38:42 +08:00
</el-select>
</el-form-item>
<el-form-item label="电压等级:" prop="voltageLevel">
2024-12-25 10:53:07 +08:00
<el-select v-model.trim="form1.voltageLevel" placeholder="请选择电压等级" clearable style="width: 100%"
2024-11-19 10:39:46 +08:00
@change="changeVoltageLevel">
<el-option v-for="(item, index) in voltageLevelList" :key="index" :label="item.name"
:value="item.id"></el-option>
2024-06-24 14:38:42 +08:00
</el-select>
</el-form-item>
<el-form-item label="接线方式:" prop="volConType">
2024-12-25 10:53:07 +08:00
<el-select v-model.trim="form1.volConType" placeholder="请选择接线方式" clearable style="width: 100%">
2024-11-19 10:39:46 +08:00
<el-option v-for="(item, index) in volConTypeList" :key="index" :label="item.name"
:value="item.id"></el-option>
2024-06-24 14:38:42 +08:00
</el-select>
</el-form-item>
<el-form-item label="最小短路容量:" prop="capacitySscmin">
2024-12-25 10:53:07 +08:00
<el-input maxlength="32" show-word-limit v-model.trim="form1.capacitySscmin" oninput="value=value.replace(/[^\-?\d.]/g,'')
2024-06-24 14:38:42 +08:00
.replace(/^\./g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.')
2024-11-19 10:39:46 +08:00
.replace('-','$#$').replace(/\-/g,'').replace('$#$','-')" autocomplete="off" placeholder="请选择最小短路容量">
2024-06-24 14:38:42 +08:00
<template #append>MVA</template>
</el-input>
</el-form-item>
<el-form-item label="用户协议容量:" prop="capacitySi">
2024-12-25 10:53:07 +08:00
<el-input maxlength="32" show-word-limit v-model.trim="form1.capacitySi" autocomplete="off"
oninput="value=value.replace(/[^\-?\d.]/g,'')
2024-06-24 14:38:42 +08:00
.replace(/^\./g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.')
2024-11-19 10:39:46 +08:00
.replace('-','$#$').replace(/\-/g,'').replace('$#$','-')" placeholder="请输入用户协议容量">
2024-06-24 14:38:42 +08:00
<template #append>MVA</template>
</el-input>
</el-form-item>
<el-form-item label="基准短路容量:" prop="capacitySscb">
2024-12-25 10:53:07 +08:00
<el-input maxlength="32" show-word-limit v-model.trim="form1.capacitySscb" oninput="value=value.replace(/[^\-?\d.]/g,'')
2024-06-24 14:38:42 +08:00
.replace(/^\./g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.')
2024-11-19 10:39:46 +08:00
.replace('-','$#$').replace(/\-/g,'').replace('$#$','-')" placeholder="请输入基准短路容量">
2024-06-24 14:38:42 +08:00
<template #append>MVA</template>
</el-input>
</el-form-item>
<el-form-item label="供电设备容量:" prop="capacitySt">
2024-12-25 10:53:07 +08:00
<el-input maxlength="32" show-word-limit v-model.trim="form1.capacitySt" oninput="value=value.replace(/[^\-?\d.]/g,'')
2024-06-24 14:38:42 +08:00
.replace(/^\./g,'').replace('.','$#$').replace(/\./g,'').replace('$#$','.')
2024-11-19 10:39:46 +08:00
.replace('-','$#$').replace(/\-/g,'').replace('$#$','-')" placeholder="请输入供电设备容量">
2024-06-24 14:38:42 +08:00
<template #append>MVA</template>
</el-input>
</el-form-item>
<el-form-item label="PT变比" prop="pt">
2024-12-25 10:53:07 +08:00
<el-input maxlength="32" show-word-limit style="width: 48%" v-model.trim="form1.pt"
2024-12-13 14:36:23 +08:00
autocomplete="off" placeholder="请输入PT变比" oninput="value=value.replace(/[^0-9.]/g,'')" />
2024-12-25 10:53:07 +08:00
<el-input maxlength="32" show-word-limit style="width: 48%" v-model.trim="form1.pt1"
2024-12-13 14:36:23 +08:00
autocomplete="off" placeholder="请输入PT变比" oninput="value=value.replace(/[^0-9.]/g,'')" />
2024-06-24 14:38:42 +08:00
</el-form-item>
<el-form-item label="CT变比" prop="ct">
2024-12-25 10:53:07 +08:00
<el-input maxlength="32" show-word-limit v-model.trim="form1.ct" style="width: 48%"
2024-12-13 14:36:23 +08:00
autocomplete="off" oninput="value=value.replace(/[^0-9.]/g,'')" placeholder="请输入CT变比" />
2024-12-25 10:53:07 +08:00
<el-input maxlength="32" show-word-limit v-model.trim="form1.ct1" style="width: 48%"
2024-12-13 14:36:23 +08:00
autocomplete="off" oninput="value=value.replace(/[^0-9.]/g,'')" placeholder="请输入CT变比" />
2024-06-24 14:38:42 +08:00
</el-form-item>
<el-form-item label="监测位置:" prop="location" style="width: 100%">
2024-12-25 10:53:07 +08:00
<el-input maxlength="300" show-word-limit type="textarea" v-model.trim="form1.location"
2024-12-13 14:36:23 +08:00
placeholder="请输入监测位置" />
2024-06-24 14:38:42 +08:00
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane label="数据绑定" :name="1" v-if="openType == 'table'">
2024-07-12 16:55:10 +08:00
<TreeTransfers :fromData="unBindList" :toData="bindList" @getData="getData" />
2024-06-24 14:38:42 +08:00
</el-tab-pane>
</el-tabs>
<template #footer="">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="submit"> </el-button>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
2024-10-30 15:02:25 +08:00
import { ref, defineEmits } from 'vue'
2024-06-24 14:38:42 +08:00
import { ElMessage } from 'element-plus'
2024-10-30 15:02:25 +08:00
import { addPlan, addRecord, updateRecord, getDeviceList } from '@/api/cs-device-boot/planData'
2024-06-24 14:38:42 +08:00
import { useDictData } from '@/stores/dictData'
2024-07-12 16:55:10 +08:00
import TreeTransfers from './treeTransfers.vue'
2024-06-24 14:38:42 +08:00
const dictData = useDictData()
const dialogVisible = ref(false)
const voltageLevelList: any = dictData.getBasicData('Dev_Voltage_Stand')
2024-06-24 14:38:42 +08:00
const volConTypeList = dictData.getBasicData('Dev_Connect')
const emit = defineEmits(['onSubmit'])
//表单数据
const form = ref({})
//测试项数据
2024-09-26 11:20:12 +08:00
const form1: any = ref({})
2024-06-24 14:38:42 +08:00
//折叠面板初始值
const activeTab = ref(0)
//tab初始值
const activeName = ref(0)
//测量间隔数据
const statisticalIntervalList = [
{
id: 1,
name: '1分钟'
},
{
id: 3,
name: '3分钟'
},
{
id: 5,
name: '5分钟'
},
{
id: 10,
name: '10分钟'
}
]
//初始化form
const initForm = () => {
//方案数据
form.value = {
itemName: '', //方案名称
describe: '' //方案描述
}
//测试项数据
form1.value = {
itemName: '', //测试项名称
2024-06-27 09:39:53 +08:00
statisticalInterval: statisticalIntervalList[1].id, //测量间隔
2024-06-24 14:38:42 +08:00
voltageLevel: voltageLevelList[0].id, //电压等级
volConType: volConTypeList[0].id, //接线方式
capacitySscmin: 10, //最小短路容量
capacitySi: 10, //用户协议容量
capacitySscb: 10, //基准短路容量
capacitySt: 10, //供电设备容量
pt: 1, //pt变比1
pt1: 1, //pt变比2
ct: 300, //ct变比1
ct1: 5, //ct变比2
location: '' //监测位置
}
2024-07-12 16:55:10 +08:00
changeVoltageLevel()
}
const codeValue = (val: any) => {
return (
voltageLevelList.find((item: any) => {
return item.code == val
})?.value * 1
)
}
//改变电压等级计算基准短路容量
const changeVoltageLevel = async () => {
let value: any =
voltageLevelList.find((item: any) => {
return item.id == form1.value.voltageLevel
})?.value * 1
if (value < codeValue('6kV')) {
form1.value.capacitySscb = 10
} else if (value < codeValue('20kV')) {
form1.value.capacitySscb = 100
} else if (value < codeValue('35kV')) {
form1.value.capacitySscb = 200
} else if (value < codeValue('66kV')) {
form1.value.capacitySscb = 250
} else if (value < codeValue('110kV')) {
form1.value.capacitySscb = 500
} else if (value < codeValue('220kV')) {
form1.value.capacitySscb = 750
} else if (value < codeValue('330kV')) {
form1.value.capacitySscb = 2000
} else if (value < codeValue('500kV')) {
form1.value.capacitySscb = 3000
} else if (value < codeValue('750kV')) {
form1.value.capacitySscb = 4500
} else if (value < codeValue('1000kV')) {
form1.value.capacitySscb = 7000
} else {
form1.value.capacitySscb = 9000
}
//PT变比 电压<0.48kv 1:1 电压>0.48 *1000/100
if (Number(value) <= 0.48) {
form1.value.pt = 1
form1.value.pt1 = 1
}
if (Number(value) > 0.48) {
form1.value.pt = value * 10
form1.value.pt1 = 1
}
2024-06-24 14:38:42 +08:00
}
2024-07-12 16:55:10 +08:00
2024-06-24 14:38:42 +08:00
initForm()
//方案校验规则
const rules1 = ref({
//方案名称
itemName: [
{
required: true,
message: '请输入方案名称',
trigger: 'blur'
}
],
//方案名称
describe: [
{
required: true,
message: '请输入方案描述',
trigger: 'blur'
}
]
})
//测试项校验规则
const rules2 = ref({
//测试项名称
itemName: [
{
required: true,
message: '请输入测试项名称',
trigger: 'blur'
}
],
describe: [
{
required: true,
message: '请选择测量间隔',
trigger: 'change'
}
],
voltageLevel: [
{
required: true,
message: '请选择电压等级',
trigger: 'change'
}
],
volConType: [
{
required: true,
message: '请选择接线方式',
trigger: 'change'
}
],
capacitySscmin: [
{
required: true,
message: '请输入最小短路容量',
trigger: 'blur'
}
],
capacitySi: [
{
required: true,
message: '请输入用户协议容量',
trigger: 'blur'
}
],
capacitySscb: [
{
required: true,
message: '请输入基准短路容量',
trigger: 'blur'
}
],
capacitySt: [
{
required: true,
message: '请输入供电设备容量',
trigger: 'blur'
}
],
pt: [
{
required: true,
message: '请输入PT变比',
trigger: 'blur'
}
],
ct: [
{
required: true,
message: '请输入CT变比',
trigger: 'blur'
}
],
location: [
{
required: true,
message: '请输入监测位置',
trigger: 'blur'
}
]
})
//弹框标题
const title: any = ref('')
//判断页面显示条件
2024-09-25 16:31:45 +08:00
const popupType: any = ref(null)
2024-06-24 14:38:42 +08:00
//方案/测试项id
const planId: any = ref('')
//打开的类型
const openType = ref('')
const detailsType = (val: any) => {
openType.value = val
if (val == 'tree') {
activeName.value = 0
}
if (val == 'table') {
activeName.value = 1
}
}
2024-06-24 14:38:42 +08:00
//回显方案、测试项操作
const details = (val: any) => {
2024-10-23 09:44:21 +08:00
if (val) {
2024-09-26 11:20:12 +08:00
form.value = {
describe: val.describe,
itemName: val.itemName
}
}
if (val) {
2024-09-26 11:20:12 +08:00
form1.value = val
2024-10-23 09:44:21 +08:00
checkedIdList.value = form1.value.list
2024-09-26 11:20:12 +08:00
}
2024-06-24 14:38:42 +08:00
}
2024-07-12 16:55:10 +08:00
//未绑定数据tree
const unBindList = ref([])
//已绑定数据tree
const bindList = ref([])
2024-06-24 14:38:42 +08:00
//0 新增方案 1 修改方案 2 新增测试项 3 修改测试项 4 设备信息
2024-11-19 10:39:46 +08:00
const open = async (val: any, id: any, name?: any) => {
// console.log("🚀 ~ open ~ val:", val)
2024-09-25 16:31:45 +08:00
popupType.value = val
2024-12-09 16:30:40 +08:00
title.value = val == 0 ? '新增方案' : val == 1 ? '修改方案' : val == 2 ? '新增测试项' : val == 3 ? '修改测试项' : ('绑定测试项' + '_' + name)
2024-06-24 14:38:42 +08:00
dialogVisible.value = true
planId.value = id
//新增方案或者测试项数据
if (val == 0 || val == 2) {
initForm()
}
if (val != 0 && val != 1) {
//1 列表 0树
// getDeviceList({ id: id, isTrueFlag: 0, pageNum: 1, pageSize: 200 }).then(res => {})
dialogVisible.value = true
selectId.value = id
2024-07-12 16:55:10 +08:00
//0未绑定数据 1 已绑定数据
//获取未绑定树形数据
2024-06-24 14:38:42 +08:00
getDeviceList({ id: id, isTrueFlag: 0 }).then(res => {
2024-07-12 16:55:10 +08:00
unBindList.value = res.data
})
//获取已绑定树形数据
getDeviceList({ id: id, isTrueFlag: 1 }).then(res => {
bindList.value = res.data
2024-06-24 14:38:42 +08:00
})
// activeName.value = 0
2024-06-24 14:38:42 +08:00
}
}
2024-07-12 16:55:10 +08:00
//获取选择的绑定的数据
const checkedIdList: any = ref([])
const getData = (rightData: any) => {
checkedIdList.value = []
if (rightData && rightData.length != 0) {
rightData.map((item: any) => {
item.children.map((vv: any) => {
vv.children.map((kk: any) => {
checkedIdList.value.push(kk.id)
})
})
})
}
checkedIdList.value = [...new Set(checkedIdList.value)]
}
2024-06-24 14:38:42 +08:00
//判断是否显示新增页面 false显示详情页面和删除按钮隐藏确定按钮 true显示新增页面与确定按钮隐藏删除按钮
const addFlag = ref(false)
const selectId: any = ref('')
//判断是否选择了设备数据
const checkedList: any = ref([])
//关闭
const ruleFormRef1 = ref()
const ruleFormRef2 = ref()
const close = () => {
dialogVisible.value = false
//折叠面板
activeTab.value = 0
if (addFlag.value) {
addFlag.value = false
checkedList.value = []
} else {
dialogVisible.value = false
}
//取消表单校验状态
2024-09-25 16:31:45 +08:00
if (popupType.value == 0 || popupType.value == 1) {
2024-06-24 14:38:42 +08:00
ruleFormRef1.value && ruleFormRef1.value.resetFields()
} else {
ruleFormRef2.value && ruleFormRef2.value?.resetFields()
}
//tabs
activeName.value = 0
2024-07-12 16:55:10 +08:00
unBindList.value = []
bindList.value = []
2024-06-24 14:38:42 +08:00
initForm()
}
//提交
const submit = () => {
//新增方案
2024-09-25 16:31:45 +08:00
if (popupType.value == 0) {
2024-09-26 11:20:12 +08:00
ruleFormRef1.value.validate((valid: any) => {
2024-06-24 14:38:42 +08:00
if (valid) {
const subForm = {
itemName: form.value.itemName,
describe: form.value.describe
}
addPlan(subForm).then((res: any) => {
if (res.code == 'A0000') {
ElMessage.success('新增方案成功')
initForm()
emit('onSubmit')
close()
}
2024-06-24 14:38:42 +08:00
})
} else {
console.log('表单验证失败')
return false
}
})
}
//修改方案
2024-09-25 16:31:45 +08:00
if (popupType.value == 1) {
ruleFormRef1.value.validate((valid: boolean) => {
2024-06-24 14:38:42 +08:00
if (valid) {
const subForm = {
id: planId.value,
itemName: form.value.itemName,
describe: form.value.describe
}
addPlan(subForm).then(res => {
ElMessage.success('修改方案成功')
emit('onSubmit')
close()
})
}
})
}
//新增测试项
2024-09-25 16:31:45 +08:00
if (popupType.value == 2) {
ruleFormRef2.value.validate((valid: boolean) => {
2024-06-24 14:38:42 +08:00
if (valid) {
2024-07-12 16:55:10 +08:00
let subForm = {
2024-06-24 14:38:42 +08:00
id: planId.value,
records: [form1.value]
}
2024-07-12 16:55:10 +08:00
subForm.records[0].list = checkedIdList.value
2024-06-24 14:38:42 +08:00
addRecord(subForm).then(res => {
ElMessage.success('新增测试项成功')
2024-07-03 19:31:29 +08:00
initForm()
2024-06-24 14:38:42 +08:00
emit('onSubmit')
close()
})
}
})
}
//修改测试项
2024-12-09 16:30:40 +08:00
if (popupType.value == 3 || popupType.value == 4) {
let subForm = JSON.parse(JSON.stringify(form1.value))
subForm.list = checkedIdList.value
updateRecord(subForm).then((res: any) => {
if (res.code == 'A0000') {
ElMessage.success('修改测试项成功')
initForm()
emit('onSubmit')
close()
}
})
2024-06-24 14:38:42 +08:00
}
}
defineExpose({ open, details, detailsType })
2024-06-24 14:38:42 +08:00
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__content {
display: flex !important;
justify-content: space-between !important;
}
2024-11-19 10:39:46 +08:00
2024-06-24 14:38:42 +08:00
::v-deep .form-two {
.el-select {
width: 100% !important;
}
}
2024-11-19 10:39:46 +08:00
2024-06-24 14:38:42 +08:00
.button_info {
width: 100%;
display: flex;
justify-content: flex-end;
2024-06-27 09:39:53 +08:00
margin: 10px 0;
2024-06-24 14:38:42 +08:00
}
2024-07-12 16:55:10 +08:00
.device_info {
2024-06-24 14:38:42 +08:00
width: 100%;
display: flex;
2024-07-12 16:55:10 +08:00
.left_device,
.right_device {
width: 410px;
border: 1px solid #eee;
padding-right: 10px;
2024-11-19 10:39:46 +08:00
2024-07-12 16:55:10 +08:00
p {
margin: 10px 10px 0 10px;
font-weight: 800;
font-size: 14px;
}
}
.center_bind {
2024-06-24 14:38:42 +08:00
flex: 1;
2024-07-12 16:55:10 +08:00
display: flex;
padding: 0 30px;
align-items: center;
justify-content: center;
2024-06-24 14:38:42 +08:00
}
}
</style>