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

183 lines
5.7 KiB
Vue
Raw Normal View History

2025-02-17 08:39:18 +08:00
<template>
<div>
<el-table
:data="tableData"
:header-cell-style="{
textAlign: 'center',
backgroundColor: '#003078',
color: '#fff'
}"
stripe
2025-02-27 15:09:09 +08:00
height="calc(100vh - 480px)"
2025-02-17 08:39:18 +08:00
:style="{ overflow: 'hidden' }"
row-key="id"
default-expand-all
>
2025-02-27 15:09:09 +08:00
<el-table-column prop="name" label="指标" show-overflow-tooltip />
<el-table-column align="center" label="参与误差比较" width="110px">
2025-02-17 08:39:18 +08:00
<template #default="{ row }">
2025-02-24 16:45:39 +08:00
<el-switch
v-model="row.errorFlag"
v-if="row.show"
:active-value="1"
:inactive-value="0"
:disabled="row.disabled || disabled"
2025-02-24 16:45:39 +08:00
>
2025-02-17 08:39:18 +08:00
<template #active-action>
<span></span>
</template>
<template #inactive-action>
<span>×</span>
</template>
</el-switch>
</template>
</el-table-column>
2025-02-27 15:09:09 +08:00
<el-table-column align="center" label="是否启用" width="85px">
2025-02-17 08:39:18 +08:00
<template #default="{ row }">
2025-02-24 16:45:39 +08:00
<el-switch
v-model="row.enable"
v-if="row.show"
:active-value="1"
:inactive-value="0"
:disabled="row.disabled || disabled"
2025-02-24 16:45:39 +08:00
>
2025-02-17 08:39:18 +08:00
<template #active-action>
<span></span>
</template>
<template #inactive-action>
<span>×</span>
</template>
</el-switch>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import type { Dict } from '@/api/system/dictionary/interface'
2025-02-17 09:00:27 +08:00
import { getDictTreeByCode } from '@/api/system/dictionary/dictTree'
2025-02-24 08:38:54 +08:00
import { checkDataList } from '@/api/device/testScript'
2025-02-17 08:39:18 +08:00
const props = defineProps({
2025-02-24 08:38:54 +08:00
activeName: {
type: String,
2025-02-17 08:39:18 +08:00
required: true
2025-02-24 16:45:39 +08:00
},
formContent: {
type: Object,
required: true
},
disabled: {
type: Boolean,
default: true
},
options: {
type: Array,
required: true
2025-02-17 08:39:18 +08:00
}
})
const tableData = ref<any[]>([])
2025-02-24 08:38:54 +08:00
const info = async () => {
2025-02-24 16:45:39 +08:00
let checkData: any = []
let title = props.options.filter((i: any) => i.value == props.activeName)[0]
2025-02-24 16:45:39 +08:00
await checkDataList({
scriptId: props.formContent.id,
scriptType: props.activeName
}).then((res: any) => {
checkData = res.data
})
2025-02-24 08:38:54 +08:00
let { data } = await getDictTreeByCode({
2025-02-18 16:36:54 +08:00
name: '',
id: '',
pid: '',
pids: '',
code: 'Script_Error',
sort: 0
})
2025-02-17 08:39:18 +08:00
2025-02-24 08:38:54 +08:00
data[0].children.forEach((item: any, i: number) => {
2025-02-17 08:39:18 +08:00
tableData.value.push({
id: item.id,
name: item.name,
show: false,
children: []
})
item.children.forEach((k: any) => {
2025-02-24 16:45:39 +08:00
let childrenList: any = []
checkData.forEach((j: any) => {
if (j.valueType == k.id) {
childrenList.push(j)
}
2025-02-17 08:39:18 +08:00
})
2025-02-24 16:45:39 +08:00
if (childrenList.length > 0) {
tableData.value[i].children.push({
id: k.id,
pid: item.id,
name: k.name,
pname: item.name,
2025-02-27 16:24:13 +08:00
dataType:
item.name == '谐波有功功率'
? 'avg'
: item.name == '闪变'
? 'avg'
: item.name == '暂态'
? 'avg'
: 'real',
2025-02-24 16:45:39 +08:00
show: true,
errorFlag: childrenList[0].errorFlag,
enable: childrenList[0].enable
})
} else {
tableData.value[i].children.push({
id: k.id,
pid: item.id,
name: k.name,
disabled: false,
pname: item.name,
2025-02-27 16:24:13 +08:00
dataType: '谐波有功功率'
? 'avg'
: item.name == '闪变'
? 'avg'
: item.name == '暂态'
? 'avg'
: 'real',
2025-02-24 16:45:39 +08:00
show: true,
errorFlag: 0,
enable: 0
})
}
2025-02-17 08:39:18 +08:00
})
// 默认够选通讯脚本
if (item.name == title.label.replace(/准确度|检测/g, '')) {
if (item.name == '暂态') {
tableData.value[i].children.forEach((k: any) => {
k.disabled = true
k.enable = 1
k.errorFlag = 1
})
} else {
tableData.value[i].children[0].disabled = true
tableData.value[i].children[0].enable = 1
tableData.value[i].children[0].errorFlag = 1
}
}
2025-02-17 08:39:18 +08:00
})
2025-02-24 16:45:39 +08:00
console.log('🚀 ~ item.children.forEach ~ tableData.value:', tableData.value)
}
const getData = () => {
return tableData.value
2025-02-24 08:38:54 +08:00
}
onMounted(() => {
info()
2025-02-17 08:39:18 +08:00
// tableData.value = data.data[0].children || []
})
2025-02-24 16:45:39 +08:00
// 对外映射
defineExpose({ getData })
2025-02-17 08:39:18 +08:00
</script>
<style lang="scss" scoped></style>