微调
This commit is contained in:
@@ -30,6 +30,7 @@ const routerMode = {
|
||||
* @param meta.isKeepAlive ==> 当前路由是否缓存
|
||||
* */
|
||||
const router = createRouter({
|
||||
|
||||
history: routerMode[mode](),
|
||||
routes: [...staticRouter],
|
||||
// 不区分路由大小写,非严格模式下提供了更宽松的路径匹配
|
||||
@@ -68,10 +69,9 @@ router.beforeEach(async (to, from, next) => {
|
||||
await initDynamicRouter()
|
||||
return next({ ...to, replace: true })
|
||||
}
|
||||
//console.log(to)
|
||||
|
||||
// 7.存储 routerName 做按钮权限筛选
|
||||
authStore.setRouteName(to.name as string)
|
||||
|
||||
// 8.正常访问页面
|
||||
next()
|
||||
})
|
||||
|
||||
@@ -41,6 +41,7 @@ export const initDynamicRouter = async () => {
|
||||
if (item.component && typeof item.component == "string") {
|
||||
item.component = modules["/src/views" + item.component + ".vue"];
|
||||
}
|
||||
|
||||
if (item.meta.isFull) {
|
||||
router.addRoute(item as unknown as RouteRecordRaw);
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,473 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="divider-container">
|
||||
<el-divider style="width: 260px" content-position="left">检测脚本信息</el-divider>
|
||||
<el-divider style="flex: 1" content-position="left">检测项目概要信息</el-divider>
|
||||
</div>
|
||||
<div class="data-check-content">
|
||||
<div class="content-tree">
|
||||
<Tree :treeData="treeData" @setTab="setTab" />
|
||||
</div>
|
||||
|
||||
<div class="content-right-Tabs" style="height: calc(100vh - 315px); width: 100px">
|
||||
<el-tabs type="border-card" style="height: 100%" v-model="activeName" @tab-change="tabChange">
|
||||
<el-tab-pane v-for="tab in tabData" :key="tab.value" :label="tab.label" :name="tab.value">
|
||||
<div v-if="activeName == tab.value">
|
||||
<div class="dialog-footer">
|
||||
<el-button :icon="CirclePlus" type="primary" @click="openDialog('add')">新增</el-button>
|
||||
</div>
|
||||
<div style="display: flex">
|
||||
<!-- 2级tab -->
|
||||
<el-tabs
|
||||
type="border-card"
|
||||
style="flex: 1; margin-left: 10px"
|
||||
v-model="childActiveName"
|
||||
@tab-change="inquireTable"
|
||||
>
|
||||
<el-tab-pane
|
||||
v-for="subTab in tab.children || []"
|
||||
:key="subTab.value"
|
||||
:label="subTab.label"
|
||||
:name="subTab.value"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
:header-cell-style="{
|
||||
textAlign: 'center',
|
||||
backgroundColor: '#003078',
|
||||
color: '#fff'
|
||||
}"
|
||||
stripe
|
||||
:cell-style="{ textAlign: 'center' }"
|
||||
height="calc(100vh - 480px)"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column type="index" label="组次" width="60" />
|
||||
<el-table-column prop="ffreq" label="频率(Hz)" width="90" />
|
||||
<el-table-column
|
||||
:label="item.label"
|
||||
v-for="item in column"
|
||||
:key="item.label"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<table class="tableL">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="theFirst">V</td>
|
||||
<td>
|
||||
{{
|
||||
row.channelList[item.num].famp == null
|
||||
? '/'
|
||||
: '' +
|
||||
row.channelList[item.num]?.famp +
|
||||
(valueCode == 'Absolute' ? 'V' : '%')
|
||||
}}
|
||||
</td>
|
||||
<td>
|
||||
{{
|
||||
row.channelList[item.num].fphase == null
|
||||
? '/'
|
||||
: '' +
|
||||
row.channelList[item.num].fphase +
|
||||
'°'
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="theFirst">I</td>
|
||||
<td>
|
||||
{{
|
||||
row.channelList[item.num + 1].famp == null
|
||||
? '/'
|
||||
: '' +
|
||||
row.channelList[item.num + 1].famp +
|
||||
(valueCode == 'Absolute' ? 'V' : '%')
|
||||
}}
|
||||
</td>
|
||||
<td>
|
||||
{{
|
||||
row.channelList[item.num + 1].fphase == null
|
||||
? '/'
|
||||
: '' +
|
||||
row.channelList[item.num + 1].fphase +
|
||||
'°'
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="165">
|
||||
<template #default="{ row }">
|
||||
<div class="actionButtons">
|
||||
<el-button type="primary" link :icon="View" @click="view(row)">
|
||||
查看
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<div class="page">
|
||||
<div class="loading-container">
|
||||
<el-progress
|
||||
v-if="loading"
|
||||
type="circle"
|
||||
>
|
||||
<template #default="{}">
|
||||
<span class="Loading">Loading</span>
|
||||
</template>
|
||||
</el-progress>
|
||||
</div>
|
||||
<el-button :icon="CirclePlus"
|
||||
type="primary"
|
||||
size="large"
|
||||
@click="startLoading"
|
||||
style="margin-left: 70px;margin-top: 10px;"
|
||||
>启动</el-button>
|
||||
<el-button :icon="CirclePlus"
|
||||
type="primary"
|
||||
size="large"
|
||||
@click="stopLoading"
|
||||
style="margin-top: 10px;"
|
||||
>停止</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TestProjectPopup
|
||||
ref="testProjectPopupRef"
|
||||
:options="props.options"
|
||||
:activeName="activeName"
|
||||
:childActiveName="childActiveName"
|
||||
:formContent="props.formContent"
|
||||
:communicationList="communicationList"
|
||||
@addTab="addTab"
|
||||
@getCommunication="getCommunication"
|
||||
@close="showDialog = false"
|
||||
v-if="showDialog"
|
||||
/>
|
||||
<!-- 查看 -->
|
||||
<ViewRow ref="viewRowRef"
|
||||
:activeName="activeName"
|
||||
:formContent="props.formContent"
|
||||
@close="viewDialog = false"
|
||||
v-if="viewDialog"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type PropType, ref, nextTick, onMounted, watch } from 'vue'
|
||||
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, Check, CopyDocument, View, EditPen } 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, deleteDtls, updateDtls, addScriptDtls, checkDataList } from '@/api/device/testScript'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
import { scriptDtlsCheckDataList } from '@/api/device/testScript/index'
|
||||
import ViewRow from '@/views/machine/testScript/components/viewRow.vue'
|
||||
interface TabOption {
|
||||
label?: string
|
||||
name?: string
|
||||
value?: string
|
||||
code?: string
|
||||
children?: TabOption[]
|
||||
}
|
||||
const communRef = ref()
|
||||
const treeData = ref<CheckData.TreeItem[]>([])
|
||||
const valueCode = ref('') //Absolute绝对值
|
||||
const props = defineProps({
|
||||
options: {
|
||||
type: Array as PropType<TabOption[]>,
|
||||
required: true
|
||||
},
|
||||
formContent: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
const showDialog = ref(false)
|
||||
const viewDialog = ref(false)
|
||||
const dictStore = useDictStore()
|
||||
const activeName = ref('')
|
||||
const childActiveName = ref('')
|
||||
const firstName = 'first'
|
||||
const viewRowRef = ref()
|
||||
const communicationList = ref([])
|
||||
const testProjectPopupRef = ref()
|
||||
const tableData: any = ref([])
|
||||
const tabData: any = ref([])
|
||||
|
||||
const loading = ref(true)
|
||||
const column = ref([
|
||||
{
|
||||
label: 'L1',
|
||||
num: 0
|
||||
},
|
||||
{
|
||||
label: 'L2',
|
||||
num: 2
|
||||
},
|
||||
{
|
||||
label: 'L3',
|
||||
num: 4
|
||||
}
|
||||
])
|
||||
// 获取树
|
||||
const getTree = () => {
|
||||
getTreeData({
|
||||
scriptId: '9ff96807cf8c7524587982ed8baa8b57'
|
||||
}).then(res => {
|
||||
if (res.code === 'A0000') {
|
||||
treeData.value = res.data
|
||||
|
||||
// 添加tab子项
|
||||
props.options.forEach((k: any, i: number) => {
|
||||
tabData.value[i].children = []
|
||||
treeData.value.forEach((item: any) => {
|
||||
if (k.value == item.scriptTypeCode) {
|
||||
item.children.forEach((s: any) => {
|
||||
k.children.forEach((P: any) => {
|
||||
if (P.code == s.scriptTypeCode) {
|
||||
tabData.value[i].children.push({
|
||||
label: P.label,
|
||||
value: P.code,
|
||||
children: []
|
||||
})
|
||||
} else {
|
||||
s.children.forEach((j: any) => {
|
||||
if (j.scriptTypeCode == P.code) {
|
||||
tabData.value[i].children.push({
|
||||
label: P.label,
|
||||
value: P.code,
|
||||
children: []
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
tabChange()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 设置树点击tab
|
||||
const setTab = row => {
|
||||
activeName.value = row.activeName
|
||||
childActiveName.value = row.childActiveName
|
||||
getTree()
|
||||
}
|
||||
const copyActiveName = ref('')
|
||||
// 获取通讯脚本点击
|
||||
const getCommunication = () => {
|
||||
communicationList.value = communRef.value[0]?.getData()
|
||||
}
|
||||
// 切换大tab控制小tab
|
||||
const tabChange = () => {
|
||||
if (copyActiveName.value != activeName.value) {
|
||||
copyActiveName.value == activeName.value
|
||||
|
||||
if (
|
||||
tabData.value
|
||||
.filter((item: any) => item.value == activeName.value)[0]
|
||||
?.children.filter((item: any) => item.value == childActiveName.value).length == 0
|
||||
) {
|
||||
childActiveName.value =
|
||||
tabData.value.filter((item: any) => item.value == activeName.value)[0]?.children[0]?.value || ''
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
inquireTable()
|
||||
}
|
||||
//根据脚本id查询检测脚本详情
|
||||
const inquireTable = () => {
|
||||
const sortOrder = ['Ua', 'Ia', 'Ub', 'Ib', 'Uc', 'Ic']
|
||||
dlsDetails({
|
||||
scriptId: '9ff96807cf8c7524587982ed8baa8b57',
|
||||
scriptType: activeName.value,
|
||||
scriptSubType: childActiveName.value
|
||||
}).then((res: any) => {
|
||||
if (res.code === 'A0000') {
|
||||
res.data.forEach((item: any) => {
|
||||
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<TestScript.ResTestScript> = {}) => {
|
||||
showDialog.value = true
|
||||
setTimeout(() => {
|
||||
testProjectPopupRef.value?.open(titleType, row)
|
||||
}, 0)
|
||||
}
|
||||
|
||||
// 查看
|
||||
const view = (row: Partial<TestScript.ResTestScript> = {}) => {
|
||||
|
||||
getCommunication()
|
||||
//当前点击的一级tab
|
||||
const parentTabName = communicationList.value.find(t => t.id === activeName.value)?.name || '未找到对应名称';
|
||||
//当前点击的二级tab
|
||||
const childrenTabName = ref('')
|
||||
tabData.value.forEach((item: any) => {
|
||||
if (item.value == activeName.value) {
|
||||
item.children.forEach((k: any) => {
|
||||
if (k.value == childActiveName.value) {
|
||||
childrenTabName.value = k.label
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
viewDialog.value = true
|
||||
setTimeout(() => {
|
||||
viewRowRef.value?.open(row, communicationList.value, parentTabName, childrenTabName.value)
|
||||
}, 0)
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 获取左边树数据
|
||||
// 新增保存
|
||||
const addTab = (row: any) => {
|
||||
getTree()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTree()
|
||||
props.options.forEach((item: any) => {
|
||||
tabData.value.push({
|
||||
label: item.label.replace(/准确度|检测/g, ''),
|
||||
value: item.value,
|
||||
code: item.code,
|
||||
children: []
|
||||
})
|
||||
})
|
||||
activeName.value = tabData.value[0].value
|
||||
|
||||
valueCode.value = dictStore
|
||||
.getDictData('Script_Value_Type')
|
||||
.filter(item => item.id == props.formContent.valueType)[0].code
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.data-check-content {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.content-tree {
|
||||
width: 260px;
|
||||
height: calc(100vh - 315px);
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
// margin-right: 10px;
|
||||
overflow: auto; /* 同时启用垂直和水平滚动 */
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.scriptTree {
|
||||
height: calc(100vh - 520px);
|
||||
}
|
||||
|
||||
/* 确保 el-tree 内容可以超出容器宽度 */
|
||||
.el-tree {
|
||||
width: fit-content; /* 根据内容自适应宽度 */
|
||||
}
|
||||
|
||||
.content-right-Tabs {
|
||||
flex: 1; /* 根据需要调整宽度比例 */
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
margin-left: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.divider-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.divider-container .el-divider {
|
||||
margin-right: 30px; /* 根据需要调整间距 */
|
||||
}
|
||||
:deep(.el-descriptions__body .el-descriptions__table:not(.is-bordered) .el-descriptions__cell) {
|
||||
padding: 3px 11px;
|
||||
}
|
||||
:deep(.el-loading-mask) {
|
||||
z-index: 3000;
|
||||
}
|
||||
.tableL {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
|
||||
td {
|
||||
border: 1px solid #ccc;
|
||||
padding: 5px;
|
||||
width: 45%;
|
||||
}
|
||||
.theFirst {
|
||||
background-color: #003078;
|
||||
color: #fff;
|
||||
width: 20px !important;
|
||||
}
|
||||
}
|
||||
.actionButtons {
|
||||
.el-button {
|
||||
margin-left: 0px;
|
||||
margin: 5px 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
background-color: #000;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-left: 20px;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
input::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none !important;
|
||||
}
|
||||
|
||||
input::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none !important;
|
||||
}
|
||||
.el-divider--horizontal {
|
||||
margin: 4px 0 24px 0;
|
||||
}
|
||||
.el-tabs--border-card > .el-tabs__content {
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
106
frontend/src/views/machine/controlSource/components/tree.vue
Normal file
106
frontend/src/views/machine/controlSource/components/tree.vue
Normal file
@@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<el-tree
|
||||
node-key="id"
|
||||
default-expand-all
|
||||
:data="props.treeData"
|
||||
:props="defaultProps"
|
||||
style="width: 100%"
|
||||
:expand-on-click-node="false"
|
||||
@node-click="handleNodeClick"
|
||||
show-checkbox
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<el-tooltip effect="dark" :content="data.sourceDesc || data.scriptTypeName" placement="top" :hide-after="0">
|
||||
<div class="custom-tree-node">
|
||||
{{ data.scriptTypeName || data.sourceDesc }}
|
||||
</div>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-tree>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from 'vue'
|
||||
|
||||
import { CheckData } from '@/api/check/interface'
|
||||
const props = defineProps({
|
||||
treeData: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['setTab'])
|
||||
const dataTree = ref<CheckData.TreeItem[]>([])
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
label: 'scriptTypeName',
|
||||
pid: 'pid'
|
||||
}
|
||||
const activeName = ref('')
|
||||
const childActiveName = ref('')
|
||||
const handleNodeClick = (data, node) => {
|
||||
let code = ['Base', 'VOL', 'Freq', 'Harm', 'Base_0_10', 'Base_20_85', 'Base_110_200']
|
||||
const parents = getParentNodes(node, [])
|
||||
parents.pop()
|
||||
parents.unshift(node.data)
|
||||
parents.reverse()
|
||||
let active = parents[0].scriptTypeCode
|
||||
let childActive = findTargetCodes(parents, code)[0] || ''
|
||||
// 获取当前节点的直接父节点
|
||||
if (activeName.value != active || childActiveName.value != childActive) {
|
||||
activeName.value = active
|
||||
childActiveName.value = childActive
|
||||
emit('setTab', {
|
||||
activeName: active,
|
||||
childActiveName: childActive
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 返回父级
|
||||
const getParentNodes = (node, parents) => {
|
||||
if (node.parent) {
|
||||
// 将父节点添加到数组中
|
||||
parents.push(node.parent.data)
|
||||
// 递归获取更高层级的父节点
|
||||
getParentNodes(node.parent, parents)
|
||||
}
|
||||
return parents
|
||||
}
|
||||
// 判断childActiveName值
|
||||
function findTargetCodes(data: any[], targetCodes: string[]) {
|
||||
let result: string[] = []
|
||||
data.forEach(item => {
|
||||
if (item.scriptTypeCode != null) {
|
||||
if (targetCodes.includes(item.scriptTypeCode)) {
|
||||
result.push(item.scriptTypeCode)
|
||||
}
|
||||
}
|
||||
})
|
||||
return result
|
||||
// for (let item of data) {
|
||||
// // 判断当前项的 scriptTypeCode 是否包含目标值
|
||||
// if (item.scriptTypeCode !=null && targetCodes.includes(item.scriptTypeCode)) {
|
||||
// console.log("🚀 ~ findTargetCodes ~ targetCodes.includes(item.scriptTypeCode):",item.scriptTypeCode, targetCodes.includes(item.scriptTypeCode))
|
||||
// result.push(item.scriptTypeCode)
|
||||
// return result
|
||||
// }
|
||||
// // 如果存在 children,递归检查
|
||||
// if (item.children && item.children.length > 0) {
|
||||
// result = result.concat(findTargetCodes(item.children, targetCodes))
|
||||
// }
|
||||
// }
|
||||
// return result
|
||||
}
|
||||
|
||||
onMounted(() => {})
|
||||
// // 对外映射
|
||||
// defineExpose({ init })
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.custom-tree-node {
|
||||
max-width: 230px;
|
||||
overflow-x: hidden !important;
|
||||
white-space: nowrap !important;
|
||||
text-overflow: ellipsis !important;
|
||||
}
|
||||
</style>
|
||||
211
frontend/src/views/machine/controlSource/index.vue
Normal file
211
frontend/src/views/machine/controlSource/index.vue
Normal file
@@ -0,0 +1,211 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card style="margin-bottom: 10px" class="cardTop">
|
||||
<el-form
|
||||
:inline="true"
|
||||
label-width="auto"
|
||||
ref="dialogFormRef"
|
||||
class="form-five"
|
||||
>
|
||||
<el-form-item label='检测源' prop='sourceIds' >
|
||||
<el-select v-model="sourceValue" collapse-tags placeholder="请选择检测源">
|
||||
<el-option
|
||||
v-for="(option, index) in pqSourceArray"
|
||||
:key="index"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div class="formBut">
|
||||
<el-button type="primary" :icon="Select" >通讯校验</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card v-if="show">
|
||||
<ControlSourceDetail v-if="secondLevelOptions.length > 0" :options="secondLevelOptions" :formContent="formContent" />
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, nextTick, onMounted, onBeforeMount, reactive } from 'vue'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import ControlSourceDetail from '@/views/machine/controlSource/components/controlSourceDetail.vue'
|
||||
import { type TestScript } from '@/api/device/interface/testScript'
|
||||
import type { Dict } from '@/api/system/dictionary/interface'
|
||||
import { getDictTreeByCode } from '@/api/system/dictionary/dictTree'
|
||||
import { Select } from '@element-plus/icons-vue'
|
||||
import { pqScriptAdd } from '@/api/device/testScript'
|
||||
import { getTestSourceList } from '@/api/plan/plan.ts'
|
||||
import { TestSource } from '@/api/device/interface/testSource'
|
||||
import { CascaderOption, ElMessage } from 'element-plus'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||
import socketClient from '@/utils/webSocketClient'
|
||||
const show = ref(false)
|
||||
const router = useRouter()
|
||||
const modeId = ref()
|
||||
const sourceValue = ref([])
|
||||
const secondLevelOptions: any[] = []
|
||||
// 定义弹出组件元信息
|
||||
const dialogFormRef = ref()
|
||||
const dictStore = useDictStore()
|
||||
const pqSourceList=ref<TestSource.ResTestSource[]>([])//获取指定模式下所有检测源
|
||||
const modeStore = useModeStore()
|
||||
const pqSourceArray = ref<{ label: string; value: string; }[]>()
|
||||
const formContent = ref<TestScript.ResTestScript>({
|
||||
id : '9ff96807cf8c7524587982ed8baa8b57',
|
||||
name: '测试',
|
||||
type: '1',
|
||||
valueType: '2973cb938b591b93d0df2547599b87d8',
|
||||
pattern: modeId.value,
|
||||
standardName: 'GBT 19862',
|
||||
standardTime: '2025',
|
||||
state: 1
|
||||
})
|
||||
//开始创建webSocket客户端
|
||||
const dataSocket = reactive({
|
||||
socketServe: socketClient.Instance,
|
||||
});
|
||||
const webMsgSend = ref()//webSocket推送的数据
|
||||
onMounted(async () => {
|
||||
// 检查 socketClient.Instance 是否存在
|
||||
if (!socketClient.Instance) {
|
||||
console.error('WebSocket 客户端实例不存在');
|
||||
return;
|
||||
}
|
||||
socketClient.Instance.connect();
|
||||
dataSocket.socketServe = socketClient.Instance;
|
||||
dataSocket.socketServe.registerCallBack('aaa', (res: { code: number; }) => {
|
||||
// 处理来自服务器的消息
|
||||
//console.log('Received message:', res)
|
||||
// 根据需要在这里添加更多的处理逻辑
|
||||
if (res.code === 20000) {
|
||||
ElMessage.error(message.message)
|
||||
loading.close()
|
||||
} else {
|
||||
webMsgSend.value = res
|
||||
}
|
||||
})
|
||||
|
||||
const pqSource_Result = await getTestSourceList({
|
||||
'pattern': "a303b2224845fcc6f60098b8ca73dca7",
|
||||
datasourceIds: '',
|
||||
sourceIds: '',
|
||||
planId: '',
|
||||
scriptName: '',
|
||||
errorSysName: '',
|
||||
sourceName: '',
|
||||
devIds: [],
|
||||
id: '',
|
||||
name: '',
|
||||
dataSourceId: '',
|
||||
scriptId: '',
|
||||
errorSysId: '',
|
||||
timeCheck: 0,
|
||||
testState: 0,
|
||||
reportState: 0,
|
||||
result: 0,
|
||||
code: 0,
|
||||
state: 1
|
||||
})
|
||||
pqSourceList.value = pqSource_Result.data as TestSource.ResTestSource[];
|
||||
const sourceArray1 = Array.isArray(pqSourceList.value) ? pqSourceList.value : []
|
||||
// 将 pqSource_Result 转换成 { label, value } 数组
|
||||
pqSourceArray.value = sourceArray1.map(item => ({
|
||||
label: item.name || '',
|
||||
value: item.id
|
||||
}));
|
||||
|
||||
|
||||
nextTick(async () => {
|
||||
|
||||
await treeInfo(modeStore.currentMode)
|
||||
formContent.value.pattern = modeId.value
|
||||
console.log( formContent.value);
|
||||
show.value = true
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
// 获取树字典
|
||||
const treeInfo = async (currentMode: string) => {
|
||||
const data: Dict.ResDictTree = {
|
||||
name: '',
|
||||
id: '',
|
||||
pid: '',
|
||||
pids: '',
|
||||
code: 'Script_Indicator_Items',
|
||||
sort: 0
|
||||
}
|
||||
const result = await getDictTreeByCode(data)
|
||||
const result1 = (await getDictTreeByCode({ ...data, code: 'Script_Error' })).data[0].children
|
||||
const allOptions = await convertToOptions(result.data as Dict.ResDictTree[])
|
||||
const setAllTree = await setTree(allOptions[0]?.children, result1)
|
||||
secondLevelOptions.push(...(setAllTree || []))
|
||||
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
|
||||
console.log('🚀 ~ treeInfo ~ result1:', currentMode)
|
||||
}
|
||||
|
||||
const setTree = async (data, data1) => {
|
||||
data.forEach(item => {
|
||||
data1.forEach(item1 => {
|
||||
if (item.label.replace(/准确度|检测/g, '') == item1.name) {
|
||||
item.value = item1.id
|
||||
}
|
||||
})
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
// 转换函数
|
||||
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
|
||||
return dictTree.map(item => ({
|
||||
value: item.id,
|
||||
code: item.code.split('-')[1] || item.code.split('-')[0],
|
||||
label: item.name,
|
||||
children: item.children ? convertToOptions(item.children) : undefined
|
||||
}))
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
/* .dialog-content {
|
||||
padding: 10px;
|
||||
} */
|
||||
:deep(.cardTop) {
|
||||
.el-card__body {
|
||||
padding: 20px 0 0 20px;
|
||||
}
|
||||
}
|
||||
.formBut {
|
||||
width: 50%;
|
||||
display: flex;
|
||||
justify-content: end;
|
||||
}
|
||||
.form-five {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
// justify-content: space-between;
|
||||
.el-form-item {
|
||||
display: flex;
|
||||
width: 22.8%;
|
||||
|
||||
.el-form-item__content {
|
||||
flex: 1;
|
||||
.el-select,
|
||||
.el-cascader,
|
||||
.el-input__inner,
|
||||
.el-date-editor {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -258,11 +258,13 @@ const column = ref([
|
||||
])
|
||||
// 获取树
|
||||
const getTree = () => {
|
||||
console.log('props.formContent.id', props.formContent.id)
|
||||
getTreeData({
|
||||
scriptId: props.formContent.id
|
||||
}).then(res => {
|
||||
if (res.code === 'A0000') {
|
||||
treeData.value = res.data
|
||||
console.log('tree',treeData.value)
|
||||
// 添加tab子项
|
||||
props.options.forEach((k: any, i: number) => {
|
||||
tabData.value[i].children = []
|
||||
@@ -385,7 +387,7 @@ const copyRow = async (row: any) => {
|
||||
}
|
||||
// 查看
|
||||
const view = (row: Partial<TestScript.ResTestScript> = {}) => {
|
||||
|
||||
|
||||
getCommunication()
|
||||
//当前点击的一级tab
|
||||
const parentTabName = communicationList.value.find(t => t.id === activeName.value)?.name || '未找到对应名称';
|
||||
@@ -441,6 +443,7 @@ const addTab = (row: any) => {
|
||||
const saveTheNewsletter = () => {}
|
||||
onMounted(() => {
|
||||
getTree()
|
||||
console.log('123',props.options)
|
||||
props.options.forEach((item: any) => {
|
||||
tabData.value.push({
|
||||
label: item.label.replace(/准确度|检测/g, ''),
|
||||
@@ -453,6 +456,7 @@ onMounted(() => {
|
||||
valueCode.value = dictStore
|
||||
.getDictData('Script_Value_Type')
|
||||
.filter(item => item.id == props.formContent.valueType)[0].code
|
||||
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -120,6 +120,7 @@ const resetFormContent = () => {
|
||||
}
|
||||
// 关闭弹窗
|
||||
const close = () => {
|
||||
|
||||
// 清空dialogForm中的值
|
||||
resetFormContent()
|
||||
// 重置表单
|
||||
@@ -162,9 +163,9 @@ const open = async (title: string, row: any) => {
|
||||
} else {
|
||||
let list = JSON.parse(row)
|
||||
formContent.value = list
|
||||
console.log('🚀 ~ open ~ list:', formContent.value )
|
||||
show.value = true
|
||||
}
|
||||
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
}
|
||||
@@ -181,7 +182,7 @@ const treeInfo = async (currentMode: string) => {
|
||||
const result = await getDictTreeByCode(data)
|
||||
const result1 = (await getDictTreeByCode({ ...data, code: 'Script_Error' })).data[0].children
|
||||
const allOptions = await convertToOptions(result.data as Dict.ResDictTree[])
|
||||
console.log('🚀 ~ treeInfo ~ result1:', allOptions[0]?.children)
|
||||
//console.log('🚀 ~ treeInfo ~ result1:', allOptions[0]?.children)
|
||||
const setallTree = await setTree(allOptions[0]?.children, result1)
|
||||
secondLevelOptions.push(...(setallTree || []))
|
||||
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
|
||||
|
||||
@@ -37,6 +37,7 @@ const defaultProps = {
|
||||
const activeName = ref('')
|
||||
const childActiveName = ref('')
|
||||
const handleNodeClick = (data, node) => {
|
||||
console.log('handleNodeClick', data, node)
|
||||
let code = ['Base', 'VOL', 'Freq', 'Harm', 'Base_0_10', 'Base_20_85', 'Base_110_200']
|
||||
const parents = getParentNodes(node, [])
|
||||
parents.pop()
|
||||
|
||||
@@ -81,7 +81,6 @@ const testScriptPopup = ref()
|
||||
const valueTypePopup = ref()
|
||||
const modeStore = useModeStore()
|
||||
const dictStore = useDictStore()
|
||||
|
||||
const getTableList = (params: any) => {
|
||||
let newParams = JSON.parse(JSON.stringify(params))
|
||||
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id //获取数据字典中对应的id
|
||||
@@ -144,6 +143,7 @@ const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> =
|
||||
if (modeStore.currentMode == '比对式') {
|
||||
comparisonPopup.value?.open(titleType, row, modeStore.currentMode)
|
||||
} else {
|
||||
|
||||
if (titleType == 'add') {
|
||||
router.push({
|
||||
path: '/machine/testScriptAdd',
|
||||
|
||||
@@ -305,6 +305,7 @@ const open = async (sign: string,
|
||||
|
||||
if(sign == 'add')
|
||||
{
|
||||
console.log('add',data)
|
||||
const [pqSource_Result, PqScript_Result, PqErrSys_Result,pqDevList_Result] = await Promise.all([
|
||||
getTestSourceList(data),
|
||||
getPqScriptList(data),
|
||||
|
||||
Reference in New Issue
Block a user