联调检测脚本修改功能

This commit is contained in:
GGJ
2025-02-20 16:39:15 +08:00
parent 629fd174e4
commit 14583d919d
9 changed files with 498 additions and 296 deletions

View File

@@ -2,34 +2,42 @@
<div>
<div class="divider-container">
<el-divider style="width: 300px" 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>
</div>
<div class="data-check-content">
<div class="content-tree">
<Tree :treeData="treeData" />
</div>
<div class="content-tree" style="width: 400px">
<Commun :options="props.options" />
</div>
<div class="content-right-Tabs" style="height: calc(100vh - 335px); width: 100px">
<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">
<div class="dialog-footer">
<el-button :icon="CirclePlus" type="primary" @click="openDialog('add')">新增</el-button>
<!-- <el-button :icon="CirclePlus" type="primary" @click="openAddDialog()">保存测试项</el-button> -->
<el-button :icon="Check" type="primary">保存通讯脚本</el-button>
</div>
<!-- 频率tab -->
<!-- {{ tab.children }} -->
<el-tabs type="border-card" v-model="childActiveName" @tab-change="inquireTable">
<el-tab-pane
v-for="subTab in tab.children || []"
:key="subTab.value"
:label="subTab.label"
:name="subTab.value"
<div style="display: flex">
<!-- 通信脚本 -->
<el-tabs type="border-card" v-model="firstName" style="height: 100%">
<el-tab-pane label="通讯脚本" name="first">
<Commun :options="props.options" style="width: 400px" />
</el-tab-pane>
</el-tabs>
<!-- 2级tab -->
<el-tabs
type="border-card"
style="flex: 1; margin-left: 10px"
v-model="childActiveName"
@tab-change="inquireTable"
>
<div class="table-container">
<el-tab-pane
v-for="subTab in tab.children || []"
:key="subTab.value"
:label="subTab.label"
:name="subTab.value"
style="width: 100%"
>
<el-table
:data="tableData"
:header-cell-style="{
@@ -40,6 +48,7 @@
stripe
:cell-style="{ textAlign: 'center' }"
height="calc(100vh - 515px)"
style="width: 100%"
>
<el-table-column type="index" label="组次" width="60" />
<el-table-column prop="ffreq" label="频率(Hz)" width="100" />
@@ -50,178 +59,49 @@
<td class="theFirst">V</td>
<td>
{{
row.channelList[item.num]?.famp
? '电压=' +
row.channelList[item.num]?.famp +
(valueCode == 'Absolute' ? 'V' : '%')
: '/'
'电压=' +
row.channelList[item.num]?.famp +
(valueCode == 'Absolute' ? 'V' : '%')
}}
</td>
<td>
{{
row.channelList[item.num]?.fphase
? '电流=' + row.channelList[item.num]?.fphase + '°'
: '/'
}}
{{ '相角=' + row.channelList[item.num]?.fphase + '°' }}
</td>
</tr>
<tr>
<td class="theFirst">I</td>
<td>
{{
row.channelList[item.num + 1]?.famp
? '电压=' +
row.channelList[item.num + 1]?.famp +
(valueCode == 'Absolute' ? 'V' : '%')
: '/'
'电流=' +
row.channelList[item.num + 1]?.famp +
(valueCode == 'Absolute' ? 'V' : '%')
}}
</td>
<td>
{{
row.channelList[item.num + 1]?.fphase
? '电流=' +
row.channelList[item.num + 1]?.fphase +
'°'
: '/'
}}
{{ '相角=' + row.channelList[item.num + 1]?.fphase + '°' }}
</td>
</tr>
</table>
</template>
</el-table-column>
<!-- <el-table-column label="L1">
<el-table-column label="是否启用" width="90">
<template #default="{ row }">
<table class="tableL">
<tr>
<td class="theFirst">V</td>
<td>
{{
row.channelList[0]?.famp
? '电压=' +
row.channelList[0]?.famp +
(valueCode == 'Absolute' ? 'V' : '%')
: '/'
}}
</td>
<td>
{{
row.channelList[0]?.fphase
? '电流=' + row.channelList[0]?.fphase + '°'
: '/'
}}
</td>
</tr>
<tr>
<td class="theFirst">I</td>
<td>
{{
row.channelList[1]?.famp
? '电压=' +
row.channelList[1]?.famp +
(valueCode == 'Absolute' ? 'V' : '%')
: '/'
}}
</td>
<td>
{{
row.channelList[1]?.fphase
? '电流=' + row.channelList[1]?.fphase + '°'
: '/'
}}
</td>
</tr>
</table>
<el-switch
v-model="row.enable"
:active-value="1"
:inactive-value="0"
@change="enableRow(row)"
>
<template #active-action>
<span></span>
</template>
<template #inactive-action>
<span>×</span>
</template>
</el-switch>
</template>
</el-table-column>
<el-table-column label="L2">
<template #default="{ row }">
<table class="tableL">
<tr>
<td class="theFirst">V</td>
<td>
{{
row.channelList[2]?.famp
? '电压=' +
row.channelList[2]?.famp +
(valueCode == 'Absolute' ? 'V' : '%')
: '/'
}}
</td>
<td>
{{
row.channelList[2]?.fphase
? '电流=' + row.channelList[2]?.fphase + '°'
: '/'
}}
</td>
</tr>
<tr>
<td class="theFirst">I</td>
<td>
{{
row.channelList[3]?.famp
? '电压=' +
row.channelList[3]?.famp +
(valueCode == 'Absolute' ? 'V' : '%')
: '/'
}}
</td>
<td>
{{
row.channelList[3]?.fphase
? '电流=' + row.channelList[3]?.fphase + '°'
: '/'
}}
</td>
</tr>
</table>
</template>
</el-table-column>
<el-table-column prop="L3" label="L3">
<template #default="{ row }">
<table class="tableL">
<tr>
<td class="theFirst">V</td>
<td>
{{
row.channelList[4]?.famp
? '电压=' +
row.channelList[4]?.famp +
(valueCode == 'Absolute' ? 'V' : '%')
: '/'
}}
</td>
<td>
{{
row.channelList[4]?.fphase
? '电流=' + row.channelList[4]?.fphase + '°'
: '/'
}}
</td>
</tr>
<tr>
<td class="theFirst">I</td>
<td>
{{
row.channelList[5]?.famp
? '电压=' +
row.channelList[5]?.famp +
(valueCode == 'Absolute' ? 'V' : '%')
: '/'
}}
</td>
<td>
{{
row.channelList[5]?.fphase
? '电流=' + row.channelList[5]?.fphase + '°'
: '/'
}}
</td>
</tr>
</table>
</template>
</el-table-column> -->
<el-table-column label="操作" width="210">
<el-table-column label="操作" width="220">
<template #default="{ row }">
<el-button
type="primary"
@@ -235,7 +115,7 @@
type="primary"
link
:icon="CopyDocument"
@click="openAddDialog('edit', row)"
@click="openDialog('edit', row)"
>
编辑
</el-button>
@@ -245,9 +125,9 @@
</template>
</el-table-column>
</el-table>
</div>
</el-tab-pane>
</el-tabs>
</el-tab-pane>
</el-tabs>
</div>
</el-tab-pane>
</el-tabs>
</div>
@@ -257,8 +137,11 @@
ref="testProjectPopupRef"
:options="props.options"
:activeName="activeName"
@addTab="addTab"
:childActiveName="childActiveName"
:formContent="props.formContent"
@addTab="addTab"
@close="showDialog = false"
v-if="showDialog"
/>
</div>
</template>
@@ -269,12 +152,13 @@ import Tree from './tree.vue'
import Commun from './communication.vue'
import type { CascaderOption } from 'element-plus'
import { getTreeData } from '@/api/check/test'
import { CirclePlus, Delete, EditPen, CopyDocument } from '@element-plus/icons-vue'
import { CirclePlus, Delete, Check, CopyDocument } from '@element-plus/icons-vue'
import type { TestScript } from '@/api/device/interface/testScript'
import TestProjectPopup from '@/views/machine/testScript/components/testProjectPopup.vue'
import { CheckData } from '@/api/check/interface'
import { dlsDetails } from '@/api/device/testScript'
import { dlsDetails, deleteDtls, updateDtls, addScriptDtls } from '@/api/device/testScript'
import { useDictStore } from '@/stores/modules/dict'
import { useHandleData } from '@/hooks/useHandleData'
interface TabOption {
label?: string
name?: string
@@ -294,9 +178,11 @@ const props = defineProps({
required: true
}
})
const showDialog = ref(false)
const dictStore = useDictStore()
const activeName = ref('')
const childActiveName = ref('')
const firstName = 'first'
const testProjectPopupRef = ref()
const tableData: any = ref([])
const tabData: any = ref([])
@@ -362,7 +248,7 @@ const tabChange = () => {
copyActiveName.value == activeName.value
childActiveName.value = ''
childActiveName.value =
tabData.value.filter(item => item.value == activeName.value)[0]?.children[0]?.value || ''
tabData.value.filter((item: any) => item.value == activeName.value)[0]?.children[0]?.value || ''
}
inquireTable()
}
@@ -376,22 +262,63 @@ const inquireTable = () => {
}).then((res: any) => {
if (res.code === 'A0000') {
res.data.forEach((item: any) => {
item.channelList = item.channelList.sort((a, b) => {
item.channelList = item.channelList.sort((a: any, b: any) => {
const indexA = sortOrder.indexOf(a.channelType)
const indexB = sortOrder.indexOf(b.channelType)
return indexA - indexB
})
})
tableData.value = res.data
}
})
}
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> = {}) => {
if (titleType == 'add') {
}
testProjectPopupRef.value?.open(titleType, row)
showDialog.value = true
setTimeout(() => {
testProjectPopupRef.value?.open(titleType, row)
}, 0)
}
// 复制
const copyRow = (row: any) => {
let copyRow = JSON.parse(JSON.stringify(row))
delete copyRow.index
addScriptDtls({ ...copyRow, scriptType: activeName.value }).then(res => {
if (res.code === 'A0000') {
ElMessage.success({
message: '复制成功!',
type: 'success'
})
getTree()
}
})
}
// 删除
const deleteRow = async (row: any) => {
await useHandleData(deleteDtls, { enable: row.enable, index: row.index, scriptId: row.scriptId }, `删除`)
getTree()
}
// 启用
const enableRow = async (row: any) => {
ElMessageBox.confirm(`是否${row.enable == 0 ? `禁用` : `启用`}?`, '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
draggable: true
})
.then(async () => {
updateDtls({ enable: row.enable, index: row.index, scriptId: row.scriptId }).then(res => {
ElMessage({
type: 'success',
message: `${row.enable == 0 ? `禁用` : `启用`}成功!`
})
getTree()
})
})
.catch(() => {
row.enable = row.enable == 0 ? 1 : 0
})
}
// 获取左边树数据
// 新增保存
@@ -420,7 +347,6 @@ const addTab = (row: any) => {
// }
}
onMounted(() => {
console.log('🚀 ~ onMounted ~ props.options:', props.options)
getTree()
props.options.forEach((item: any) => {
tabData.value.push({
@@ -451,6 +377,9 @@ onMounted(() => {
overflow: auto; /* 同时启用垂直和水平滚动 */
overflow-x: hidden;
}
.scriptTree {
height: calc(100vh - 520px);
}
/* 确保 el-tree 内容可以超出容器宽度 */
.el-tree {
@@ -496,3 +425,12 @@ onMounted(() => {
}
}
</style>
<style>
input::-webkit-inner-spin-button {
-webkit-appearance: none !important;
}
input::-webkit-outer-spin-button {
-webkit-appearance: none !important;
}
</style>