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

261 lines
9.5 KiB
Vue
Raw Normal View History

2024-12-26 09:28:19 +08:00
<template>
2025-02-13 16:15:26 +08:00
<el-dialog :title="dialogTitle" v-model="dialogVisible" @close="close" v-bind="dialogBig" width="1400px">
<div class="dialog-content">
<el-tabs type="border-card" class="left-tabs" style="height: 100%">
2024-12-30 14:43:13 +08:00
<el-tab-pane label="输出菜单">
<!-- 输出菜单内容 -->
2025-02-13 16:15:26 +08:00
<el-table
:data="tableData"
:header-cell-style="{ textAlign: 'center', backgroundColor: '#003078', color: '#fff' }"
:cell-style="{ textAlign: 'center' }"
style="width: 100%"
:style="{ height: '295px', overflow: 'hidden' }"
:show-header="false"
:span-method="arraySpanMethod"
>
<el-table-column prop="sort" label="相别" width="60" />
<el-table-column prop="frequency" label="电压/电流" width="90" />
<el-table-column prop="L1" label="值" width="180" />
<el-table-column label="操作" width="80">
<template #default="{}">
<el-button type="info" :icon="Bottom"></el-button>
</template>
</el-table-column>
<el-table-column label="操作">
<template #default="{ row, $index }">
<el-button
:type="buttonTypes[$index].channel || 'info'"
@click="toggleType(row, $index, 'channel')"
>
通道使能
</el-button>
<el-button
:type="buttonTypes[$index]?.harmonic || 'info'"
@click="toggleType(row, $index, 'harmonic')"
>
谐波使能
</el-button>
<el-button
:type="buttonTypes[$index]?.interHarmonic || 'info'"
@click="toggleType(row, $index, 'interHarmonic')"
>
间谐波使能
</el-button>
<el-button
:type="buttonTypes[$index]?.flicker || 'info'"
@click="toggleType(row, $index, 'flicker')"
>
闪变使能
</el-button>
<el-button
:type="buttonTypes[$index]?.transient || 'info'"
@click="toggleType(row, $index, 'transient')"
>
暂态使能
</el-button>
</template>
</el-table-column>
</el-table>
2024-12-30 14:43:13 +08:00
</el-tab-pane>
</el-tabs>
2025-02-13 16:15:26 +08:00
<el-tabs type="border-card" class="right-tabs" style="height: 100%">
2024-12-30 14:43:13 +08:00
<el-tab-pane label="全局设置菜单">
2025-02-13 16:15:26 +08:00
<!-- 全局设置菜单内容 -->
<div style="height: 295px;">
<div class="form-item-container">
<el-form-item label="频率:" prop="name">
<div class="input-label-container">
<el-input style="width: 100px" />
<label>Hz</label>
</div>
</el-form-item>
</div>
<div class="button-label-container">
<label>参考设定值列表:</label>
<el-button type="primary" :icon="EditPen" @click="openDialog">编辑</el-button>
</div>
2025-01-06 09:21:24 +08:00
</div>
2024-12-30 14:43:13 +08:00
</el-tab-pane>
</el-tabs>
2025-02-13 16:15:26 +08:00
</div>
<div style="margin-top: 10px">
<el-tabs type="border-card" class="custom-tabs">
<el-tab-pane label="电压/电流编辑">
<TestScriptVolCurTab />
</el-tab-pane>
<el-tab-pane label="谐波编辑">
<TestScriptHarmTab />
</el-tab-pane>
<el-tab-pane label="间谐波编辑">
<TestScriptInHarmTab />
</el-tab-pane>
<el-tab-pane label="闪变编辑">
<TestScriptFlickerTab />
</el-tab-pane>
<el-tab-pane label="暂态编辑">
<TestScriptDipTab />
</el-tab-pane>
</el-tabs>
</div>
<SetValueTable ref="setValueTable" />
<template #footer>
<div>
<el-button @click="close()"> </el-button>
<el-button type="primary" @click="save()">保存</el-button>
</div>
</template>
2024-12-26 09:28:19 +08:00
</el-dialog>
2024-12-30 14:43:13 +08:00
</template>
2024-12-26 09:28:19 +08:00
<script setup lang="ts">
import { dialogBig } from '@/utils/elementBind'
2024-12-30 14:43:13 +08:00
import { onMounted, reactive, ref } from 'vue'
2025-02-13 16:15:26 +08:00
import SetValueTable from '@/views/machine/testScript/components/setValueTable.vue'
import { EditPen, ArrowDown, Bottom } from '@element-plus/icons-vue'
import { type TabsInstance } from 'element-plus'
import TestScriptVolCurTab from '@/views/machine/testScript/components/testScriptVolCurTab.vue'
import TestScriptHarmTab from '@/views/machine/testScript/components/testScriptHarmTab.vue'
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'
2024-12-26 09:28:19 +08:00
const dialogVisible = ref(false)
const dialogTitle = ref()
const setValueTable = ref()
2025-02-13 16:15:26 +08:00
const buttonTypeOptions = ['default', 'text', 'success', 'warning', 'info', 'primary', 'danger'] as const
type ButtonType = (typeof buttonTypeOptions)[number]
2024-12-30 14:43:13 +08:00
// 初始化按钮类型
2025-02-13 16:15:26 +08:00
const buttonTypes = reactive<{
[key: number]: {
channel: ButtonType
harmonic: ButtonType
interHarmonic: ButtonType
flicker: ButtonType
transient: ButtonType
}
}>({})
const tableData = [
{ sort: 'L1', frequency: 'V', L1: '电压:57.75V 相角:0°' },
{ sort: 'L1', frequency: 'I', L1: '电压:57.75V 相角:0°' },
{ sort: 'L2', frequency: 'V', L1: '电压:57.75V 相角:0°' },
{ sort: 'L2', frequency: 'I', L1: '电压:57.75V 相角:0°' },
{ sort: 'L3', frequency: 'V', L1: '电压:57.75V 相角:0°' },
{ sort: 'L3', frequency: 'I', L1: '电压:57.75V 相角:0°' }
]
2024-12-30 14:43:13 +08:00
// 定义 span-method 逻辑
const arraySpanMethod = ({ rowIndex, columnIndex }: { rowIndex: number; columnIndex: number }) => {
2025-02-13 16:15:26 +08:00
if (columnIndex === 0 || columnIndex === 3) {
// 第一列
if (rowIndex % 2 === 0) {
return {
rowspan: 2,
colspan: 1
}
} else {
return {
rowspan: 0,
colspan: 0
}
}
2024-12-30 14:43:13 +08:00
}
2025-02-13 16:15:26 +08:00
}
2024-12-26 09:28:19 +08:00
2024-12-30 14:43:13 +08:00
// 切换按钮类型
2025-02-13 16:15:26 +08:00
const toggleType = (
row: any,
$index: number,
buttonType: 'channel' | 'harmonic' | 'interHarmonic' | 'flicker' | 'transient'
) => {
if ($index !== undefined) {
const currentType = buttonTypes[$index][buttonType]
buttonTypes[$index][buttonType] = currentType === 'info' ? 'primary' : 'info'
}
}
2024-12-30 14:43:13 +08:00
2024-12-26 09:28:19 +08:00
// 关闭弹窗
const close = () => {
dialogVisible.value = false
}
2024-12-30 14:43:13 +08:00
2025-02-13 16:15:26 +08:00
// 保存数据
const save = () => {}
2024-12-30 14:43:13 +08:00
2024-12-26 09:28:19 +08:00
// 打开弹窗,可能是新增,也可能是编辑
2025-02-13 16:15:26 +08:00
const open = (sign: string, row: any) => {
2024-12-26 09:28:19 +08:00
dialogVisible.value = true
2025-02-13 16:15:26 +08:00
dialogTitle.value = sign === 'add' ? '新增检测项目信息' : '编辑检测项目信息'
2024-12-30 14:43:13 +08:00
// 初始化按钮类型
2025-02-13 16:15:26 +08:00
tableData.forEach((_, index) => {
buttonTypes[index] = {
channel: 'info',
harmonic: 'info',
interHarmonic: 'info',
flicker: 'info',
transient: 'info'
}
})
2024-12-30 14:43:13 +08:00
}
// 打开 drawer(新增、编辑)
const openDialog = () => {
2025-02-13 16:15:26 +08:00
setValueTable.value?.open()
2024-12-26 09:28:19 +08:00
}
// 对外映射
defineExpose({ open })
</script>
<style scoped>
2024-12-30 14:43:13 +08:00
.dialog-content {
2025-02-13 16:15:26 +08:00
display: flex;
justify-content: flex-start;
align-items: stretch;
height: 100%;
2024-12-30 14:43:13 +08:00
}
.tabs-container {
2025-02-13 16:15:26 +08:00
display: flex;
flex-direction: row;
height: 100%;
width: 100%;
2024-12-30 14:43:13 +08:00
}
.left-tabs {
2025-02-13 16:15:26 +08:00
flex: 3; /* 左侧 tab 占据 3/4 的宽度 */
margin-right: 10px; /* 可选:添加间距 */
2024-12-30 14:43:13 +08:00
}
.right-tabs {
2025-02-13 16:15:26 +08:00
flex: 1; /* 右侧 tab 占据 1/4 的宽度 */
2024-12-30 14:43:13 +08:00
}
.form-item-container {
2025-02-13 16:15:26 +08:00
display: flex;
justify-content: center; /* 水平居中 */
margin-bottom: 10px; /* 可选:添加间距 */
2024-12-30 14:43:13 +08:00
}
.button-label-container {
2025-02-13 16:15:26 +08:00
display: flex;
justify-content: center; /* 水平居中 */
align-items: center; /* 垂直居中 */
2024-12-30 14:43:13 +08:00
}
.button-label-container label {
2025-02-13 16:15:26 +08:00
margin-right: 10px; /* 按钮和文字之间的距离 */
2024-12-30 14:43:13 +08:00
}
2025-01-06 09:21:24 +08:00
.input-label-container {
2025-02-13 16:15:26 +08:00
display: flex;
align-items: center; /* 垂直居中对齐 */
2025-01-06 09:21:24 +08:00
}
2024-12-30 14:43:13 +08:00
2025-01-06 09:21:24 +08:00
.input-label-container label {
2025-02-13 16:15:26 +08:00
margin-left: 5px; /* 添加标签与输入框之间的间距 */
2025-01-06 09:21:24 +08:00
}
2025-02-13 16:15:26 +08:00
</style>