修改检测脚本页面
This commit is contained in:
@@ -23,7 +23,7 @@ export namespace TestScript {
|
|||||||
valueType?: string;//脚本值类型(字典表Code字段,相对值脚本、绝对值脚本、无)
|
valueType?: string;//脚本值类型(字典表Code字段,相对值脚本、绝对值脚本、无)
|
||||||
standardName: string;//参照标准名称
|
standardName: string;//参照标准名称
|
||||||
standardTime: string;//标准推行时间
|
standardTime: string;//标准推行时间
|
||||||
state:number;//
|
state?:number;//
|
||||||
createBy?: string;
|
createBy?: string;
|
||||||
createTime?: string;
|
createTime?: string;
|
||||||
updateBy?: string;
|
updateBy?: string;
|
||||||
|
|||||||
@@ -4,12 +4,19 @@ import http from '@/api'
|
|||||||
/**
|
/**
|
||||||
* @name 检测脚本管理模块
|
* @name 检测脚本管理模块
|
||||||
*/
|
*/
|
||||||
|
// 新增脚本
|
||||||
|
export const pqScriptAdd = (params: TestScript.ResTestScript) => {
|
||||||
|
return http.post(`/pqScript/add`, params)
|
||||||
|
}
|
||||||
|
// 修改脚本
|
||||||
|
export const pqScriptUpdate = (params: TestScript.ResTestScript) => {
|
||||||
|
return http.post(`/pqScript/update`, params)
|
||||||
|
}
|
||||||
// 获取检测脚本列表
|
// 获取检测脚本列表
|
||||||
export const getPqScriptList = (params: TestScript.ReqTestScriptParams) => {
|
export const getPqScriptList = (params: TestScript.ReqTestScriptParams) => {
|
||||||
return http.post(`/pqScript/list`, params)
|
return http.post(`/pqScript/list`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//升级为模版
|
//升级为模版
|
||||||
export const updatePqScript = (params: TestScript.ResTestScript) => {
|
export const updatePqScript = (params: TestScript.ResTestScript) => {
|
||||||
return http.get(`/pqScript/upgradeToTemplate?id=${params.id}`)
|
return http.get(`/pqScript/upgradeToTemplate?id=${params.id}`)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog :title="dialogTitle" v-model="dialogVisible" @close="close" v-bind="dialogBig" width="1500px">
|
<el-dialog :title="dialogTitle" v-model="dialogVisible" @close="close" v-bind="dialogBig" width="1400px">
|
||||||
<div class="dialog-content">
|
<div class="dialog-content">
|
||||||
<el-tabs type="border-card" class="right-tabs" style="height: 100%">
|
<el-tabs type="border-card" class="right-tabs" style="height: 100%">
|
||||||
<el-tab-pane label="全局设置菜单">
|
<el-tab-pane label="检测">
|
||||||
<!-- 全局设置菜单内容 -->
|
<!-- 全局设置菜单内容 -->
|
||||||
<div style="height: 295px">
|
<div style="height: 295px">
|
||||||
<el-radio-group v-model="radio">
|
<el-radio-group v-model="radio">
|
||||||
@@ -30,48 +30,30 @@
|
|||||||
:span-method="arraySpanMethod"
|
:span-method="arraySpanMethod"
|
||||||
:cell-style="tableStyle.cellStyle"
|
:cell-style="tableStyle.cellStyle"
|
||||||
:header-cell-style="{ textAlign: 'center', backgroundColor: '#003078', color: '#fff' }"
|
:header-cell-style="{ textAlign: 'center', backgroundColor: '#003078', color: '#fff' }"
|
||||||
@row-click="handleRowClick"
|
@cell-click="handleRowClick"
|
||||||
>
|
>
|
||||||
<el-table-column prop="sort" label="相别" width="60" align="center" />
|
<el-table-column prop="name" label="相别" width="60" align="center" />
|
||||||
<el-table-column prop="frequency" label="电压/电流" align="center" width="90" />
|
<el-table-column prop="frequency" label="电压/电流" align="center" width="60" />
|
||||||
<el-table-column prop="L1" label="值" width="180" align="center" />
|
<el-table-column prop="L1" label="值" width="180" align="center">
|
||||||
<el-table-column label="操作" width="80">
|
<template #default="{ row, $index }">
|
||||||
|
<span>
|
||||||
|
{{ row.frequency === 'V' ? '电压' : '电流' }}{{ form.children[$index].fAmp
|
||||||
|
}}{{ row.frequency === 'V' ? 'V' : 'A' }} 相角{{ form.children[$index].fPhase }}°
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="85">
|
||||||
<template #default="{}">
|
<template #default="{}">
|
||||||
<el-button type="primary" :icon="Bottom"></el-button>
|
<el-button type="primary" link :icon="Bottom">复制</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center">
|
<el-table-column label="操作" align="center">
|
||||||
<template #default="{ row, $index }">
|
<template #default="{ row, $index }">
|
||||||
<el-button
|
<el-checkbox-group v-model="form.children[$index].checkboxGroup">
|
||||||
:type="buttonTypes[$index].channel || 'info'"
|
<el-checkbox-button v-for="item in GroupList" :key="item.value" :value="item.value">
|
||||||
@click="toggleType(row, $index, 'channel')"
|
{{ item.label }}
|
||||||
>
|
</el-checkbox-button>
|
||||||
通道使能
|
</el-checkbox-group>
|
||||||
</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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -84,7 +66,7 @@
|
|||||||
<div class="form-item-container">
|
<div class="form-item-container">
|
||||||
<el-form-item label="频率:" prop="name">
|
<el-form-item label="频率:" prop="name">
|
||||||
<div class="input-label-container">
|
<div class="input-label-container">
|
||||||
<el-input style="width: 100px" />
|
<el-input style="width: 100px" v-model="form.fFreq" />
|
||||||
<label>Hz</label>
|
<label>Hz</label>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -100,19 +82,19 @@
|
|||||||
<div style="margin-top: 10px">
|
<div style="margin-top: 10px">
|
||||||
<el-tabs type="border-card" class="custom-tabs">
|
<el-tabs type="border-card" class="custom-tabs">
|
||||||
<el-tab-pane label="电压/电流编辑">
|
<el-tab-pane label="电压/电流编辑">
|
||||||
<TestScriptVolCurTab />
|
<TestScriptVolCurTab :childForm="childForm" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="谐波编辑">
|
<el-tab-pane label="谐波编辑">
|
||||||
<TestScriptHarmTab />
|
<TestScriptHarmTab :childForm="childForm" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="间谐波编辑">
|
<el-tab-pane label="间谐波编辑">
|
||||||
<TestScriptInHarmTab />
|
<TestScriptInHarmTab :childForm="childForm" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="闪变编辑">
|
<el-tab-pane label="闪变编辑">
|
||||||
<TestScriptFlickerTab />
|
<TestScriptFlickerTab :childForm="childForm" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="暂态编辑">
|
<el-tab-pane label="暂态编辑">
|
||||||
<TestScriptDipTab />
|
<TestScriptDipTab :childForm="childForm" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
@@ -132,13 +114,14 @@
|
|||||||
import { dialogBig } from '@/utils/elementBind'
|
import { dialogBig } from '@/utils/elementBind'
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
import SetValueTable from '@/views/machine/testScript/components/setValueTable.vue'
|
import SetValueTable from '@/views/machine/testScript/components/setValueTable.vue'
|
||||||
import { EditPen, ArrowDown, Bottom } from '@element-plus/icons-vue'
|
import { EditPen, ArrowDown, Bottom, CopyDocument } from '@element-plus/icons-vue'
|
||||||
import { type TabsInstance } from 'element-plus'
|
import { type TabsInstance } from 'element-plus'
|
||||||
import TestScriptVolCurTab from '@/views/machine/testScript/components/testScriptVolCurTab.vue'
|
import TestScriptVolCurTab from '@/views/machine/testScript/components/testScriptVolCurTab.vue'
|
||||||
import TestScriptHarmTab from '@/views/machine/testScript/components/testScriptHarmTab.vue'
|
import TestScriptHarmTab from '@/views/machine/testScript/components/testScriptHarmTab.vue'
|
||||||
import TestScriptInHarmTab from '@/views/machine/testScript/components/testScriptInHarmTab.vue'
|
import TestScriptInHarmTab from '@/views/machine/testScript/components/testScriptInHarmTab.vue'
|
||||||
import TestScriptFlickerTab from '@/views/machine/testScript/components/testScriptFlickerTab.vue'
|
import TestScriptFlickerTab from '@/views/machine/testScript/components/testScriptFlickerTab.vue'
|
||||||
import TestScriptDipTab from '@/views/machine/testScript/components/testScriptDipTab.vue'
|
import TestScriptDipTab from '@/views/machine/testScript/components/testScriptDipTab.vue'
|
||||||
|
|
||||||
const emit = defineEmits(['addTab'])
|
const emit = defineEmits(['addTab'])
|
||||||
interface TabOption {
|
interface TabOption {
|
||||||
label: string
|
label: string
|
||||||
@@ -157,34 +140,105 @@ const props = defineProps({
|
|||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const form = ref({
|
const GroupList = [
|
||||||
|
{
|
||||||
|
label: '通道使能',
|
||||||
|
value: 'channelFlag'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '谐波使能',
|
||||||
|
value: 'harmFlag'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '间谐波使能',
|
||||||
|
value: 'inHarmFlag'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '闪变使能',
|
||||||
|
value: 'flickerFlag'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '暂态使能',
|
||||||
|
value: 'dipFlag'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
const form: any = ref({
|
||||||
value: '',
|
value: '',
|
||||||
label: ''
|
label: '',
|
||||||
|
fFreq: 50,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
checkboxGroup: ['channelFlag','harmFlag'],//通道选择
|
||||||
|
fAmp: 0, //幅值
|
||||||
|
fPhase: 0, //相角
|
||||||
|
harmList: [
|
||||||
|
{
|
||||||
|
harm: 1, //谐波次数
|
||||||
|
fAmp: 0, //谐波含有率
|
||||||
|
fPhase: 0 // 谐波相角
|
||||||
|
}
|
||||||
|
], //谐波
|
||||||
|
inHarmList: [
|
||||||
|
{
|
||||||
|
inharm: 1, //间谐波次数
|
||||||
|
fAmp: 0, //间谐波含有率
|
||||||
|
fPhase: 0 // 间谐波相角
|
||||||
|
}
|
||||||
|
], //间谐波
|
||||||
|
flickerData: {
|
||||||
|
fChagValue: 0,//电压变动幅度
|
||||||
|
fChagFre: 0, //波动频度
|
||||||
|
waveFluType: 0, //波动类型
|
||||||
|
waveType: 0, //波类型
|
||||||
|
fDutyCycle: 0, //占空比
|
||||||
|
|
||||||
|
}, //闪变
|
||||||
|
dipData: {
|
||||||
|
fTransValue: 0, // 暂态幅值
|
||||||
|
fRetainTime: 0 // 暂态持续时间
|
||||||
|
} //暂态
|
||||||
|
},
|
||||||
|
{
|
||||||
|
checkboxGroup: [],
|
||||||
|
fAmp: 0,
|
||||||
|
fPhase: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
checkboxGroup: [],
|
||||||
|
fAmp: 0,
|
||||||
|
fPhase: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
checkboxGroup: [],
|
||||||
|
fAmp: 0,
|
||||||
|
fPhase: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
checkboxGroup: [],
|
||||||
|
fAmp: 0,
|
||||||
|
fPhase: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
checkboxGroup: [],
|
||||||
|
fAmp: 0,
|
||||||
|
fPhase: 0
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
const childForm: any = ref([])
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const dialogTitle = ref()
|
const dialogTitle = ref()
|
||||||
const setValueTable = ref()
|
const setValueTable = ref()
|
||||||
const buttonTypeOptions = ['default', 'text', 'success', 'warning', 'info', 'primary', 'danger'] as const
|
const buttonTypeOptions = ['default', 'text', 'success', 'warning', 'info', 'primary', 'danger'] as const
|
||||||
type ButtonType = (typeof buttonTypeOptions)[number]
|
|
||||||
// 初始化按钮类型
|
|
||||||
const buttonTypes = reactive<{
|
|
||||||
[key: number]: {
|
|
||||||
channel: ButtonType
|
|
||||||
harmonic: ButtonType
|
|
||||||
interHarmonic: ButtonType
|
|
||||||
flicker: ButtonType
|
|
||||||
transient: ButtonType
|
|
||||||
}
|
|
||||||
}>({})
|
|
||||||
|
|
||||||
const tableData = [
|
const tableData = [
|
||||||
{ sort: 'L1', frequency: 'V', L1: '电压:57.75V 相角:0°' },
|
{ name: 'L1', frequency: 'V', electricity: 0, fPhase: 0, sort: 0 },
|
||||||
{ sort: 'L1', frequency: 'I', L1: '电压:57.75V 相角:0°' },
|
{ name: 'L1', frequency: 'I', electricity: 0, fPhase: 0, sort: 0 },
|
||||||
{ sort: 'L2', frequency: 'V', L1: '电压:57.75V 相角:0°' },
|
{ name: 'L2', frequency: 'V', electricity: 0, fPhase: 0, sort: 1 },
|
||||||
{ sort: 'L2', frequency: 'I', L1: '电压:57.75V 相角:0°' },
|
{ name: 'L2', frequency: 'I', electricity: 0, fPhase: 0, sort: 1 },
|
||||||
{ sort: 'L3', frequency: 'V', L1: '电压:57.75V 相角:0°' },
|
{ name: 'L3', frequency: 'V', electricity: 0, fPhase: 0, sort: 2 },
|
||||||
{ sort: 'L3', frequency: 'I', L1: '电压:57.75V 相角:0°' }
|
{ name: 'L3', frequency: 'I', electricity: 0, fPhase: 0, sort: 2 }
|
||||||
]
|
]
|
||||||
const radio = ref('')
|
const radio = ref('')
|
||||||
const tabChildren: any = ref([])
|
const tabChildren: any = ref([])
|
||||||
@@ -205,28 +259,24 @@ const arraySpanMethod = ({ rowIndex, columnIndex }: { rowIndex: number; columnIn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const selectedRow = ref('L1')
|
const selectedRow = ref('')
|
||||||
const tableStyle = {
|
const tableStyle = {
|
||||||
cellStyle: ({ row }: { row: any }) => {
|
cellStyle: ({ row }: { row: any }) => {
|
||||||
return row.sort === selectedRow.value
|
return row.name === selectedRow.value
|
||||||
? { backgroundColor: '#dcdcdc' } // 设置选中行的背景颜色
|
? { backgroundColor: '#dcdcdc' } // 设置选中行的背景颜色
|
||||||
: {}
|
: {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const handleRowClick = async (row: any) => {
|
const handleRowClick = async (row: any, column: any) => {
|
||||||
selectedRow.value = row.sort
|
if (column.label == '相别') {
|
||||||
}
|
childForm.value = []
|
||||||
|
selectedRow.value = row.name
|
||||||
// 切换按钮类型
|
childForm.value.push(form.value.children[row.sort * 2])
|
||||||
const toggleType = (
|
childForm.value.push(form.value.children[row.sort * 2 + 1])
|
||||||
row: any,
|
console.log('🚀 ~ handleRowClick ~ childForm.value:', childForm.value)
|
||||||
$index: number,
|
|
||||||
buttonType: 'channel' | 'harmonic' | 'interHarmonic' | 'flicker' | 'transient'
|
|
||||||
) => {
|
|
||||||
if ($index !== undefined) {
|
|
||||||
const currentType = buttonTypes[$index][buttonType]
|
|
||||||
buttonTypes[$index][buttonType] = currentType === 'info' ? 'primary' : 'info'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// childForm.value = row
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
@@ -236,6 +286,7 @@ const close = () => {
|
|||||||
|
|
||||||
// 保存数据
|
// 保存数据
|
||||||
const save = () => {
|
const save = () => {
|
||||||
|
dialogVisible.value = false
|
||||||
form.value.value = radio.value
|
form.value.value = radio.value
|
||||||
form.value.label = tabChildren.value.filter(item => item.value == radio.value)[0].label
|
form.value.label = tabChildren.value.filter(item => item.value == radio.value)[0].label
|
||||||
emit('addTab', form.value)
|
emit('addTab', form.value)
|
||||||
@@ -245,19 +296,10 @@ const save = () => {
|
|||||||
const open = (sign: string, row: any) => {
|
const open = (sign: string, row: any) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
dialogTitle.value = sign === 'add' ? '新增检测项目信息' : '编辑检测项目信息'
|
dialogTitle.value = sign === 'add' ? '新增检测项目信息' : '编辑检测项目信息'
|
||||||
|
// 添加选择检测项目
|
||||||
// 初始化按钮类型
|
|
||||||
tableData.forEach((_, index) => {
|
|
||||||
buttonTypes[index] = {
|
|
||||||
channel: 'info',
|
|
||||||
harmonic: 'info',
|
|
||||||
interHarmonic: 'info',
|
|
||||||
flicker: 'info',
|
|
||||||
transient: 'info'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
tabChildren.value = props.options.filter(item => item.value == props.activeName)[0].children || []
|
tabChildren.value = props.options.filter(item => item.value == props.activeName)[0].children || []
|
||||||
radio.value = tabChildren.value[0].value || ''
|
radio.value = tabChildren.value[0].value || ''
|
||||||
|
handleRowClick({ name: 'L1', sort: 0 }, { label: '相别' })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开 drawer(新增、编辑)
|
// 打开 drawer(新增、编辑)
|
||||||
@@ -285,7 +327,7 @@ defineExpose({ open })
|
|||||||
}
|
}
|
||||||
|
|
||||||
.left-tabs {
|
.left-tabs {
|
||||||
width: 980px;
|
width: 900px;
|
||||||
margin: 0 10px; /* 可选:添加间距 */
|
margin: 0 10px; /* 可选:添加间距 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="data-check-content">
|
<div class="data-check-content">
|
||||||
<div class="content-tree">
|
<div class="content-tree">
|
||||||
<Tree />
|
<Tree :scriptId="props.scriptId" />
|
||||||
</div>
|
</div>
|
||||||
<div class="content-tree" style="width: 400px">
|
<div class="content-tree" style="width: 400px">
|
||||||
<Commun :options="props.options" />
|
<Commun :options="props.options" />
|
||||||
@@ -114,6 +114,10 @@ const props = defineProps({
|
|||||||
options: {
|
options: {
|
||||||
type: Array as PropType<TabOption[]>,
|
type: Array as PropType<TabOption[]>,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
scriptId: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const activeName = ref('')
|
const activeName = ref('')
|
||||||
@@ -136,24 +140,28 @@ const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> =
|
|||||||
}
|
}
|
||||||
// 新增保存
|
// 新增保存
|
||||||
const addTab = (row: any) => {
|
const addTab = (row: any) => {
|
||||||
let flag = false
|
let data = JSON.parse(JSON.stringify(row))
|
||||||
|
let flag = true
|
||||||
let list: any = {}
|
let list: any = {}
|
||||||
|
let childrenList = {}
|
||||||
tabData.value.forEach(item => {
|
tabData.value.forEach(item => {
|
||||||
if (item.value == activeName.value) {
|
if (item.value == activeName.value) {
|
||||||
|
// item.children.push(JSON.parse(JSON.stringify(row)))
|
||||||
list = item
|
list = item
|
||||||
item.children.forEach(k => {
|
item.children.forEach(k => {
|
||||||
if (k.value == row.value) {
|
if (k.value == row.value) {
|
||||||
flag = true
|
flag = false
|
||||||
|
childrenList = k
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (flag) {
|
if (flag) {
|
||||||
list.children.push(row)
|
list.children.push(data)
|
||||||
|
} else {
|
||||||
|
childrenList.children.push(data)
|
||||||
}
|
}
|
||||||
// if (tab.length == 0) {
|
console.log('🚀 ~ addTab ~ tabData.value:', tabData.value)
|
||||||
// tabData.value.filter(item => item.value == activeName.value)[0].children?.push(row)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
props.options.forEach(item => {
|
props.options.forEach(item => {
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<el-card style="margin-bottom: 10px" class="cardTop">
|
<el-card style="margin-bottom: 10px" class="cardTop">
|
||||||
<el-form :model="formContent" :inline="true" label-width="auto" class="form-five">
|
<el-form
|
||||||
|
:model="formContent"
|
||||||
|
:inline="true"
|
||||||
|
label-width="auto"
|
||||||
|
ref="dialogFormRef"
|
||||||
|
:rules="rules"
|
||||||
|
class="form-five"
|
||||||
|
>
|
||||||
<el-form-item label="脚本名称" prop="name">
|
<el-form-item label="脚本名称" prop="name">
|
||||||
<el-input v-model.trim="formContent.name" placeholder="请输入脚本名称" clearable />
|
<el-input v-model.trim="formContent.name" placeholder="请输入脚本名称" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -9,10 +16,22 @@
|
|||||||
<el-input v-model.trim="formContent.standardName" placeholder="请输入参照标准名称" clearable />
|
<el-input v-model.trim="formContent.standardName" placeholder="请输入参照标准名称" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="标准推行年份" prop="standardTime">
|
<el-form-item label="标准推行年份" prop="standardTime">
|
||||||
<el-date-picker v-model="formContent.standardTime" type="year" placeholder="请选择标准推行年份" />
|
<el-date-picker
|
||||||
|
v-model="formContent.standardTime"
|
||||||
|
style="width: 100%"
|
||||||
|
type="year"
|
||||||
|
format="YYYY"
|
||||||
|
value-format="YYYY"
|
||||||
|
placeholder="请选择标准推行年份"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="检测脚本值类型">
|
<el-form-item label="模版类型" prop="type">
|
||||||
<el-select v-model="formContent.selectedValue" filterable clearable placeholder="请选择值类型">
|
<el-select v-model="formContent.type" filterable clearable placeholder="请选择模版类型">
|
||||||
|
<el-option v-for="item in stencil" :key="item.value" :label="item.name" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="检测脚本值类型" prop="valueType">
|
||||||
|
<el-select v-model="formContent.valueType" filterable clearable placeholder="请选择值类型">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dictStore.getDictData('Script_Value_Type')"
|
v-for="item in dictStore.getDictData('Script_Value_Type')"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@@ -29,13 +48,13 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card>
|
<el-card v-if="show">
|
||||||
<TestScriptDetail :options="secondLevelOptions" v-if="show" />
|
<TestScriptDetail :options="secondLevelOptions" :scriptId="scriptId" />
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import { useDictStore } from '@/stores/modules/dict'
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
import TestScriptDetail from '@/views/machine/testScript/components/testScriptDetail.vue'
|
import TestScriptDetail from '@/views/machine/testScript/components/testScriptDetail.vue'
|
||||||
import { type TestScript } from '@/api/device/interface/testScript'
|
import { type TestScript } from '@/api/device/interface/testScript'
|
||||||
@@ -43,10 +62,12 @@ import type { Dict } from '@/api/system/dictionary/interface'
|
|||||||
import { getDictTreeByCode } from '@/api/system/dictionary/dictTree'
|
import { getDictTreeByCode } from '@/api/system/dictionary/dictTree'
|
||||||
import type { CascaderOption } from 'element-plus'
|
import type { CascaderOption } from 'element-plus'
|
||||||
import { Select, Close } from '@element-plus/icons-vue'
|
import { Select, Close } from '@element-plus/icons-vue'
|
||||||
|
import { pqScriptAdd, pqScriptUpdate } from '@/api/device/testScript'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
const modeId = ref()
|
const modeId = ref()
|
||||||
const show = ref(false)
|
const show = ref(false)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const scriptId = ref('46296b72528f805376e362df594fc669')
|
||||||
const secondLevelOptions: any[] = []
|
const secondLevelOptions: any[] = []
|
||||||
// 定义弹出组件元信息
|
// 定义弹出组件元信息
|
||||||
const dialogFormRef = ref()
|
const dialogFormRef = ref()
|
||||||
@@ -61,10 +82,21 @@ function useMetaInfo() {
|
|||||||
standardName: '',
|
standardName: '',
|
||||||
standardTime: '',
|
standardTime: '',
|
||||||
state: 1,
|
state: 1,
|
||||||
selectedValue: ''
|
valueType: ''
|
||||||
})
|
})
|
||||||
return { titleType, formContent }
|
return { titleType, formContent }
|
||||||
}
|
}
|
||||||
|
const stencil = [
|
||||||
|
{ name: '脚本', value: 0 },
|
||||||
|
{ name: '模版', value: 1 }
|
||||||
|
]
|
||||||
|
const rules = {
|
||||||
|
name: [{ required: true, message: '请输入脚本名称', trigger: 'blur' }],
|
||||||
|
standardName: [{ required: true, message: '请输入参照标准名称', trigger: 'blur' }],
|
||||||
|
standardTime: [{ required: true, message: '请选择标准推行年份', trigger: 'change' }],
|
||||||
|
type: [{ required: true, message: '请选择模版类型', trigger: 'change' }],
|
||||||
|
valueType: [{ required: true, message: '请选择检测脚本值类型', trigger: 'change' }]
|
||||||
|
}
|
||||||
|
|
||||||
const { titleType, formContent } = useMetaInfo()
|
const { titleType, formContent } = useMetaInfo()
|
||||||
|
|
||||||
@@ -74,14 +106,13 @@ const resetFormContent = () => {
|
|||||||
name: '',
|
name: '',
|
||||||
type: '',
|
type: '',
|
||||||
valueType: '',
|
valueType: '',
|
||||||
pattern: modeId.value,
|
pattern: '',
|
||||||
standardName: '',
|
standardName: '',
|
||||||
standardTime: '',
|
standardTime: '',
|
||||||
state: 1
|
state: 1
|
||||||
}
|
}
|
||||||
router.go(-1)
|
router.go(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
const close = () => {
|
const close = () => {
|
||||||
// 清空dialogForm中的值
|
// 清空dialogForm中的值
|
||||||
@@ -93,29 +124,62 @@ const close = () => {
|
|||||||
const closeInformation = () => {}
|
const closeInformation = () => {}
|
||||||
|
|
||||||
// 保存数据
|
// 保存数据
|
||||||
const save = () => {}
|
const save = () => {
|
||||||
|
// dialogFormRef
|
||||||
|
dialogFormRef.value.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (titleType.value == '新增检测脚本') {
|
||||||
|
formContent.value.pattern = modeId.value
|
||||||
|
pqScriptAdd(formContent.value).then(res => {
|
||||||
|
if (res.code === 'A0000') {
|
||||||
|
ElMessage.success({ message: res.message })
|
||||||
|
// scriptId.value = res.data
|
||||||
|
scriptId.value = '46296b72528f805376e362df594fc669'
|
||||||
|
show.value = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
pqScriptUpdate(formContent.value).then(res => {
|
||||||
|
if (res.code === 'A0000') {
|
||||||
|
ElMessage.success({ message: res.message })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 打开弹窗,可能是新增,也可能是编辑
|
// 打开弹窗,可能是新增,也可能是编辑
|
||||||
const open = async (sign: string, row: any, currentMode: string, id: string) => {
|
const open = async (title: string, row: any) => {
|
||||||
|
titleType.value = title
|
||||||
const result = await getDictTreeByCode({ code: 'Script_Indicator_Items' })
|
if (title == '新增检测脚本') {
|
||||||
|
show.value = false
|
||||||
const allOptions = convertToOptions(result.data as Dict.ResDictTree[])
|
} else {
|
||||||
secondLevelOptions.push(...(allOptions[0]?.children || []))
|
let list = JSON.parse(row)
|
||||||
if (id != '') {
|
formContent.value = list
|
||||||
//新增的时候才会重新赋值值类型
|
scriptId.value = list.id
|
||||||
formContent.value.valueType = id
|
|
||||||
}
|
|
||||||
titleType.value = sign
|
|
||||||
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
|
|
||||||
show.value = true
|
show.value = true
|
||||||
|
}
|
||||||
|
|
||||||
// 重置表单
|
// 重置表单
|
||||||
dialogFormRef.value?.resetFields()
|
dialogFormRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
// 获取树字典
|
||||||
|
const treeInfo = async (currentMode: string) => {
|
||||||
|
const result = await getDictTreeByCode({ code: 'Script_Indicator_Items' })
|
||||||
|
const allOptions = convertToOptions(result.data as Dict.ResDictTree[])
|
||||||
|
secondLevelOptions.push(...(allOptions[0]?.children || []))
|
||||||
|
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log(router.options.history.state)
|
|
||||||
let data: any = router.options.history.state
|
let data: any = router.options.history.state
|
||||||
open(data.title, data.row, data.mode, data.id)
|
console.log('🚀 ~ onMounted ~ data:', data)
|
||||||
|
if (data.title == null) return
|
||||||
|
nextTick(async () => {
|
||||||
|
await treeInfo(data.mode)
|
||||||
|
await open(data.title, data.row)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// 转换函数
|
// 转换函数
|
||||||
@@ -150,11 +214,10 @@ defineExpose({ open })
|
|||||||
// justify-content: space-between;
|
// justify-content: space-between;
|
||||||
.el-form-item {
|
.el-form-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 19%;
|
width: 15.8%;
|
||||||
|
|
||||||
.el-form-item__content {
|
.el-form-item__content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
||||||
.el-select,
|
.el-select,
|
||||||
.el-cascader,
|
.el-cascader,
|
||||||
.el-input__inner,
|
.el-input__inner,
|
||||||
|
|||||||
@@ -9,16 +9,16 @@
|
|||||||
<!-- 右侧编辑区域内容 -->
|
<!-- 右侧编辑区域内容 -->
|
||||||
<el-form :inline="true" label-width="auto" :model="form" class="form-two">
|
<el-form :inline="true" label-width="auto" :model="form" class="form-two">
|
||||||
<el-form-item label="电压有效值(V)">
|
<el-form-item label="电压有效值(V)">
|
||||||
<el-input v-model="form.input1" />
|
<el-input-number v-model="form[0].fAmp" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="电流有效值(A)">
|
<el-form-item label="电流有效值(A)">
|
||||||
<el-input v-model="form.input2" />
|
<el-input-number v-model="form[0].fPhase" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="电压相角(°)">
|
<el-form-item label="电压相角(°)">
|
||||||
<el-input v-model="form.input3" />
|
<el-input-number v-model="form[1].fAmp" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="电流相角(°)">
|
<el-form-item label="电流相角(°)">
|
||||||
<el-input v-model="form.input4" />
|
<el-input-number v-model="form[1].fPhase" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
@@ -26,22 +26,33 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref ,watch} from 'vue'
|
||||||
import Line from '@/components/echarts/line/index.vue'
|
import Line from '@/components/echarts/line/index.vue'
|
||||||
const form = ref({
|
// const emit = defineEmits(['update'])
|
||||||
input1: 220,
|
const props = defineProps({
|
||||||
input2: 0,
|
childForm: {
|
||||||
input3: 0,
|
type: Array,
|
||||||
input4: 0
|
required: true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const lineRef: any = ref()
|
const lineRef: any = ref()
|
||||||
const chartsData = ref({})
|
const chartsData = ref({})
|
||||||
const canvas = ref<HTMLCanvasElement | null>(null)
|
// 解构并创建响应式变量
|
||||||
|
const form = computed({
|
||||||
|
get() {
|
||||||
|
return props.childForm
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
drawSineWave()
|
drawSineWave()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
function drawSineWave() {
|
function drawSineWave() {
|
||||||
chartsData.value = {
|
chartsData.value = {
|
||||||
tooltip: {
|
tooltip: {
|
||||||
@@ -88,7 +99,7 @@ function drawSineWave() {
|
|||||||
{
|
{
|
||||||
name: '',
|
name: '',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: [10, -10, 10, -10, 10, -10, 10, -10, 10, -10,10],
|
data: [10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10],
|
||||||
showSymbol: false,
|
showSymbol: false,
|
||||||
smooth: true
|
smooth: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-tree node-key="id" default-expand-all :data="dataTree" :props="defaultProps">
|
<el-tree node-key="id" default-expand-all :data="dataTree" :props="defaultProps" style="width: 100%">
|
||||||
<template #default="{ node, data }">
|
<template #default="{ node, data }">
|
||||||
<el-tooltip effect="dark" :content="data.scriptTypeName" placement="top" :hide-after="0">
|
<el-tooltip effect="dark" :content="data.scriptTypeName" placement="top" :hide-after="0">
|
||||||
<div class="custom-tree-node">
|
<div class="custom-tree-node">
|
||||||
@@ -13,6 +13,12 @@
|
|||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive } from 'vue'
|
||||||
import { getTreeData } from '@/api/check/test'
|
import { getTreeData } from '@/api/check/test'
|
||||||
import { CheckData } from '@/api/check/interface'
|
import { CheckData } from '@/api/check/interface'
|
||||||
|
const props = defineProps({
|
||||||
|
scriptId: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
const dataTree = ref<CheckData.TreeItem[]>([])
|
const dataTree = ref<CheckData.TreeItem[]>([])
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
children: 'children',
|
children: 'children',
|
||||||
@@ -21,7 +27,7 @@ const defaultProps = {
|
|||||||
}
|
}
|
||||||
const open = () => {
|
const open = () => {
|
||||||
getTreeData({
|
getTreeData({
|
||||||
scriptId: 'a303b2224845fcc6f60198b8ca23dca9'
|
scriptId: props.scriptId
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
dataTree.value = res.data
|
dataTree.value = res.data
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ import { useRouter } from 'vue-router'
|
|||||||
import { getPqScriptList, updatePqScript, deletePqScript } from '@/api/device/testScript/index'
|
import { getPqScriptList, updatePqScript, deletePqScript } from '@/api/device/testScript/index'
|
||||||
import { computed, reactive, ref } from 'vue'
|
import { computed, reactive, ref } from 'vue'
|
||||||
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||||
defineOptions({
|
// defineOptions({
|
||||||
name: 'testScript'
|
// name: 'testScript'
|
||||||
})
|
// })
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const comparisonPopup = ref()
|
const comparisonPopup = ref()
|
||||||
const testScriptPopup = ref()
|
const testScriptPopup = ref()
|
||||||
@@ -145,14 +145,15 @@ const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> =
|
|||||||
comparisonPopup.value?.open(titleType, row, modeStore.currentMode)
|
comparisonPopup.value?.open(titleType, row, modeStore.currentMode)
|
||||||
} else {
|
} else {
|
||||||
if (titleType == 'add') {
|
if (titleType == 'add') {
|
||||||
// valueTypePopup.value?.open(titleType, row,modeStore.currentMode)
|
|
||||||
// testScriptPopup.value?.open('新增检测脚本', {}, row, modeStore.currentMode, '')
|
|
||||||
router.push({
|
router.push({
|
||||||
path: '/machine/testScriptAdd',
|
path: '/machine/testScriptAdd',
|
||||||
state: { title: '新增检测脚本', row: row, mode: modeStore.currentMode }
|
state: { title: '新增检测脚本', row: '', mode: modeStore.currentMode }
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
testScriptPopup.value?.open(titleType, row, modeStore.currentMode, '')
|
router.push({
|
||||||
|
path: '/machine/testScriptAdd',
|
||||||
|
state: { title: '编辑检测脚本', row: JSON.stringify(row), mode: modeStore.currentMode }
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user