Merge branch 'master' into dev

# Conflicts:
#	frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue
This commit is contained in:
caozehui
2025-02-28 09:03:05 +08:00
11 changed files with 508 additions and 329 deletions

View File

@@ -1,5 +1,6 @@
import type { TestScript } from '@/api/device/interface/testScript' import type { TestScript } from '@/api/device/interface/testScript'
import http from '@/api' import http from '@/api'
import { Loading } from '@element-plus/icons-vue'
/** /**
* @name 检测脚本管理模块 * @name 检测脚本管理模块
@@ -48,5 +49,5 @@ export const scriptDtlsCheckDataList = (params: any) => {
} }
// 通讯脚本回显 // 通讯脚本回显
export const checkDataList = (params: any) => { export const checkDataList = (params: any) => {
return http.post(`/pqScript/checkDataList`, params) return http.post(`/pqScript/checkDataList`, params, { loading: true })
} }

View File

@@ -1,15 +1,15 @@
import http from '@/api' import http from '@/api'
import { type Dict } from '@/api/system/dictionary/interface' import { type Dict } from '@/api/system/dictionary/interface'
import {c} from "vite/dist/node/types.d-aGj9QkWt"; import { c } from 'vite/dist/node/types.d-aGj9QkWt'
//获取字典类型 //获取字典类型
export const getDictTreeByCode = (params: Dict.ResDictTree) => { export const getDictTreeByCode = (params: Dict.ResDictTree) => {
const code = params.code || ''; const code = params.code || ''
return http.get(`/dictTree/getTreeByCode?code=${code}`) return http.get(`/dictTree/getTreeByCode?code=${code}`, { loading: true })
} }
export const getDictTreeByName = (params: Dict.ResDictTree) => { export const getDictTreeByName = (params: Dict.ResDictTree) => {
const name = params.name || ''; const name = params.name || ''
return http.get(`/dictTree/getTreeByName?name=${name}`) return http.get(`/dictTree/getTreeByName?name=${name}`)
} }
@@ -27,4 +27,3 @@ export const updateDictTree = (params: Dict.ResDictTree) => {
export const deleteDictTree = (params: Dict.ResDictTree) => { export const deleteDictTree = (params: Dict.ResDictTree) => {
return http.post(`/dictTree/delete?id=${params.id}`) return http.post(`/dictTree/delete?id=${params.id}`)
} }

View File

@@ -8,13 +8,13 @@
color: '#fff' color: '#fff'
}" }"
stripe stripe
height="calc(100vh - 515px)" height="calc(100vh - 480px)"
:style="{ overflow: 'hidden' }" :style="{ overflow: 'hidden' }"
row-key="id" row-key="id"
default-expand-all default-expand-all
> >
<el-table-column prop="name" label="指标" show-overflow-tooltip width="180px" /> <el-table-column prop="name" label="指标" show-overflow-tooltip />
<el-table-column align="center" label="参与误差比较"> <el-table-column align="center" label="参与误差比较" width="110px">
<template #default="{ row }"> <template #default="{ row }">
<el-switch <el-switch
v-model="row.errorFlag" v-model="row.errorFlag"
@@ -32,7 +32,7 @@
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="是否启用"> <el-table-column align="center" label="是否启用" width="85px">
<template #default="{ row }"> <template #default="{ row }">
<el-switch <el-switch
v-model="row.enable" v-model="row.enable"
@@ -118,7 +118,14 @@ const info = async () => {
pid: item.id, pid: item.id,
name: k.name, name: k.name,
pname: item.name, pname: item.name,
dataType: item.name == '闪变' ? 'avg' : item.name == '暂态' ? 'avg' : 'real', dataType:
item.name == '谐波有功功率'
? 'avg'
: item.name == '闪变'
? 'avg'
: item.name == '暂态'
? 'avg'
: 'real',
show: true, show: true,
errorFlag: childrenList[0].errorFlag, errorFlag: childrenList[0].errorFlag,
enable: childrenList[0].enable enable: childrenList[0].enable
@@ -130,7 +137,13 @@ const info = async () => {
name: k.name, name: k.name,
disabled: false, disabled: false,
pname: item.name, pname: item.name,
dataType: item.name == '闪变' ? 'avg' : item.name == '暂态' ? 'avg' : 'real', dataType: '谐波有功功率'
? 'avg'
: item.name == '闪变'
? 'avg'
: item.name == '暂态'
? 'avg'
: 'real',
show: true, show: true,
errorFlag: 0, errorFlag: 0,
enable: 0 enable: 0

View File

@@ -1,3 +1,5 @@
import { log } from 'console'
let scriptForm: any = { let scriptForm: any = {
subType: '', //tabcode subType: '', //tabcode
ffreq: 50, //频率 ffreq: 50, //频率
@@ -19,11 +21,11 @@ let scriptForm: any = {
// }, // },
], //谐波 ], //谐波
inharmList: [ inharmList: [
{ // {
inharm: '', //间谐波次数 // inharm: '', //间谐波次数
famp: 0, //间谐波含有率 // famp: 0, //间谐波含有率
fphase: 0 // 间谐波相角 // fphase: 0 // 间谐波相角
} // }
], //间谐波 ], //间谐波
flickerData: { flickerData: {
flickerValue: '1', //标准值 flickerValue: '1', //标准值
@@ -49,11 +51,11 @@ let scriptForm: any = {
fphase: 0, //相角 fphase: 0, //相角
harmList: [], //谐波 harmList: [], //谐波
inharmList: [ inharmList: [
{ // {
inharm: '', //间谐波次数 // inharm: '', //间谐波次数
famp: 0, //间谐波含有率 // famp: 0, //间谐波含有率
fphase: 0 // 间谐波相角 // fphase: 0 // 间谐波相角
} // }
], //间谐波 ], //间谐波
flickerData: { flickerData: {
flickerValue: '1', //标准值 flickerValue: '1', //标准值
@@ -79,11 +81,11 @@ let scriptForm: any = {
fphase: -120, //相角 fphase: -120, //相角
harmList: [], //谐波 harmList: [], //谐波
inharmList: [ inharmList: [
{ // {
inharm: '', //间谐波次数 // inharm: '', //间谐波次数
famp: 0, //间谐波含有率 // famp: 0, //间谐波含有率
fphase: 0 // 间谐波相角 // fphase: 0 // 间谐波相角
} // }
], //间谐波 ], //间谐波
flickerData: { flickerData: {
flickerValue: '1', //标准值 flickerValue: '1', //标准值
@@ -109,11 +111,11 @@ let scriptForm: any = {
fphase:-120, //相角 fphase:-120, //相角
harmList: [], //谐波 harmList: [], //谐波
inharmList: [ inharmList: [
{ // {
inharm: '', //间谐波次数 // inharm: '', //间谐波次数
famp: 0, //间谐波含有率 // famp: 0, //间谐波含有率
fphase: 0 // 间谐波相角 // fphase: 0 // 间谐波相角
} // }
], //间谐波 ], //间谐波
flickerData: { flickerData: {
flickerValue: '1', //标准值 flickerValue: '1', //标准值
@@ -139,11 +141,11 @@ let scriptForm: any = {
fphase: 120, //相角 fphase: 120, //相角
harmList: [], //谐波 harmList: [], //谐波
inharmList: [ inharmList: [
{ // {
inharm: '', //间谐波次数 // inharm: '', //间谐波次数
famp: 0, //间谐波含有率 // famp: 0, //间谐波含有率
fphase: 0 // 间谐波相角 // fphase: 0 // 间谐波相角
} // }
], //间谐波 ], //间谐波
flickerData: { flickerData: {
flickerValue: '1', //标准值 flickerValue: '1', //标准值
@@ -169,11 +171,11 @@ let scriptForm: any = {
fphase: 120, //相角 fphase: 120, //相角
harmList: [], //谐波 harmList: [], //谐波
inharmList: [ inharmList: [
{ // {
inharm: '', //间谐波次数 // inharm: '', //间谐波次数
famp: 0, //间谐波含有率 // famp: 0, //间谐波含有率
fphase: 0 // 间谐波相角 // fphase: 0 // 间谐波相角
} // }
], //间谐波 ], //间谐波
flickerData: { flickerData: {
flickerValue: '1', //标准值 flickerValue: '1', //标准值
@@ -191,16 +193,6 @@ let scriptForm: any = {
] ]
} }
// 追加谐波 // 追加谐波
function getScriptForm() {
for (let i = 2; i < 51; i++) {
scriptForm.channelList.forEach(item => {
item.harmList.push({
harm: i, //谐波次数
famp: 0, //谐波含有率
fphase: 0 // 谐波相角
})
})
}
}
// getScriptForm()
export default scriptForm export default scriptForm

View File

@@ -1,5 +1,9 @@
<template> <template>
<div class="table-container"> <div class="table-container">
<div class="recalculation">
<el-button type="primary" :icon="Refresh" @click="recalculation">一键重算</el-button>
</div>
<el-table <el-table
:data="tableData" :data="tableData"
:header-cell-style="{ :header-cell-style="{
@@ -9,25 +13,28 @@
}" }"
stripe stripe
:cell-style="{ textAlign: 'center' }" :cell-style="{ textAlign: 'center' }"
height="600px" height="550px"
> >
<el-table-column type="index" label="序号" width="60" /> <el-table-column type="index" label="序号" width="60" />
<el-table-column prop="pname" label="参考设定值类型" /> <el-table-column prop="pname" label="参考设定值类型" />
<el-table-column prop="name" label="参考设定值子类型" width="250"> <el-table-column prop="name" label="参考设定值子类型" width="250">
<template #default="{ row }">{{ row.harmNum ? `(${row.harmNum}次)` : '' }} {{ row.name }}</template> <template #default="{ row }">{{ row.harmNum ? `(${row.harmNum}次)` : '' }} {{ row.name }}</template>
</el-table-column> </el-table-column>
<el-table-column prop="dataType" label="值类型" :formatter="formatter" /> <el-table-column prop="dataType" label="值类型">
<template #default="{ row }">
<el-select v-model="row.dataType" v-if="!row.show">
<el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<span v-else>
{{ typeList.find(item => item.value == row.dataType)?.label || row.dataType }}
</span>
</template>
</el-table-column>
<el-table-column prop="phase" label="相别" /> <el-table-column prop="phase" label="相别" />
<el-table-column prop="value" label="参考设定值"> <el-table-column prop="value" label="参考设定值">
<template #default="{ row }"> <template #default="{ row }">
<span v-if="row.show">{{ row.value }}</span> <span v-if="row.show">{{ row.value }}</span>
<el-input <el-input type="number" v-else v-model="row.value" placeholder="请输入值" />
type="number"
v-else
v-model="row.value"
placeholder="请输入值"
@blur="row.show = !row.show"
/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="value" label="参与误差比较"> <el-table-column prop="value" label="参与误差比较">
@@ -68,7 +75,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { CirclePlus, EditPen, Check, Share } from '@element-plus/icons-vue' import { Refresh, EditPen, Check, Share } from '@element-plus/icons-vue'
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import { getDictTreeByCode } from '@/api/system/dictionary/dictTree' import { getDictTreeByCode } from '@/api/system/dictionary/dictTree'
import { dialogBig } from '@/utils/elementBind' import { dialogBig } from '@/utils/elementBind'
@@ -91,29 +98,36 @@ const props = defineProps({
required: true required: true
} }
}) })
const emit = defineEmits(['recalculation'])
const tableData: any = ref([]) const tableData: any = ref([])
// 表格配置项 // 表格配置项
const typeList = [
{
label: '实时',
value: 'real'
},
{
label: 'CP95值',
value: 'cp95'
},
{
label: '平均值',
value: 'avg'
},
{
label: '最小值',
value: 'min'
},
{
label: '最大值',
value: 'max'
}
]
const form = ref({ const form = ref({
name: 220, name: 220,
standardName: 0, standardName: 0,
standardTime: 0 standardTime: 0
}) })
const formatter = (row: any, column: any) => {
if (column.property == 'dataType') {
return row.dataType == 'real'
? '实时'
: row.dataType == 'cp95'
? 'CP95值'
: row.dataType == 'avg'
? '平均值'
: row.dataType == 'min'
? '最小值'
: row.dataType == 'max'
? '最大值'
: row.dataType
}
}
// 打开弹窗,可能是新增,也可能是编辑 // 打开弹窗,可能是新增,也可能是编辑
@@ -161,8 +175,12 @@ const open = async (row: any, copyRowList: any) => {
tableData.value = res.data tableData.value = res.data
}) })
} }
// 重算
const recalculation = () => {
emit('recalculation')
}
// 处理多余数据 // 处理多余数据
const handleHarmData = row => { const handleHarmData = (row: any) => {
row.channelList.forEach((channel: any) => { row.channelList.forEach((channel: any) => {
// 筛选出 famp 和 fphase 不同时为 0 的对象 // 筛选出 famp 和 fphase 不同时为 0 的对象
channel.harmList = channel.harmList.filter((item: any) => item.famp != 0 || item.fphase != 0) channel.harmList = channel.harmList.filter((item: any) => item.famp != 0 || item.fphase != 0)
@@ -173,7 +191,7 @@ const handleHarmData = row => {
return row return row
} }
// 判断数据是否变化 // 判断数据是否变化
const isEqual = (obj1, obj2) => { const isEqual = (obj1: any, obj2: any) => {
// 如果两个对象是同一个引用,直接返回 true // 如果两个对象是同一个引用,直接返回 true
if (obj1 == obj2) return true if (obj1 == obj2) return true
// 如果其中一个是 null 或者不是对象,返回 false // 如果其中一个是 null 或者不是对象,返回 false
@@ -211,4 +229,10 @@ onMounted(() => {})
defineExpose({ open, getTableData }) defineExpose({ open, getTableData })
</script> </script>
<style scoped></style> <style scoped>
.recalculation {
display: flex;
justify-content: end;
margin-bottom: 10px;
}
</style>

View File

@@ -154,6 +154,7 @@
:formContent="props.formContent" :formContent="props.formContent"
:form="form" :form="form"
:key="initial" :key="initial"
@recalculation="recalculation"
/> />
</el-carousel-item> </el-carousel-item>
</el-carousel> </el-carousel>
@@ -333,6 +334,10 @@ const next = () => {
}, 100) }, 100)
// 切换轮播图 // 切换轮播图
} }
// 重新计算
const recalculation = () => {
setValueTableRef.value?.open(props.communicationList, {})
}
// 判断够选通道 // 判断够选通道
const checkFlags = () => { const checkFlags = () => {
@@ -564,7 +569,7 @@ const open = (sign: string, row: any) => {
}) })
} }
} else { } else {
form.value = setharmList(JSON.parse(JSON.stringify(row))) form.value = JSON.parse(JSON.stringify(row))
copyRowList.value = JSON.parse(JSON.stringify(row)) copyRowList.value = JSON.parse(JSON.stringify(row))
} }
if (['Base_0_10', 'Base_20_85', 'Base_110_200'].includes(form.value.subType)) { if (['Base_0_10', 'Base_20_85', 'Base_110_200'].includes(form.value.subType)) {

View File

@@ -1,16 +1,16 @@
<template> <template>
<div> <div>
<div class="divider-container"> <div class="divider-container">
<el-divider style="width: 300px" content-position="left">检测脚本信息</el-divider> <el-divider style="width: 260px" content-position="left">检测脚本信息</el-divider>
<!-- <el-divider style="width: 400px" content-position="left">通讯脚本</el-divider> --> <!-- <el-divider style="width: 400px" content-position="left">通讯脚本</el-divider> -->
<el-divider style="flex: 1" content-position="left">检测项目概要信息</el-divider> <el-divider style="flex: 1" content-position="left">检测项目概要信息</el-divider>
</div> </div>
<div class="data-check-content"> <div class="data-check-content">
<div class="content-tree"> <div class="content-tree">
<Tree :treeData="treeData" /> <Tree :treeData="treeData" @setTab="setTab" />
</div> </div>
<div class="content-right-Tabs" style="height: calc(100vh - 335px); width: 100px"> <div class="content-right-Tabs" style="height: calc(100vh - 315px); width: 100px">
<el-tabs type="border-card" style="height: 100%" v-model="activeName" @tab-change="tabChange"> <el-tabs type="border-card" style="height: 100%" v-model="activeName" @tab-change="tabChange">
<el-tab-pane v-for="tab in tabData" :key="tab.value" :label="tab.label" :name="tab.value"> <el-tab-pane v-for="tab in tabData" :key="tab.value" :label="tab.label" :name="tab.value">
<div v-if="activeName == tab.value"> <div v-if="activeName == tab.value">
@@ -25,7 +25,7 @@
:activeName="activeName" :activeName="activeName"
:formContent="props.formContent" :formContent="props.formContent"
:options="props.options" :options="props.options"
style="width: 400px" style="width: 360px"
:disabled="tab.children.length == 0 ? false : true" :disabled="tab.children.length == 0 ? false : true"
ref="communRef" ref="communRef"
/> />
@@ -54,11 +54,11 @@
}" }"
stripe stripe
:cell-style="{ textAlign: 'center' }" :cell-style="{ textAlign: 'center' }"
height="calc(100vh - 515px)" height="calc(100vh - 480px)"
style="width: 100%" style="width: 100%"
> >
<el-table-column type="index" label="组次" width="60" /> <el-table-column type="index" label="组次" width="60" />
<el-table-column prop="ffreq" label="频率(Hz)" width="100" /> <el-table-column prop="ffreq" label="频率(Hz)" width="90" />
<el-table-column <el-table-column
:label="item.label" :label="item.label"
v-for="item in column" v-for="item in column"
@@ -73,7 +73,7 @@
{{ {{
row.channelList[item.num].famp == null row.channelList[item.num].famp == null
? '/' ? '/'
: '电压=' + : '' +
row.channelList[item.num]?.famp + row.channelList[item.num]?.famp +
(valueCode == 'Absolute' ? 'V' : '%') (valueCode == 'Absolute' ? 'V' : '%')
}} }}
@@ -82,7 +82,7 @@
{{ {{
row.channelList[item.num].fphase == null row.channelList[item.num].fphase == null
? '/' ? '/'
: '相角=' + : '' +
row.channelList[item.num].fphase + row.channelList[item.num].fphase +
'°' '°'
}} }}
@@ -94,7 +94,7 @@
{{ {{
row.channelList[item.num + 1].famp == null row.channelList[item.num + 1].famp == null
? '/' ? '/'
: '电流=' + : '' +
row.channelList[item.num + 1].famp + row.channelList[item.num + 1].famp +
(valueCode == 'Absolute' ? 'V' : '%') (valueCode == 'Absolute' ? 'V' : '%')
}} }}
@@ -103,7 +103,7 @@
{{ {{
row.channelList[item.num + 1].fphase == null row.channelList[item.num + 1].fphase == null
? '/' ? '/'
: '相角=' + : '' +
row.channelList[item.num + 1].fphase + row.channelList[item.num + 1].fphase +
'°' '°'
}} }}
@@ -113,7 +113,7 @@
</table> </table>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="是否启用" width="90"> <el-table-column label="是否启用" width="85">
<template #default="{ row }"> <template #default="{ row }">
<el-switch <el-switch
v-model="row.enable" v-model="row.enable"
@@ -130,7 +130,7 @@
</el-switch> </el-switch>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="220"> <el-table-column label="操作" width="215">
<template #default="{ row }"> <template #default="{ row }">
<el-button <el-button
type="primary" type="primary"
@@ -280,6 +280,12 @@ const getTree = () => {
} }
}) })
} }
// 设置树点击tab
const setTab = row => {
activeName.value = row.activeName
childActiveName.value = row.childActiveName
getTree()
}
const copyActiveName = ref('') const copyActiveName = ref('')
// 获取通讯脚本点击 // 获取通讯脚本点击
const getCommunication = () => { const getCommunication = () => {
@@ -415,11 +421,11 @@ onMounted(() => {
} }
.content-tree { .content-tree {
width: 300px; width: 260px;
height: calc(100vh - 335px); height: calc(100vh - 315px);
border: 1px solid #dcdfe6; border: 1px solid #dcdfe6;
border-radius: 4px; border-radius: 4px;
margin-right: 10px; // margin-right: 10px;
overflow: auto; /* 同时启用垂直和水平滚动 */ overflow: auto; /* 同时启用垂直和水平滚动 */
overflow-x: hidden; overflow-x: hidden;
} }
@@ -479,4 +485,10 @@ input::-webkit-inner-spin-button {
input::-webkit-outer-spin-button { input::-webkit-outer-spin-button {
-webkit-appearance: none !important; -webkit-appearance: none !important;
} }
.el-divider--horizontal {
margin: 4px 0 24px 0;
}
.el-tabs--border-card > .el-tabs__content {
padding: 10px;
}
</style> </style>

View File

@@ -36,8 +36,8 @@
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="onSubmit" size="small">确定</el-button> <el-button type="primary" :icon="Check" @click="onSubmit" size="small">确定</el-button>
<el-button type="primary" @click="empty(0)" size="small">清空</el-button> <el-button type="primary" :icon="Delete" @click="empty(0)" size="small">清空表</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 电压通道内容 --> <!-- 电压通道内容 -->
@@ -46,23 +46,13 @@
<el-table-column prop="harm" align="center" label="次数" width="60" /> <el-table-column prop="harm" align="center" label="次数" width="60" />
<el-table-column prop="famp" align="center" label="谐波含有率"> <el-table-column prop="famp" align="center" label="谐波含有率">
<template #default="{ row }"> <template #default="{ row }">
<el-input <el-input type="number" v-if="row.show" v-model="row.famp" />
type="number"
v-if="row.show"
@blur="row.show = !row.show"
v-model="row.famp"
/>
<span v-else>{{ row.famp }}%</span> <span v-else>{{ row.famp }}%</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="fphase" label="谐波相角" align="center"> <el-table-column prop="fphase" label="谐波相角" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input <el-input type="number" v-if="row.show" v-model="row.fphase" />
type="number"
v-if="row.show"
@blur="row.show = !row.show"
v-model="row.fphase"
/>
<span v-else>{{ row.fphase }}°</span> <span v-else>{{ row.fphase }}°</span>
</template> </template>
</el-table-column> </el-table-column>
@@ -86,35 +76,6 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- <el-table :data="tableData2" border size="small" class="half-width-table">
<el-table-column prop="date" label="次数" align="center" width="60" />
<el-table-column prop="date" label="谐波含有率" align="center" width="120">
<template #default="{ row, $index }">
<div class="input-label-container">
<el-input
type="number"
size="small"
v-model="form[0].harmList[$index + 24].famp"
:disabled="!form[0].harmFlag"
/>
<label>%</label>
</div>
</template>
</el-table-column>
<el-table-column prop="name" label="谐波相角" align="center" width="120">
<template #default="{ row, $index }">
<div class="input-label-container">
<el-input
type="number"
size="small"
v-model="form[0].harmList[$index + 24].fphase"
:disabled="!form[0].harmFlag"
/>
<label>°</label>
</div>
</template>
</el-table-column>
</el-table> -->
</div> </div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@@ -155,7 +116,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="onSubmit1" size="small">确定</el-button> <el-button type="primary" @click="onSubmit1" size="small">确定</el-button>
<el-button type="primary" @click="empty(1)" size="small">清空</el-button> <el-button type="primary" @click="empty(1)" size="small">清空表</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 电流通道内容 --> <!-- 电流通道内容 -->
@@ -164,23 +125,13 @@
<el-table-column prop="harm" align="center" label="次数" width="60" /> <el-table-column prop="harm" align="center" label="次数" width="60" />
<el-table-column prop="famp" align="center" label="谐波含有率"> <el-table-column prop="famp" align="center" label="谐波含有率">
<template #default="{ row }"> <template #default="{ row }">
<el-input <el-input type="number" v-if="row.show" v-model="row.famp" />
type="number"
v-if="row.show"
@blur="row.show = !row.show"
v-model="row.famp"
/>
<span v-else>{{ row.famp }}%</span> <span v-else>{{ row.famp }}%</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="fphase" label="谐波相角" align="center"> <el-table-column prop="fphase" label="谐波相角" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-input <el-input type="number" v-if="row.show" v-model="row.fphase" />
type="number"
v-if="row.show"
@blur="row.show = !row.show"
v-model="row.fphase"
/>
<span v-else>{{ row.fphase }}°</span> <span v-else>{{ row.fphase }}°</span>
</template> </template>
</el-table-column> </el-table-column>
@@ -325,25 +276,6 @@ const onSubmit1 = () => {
const HarmFlagDelete = (index: number, number: number) => { const HarmFlagDelete = (index: number, number: number) => {
props.childForm[index].harmList.splice(number, 1) props.childForm[index].harmList.splice(number, 1)
} }
// 定义并初始化 tableData
const tableData1 = ref<TableItem[]>([])
const tableData2 = ref<TableItem[]>([])
for (let i = 2; i <= 25; i++) {
tableData1.value.push({
date: i.toString(),
harmonicRate: `谐波含有率${i}`,
harmonicPhase: `谐波相角${i}`
})
}
for (let i = 26; i <= 50; i++) {
tableData2.value.push({
date: i.toString(),
harmonicRate: `谐波含有率${i}`,
harmonicPhase: `谐波相角${i}`
})
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -2,141 +2,191 @@
<div class="tabs-container"> <div class="tabs-container">
<el-tabs type="border-card" class="right-tabs" style="height: 100%"> <el-tabs type="border-card" class="right-tabs" style="height: 100%">
<el-tab-pane label="电压通道"> <el-tab-pane label="电压通道">
<el-table :data="form[0].inharmList" border size="small" class="half-width-table"> <el-form :inline="true" :model="formInline" :disabled="!props.childForm[0].inHarmFlag">
<el-table-column prop="date" align="center" label="次数"> <el-form-item label="次数">
<template #default="{ row, $index }">
<div class="input-label-container">
<el-select <el-select
v-model="form[0].inharmList[$index].inharm" v-model="formInline.inharm"
:disabled="!form[0].inHarmFlag" multiple
collapse-tags
collapse-tags-tooltip
style="width: 160px"
filterable filterable
placeholder="选择次数" clearable
size="small"
> >
<el-option label="全部" value="0" />
<el-option v-for="item in 49" :key="item" :label="item + 0.5" :value="item + 0.5" /> <el-option v-for="item in 49" :key="item" :label="item + 0.5" :value="item + 0.5" />
</el-select> </el-select>
</div> </el-form-item>
</template> <el-form-item label="含有率">
</el-table-column> <el-input
<el-table-column prop="date" align="center" label="间谐波含有率"> v-model="formInline.famp"
<template #default="{ row, $index }"> type="number"
<div class="input-label-container"> placeholder="含有率"
style="width: 80px"
clearable
/>
</el-form-item>
<el-form-item label="相角">
<el-input
v-model="formInline.fphase"
type="number"
placeholder="相角"
style="width: 80px"
clearable
/>
</el-form-item>
<el-form-item>
<el-button type="primary" :icon="Check" @click="onSubmit" size="small">确定</el-button>
<el-button type="primary" :icon="Delete" @click="empty(0)" size="small">清空表格</el-button>
</el-form-item>
</el-form>
<!-- 电压通道内容 -->
<div class="table-container">
<el-table :data="form[0].inharmList" border stripe size="small">
<el-table-column prop="inharm" align="center" label="次数" width="60" />
<el-table-column prop="famp" align="center" label="间谐波含有率">
<template #default="{ row }">
<el-input <el-input
type="number" type="number"
size="small" v-if="row.show"
v-model="form[0].inharmList[$index].famp"
:disabled="!form[0].inHarmFlag" v-model="row.famp"
/> />
<label>%</label> <span v-else>{{ row.famp }}%</span>
</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="name" label="间谐波相角" align="center"> <el-table-column prop="fphase" label="间谐波相角" align="center">
<template #default="{ row, $index }"> <template #default="{ row }">
<div class="input-label-container">
<el-input <el-input
type="number" type="number"
size="small" v-if="row.show"
v-model="form[0].inharmList[$index].fphase"
:disabled="!form[0].inHarmFlag" v-model="row.fphase"
/> />
<label>°</label> <span v-else>{{ row.fphase }}°</span>
</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="date" align="center" label="操作" width="100"> <el-table-column label="操作" align="center">
<template #default="{ row, $index }"> <template #default="{ row, $index }">
<el-button <el-button
v-if="$index == 0"
type="primary" type="primary"
size="small"
link link
:icon="CirclePlus" :icon="EditPen"
@click="inHarmFlagAdd(0, row)" v-if="!row.show"
@click="row.show = true"
> >
新增 编辑
</el-button> </el-button>
<el-button v-else type="primary" link :icon="Delete" @click="inHarmFlagDelete(0, $index)"> <el-button type="primary" link :icon="Check" v-else @click="row.show = false">
保存
</el-button>
<el-button type="primary" link :icon="Delete" @click="inHarmFlagDelete(0, $index)">
删除 删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<el-tabs type="border-card" class="right-tabs" style="height: 100%"> <el-tabs type="border-card" style="height: 100%">
<el-tab-pane label="电流通道"> <el-tab-pane label="电流通道">
<el-table :data="form[1].inharmList" border size="small" class="half-width-table"> <el-form :inline="true" :model="formInline1" :disabled="!props.childForm[1].inHarmFlag">
<el-table-column prop="date" align="center" label="次数"> <el-form-item label="次数">
<template #default="{ row, $index }">
<div class="input-label-container">
<el-select <el-select
v-model="form[1].inharmList[$index].inharm" v-model="formInline1.inharm"
:disabled="!form[1].inHarmFlag" multiple
collapse-tags
collapse-tags-tooltip
style="width: 160px"
filterable filterable
placeholder="选择次数" clearable
size="small"
> >
<el-option label="全部" value="0" />
<el-option v-for="item in 49" :key="item" :label="item + 0.5" :value="item + 0.5" /> <el-option v-for="item in 49" :key="item" :label="item + 0.5" :value="item + 0.5" />
</el-select> </el-select>
</div> </el-form-item>
</template> <el-form-item label="含有率">
</el-table-column> <el-input
<el-table-column prop="date" align="center" label="间谐波含有率"> v-model="formInline1.famp"
<template #default="{ row, $index }"> type="number"
<div class="input-label-container"> placeholder="含有率"
style="width: 80px"
clearable
/>
</el-form-item>
<el-form-item label="相角">
<el-input
v-model="formInline1.fphase"
type="number"
placeholder="相角"
style="width: 80px"
clearable
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit1" size="small">确定</el-button>
<el-button type="primary" @click="empty(1)" size="small">清空表格</el-button>
</el-form-item>
</el-form>
<!-- 电流通道内容 -->
<div class="table-container">
<el-table :data="form[1].inharmList" border stripe size="small">
<el-table-column prop="inharm" align="center" label="次数" width="60" />
<el-table-column prop="famp" align="center" label="间谐波含有率">
<template #default="{ row }">
<el-input <el-input
type="number" type="number"
size="small" v-if="row.show"
v-model="form[1].inharmList[$index].famp"
:disabled="!form[1].inHarmFlag" v-model="row.famp"
/> />
<label>%</label> <span v-else>{{ row.famp }}%</span>
</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="name" label="间谐波相角" align="center"> <el-table-column prop="fphase" label="间谐波相角" align="center">
<template #default="{ row, $index }"> <template #default="{ row }">
<div class="input-label-container">
<el-input <el-input
type="number" type="number"
size="small" v-if="row.show"
v-model="form[1].inharmList[$index].fphase"
:disabled="!form[1].inHarmFlag" v-model="row.fphase"
/> />
<label>°</label> <span v-else>{{ row.fphase }}°</span>
</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="date" align="center" label="操作" width="100"> <el-table-column label="操作" align="center">
<template #default="{ row, $index }"> <template #default="{ row, $index }">
<el-button <el-button
v-if="$index == 0"
type="primary" type="primary"
size="small"
link link
:icon="CirclePlus" :icon="EditPen"
@click="inHarmFlagAdd(1, row)" v-if="!row.show"
@click="row.show = true"
> >
新增 编辑
</el-button> </el-button>
<el-button v-else type="primary" link :icon="Delete" @click="inHarmFlagDelete(1, $index)"> <el-button type="primary" link :icon="Check" v-else @click="row.show = false">
保存
</el-button>
<el-button type="primary" link :icon="Delete" @click="inHarmFlagDelete(1, $index)">
删除 删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Check, Delete, EditPen, CopyDocument } from '@element-plus/icons-vue'
import { ref } from 'vue' import { ref } from 'vue'
import { CirclePlus, Delete, EditPen, CopyDocument } from '@element-plus/icons-vue'
const props = defineProps({ const props = defineProps({
childForm: { childForm: {
type: Array, type: Array as any,
required: true required: true
} }
}) })
@@ -147,45 +197,138 @@ const form: any = computed({
}, },
set(value) {} set(value) {}
}) })
const num = ref(0) const formInline = ref({
inharm: [],
famp: '',
fphase: ''
})
const formInline1 = ref({
inharm: [],
famp: '',
fphase: ''
})
// 定义表格数据项的类型
interface TableItem {
date: string
inharmonicRate?: string
inharmonicPhase?: string
name?: string
}
const empty = (index: number) => {
props.childForm[index].inharmList = []
}
const onSubmit = () => {
console.log('🚀 ~ onSubmit ~ props.childForm[0]:', props.childForm[0].inharmList)
if (formInline.value.inharm.length == 0 || formInline.value.famp == '' || formInline.value.fphase == '') {
ElMessage.warning('请填写值!')
return
}
if (formInline.value.inharm.includes('0')) {
props.childForm[0].inharmList = []
for (let i = 2; i < 51; i++) {
props.childForm[0].inharmList.push({
inharm: i, //间间谐波次数
famp: formInline.value.famp, //间间谐波含有率
fphase: formInline.value.fphase // 间间谐波相角
})
}
} else {
formInline.value.inharm.forEach((item: any) => {
props.childForm[0].inharmList.push({
inharm: item, //间间谐波次数
famp: formInline.value.famp, //间间谐波含有率
fphase: formInline.value.fphase // 间间谐波相角
})
})
const seen = new Set()
const uniqueData = []
// 添加间间谐波 // 反向遍历数组
const inHarmFlagAdd = (index: number, row: any) => { for (let i = props.childForm[0].inharmList.length - 1; i >= 0; i--) {
props.childForm[index].inharmList.push({ inharm: '', famp: 0, fphase: 0 }) const item = props.childForm[0].inharmList[i]
num.value += 1 // 如果 inharm 还未出现过,则添加到结果数组
if (!seen.has(item.inharm)) {
seen.add(item.inharm)
uniqueData.unshift(item) // 添加到结果数组的开头
}
}
props.childForm[0].inharmList = uniqueData.sort((a, b) => a.inharm - b.inharm)
}
}
const onSubmit1 = () => {
if (formInline1.value.inharm.length == 0 || formInline1.value.famp == '' || formInline1.value.fphase == '') {
ElMessage.warning('请填写值!')
return
}
if (formInline1.value.inharm.includes('0')) {
props.childForm[1].inharmList = []
for (let i = 2; i < 51; i++) {
props.childForm[1].inharmList.push({
inharm: i, //间间谐波次数
famp: formInline1.value.famp, //间间谐波含有率
fphase: formInline1.value.fphase // 间间谐波相角
})
}
} else {
formInline1.value.inharm.forEach((item: any) => {
props.childForm[1].inharmList.push({
inharm: item, //间间谐波次数
famp: formInline1.value.famp, //间间谐波含有率
fphase: formInline1.value.fphase // 间间谐波相角
})
})
const seen = new Set()
const uniqueData = []
// 反向遍历数组
for (let i = props.childForm[1].inharmList.length - 1; i >= 0; i--) {
const item = props.childForm[1].inharmList[i]
// 如果 inharm 还未出现过,则添加到结果数组
if (!seen.has(item.inharm)) {
seen.add(item.inharm)
uniqueData.unshift(item) // 添加到结果数组的开头
}
}
props.childForm[1].inharmList = uniqueData.sort((a, b) => a.inharm - b.inharm)
}
} }
// 删除 // 删除
const inHarmFlagDelete = (index: number, number: number) => { const inHarmFlagDelete = (index: number, number: number) => {
props.childForm[index].inharmList.splice(number, 1) props.childForm[index].inharmList.splice(number, 1)
num.value -= 1
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .tabs-container {
display: flex; display: flex;
align-items: center; justify-content: space-between; /* 使两个 el-tabs 之间有间距 */
border-bottom: 1px solid #ccc; height: 100%;
}
.right-tabs {
flex: 1; /* 使两个 el-tabs 占据相同的空间 */
margin-right: 10px; /* 可选:添加右侧间距 */
}
.el-tabs {
flex: 1; /* 使两个 el-tabs 占据相同的空间 */
}
.table-container {
display: flex;
justify-content: space-between; /* 使两个表格之间有间距 */
width: 100%; width: 100%;
margin-top: 10px;
height: 40px;
} }
.fixed-width-tabs:last-child { .half-width-table {
margin-right: 0; /* 最后一个 el-tabs 不需要右侧间距 */ flex: 1; /* 使两个表格占据相同的空间 */
margin-right: 10px; /* 可选:添加表格之间的间距 */
} }
.el-tab-pane { .half-width-table:last-child {
display: flex; margin-right: 0; /* 最后一个表格不需要右侧间距 */
flex-direction: column; /* 确保内容上下排列 */
} }
.el-form-item {
margin-bottom: 20px; /* 可选:添加表单项之间的间距 */
}
:deep(.el-form-item) {
margin-bottom: 10px !important;
}
.input-label-container { .input-label-container {
display: flex; display: flex;
align-items: center; /* 垂直居中对齐 */ align-items: center; /* 垂直居中对齐 */
@@ -194,13 +337,7 @@ const inHarmFlagDelete = (index: number, number: number) => {
.input-label-container label { .input-label-container label {
margin-left: 5px; /* 添加标签与输入框之间的间距 */ margin-left: 5px; /* 添加标签与输入框之间的间距 */
} }
.tabs-container { // 全局css 加上以下代码,可以隐藏上下箭头
display: flex;
justify-content: space-between; /* 使两个 el-tabs 之间有间距 */ // 取消input的上下箭头
height: 100%;
.right-tabs {
flex: 1; /* 使两个 el-tabs 占据相同的空间 */
margin-right: 10px; /* 可选:添加右侧间距 */
}
}
</style> </style>

View File

@@ -189,7 +189,6 @@ const treeInfo = async (currentMode: string) => {
onMounted(() => { onMounted(() => {
let data: any = router.options.history.state let data: any = router.options.history.state
console.log('🚀 ~ onMounted ~ data:', data)
if (data.title == null) return if (data.title == null) return
nextTick(async () => { nextTick(async () => {
await treeInfo(data.mode) await treeInfo(data.mode)

View File

@@ -1,7 +1,15 @@
<template> <template>
<el-tree node-key="id" default-expand-all :data="props.treeData" :props="defaultProps" style="width: 100%"> <el-tree
node-key="id"
default-expand-all
:data="props.treeData"
:props="defaultProps"
style="width: 100%"
:expand-on-click-node="false"
@node-click="handleNodeClick"
>
<template #default="{ node, data }"> <template #default="{ node, data }">
<el-tooltip effect="dark" :content="data.scriptTypeName || data.sourceDesc" placement="top" :hide-after="0"> <el-tooltip effect="dark" :content="data.sourceDesc || data.scriptTypeName" placement="top" :hide-after="0">
<div class="custom-tree-node"> <div class="custom-tree-node">
{{ data.scriptTypeName || data.sourceDesc }} {{ data.scriptTypeName || data.sourceDesc }}
</div> </div>
@@ -19,12 +27,69 @@ const props = defineProps({
required: true required: true
} }
}) })
const emit = defineEmits(['setTab'])
const dataTree = ref<CheckData.TreeItem[]>([]) const dataTree = ref<CheckData.TreeItem[]>([])
const defaultProps = { const defaultProps = {
children: 'children', children: 'children',
label: 'scriptTypeName', label: 'scriptTypeName',
pid: 'pid' pid: 'pid'
} }
const activeName = ref('')
const childActiveName = ref('')
const handleNodeClick = (data, node) => {
let code = ['Base', 'VOL', 'Freq', 'Harm', 'Base_0_10', 'Base_20_85', 'Base_110_200']
const parents = getParentNodes(node, [])
parents.pop()
parents.unshift(node.data)
parents.reverse()
let active = parents[0].scriptTypeCode
let childActive = findTargetCodes(parents, code)[0] || ''
// 获取当前节点的直接父节点
if (activeName.value != active || childActiveName.value != childActive) {
activeName.value = active
childActiveName.value = childActive
emit('setTab', {
activeName: active,
childActiveName: childActive
})
}
}
// 返回父级
const getParentNodes = (node, parents) => {
if (node.parent) {
// 将父节点添加到数组中
parents.push(node.parent.data)
// 递归获取更高层级的父节点
getParentNodes(node.parent, parents)
}
return parents
}
// 判断childActiveName值
function findTargetCodes(data: any[], targetCodes: string[]) {
let result: string[] = []
data.forEach(item => {
if (item.scriptTypeCode != null) {
if (targetCodes.includes(item.scriptTypeCode)) {
result.push(item.scriptTypeCode)
}
}
})
return result
// for (let item of data) {
// // 判断当前项的 scriptTypeCode 是否包含目标值
// if (item.scriptTypeCode !=null && targetCodes.includes(item.scriptTypeCode)) {
// console.log("🚀 ~ findTargetCodes ~ targetCodes.includes(item.scriptTypeCode):",item.scriptTypeCode, targetCodes.includes(item.scriptTypeCode))
// result.push(item.scriptTypeCode)
// return result
// }
// // 如果存在 children递归检查
// if (item.children && item.children.length > 0) {
// result = result.concat(findTargetCodes(item.children, targetCodes))
// }
// }
// return result
}
onMounted(() => {}) onMounted(() => {})
// // 对外映射 // // 对外映射