diff --git a/frontend/src/api/device/testScript/index.ts b/frontend/src/api/device/testScript/index.ts index 0c3c6be..dcb6831 100644 --- a/frontend/src/api/device/testScript/index.ts +++ b/frontend/src/api/device/testScript/index.ts @@ -34,3 +34,15 @@ export const addScriptDtls = (params: any) => { export const dlsDetails = (params: any) => { return http.post(`/pqScript/dlsDetails`, params) } +// 删除脚本 +export const deleteDtls = (params: any) => { + return http.post(`/pqScript/deleteDtls`, params) +} +// 启用关闭脚本 +export const updateDtls = (params: any) => { + return http.post(`/pqScript/updateDtls`, params) +} +// 根据通讯参数生成装置下发原始数据公式 +export const scriptDtlsCheckDataList = (params: any) => { + return http.post(`/pqScript/scriptDtlsCheckDataList`, params) +} diff --git a/frontend/src/views/machine/testScript/components/communication.vue b/frontend/src/views/machine/testScript/components/communication.vue index 9bf4b6b..f6913c8 100644 --- a/frontend/src/views/machine/testScript/components/communication.vue +++ b/frontend/src/views/machine/testScript/components/communication.vue @@ -8,7 +8,7 @@ color: '#fff' }" stripe - height="calc(100vh - 335px)" + height="calc(100vh - 515px)" :style="{ overflow: 'hidden' }" row-key="id" default-expand-all diff --git a/frontend/src/views/machine/testScript/components/scriptForm.ts b/frontend/src/views/machine/testScript/components/scriptForm.ts index bdad8d0..ee64094 100644 --- a/frontend/src/views/machine/testScript/components/scriptForm.ts +++ b/frontend/src/views/machine/testScript/components/scriptForm.ts @@ -1,6 +1,4 @@ let scriptForm: any = { - // value: '', - label: '', subType: '', //tabcode ffreq: 50, //频率 channelList: [ @@ -20,9 +18,9 @@ let scriptForm: any = { // fphase: 0 // 谐波相角 // }, ], //谐波 - inHarmList: [ + inharmList: [ { - inharm: 0, //间谐波次数 + inharm: '', //间谐波次数 famp: 0, //间谐波含有率 fphase: 0 // 间谐波相角 } @@ -32,7 +30,7 @@ let scriptForm: any = { fchagFre: 0, //波动频度 waveFluType: 0, //波动类型 waveType: 0, //波类型 - fdutyCycle: 0 //占空比 + fdutyCycle: 50 //占空比 }, //闪变 dipData: { ftransValue: 0, // 暂态幅值 @@ -49,9 +47,9 @@ let scriptForm: any = { famp: 0, //幅值 fphase: 0, //相角 harmList: [], //谐波 - inHarmList: [ + inharmList: [ { - inharm: 1, //间谐波次数 + inharm: '', //间谐波次数 famp: 0, //间谐波含有率 fphase: 0 // 间谐波相角 } @@ -61,7 +59,7 @@ let scriptForm: any = { fchagFre: 0, //波动频度 waveFluType: 0, //波动类型 waveType: 0, //波类型 - fdutyCycle: 0 //占空比 + fdutyCycle: 50 //占空比 }, //闪变 dipData: { ftransValue: 0, // 暂态幅值 @@ -78,9 +76,9 @@ let scriptForm: any = { famp: 0, //幅值 fphase: 0, //相角 harmList: [], //谐波 - inHarmList: [ + inharmList: [ { - inharm: 1, //间谐波次数 + inharm: '', //间谐波次数 famp: 0, //间谐波含有率 fphase: 0 // 间谐波相角 } @@ -90,7 +88,7 @@ let scriptForm: any = { fchagFre: 0, //波动频度 waveFluType: 0, //波动类型 waveType: 0, //波类型 - fdutyCycle: 0 //占空比 + fdutyCycle: 50 //占空比 }, //闪变 dipData: { ftransValue: 0, // 暂态幅值 @@ -107,9 +105,9 @@ let scriptForm: any = { famp: 0, //幅值 fphase: 0, //相角 harmList: [], //谐波 - inHarmList: [ + inharmList: [ { - inharm: 1, //间谐波次数 + inharm: '', //间谐波次数 famp: 0, //间谐波含有率 fphase: 0 // 间谐波相角 } @@ -119,7 +117,7 @@ let scriptForm: any = { fchagFre: 0, //波动频度 waveFluType: 0, //波动类型 waveType: 0, //波类型 - fdutyCycle: 0 //占空比 + fdutyCycle: 50 //占空比 }, //闪变 dipData: { ftransValue: 0, // 暂态幅值 @@ -136,9 +134,9 @@ let scriptForm: any = { famp: 0, //幅值 fphase: 0, //相角 harmList: [], //谐波 - inHarmList: [ + inharmList: [ { - inharm: 1, //间谐波次数 + inharm: '', //间谐波次数 famp: 0, //间谐波含有率 fphase: 0 // 间谐波相角 } @@ -148,7 +146,7 @@ let scriptForm: any = { fchagFre: 0, //波动频度 waveFluType: 0, //波动类型 waveType: 0, //波类型 - fdutyCycle: 0 //占空比 + fdutyCycle: 50 //占空比 }, //闪变 dipData: { ftransValue: 0, // 暂态幅值 @@ -165,9 +163,9 @@ let scriptForm: any = { famp: 0, //幅值 fphase: 0, //相角 harmList: [], //谐波 - inHarmList: [ + inharmList: [ { - inharm: 1, //间谐波次数 + inharm: '', //间谐波次数 famp: 0, //间谐波含有率 fphase: 0 // 间谐波相角 } @@ -177,7 +175,7 @@ let scriptForm: any = { fchagFre: 0, //波动频度 waveFluType: 0, //波动类型 waveType: 0, //波类型 - fdutyCycle: 0 //占空比 + fdutyCycle: 50 //占空比 }, //闪变 dipData: { ftransValue: 0, // 暂态幅值 diff --git a/frontend/src/views/machine/testScript/components/testProjectPopup.vue b/frontend/src/views/machine/testScript/components/testProjectPopup.vue index 479ee79..dd85859 100644 --- a/frontend/src/views/machine/testScript/components/testProjectPopup.vue +++ b/frontend/src/views/machine/testScript/components/testProjectPopup.vue @@ -5,7 +5,7 @@
- +
- +
@@ -134,7 +139,7 @@ @@ -153,10 +158,10 @@ import TestScriptInHarmTab from '@/views/machine/testScript/components/testScrip import TestScriptFlickerTab from '@/views/machine/testScript/components/testScriptFlickerTab.vue' import TestScriptDipTab from '@/views/machine/testScript/components/testScriptDipTab.vue' import { useDictStore } from '@/stores/modules/dict' -import { addScriptDtls } from '@/api/device/testScript' +import { addScriptDtls, scriptDtlsCheckDataList } from '@/api/device/testScript' import scriptForm from './scriptForm' -const emit = defineEmits(['addTab']) +const emit = defineEmits(['addTab', 'close']) const dictStore = useDictStore() const props = defineProps({ options: { @@ -167,6 +172,10 @@ const props = defineProps({ type: String, required: true }, + childActiveName: { + type: String, + required: true + }, formContent: { type: [Object, Array], required: true @@ -174,7 +183,7 @@ const props = defineProps({ }) const key = ref(0) // let valueType -const form: any = ref(scriptForm) +const form: any = ref(JSON.parse(JSON.stringify(scriptForm))) const childForm: any = ref([]) const ScriptValueType = ref('') const setValueTableRef = ref() @@ -190,7 +199,7 @@ const tableData = [ { name: 'L3', frequency: 'Uc', type: 'V', electricity: 0, fphase: 0, sort: 2 }, { name: 'L3', frequency: 'Ic', type: 'I', electricity: 0, fphase: 0, sort: 2 } ] -const subType = ref('') + const tabChildren: any = ref([]) // 定义 span-method 逻辑 const arraySpanMethod = ({ rowIndex, columnIndex }: { rowIndex: number; columnIndex: number }) => { @@ -232,62 +241,104 @@ const handleRowClick = async (row: any, column: any) => { // 关闭弹窗 const close = () => { dialogVisible.value = false + emit('close') } // 保存数据 const save = () => { - // dialogVisible.value = false - form.value.subType = subType.value - form.value.label = tabChildren.value.filter((item: any) => item.code == subType.value)[0].label - let copyForm = JSON.parse(JSON.stringify(form.value)) - - copyForm.channelList.forEach((channel: any) => { - // 筛选出 famp 和 fphase 不同时为 0 的对象 - channel.harmList = channel.harmList.filter((item: any) => item.famp !== 0 || item.fphase !== 0) - channel.inHarmList = channel.inHarmList.filter( - (item: any) => item.inharm !== 0 || item.famp !== 0 || item.fphase !== 0 - ) - }) - console.log('🚀 ~ save ~ form.value:', copyForm) + let copyForm = handleHarmData() addScriptDtls({ ...copyForm, scriptId: props.formContent.id, scriptType: props.activeName }).then(res => { if (res.code === 'A0000') { - ElMessage.success({ message: res.message }) + ElMessage.success({ + message: dialogTitle.value == '新增检测项目信息' ? '添加检测脚本成功!' : '编辑检测脚本成功!', + type: 'success' + }) dialogVisible.value = false emit('addTab', form.value) } }) // emit('addTab', form.value) } +//处理谐波数据 +const handleHarmData = () => { + let copyForm = JSON.parse(JSON.stringify(form.value)) + + copyForm.channelList.forEach((channel: any) => { + // 筛选出 famp 和 fphase 不同时为 0 的对象 + channel.harmList = channel.harmList.filter((item: any) => item.famp !== 0 || item.fphase !== 0) + channel.inharmList = channel.inharmList.filter( + (item: any) => item.inharm !== '' || item.famp !== 0 || item.fphase !== 0 + ) + }) + return copyForm +} // 打开弹窗,可能是新增,也可能是编辑 const open = (sign: string, row: any) => { dialogVisible.value = true + dialogTitle.value = sign === 'add' ? '新增检测项目信息' : '编辑检测项目信息' // 添加选择检测项目 tabChildren.value = props.options.filter(item => item.value == props.activeName)[0].children || [] - subType.value = tabChildren.value[0].code || '' + // subType.value = tabChildren.value[0].code || '' + if (sign == 'add') { + form.value.subType = props.childActiveName == '' ? tabChildren.value[0].code || '' : props.childActiveName + } else { + form.value = setharmList(JSON.parse(JSON.stringify(row))) + } handleRowClick({ name: 'L1', sort: 0 }, { label: '相别' }) dictStore.getDictData('Script_Value_Type') valueCode.value = dictStore .getDictData('Script_Value_Type') .filter(item => item.id == props.formContent.valueType)[0].code } + +// 判断后台没有谐波,简谐波值 用于回显 +const setharmList = (row: any) => { + row.channelList.forEach((item: any) => { + let harmList = [] + + for (let i = 2; i < 51; i++) { + let data = item.harmList.filter((harm: any) => harm.harm == i) + if (data.length > 0) { + harmList.push({ harm: i, famp: data[0].famp, fphase: data[0].fphase }) + } else { + harmList.push({ harm: i, famp: 0, fphase: 0 }) + } + } + item.harmList = harmList + + if (item.inharmList.length == 0) { + item.inharmList.push({ inharm: 0, famp: 0, fphase: 0 }) + } + }) + + return row +} // 复制 const copyRow = (index: number) => { - scriptForm.channelList[index + 2] = JSON.parse(JSON.stringify(scriptForm.channelList[index])) - scriptForm.channelList[index + 3] = JSON.parse(JSON.stringify(scriptForm.channelList[index + 1])) - scriptForm.channelList[index].channelType == 'Ua' - ? (scriptForm.channelList[index + 2].channelType = 'Ub') - : (scriptForm.channelList[index + 2].channelType = 'Uc') - scriptForm.channelList[index + 1].channelType == 'Ia' - ? (scriptForm.channelList[index + 3].channelType = 'Ib') - : (scriptForm.channelList[index + 3].channelType = 'Ic') + form.value.channelList[index + 2] = JSON.parse(JSON.stringify(form.value.channelList[index])) + form.value.channelList[index + 3] = JSON.parse(JSON.stringify(form.value.channelList[index + 1])) + form.value.channelList[index].channelType == 'Ua' + ? (form.value.channelList[index + 2].channelType = 'Ub') + : (form.value.channelList[index + 2].channelType = 'Uc') + form.value.channelList[index + 1].channelType == 'Ia' + ? (form.value.channelList[index + 3].channelType = 'Ib') + : (form.value.channelList[index + 3].channelType = 'Ic') key.value += 1 + ElMessage.success({ + message: '复制成功!', + type: 'success' + }) } // 打开 drawer(新增、编辑) const openDialog = () => { - setValueTableRef.value?.open() + let copyForm = JSON.parse(JSON.stringify(form.value)) + scriptDtlsCheckDataList({ ...copyForm, scriptId: props.formContent?.id, scriptType: props.activeName }).then( + res => {} + ) + // setValueTableRef.value?.open() } // 对外映射 diff --git a/frontend/src/views/machine/testScript/components/testScriptDetail.vue b/frontend/src/views/machine/testScript/components/testScriptDetail.vue index ca2124b..024ebd7 100644 --- a/frontend/src/views/machine/testScript/components/testScriptDetail.vue +++ b/frontend/src/views/machine/testScript/components/testScriptDetail.vue @@ -2,34 +2,42 @@
检测脚本信息 - 通讯脚本 + 检测项目概要信息
-
- -
- - - - + + + + + + + + -
+ @@ -50,178 +59,49 @@ V {{ - row.channelList[item.num]?.famp - ? '电压=' + - row.channelList[item.num]?.famp + - (valueCode == 'Absolute' ? 'V' : '%') - : '/' + '电压=' + + row.channelList[item.num]?.famp + + (valueCode == 'Absolute' ? 'V' : '%') }} - {{ - row.channelList[item.num]?.fphase - ? '电流=' + row.channelList[item.num]?.fphase + '°' - : '/' - }} + {{ '相角=' + row.channelList[item.num]?.fphase + '°' }} I {{ - row.channelList[item.num + 1]?.famp - ? '电压=' + - row.channelList[item.num + 1]?.famp + - (valueCode == 'Absolute' ? 'V' : '%') - : '/' + '电流=' + + row.channelList[item.num + 1]?.famp + + (valueCode == 'Absolute' ? 'V' : '%') }} - {{ - row.channelList[item.num + 1]?.fphase - ? '电流=' + - row.channelList[item.num + 1]?.fphase + - '°' - : '/' - }} + {{ '相角=' + row.channelList[item.num + 1]?.fphase + '°' }} - - + -
-
-
+
+
+
@@ -257,8 +137,11 @@ ref="testProjectPopupRef" :options="props.options" :activeName="activeName" - @addTab="addTab" + :childActiveName="childActiveName" :formContent="props.formContent" + @addTab="addTab" + @close="showDialog = false" + v-if="showDialog" />
@@ -269,12 +152,13 @@ import Tree from './tree.vue' import Commun from './communication.vue' import type { CascaderOption } from 'element-plus' import { getTreeData } from '@/api/check/test' -import { CirclePlus, Delete, EditPen, CopyDocument } from '@element-plus/icons-vue' +import { CirclePlus, Delete, Check, CopyDocument } from '@element-plus/icons-vue' import type { TestScript } from '@/api/device/interface/testScript' import TestProjectPopup from '@/views/machine/testScript/components/testProjectPopup.vue' import { CheckData } from '@/api/check/interface' -import { dlsDetails } from '@/api/device/testScript' +import { dlsDetails, deleteDtls, updateDtls, addScriptDtls } from '@/api/device/testScript' import { useDictStore } from '@/stores/modules/dict' +import { useHandleData } from '@/hooks/useHandleData' interface TabOption { label?: string name?: string @@ -294,9 +178,11 @@ const props = defineProps({ required: true } }) +const showDialog = ref(false) const dictStore = useDictStore() const activeName = ref('') const childActiveName = ref('') +const firstName = 'first' const testProjectPopupRef = ref() const tableData: any = ref([]) const tabData: any = ref([]) @@ -362,7 +248,7 @@ const tabChange = () => { copyActiveName.value == activeName.value childActiveName.value = '' childActiveName.value = - tabData.value.filter(item => item.value == activeName.value)[0]?.children[0]?.value || '' + tabData.value.filter((item: any) => item.value == activeName.value)[0]?.children[0]?.value || '' } inquireTable() } @@ -376,22 +262,63 @@ const inquireTable = () => { }).then((res: any) => { if (res.code === 'A0000') { res.data.forEach((item: any) => { - item.channelList = item.channelList.sort((a, b) => { + item.channelList = item.channelList.sort((a: any, b: any) => { const indexA = sortOrder.indexOf(a.channelType) const indexB = sortOrder.indexOf(b.channelType) return indexA - indexB }) }) - + tableData.value = res.data } }) } // 打开 drawer(新增、编辑) const openDialog = (titleType: string, row: Partial = {}) => { - if (titleType == 'add') { - } - testProjectPopupRef.value?.open(titleType, row) + showDialog.value = true + setTimeout(() => { + testProjectPopupRef.value?.open(titleType, row) + }, 0) +} +// 复制 +const copyRow = (row: any) => { + let copyRow = JSON.parse(JSON.stringify(row)) + delete copyRow.index + addScriptDtls({ ...copyRow, scriptType: activeName.value }).then(res => { + if (res.code === 'A0000') { + ElMessage.success({ + message: '复制成功!', + type: 'success' + }) + getTree() + } + }) +} +// 删除 +const deleteRow = async (row: any) => { + await useHandleData(deleteDtls, { enable: row.enable, index: row.index, scriptId: row.scriptId }, `删除`) + getTree() +} +// 启用 +const enableRow = async (row: any) => { + ElMessageBox.confirm(`是否${row.enable == 0 ? `禁用` : `启用`}?`, '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + draggable: true + }) + .then(async () => { + updateDtls({ enable: row.enable, index: row.index, scriptId: row.scriptId }).then(res => { + ElMessage({ + type: 'success', + message: `${row.enable == 0 ? `禁用` : `启用`}成功!` + }) + getTree() + }) + }) + .catch(() => { + row.enable = row.enable == 0 ? 1 : 0 + }) } // 获取左边树数据 // 新增保存 @@ -420,7 +347,6 @@ const addTab = (row: any) => { // } } onMounted(() => { - console.log('🚀 ~ onMounted ~ props.options:', props.options) getTree() props.options.forEach((item: any) => { tabData.value.push({ @@ -451,6 +377,9 @@ onMounted(() => { overflow: auto; /* 同时启用垂直和水平滚动 */ overflow-x: hidden; } +.scriptTree { + height: calc(100vh - 520px); +} /* 确保 el-tree 内容可以超出容器宽度 */ .el-tree { @@ -496,3 +425,12 @@ onMounted(() => { } } + diff --git a/frontend/src/views/machine/testScript/components/testScriptFlickerTab.vue b/frontend/src/views/machine/testScript/components/testScriptFlickerTab.vue index 0b63857..c72dd59 100644 --- a/frontend/src/views/machine/testScript/components/testScriptFlickerTab.vue +++ b/frontend/src/views/machine/testScript/components/testScriptFlickerTab.vue @@ -3,15 +3,17 @@ -
+
+ - +
- - - + + +
@@ -45,7 +58,11 @@
- +
diff --git a/frontend/src/views/machine/testScript/components/testScriptHarmTab.vue b/frontend/src/views/machine/testScript/components/testScriptHarmTab.vue index 845a2fa..14d5354 100644 --- a/frontend/src/views/machine/testScript/components/testScriptHarmTab.vue +++ b/frontend/src/views/machine/testScript/components/testScriptHarmTab.vue @@ -9,7 +9,13 @@ @@ -17,7 +23,13 @@ @@ -28,7 +40,13 @@ @@ -36,7 +54,13 @@ @@ -54,7 +78,13 @@ @@ -62,7 +92,13 @@ @@ -73,7 +109,13 @@ @@ -81,7 +123,13 @@ @@ -102,7 +150,7 @@ const props = defineProps({ } }) -const form:any = computed({ +const form: any = computed({ get() { return props.childForm }, @@ -137,7 +185,7 @@ for (let i = 26; i <= 50; i++) { } - diff --git a/frontend/src/views/machine/testScript/components/testScriptInHarmTab.vue b/frontend/src/views/machine/testScript/components/testScriptInHarmTab.vue index 9910a5b..17cf889 100644 --- a/frontend/src/views/machine/testScript/components/testScriptInHarmTab.vue +++ b/frontend/src/views/machine/testScript/components/testScriptInHarmTab.vue @@ -1,42 +1,143 @@ @@ -89,4 +190,21 @@ const inHarmFlagDelete = (number: number) => { :deep(.el-form-item) { margin-bottom: 10px !important; } +.input-label-container { + display: flex; + align-items: center; /* 垂直居中对齐 */ +} + +.input-label-container label { + margin-left: 5px; /* 添加标签与输入框之间的间距 */ +} +.tabs-container { + display: flex; + justify-content: space-between; /* 使两个 el-tabs 之间有间距 */ + height: 100%; + .right-tabs { + flex: 1; /* 使两个 el-tabs 占据相同的空间 */ + margin-right: 10px; /* 可选:添加右侧间距 */ + } +} diff --git a/frontend/src/views/machine/testScript/components/testScriptVolCurTab.vue b/frontend/src/views/machine/testScript/components/testScriptVolCurTab.vue index a68bbc0..2462cdc 100644 --- a/frontend/src/views/machine/testScript/components/testScriptVolCurTab.vue +++ b/frontend/src/views/machine/testScript/components/testScriptVolCurTab.vue @@ -9,16 +9,36 @@ - + - + - + - +
@@ -26,7 +46,7 @@