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

163 lines
4.9 KiB
Vue
Raw Normal View History

2024-12-26 09:28:19 +08:00
<template>
2025-02-24 16:45:39 +08:00
<div class="table-container">
<el-table
:data="tableData"
:header-cell-style="{
textAlign: 'center',
backgroundColor: '#003078',
color: '#fff'
}"
stripe
:cell-style="{ textAlign: 'center' }"
height="600px"
>
<el-table-column type="index" label="序号" width="60" />
<el-table-column prop="pname" label="参考设定值类型" />
<el-table-column prop="name" label="参考设定值子类型" />
<el-table-column prop="dataType" label="值类型" :formatter="formatter" />
<el-table-column prop="phase" label="相别" />
<el-table-column prop="value" label="参考设定值" />
<el-table-column prop="value" label="参与误差比较">
<template #default="{ row }">
{{ row.errorFlag == 0 ? '否' : '是' }}
2024-12-30 14:43:13 +08:00
</template>
2025-02-24 16:45:39 +08:00
</el-table-column>
<el-table-column label="操作">
<template #default="{ row }">
<el-button type="primary" link :icon="EditPen">编辑</el-button>
2024-12-30 14:43:13 +08:00
</template>
2025-02-24 16:45:39 +08:00
</el-table-column>
</el-table>
</div>
2024-12-30 14:43:13 +08:00
2025-02-17 08:39:18 +08:00
<el-dialog :title="dialogTitle" v-model="showForm" @close="close" width="500">
<el-form ref="form" :model="form" label-width="auto">
<el-form-item label="参考设定值类型" prop="name">
<el-input v-model="form.name" />
</el-form-item>
<el-form-item label="参考设定值子类型" prop="standardName">
<el-input v-model="form.standardName" />
</el-form-item>
<el-form-item label="参考设定值" prop="standardTime">
<el-input v-model="form.standardTime" />
</el-form-item>
</el-form>
<template #footer>
<div>
<el-button @click="close()"> </el-button>
<el-button type="primary" @click="save"> </el-button>
</div>
</template>
2024-12-30 14:43:13 +08:00
</el-dialog>
2025-02-17 08:39:18 +08:00
</template>
2024-12-26 09:28:19 +08:00
<script setup lang="ts">
2025-02-17 08:39:18 +08:00
import { CirclePlus, EditPen, Delete, Share } from '@element-plus/icons-vue'
import { reactive, ref } from 'vue'
2025-02-24 08:38:54 +08:00
import { getDictTreeByCode } from '@/api/system/dictionary/dictTree'
2024-12-30 14:43:13 +08:00
import { dialogBig } from '@/utils/elementBind'
2025-02-24 08:38:54 +08:00
import { checkDataList, scriptDtlsCheckDataList } from '@/api/device/testScript/index'
2025-02-17 08:39:18 +08:00
const showForm = ref(false)
2024-12-30 14:43:13 +08:00
const dialogVisible = ref(false)
const dialogTitle = ref('')
2025-02-24 08:38:54 +08:00
const props = defineProps({
activeName: {
type: String,
required: true
2025-02-17 08:39:18 +08:00
},
2025-02-24 08:38:54 +08:00
formContent: {
type: [Object, Array],
required: true
2025-02-17 08:39:18 +08:00
},
2025-02-24 08:38:54 +08:00
form: {
type: [Object, Array],
required: true
}
})
const tableData: any = ref([])
// 表格配置项
2025-02-17 08:39:18 +08:00
const form = ref({
name: 220,
standardName: 0,
standardTime: 0
})
2025-02-24 16:45:39 +08:00
const formatter = (row: any, column: any) => {
if (column.property == 'dataType') {
return row.dataType == 'real'
? '实时'
: row.dataType == 'cp95'
? 'CP95值'
: row.dataType == 'avg'
? '平均值'
: row.dataType == 'min'
? '最小值'
: row.dataType == 'max'
? '最大值'
: row.dataType
}
}
2024-12-30 14:43:13 +08:00
// 打开弹窗,可能是新增,也可能是编辑
2025-02-24 08:38:54 +08:00
2025-02-24 16:45:39 +08:00
const open = async (row: any) => {
2025-02-24 08:38:54 +08:00
let treeData: any = []
await getDictTreeByCode({
name: '',
id: '',
pid: '',
pids: '',
code: 'Script_Error',
sort: 0
}).then((res: any) => {
treeData = res.data[0].children
})
2025-02-24 16:45:39 +08:00
let checkDataList: any = []
await row.forEach((item: any) => {
item.children.forEach((k: any) => {
if (k.enable != 0 || k.errorFlag != 0) {
checkDataList.push({
pid: k.pid,
valueType: k.id,
dataType: k.dataType,
enable: k.enable,
errorFlag: k.errorFlag
})
}
})
})
2025-02-24 08:38:54 +08:00
await scriptDtlsCheckDataList({
...props.form,
scriptId: props.formContent?.id,
scriptType: props.activeName,
checkDataList: checkDataList
}).then((res: any) => {
res.data.forEach((item: any) => {
let pList = treeData.filter((i: any) => i.id == item.pid)[0]
item.pname = pList.name
item.name = pList.children.filter((i: any) => i.id == item.valueType)[0].name
})
tableData.value = res.data
})
2025-02-17 08:39:18 +08:00
}
const save = () => {
dialogVisible.value = false
2024-12-30 14:43:13 +08:00
}
2025-02-24 16:45:39 +08:00
const getTableData = () => {
return tableData.value
}
2024-12-30 14:43:13 +08:00
// 关闭弹窗
const close = () => {
dialogVisible.value = false
}
2025-02-24 16:45:39 +08:00
onMounted(() => {})
2025-02-24 08:38:54 +08:00
2024-12-30 14:43:13 +08:00
// 对外映射
2025-02-24 16:45:39 +08:00
defineExpose({ open, getTableData })
2024-12-26 09:28:19 +08:00
</script>
2025-02-17 08:39:18 +08:00
<style scoped></style>