联调 新增检测脚本

This commit is contained in:
GGJ
2025-02-18 16:36:54 +08:00
parent 4f622da52c
commit ce92a1d645
13 changed files with 603 additions and 313 deletions

View File

@@ -5,12 +5,12 @@
<el-tab-pane label="检测">
<!-- 全局设置菜单内容 -->
<div style="height: 295px">
<el-radio-group v-model="radio">
<el-radio-group v-model="subType">
<el-radio
v-for="item in tabChildren"
:key="item"
:label="item.label"
:value="item.value"
:value="item.code"
border
style="margin: 0 0 10px 10px"
/>
@@ -37,23 +37,45 @@
<el-table-column prop="L1" label="值" width="180" align="center">
<template #default="{ row, $index }">
<span>
{{ row.frequency === 'V' ? '电压' : '电流' }}{{ form.children[$index].fAmp
}}{{ row.frequency === 'V' ? 'V' : 'A' }} 相角{{ form.children[$index].fPhase }}°
{{ row.frequency === 'V' ? '电压' : '电流' }}{{ form.channelList[$index].fAmp
}}{{ valueCode == 'Absolute' ? (row.frequency === 'V' ? 'V' : 'A') : '%' }} 相角{{
form.channelList[$index].fPhase
}}°
</span>
</template>
</el-table-column>
<el-table-column label="操作" width="85">
<template #default="{}">
<el-button type="primary" link :icon="Bottom">复制</el-button>
<template #default="{ row, $index }">
<el-button type="primary" v-if="$index != 4" link :icon="CopyDocument">复制</el-button>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template #default="{ row, $index }">
<el-checkbox-group v-model="form.children[$index].checkboxGroup">
<el-checkbox-button v-for="item in GroupList" :key="item.value" :value="item.value">
{{ item.label }}
</el-checkbox-button>
</el-checkbox-group>
<el-checkbox-button
v-model="form.channelList[$index].channelFlag"
label="通道使能"
size="small"
/>
<el-checkbox-button
v-model="form.channelList[$index].harmFlag"
label="谐波使能"
size="small"
/>
<el-checkbox-button
v-model="form.channelList[$index].inHarmFlag"
label="间谐波使能"
size="small"
/>
<el-checkbox-button
v-model="form.channelList[$index].flickerFlag"
label="闪变使能"
size="small"
/>
<el-checkbox-button
v-model="form.channelList[$index].dipFlag"
label="暂态使能"
size="small"
/>
</template>
</el-table-column>
</el-table>
@@ -66,7 +88,7 @@
<div class="form-item-container">
<el-form-item label="频率:" prop="name">
<div class="input-label-container">
<el-input style="width: 100px" v-model="form.fFreq" />
<el-input type="number" style="width: 100px" v-model="form.fFreq" />
<label>Hz</label>
</div>
</el-form-item>
@@ -81,19 +103,19 @@
</div>
<div style="margin-top: 10px">
<el-tabs type="border-card" class="custom-tabs">
<el-tab-pane label="电压/电流编辑">
<el-tab-pane label="电压/电流编辑" v-if="childForm[0].channelFlag || childForm[1].channelFlag">
<TestScriptVolCurTab :childForm="childForm" />
</el-tab-pane>
<el-tab-pane label="谐波编辑">
<el-tab-pane label="谐波编辑" v-if="childForm[0].harmFlag || childForm[1].harmFlag">
<TestScriptHarmTab :childForm="childForm" />
</el-tab-pane>
<el-tab-pane label="间谐波编辑">
<el-tab-pane label="间谐波编辑" v-if="childForm[0].inHarmFlag || childForm[1].inHarmFlag">
<TestScriptInHarmTab :childForm="childForm" />
</el-tab-pane>
<el-tab-pane label="闪变编辑">
<el-tab-pane label="闪变编辑" v-if="childForm[0].flickerFlag || childForm[1].flickerFlag">
<TestScriptFlickerTab :childForm="childForm" />
</el-tab-pane>
<el-tab-pane label="暂态编辑">
<el-tab-pane label="暂态编辑" v-if="childForm[0].dipFlag || childForm[1].dipFlag">
<TestScriptDipTab :childForm="childForm" />
</el-tab-pane>
</el-tabs>
@@ -121,116 +143,34 @@ import TestScriptHarmTab from '@/views/machine/testScript/components/testScriptH
import TestScriptInHarmTab from '@/views/machine/testScript/components/testScriptInHarmTab.vue'
import TestScriptFlickerTab from '@/views/machine/testScript/components/testScriptFlickerTab.vue'
import TestScriptDipTab from '@/views/machine/testScript/components/testScriptDipTab.vue'
import { useDictStore } from '@/stores/modules/dict'
import { addScriptDtls } from '@/api/device/testScript'
import scriptForm from './scriptForm'
const emit = defineEmits(['addTab'])
interface TabOption {
label: string
name: string
value: string
children?: TabOption[]
}
const dictStore = useDictStore()
const props = defineProps({
options: {
type: Array as PropType<TabOption[]>,
type: [Array, Object],
required: true
},
activeName: {
type: String,
required: true
},
formContent: {
type: Object,
required: true
}
})
const GroupList = [
{
label: '通道使能',
value: 'channelFlag'
},
{
label: '谐波使能',
value: 'harmFlag'
},
{
label: '间谐波使能',
value: 'inHarmFlag'
},
{
label: '闪变使能',
value: 'flickerFlag'
},
{
label: '暂态使能',
value: 'dipFlag'
}
]
const form: any = ref({
value: '',
label: '',
fFreq: 50,
children: [
{
checkboxGroup: ['channelFlag','harmFlag'],//通道选择
fAmp: 0, //幅值
fPhase: 0, //相角
harmList: [
{
harm: 1, //谐波次数
fAmp: 0, //谐波含有率
fPhase: 0 // 谐波相角
}
], //谐波
inHarmList: [
{
inharm: 1, //间谐波次数
fAmp: 0, //间谐波含有率
fPhase: 0 // 间谐波相角
}
], //间谐波
flickerData: {
fChagValue: 0,//电压变动幅度
fChagFre: 0, //波动频度
waveFluType: 0, //波动类型
waveType: 0, //波类型
fDutyCycle: 0, //占空比
}, //闪变
dipData: {
fTransValue: 0, // 暂态幅值
fRetainTime: 0 // 暂态持续时间
} //暂态
},
{
checkboxGroup: [],
fAmp: 0,
fPhase: 0
},
{
checkboxGroup: [],
fAmp: 0,
fPhase: 0
},
{
checkboxGroup: [],
fAmp: 0,
fPhase: 0
},
{
checkboxGroup: [],
fAmp: 0,
fPhase: 0
},
{
checkboxGroup: [],
fAmp: 0,
fPhase: 0
}
]
})
console.log(`123`, props.formContent)
// let valueType
const form: any = ref(scriptForm)
const childForm: any = ref([])
const ScriptValueType = ref('')
const dialogVisible = ref(false)
const dialogTitle = ref()
const setValueTable = ref()
const buttonTypeOptions = ['default', 'text', 'success', 'warning', 'info', 'primary', 'danger'] as const
const valueCode = ref() //Absolute绝对值
const tableData = [
{ name: 'L1', frequency: 'V', electricity: 0, fPhase: 0, sort: 0 },
@@ -240,7 +180,7 @@ const tableData = [
{ name: 'L3', frequency: 'V', electricity: 0, fPhase: 0, sort: 2 },
{ name: 'L3', frequency: 'I', electricity: 0, fPhase: 0, sort: 2 }
]
const radio = ref('')
const subType = ref('')
const tabChildren: any = ref([])
// 定义 span-method 逻辑
const arraySpanMethod = ({ rowIndex, columnIndex }: { rowIndex: number; columnIndex: number }) => {
@@ -271,8 +211,8 @@ const handleRowClick = async (row: any, column: any) => {
if (column.label == '相别') {
childForm.value = []
selectedRow.value = row.name
childForm.value.push(form.value.children[row.sort * 2])
childForm.value.push(form.value.children[row.sort * 2 + 1])
childForm.value.push(form.value.channelList[row.sort * 2])
childForm.value.push(form.value.channelList[row.sort * 2 + 1])
console.log('🚀 ~ handleRowClick ~ childForm.value:', childForm.value)
}
@@ -286,10 +226,20 @@ const close = () => {
// 保存数据
const save = () => {
dialogVisible.value = false
form.value.value = radio.value
form.value.label = tabChildren.value.filter(item => item.value == radio.value)[0].label
emit('addTab', form.value)
console.log('🚀 ~ save ~ form.value:', form.value)
// dialogVisible.value = false
form.value.subType = subType.value
form.value.label = tabChildren.value.filter((item: any) => item.code == subType.value)[0].label
let copyForm = JSON.parse(JSON.stringify(form.value))
copyForm.channelList.forEach((channel: any) => {
// 筛选出 fAmp 和 fPhase 不同时为 0 的对象
channel.harmList = channel.harmList.filter((item: any) => item.fAmp !== 0 || item.fPhase !== 0)
})
addScriptDtls({ ...copyForm, id: props.formContent.id }).then(res => {})
// emit('addTab', form.value)
}
// 打开弹窗,可能是新增,也可能是编辑
@@ -298,8 +248,12 @@ const open = (sign: string, row: any) => {
dialogTitle.value = sign === 'add' ? '新增检测项目信息' : '编辑检测项目信息'
// 添加选择检测项目
tabChildren.value = props.options.filter(item => item.value == props.activeName)[0].children || []
radio.value = tabChildren.value[0].value || ''
subType.value = tabChildren.value[0].code || ''
handleRowClick({ name: 'L1', sort: 0 }, { label: '相别' })
dictStore.getDictData('Script_Value_Type')
valueCode.value = dictStore
.getDictData('Script_Value_Type')
.filter(item => item.id == props.formContent.valueType)[0].code
}
// 打开 drawer(新增、编辑)