修改检测脚本页面
This commit is contained in:
@@ -23,7 +23,7 @@ export namespace TestScript {
|
||||
valueType?: string;//脚本值类型(字典表Code字段,相对值脚本、绝对值脚本、无)
|
||||
standardName: string;//参照标准名称
|
||||
standardTime: string;//标准推行时间
|
||||
state:number;//
|
||||
state?:number;//
|
||||
createBy?: string;
|
||||
createTime?: string;
|
||||
updateBy?: string;
|
||||
|
||||
@@ -4,18 +4,25 @@ import http from '@/api'
|
||||
/**
|
||||
* @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) => {
|
||||
return http.post(`/pqScript/list`, params)
|
||||
return http.post(`/pqScript/list`, params)
|
||||
}
|
||||
|
||||
|
||||
//升级为模版
|
||||
export const updatePqScript = (params: TestScript.ResTestScript) => {
|
||||
return http.get(`/pqScript/upgradeToTemplate?id=${params.id}`)
|
||||
return http.get(`/pqScript/upgradeToTemplate?id=${params.id}`)
|
||||
}
|
||||
|
||||
//删除检测脚本
|
||||
export const deletePqScript = (params: string[]) => {
|
||||
return http.post(`/pqScript/delete`, params)
|
||||
return http.post(`/pqScript/delete`, params)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<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">
|
||||
<el-tabs type="border-card" class="right-tabs" style="height: 100%">
|
||||
<el-tab-pane label="全局设置菜单">
|
||||
<el-tab-pane label="检测">
|
||||
<!-- 全局设置菜单内容 -->
|
||||
<div style="height: 295px">
|
||||
<el-radio-group v-model="radio">
|
||||
@@ -30,48 +30,30 @@
|
||||
:span-method="arraySpanMethod"
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
: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="frequency" label="电压/电流" align="center" width="90" />
|
||||
<el-table-column prop="L1" label="值" width="180" align="center" />
|
||||
<el-table-column label="操作" width="80">
|
||||
<el-table-column prop="name" label="相别" width="60" align="center" />
|
||||
<el-table-column prop="frequency" label="电压/电流" align="center" width="60" />
|
||||
<el-table-column prop="L1" label="值" width="180" align="center">
|
||||
<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="{}">
|
||||
<el-button type="primary" :icon="Bottom"></el-button>
|
||||
<el-button type="primary" link :icon="Bottom">复制</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<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>
|
||||
<el-checkbox-group v-model="form.children[$index].checkboxGroup">
|
||||
<el-checkbox-button v-for="item in GroupList" :key="item.value" :value="item.value">
|
||||
{{ item.label }}
|
||||
</el-checkbox-button>
|
||||
</el-checkbox-group>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -84,7 +66,7 @@
|
||||
<div class="form-item-container">
|
||||
<el-form-item label="频率:" prop="name">
|
||||
<div class="input-label-container">
|
||||
<el-input style="width: 100px" />
|
||||
<el-input style="width: 100px" v-model="form.fFreq" />
|
||||
<label>Hz</label>
|
||||
</div>
|
||||
</el-form-item>
|
||||
@@ -100,19 +82,19 @@
|
||||
<div style="margin-top: 10px">
|
||||
<el-tabs type="border-card" class="custom-tabs">
|
||||
<el-tab-pane label="电压/电流编辑">
|
||||
<TestScriptVolCurTab />
|
||||
<TestScriptVolCurTab :childForm="childForm" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="谐波编辑">
|
||||
<TestScriptHarmTab />
|
||||
<TestScriptHarmTab :childForm="childForm" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="间谐波编辑">
|
||||
<TestScriptInHarmTab />
|
||||
<TestScriptInHarmTab :childForm="childForm" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="闪变编辑">
|
||||
<TestScriptFlickerTab />
|
||||
<TestScriptFlickerTab :childForm="childForm" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="暂态编辑">
|
||||
<TestScriptDipTab />
|
||||
<TestScriptDipTab :childForm="childForm" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
@@ -132,13 +114,14 @@
|
||||
import { dialogBig } from '@/utils/elementBind'
|
||||
import { onMounted, reactive, ref } from '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 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'
|
||||
|
||||
const emit = defineEmits(['addTab'])
|
||||
interface TabOption {
|
||||
label: string
|
||||
@@ -157,34 +140,105 @@ const props = defineProps({
|
||||
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: '',
|
||||
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 dialogTitle = ref()
|
||||
const setValueTable = ref()
|
||||
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 = [
|
||||
{ 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°' }
|
||||
{ name: 'L1', frequency: 'V', electricity: 0, fPhase: 0, sort: 0 },
|
||||
{ name: 'L1', frequency: 'I', electricity: 0, fPhase: 0, sort: 0 },
|
||||
{ name: 'L2', frequency: 'V', electricity: 0, fPhase: 0, sort: 1 },
|
||||
{ name: 'L2', frequency: 'I', electricity: 0, fPhase: 0, sort: 1 },
|
||||
{ name: 'L3', frequency: 'V', electricity: 0, fPhase: 0, sort: 2 },
|
||||
{ name: 'L3', frequency: 'I', electricity: 0, fPhase: 0, sort: 2 }
|
||||
]
|
||||
const radio = 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 = {
|
||||
cellStyle: ({ row }: { row: any }) => {
|
||||
return row.sort === selectedRow.value
|
||||
return row.name === selectedRow.value
|
||||
? { backgroundColor: '#dcdcdc' } // 设置选中行的背景颜色
|
||||
: {}
|
||||
}
|
||||
}
|
||||
const handleRowClick = async (row: any) => {
|
||||
selectedRow.value = row.sort
|
||||
}
|
||||
|
||||
// 切换按钮类型
|
||||
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'
|
||||
const handleRowClick = async (row: any, column: any) => {
|
||||
if (column.label == '相别') {
|
||||
childForm.value = []
|
||||
selectedRow.value = row.name
|
||||
childForm.value.push(form.value.children[row.sort * 2])
|
||||
childForm.value.push(form.value.children[row.sort * 2 + 1])
|
||||
console.log('🚀 ~ handleRowClick ~ childForm.value:', childForm.value)
|
||||
}
|
||||
|
||||
// childForm.value = row
|
||||
}
|
||||
|
||||
// 关闭弹窗
|
||||
@@ -236,6 +286,7 @@ const close = () => {
|
||||
|
||||
// 保存数据
|
||||
const save = () => {
|
||||
dialogVisible.value = false
|
||||
form.value.value = radio.value
|
||||
form.value.label = tabChildren.value.filter(item => item.value == radio.value)[0].label
|
||||
emit('addTab', form.value)
|
||||
@@ -245,19 +296,10 @@ const save = () => {
|
||||
const open = (sign: string, row: any) => {
|
||||
dialogVisible.value = true
|
||||
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 || []
|
||||
radio.value = tabChildren.value[0].value || ''
|
||||
handleRowClick({ name: 'L1', sort: 0 }, { label: '相别' })
|
||||
}
|
||||
|
||||
// 打开 drawer(新增、编辑)
|
||||
@@ -285,7 +327,7 @@ defineExpose({ open })
|
||||
}
|
||||
|
||||
.left-tabs {
|
||||
width: 980px;
|
||||
width: 900px;
|
||||
margin: 0 10px; /* 可选:添加间距 */
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</div>
|
||||
<div class="data-check-content">
|
||||
<div class="content-tree">
|
||||
<Tree />
|
||||
<Tree :scriptId="props.scriptId" />
|
||||
</div>
|
||||
<div class="content-tree" style="width: 400px">
|
||||
<Commun :options="props.options" />
|
||||
@@ -114,6 +114,10 @@ const props = defineProps({
|
||||
options: {
|
||||
type: Array as PropType<TabOption[]>,
|
||||
required: true
|
||||
},
|
||||
scriptId: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
const activeName = ref('')
|
||||
@@ -136,24 +140,28 @@ const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> =
|
||||
}
|
||||
// 新增保存
|
||||
const addTab = (row: any) => {
|
||||
let flag = false
|
||||
let data = JSON.parse(JSON.stringify(row))
|
||||
let flag = true
|
||||
let list: any = {}
|
||||
let childrenList = {}
|
||||
tabData.value.forEach(item => {
|
||||
if (item.value == activeName.value) {
|
||||
// item.children.push(JSON.parse(JSON.stringify(row)))
|
||||
list = item
|
||||
item.children.forEach(k => {
|
||||
if (k.value == row.value) {
|
||||
flag = true
|
||||
flag = false
|
||||
childrenList = k
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
if (flag) {
|
||||
list.children.push(row)
|
||||
list.children.push(data)
|
||||
} else {
|
||||
childrenList.children.push(data)
|
||||
}
|
||||
// if (tab.length == 0) {
|
||||
// tabData.value.filter(item => item.value == activeName.value)[0].children?.push(row)
|
||||
// }
|
||||
console.log('🚀 ~ addTab ~ tabData.value:', tabData.value)
|
||||
}
|
||||
onMounted(() => {
|
||||
props.options.forEach(item => {
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
<template>
|
||||
<div>
|
||||
<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-input v-model.trim="formContent.name" placeholder="请输入脚本名称" clearable />
|
||||
</el-form-item>
|
||||
@@ -9,10 +16,22 @@
|
||||
<el-input v-model.trim="formContent.standardName" placeholder="请输入参照标准名称" clearable />
|
||||
</el-form-item>
|
||||
<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 label="检测脚本值类型">
|
||||
<el-select v-model="formContent.selectedValue" filterable clearable placeholder="请选择值类型">
|
||||
<el-form-item label="模版类型" prop="type">
|
||||
<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
|
||||
v-for="item in dictStore.getDictData('Script_Value_Type')"
|
||||
:key="item.id"
|
||||
@@ -29,13 +48,13 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<TestScriptDetail :options="secondLevelOptions" v-if="show" />
|
||||
<el-card v-if="show">
|
||||
<TestScriptDetail :options="secondLevelOptions" :scriptId="scriptId" />
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { ref, nextTick } from 'vue'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import TestScriptDetail from '@/views/machine/testScript/components/testScriptDetail.vue'
|
||||
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 type { CascaderOption } from 'element-plus'
|
||||
import { Select, Close } from '@element-plus/icons-vue'
|
||||
import { pqScriptAdd, pqScriptUpdate } from '@/api/device/testScript'
|
||||
import { useRouter } from 'vue-router'
|
||||
const modeId = ref()
|
||||
const show = ref(false)
|
||||
const router = useRouter()
|
||||
const scriptId = ref('46296b72528f805376e362df594fc669')
|
||||
const secondLevelOptions: any[] = []
|
||||
// 定义弹出组件元信息
|
||||
const dialogFormRef = ref()
|
||||
@@ -61,10 +82,21 @@ function useMetaInfo() {
|
||||
standardName: '',
|
||||
standardTime: '',
|
||||
state: 1,
|
||||
selectedValue: ''
|
||||
valueType: ''
|
||||
})
|
||||
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()
|
||||
|
||||
@@ -74,14 +106,13 @@ const resetFormContent = () => {
|
||||
name: '',
|
||||
type: '',
|
||||
valueType: '',
|
||||
pattern: modeId.value,
|
||||
pattern: '',
|
||||
standardName: '',
|
||||
standardTime: '',
|
||||
state: 1
|
||||
}
|
||||
router.go(-1)
|
||||
}
|
||||
|
||||
// 关闭弹窗
|
||||
const close = () => {
|
||||
// 清空dialogForm中的值
|
||||
@@ -93,29 +124,62 @@ const close = () => {
|
||||
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 result = await getDictTreeByCode({ code: 'Script_Indicator_Items' })
|
||||
|
||||
const allOptions = convertToOptions(result.data as Dict.ResDictTree[])
|
||||
secondLevelOptions.push(...(allOptions[0]?.children || []))
|
||||
if (id != '') {
|
||||
//新增的时候才会重新赋值值类型
|
||||
formContent.value.valueType = id
|
||||
const open = async (title: string, row: any) => {
|
||||
titleType.value = title
|
||||
if (title == '新增检测脚本') {
|
||||
show.value = false
|
||||
} else {
|
||||
let list = JSON.parse(row)
|
||||
formContent.value = list
|
||||
scriptId.value = list.id
|
||||
show.value = true
|
||||
}
|
||||
titleType.value = sign
|
||||
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
|
||||
show.value = true
|
||||
|
||||
// 重置表单
|
||||
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(() => {
|
||||
console.log(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;
|
||||
.el-form-item {
|
||||
display: flex;
|
||||
width: 19%;
|
||||
width: 15.8%;
|
||||
|
||||
.el-form-item__content {
|
||||
flex: 1;
|
||||
|
||||
.el-select,
|
||||
.el-cascader,
|
||||
.el-input__inner,
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
<!-- 右侧编辑区域内容 -->
|
||||
<el-form :inline="true" label-width="auto" :model="form" class="form-two">
|
||||
<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 label="电流有效值(A)">
|
||||
<el-input v-model="form.input2" />
|
||||
<el-input-number v-model="form[0].fPhase" />
|
||||
</el-form-item>
|
||||
<el-form-item label="电压相角(°)">
|
||||
<el-input v-model="form.input3" />
|
||||
<el-input-number v-model="form[1].fAmp" />
|
||||
</el-form-item>
|
||||
<el-form-item label="电流相角(°)">
|
||||
<el-input v-model="form.input4" />
|
||||
<el-input-number v-model="form[1].fPhase" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
@@ -26,22 +26,33 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { onMounted, ref ,watch} from 'vue'
|
||||
import Line from '@/components/echarts/line/index.vue'
|
||||
const form = ref({
|
||||
input1: 220,
|
||||
input2: 0,
|
||||
input3: 0,
|
||||
input4: 0
|
||||
// const emit = defineEmits(['update'])
|
||||
const props = defineProps({
|
||||
childForm: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
const lineRef: any = ref()
|
||||
const chartsData = ref({})
|
||||
const canvas = ref<HTMLCanvasElement | null>(null)
|
||||
// 解构并创建响应式变量
|
||||
const form = computed({
|
||||
get() {
|
||||
return props.childForm
|
||||
},
|
||||
set(value) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
drawSineWave()
|
||||
})
|
||||
|
||||
|
||||
function drawSineWave() {
|
||||
chartsData.value = {
|
||||
tooltip: {
|
||||
@@ -88,7 +99,7 @@ function drawSineWave() {
|
||||
{
|
||||
name: '',
|
||||
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,
|
||||
smooth: true
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<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 }">
|
||||
<el-tooltip effect="dark" :content="data.scriptTypeName" placement="top" :hide-after="0">
|
||||
<div class="custom-tree-node">
|
||||
@@ -13,6 +13,12 @@
|
||||
import { ref, reactive } from 'vue'
|
||||
import { getTreeData } from '@/api/check/test'
|
||||
import { CheckData } from '@/api/check/interface'
|
||||
const props = defineProps({
|
||||
scriptId: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
const dataTree = ref<CheckData.TreeItem[]>([])
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
@@ -21,7 +27,7 @@ const defaultProps = {
|
||||
}
|
||||
const open = () => {
|
||||
getTreeData({
|
||||
scriptId: 'a303b2224845fcc6f60198b8ca23dca9'
|
||||
scriptId: props.scriptId
|
||||
}).then(res => {
|
||||
dataTree.value = res.data
|
||||
})
|
||||
|
||||
@@ -72,9 +72,9 @@ import { useRouter } from 'vue-router'
|
||||
import { getPqScriptList, updatePqScript, deletePqScript } from '@/api/device/testScript/index'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||
defineOptions({
|
||||
name: 'testScript'
|
||||
})
|
||||
// defineOptions({
|
||||
// name: 'testScript'
|
||||
// })
|
||||
const router = useRouter()
|
||||
const comparisonPopup = ref()
|
||||
const testScriptPopup = ref()
|
||||
@@ -145,14 +145,15 @@ const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> =
|
||||
comparisonPopup.value?.open(titleType, row, modeStore.currentMode)
|
||||
} else {
|
||||
if (titleType == 'add') {
|
||||
// valueTypePopup.value?.open(titleType, row,modeStore.currentMode)
|
||||
// testScriptPopup.value?.open('新增检测脚本', {}, row, modeStore.currentMode, '')
|
||||
router.push({
|
||||
path: '/machine/testScriptAdd',
|
||||
state: { title: '新增检测脚本', row: row, mode: modeStore.currentMode }
|
||||
state: { title: '新增检测脚本', row: '', mode: modeStore.currentMode }
|
||||
})
|
||||
} 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