Files
pqs-9100_client/frontend/src/views/machine/testScript/components/testScriptDetail.vue

219 lines
9.4 KiB
Vue
Raw Normal View History

2024-12-24 20:22:36 +08:00
<template>
2025-02-13 16:15:26 +08:00
<div class="divider-container">
2025-02-17 08:39:18 +08:00
<el-divider style="width: 300px" 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>
2025-02-13 16:15:26 +08:00
</div>
2024-12-24 20:22:36 +08:00
<div class="data-check-content">
2025-02-13 16:15:26 +08:00
<div class="content-tree">
2025-02-17 16:44:02 +08:00
<Tree :scriptId="props.scriptId" />
2025-02-13 16:15:26 +08:00
</div>
2025-02-17 08:39:18 +08:00
<div class="content-tree" style="width: 400px">
<Commun :options="props.options" />
</div>
2025-02-13 16:15:26 +08:00
2025-02-17 08:39:18 +08:00
<div class="content-right-Tabs" style="height: calc(100vh - 335px); width: 100px">
<el-tabs type="border-card" style="height: 100%" v-model="activeName">
<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>
</div>
2025-02-13 16:15:26 +08:00
<!-- 频率tab -->
2025-02-17 08:39:18 +08:00
<el-tabs type="border-card">
2025-02-13 16:15:26 +08:00
<el-tab-pane
v-for="subTab in tab.children || []"
:key="subTab.name"
:label="subTab.label"
:name="subTab.name"
>
<div class="table-container">
<el-table
:data="tableData"
:header-cell-style="{
textAlign: 'center',
backgroundColor: '#003078',
color: '#fff'
}"
:cell-style="{ textAlign: 'center' }"
2025-02-17 08:39:18 +08:00
height="calc(100vh - 515px)"
2025-02-13 16:15:26 +08:00
>
<el-table-column prop="sort" label="组次" width="60" />
<el-table-column prop="frequency" label="频率(Hz)" width="100" />
<el-table-column prop="L1" label="L1">
<template #default="scope">
<el-descriptions border :column="1" size="small">
<el-descriptions-item label="V">0.000V   0.000°</el-descriptions-item>
<el-descriptions-item label=" I">0.000A   0.000°</el-descriptions-item>
</el-descriptions>
</template>
</el-table-column>
<el-table-column prop="L2" label="L2">
<template #default="scope">
<el-descriptions border :column="1" size="small">
<el-descriptions-item label="V">0.000V   0.000°</el-descriptions-item>
<el-descriptions-item label=" I">0.000A   0.000°</el-descriptions-item>
</el-descriptions>
</template>
</el-table-column>
<el-table-column prop="L3" label="L3">
<template #default="scope">
<el-descriptions border :column="1" size="small">
<el-descriptions-item label="V">0.000V  0.000°</el-descriptions-item>
<el-descriptions-item label=" I">0.000A   0.000°</el-descriptions-item>
</el-descriptions>
</template>
</el-table-column>
<el-table-column label="操作" min-width="100">
<template #default="{ row }">
<el-button type="primary" link :icon="CopyDocument" @click="copyRow(row)">
复制
</el-button>
<el-button
type="primary"
link
:icon="CopyDocument"
@click="openAddDialog('edit', row)"
>
编辑
</el-button>
<el-button type="primary" link :icon="Delete" @click="deleteRow(row)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</el-tab-pane>
</el-tabs>
</el-tab-pane>
</el-tabs>
2024-12-24 20:22:36 +08:00
</div>
</div>
2024-12-26 09:28:19 +08:00
2025-02-17 08:39:18 +08:00
<TestProjectPopup ref="testProjectPopup" :options="props.options" :activeName="activeName" @addTab="addTab" />
2024-12-24 20:22:36 +08:00
</template>
<script setup lang="ts">
2025-02-17 08:39:18 +08:00
import { type PropType, ref, nextTick } from 'vue'
2025-02-13 16:15:26 +08:00
import Tree from './tree.vue'
2025-02-17 08:39:18 +08:00
import Commun from './communication.vue'
2025-02-13 16:15:26 +08:00
import type { CascaderOption } from 'element-plus'
import { CirclePlus, Delete, EditPen, CopyDocument } from '@element-plus/icons-vue'
import type { TestScript } from '@/api/device/interface/testScript'
import TestProjectPopup from '@/views/machine/testScript/components/testProjectPopup.vue'
2024-12-26 09:28:19 +08:00
interface TabOption {
2025-02-13 16:15:26 +08:00
label: string
name: string
2025-02-17 08:39:18 +08:00
value: string
2025-02-13 16:15:26 +08:00
children?: TabOption[]
2024-12-26 09:28:19 +08:00
}
const props = defineProps({
options: {
2025-02-13 16:15:26 +08:00
type: Array as PropType<TabOption[]>,
required: true
2025-02-17 16:44:02 +08:00
},
scriptId: {
type: String,
required: true
2025-02-13 16:15:26 +08:00
}
})
2025-02-17 08:39:18 +08:00
const activeName = ref('')
const testProjectPopup = ref()
2025-02-13 16:15:26 +08:00
const tableData = [
{ sort: 1, frequency: 42.5, L1: '电压:57.75V 相角:0°', L2: '电压:57.75V 相角:120°', L3: '电压:57.75V 相角:-120°' },
{ sort: 2, frequency: 50, L1: '电压:57.75V 相角:0°', L2: '电压:57.75V 相角:120°', L3: '电压:57.75V 相角:-120°' },
{ sort: 3, frequency: 50.05, L1: '电压:57.75V 相角:0°', L2: '电压:57.75V 相角:120°', L3: '电压:57.75V 相角:-120°' },
{ sort: 4, frequency: 57.5, L1: '电压:57.75V 相角:0°', L2: '电压:57.75V 相角:120°', L3: '电压:57.75V 相角:-120°' },
{ sort: 5, frequency: 57.5, L1: '电压:57.75V 相角:0°', L2: '电压:57.75V 相角:120°', L3: '电压:57.75V 相角:-120°' },
{ sort: 6, frequency: 57.5, L1: '电压:57.75V 相角:0°', L2: '电压:57.75V 相角:120°', L3: '电压:57.75V 相角:-120°' }
]
2025-02-17 08:39:18 +08:00
const tabData: any = ref([])
2024-12-24 20:22:36 +08:00
2024-12-26 09:28:19 +08:00
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> = {}) => {
2025-02-17 08:39:18 +08:00
if (titleType == 'add') {
}
2024-12-26 09:28:19 +08:00
testProjectPopup.value?.open(titleType, row)
}
2025-02-17 08:39:18 +08:00
// 新增保存
const addTab = (row: any) => {
2025-02-17 16:44:02 +08:00
let data = JSON.parse(JSON.stringify(row))
let flag = true
2025-02-17 08:39:18 +08:00
let list: any = {}
2025-02-17 16:44:02 +08:00
let childrenList = {}
2025-02-17 08:39:18 +08:00
tabData.value.forEach(item => {
if (item.value == activeName.value) {
2025-02-17 16:44:02 +08:00
// item.children.push(JSON.parse(JSON.stringify(row)))
2025-02-17 08:39:18 +08:00
list = item
item.children.forEach(k => {
if (k.value == row.value) {
2025-02-17 16:44:02 +08:00
flag = false
childrenList = k
2025-02-17 08:39:18 +08:00
}
})
}
})
if (flag) {
2025-02-17 16:44:02 +08:00
list.children.push(data)
} else {
childrenList.children.push(data)
2025-02-17 08:39:18 +08:00
}
2025-02-17 16:44:02 +08:00
console.log('🚀 ~ addTab ~ tabData.value:', tabData.value)
2025-02-17 08:39:18 +08:00
}
onMounted(() => {
props.options.forEach(item => {
tabData.value.push({
label: item.label.replace(/准确度|检测/g, ''),
value: item.value,
children: []
})
})
activeName.value = tabData.value[0].value
})
2024-12-24 20:22:36 +08:00
</script>
<style scoped>
.data-check-content {
2025-02-13 16:15:26 +08:00
display: flex;
gap: 10px;
2024-12-24 20:22:36 +08:00
}
.content-tree {
2025-02-13 16:15:26 +08:00
width: 300px;
2025-02-17 08:39:18 +08:00
height: calc(100vh - 335px);
2025-02-13 16:15:26 +08:00
border: 1px solid #dcdfe6;
border-radius: 4px;
margin-right: 10px;
overflow: auto; /* 同时启用垂直和水平滚动 */
2025-02-17 08:39:18 +08:00
overflow-x: hidden;
2024-12-24 20:22:36 +08:00
}
/* 确保 el-tree 内容可以超出容器宽度 */
.el-tree {
2025-02-13 16:15:26 +08:00
width: fit-content; /* 根据内容自适应宽度 */
2024-12-24 20:22:36 +08:00
}
.content-right-Tabs {
2025-02-13 16:15:26 +08:00
flex: 1; /* 根据需要调整宽度比例 */
2024-12-24 20:22:36 +08:00
}
2024-12-26 09:28:19 +08:00
2025-02-13 16:15:26 +08:00
.dialog-footer {
display: flex;
justify-content: flex-end;
margin-bottom: 10px;
2024-12-26 09:28:19 +08:00
}
.divider-container {
2025-02-13 16:15:26 +08:00
display: flex;
2024-12-26 09:28:19 +08:00
}
.divider-container .el-divider {
2025-02-13 16:15:26 +08:00
margin-right: 30px; /* 根据需要调整间距 */
}
:deep(.el-descriptions__body .el-descriptions__table:not(.is-bordered) .el-descriptions__cell) {
padding: 3px 11px;
2024-12-26 09:28:19 +08:00
}
2024-12-24 20:22:36 +08:00
</style>