This commit is contained in:
caozehui
2025-02-14 16:22:45 +08:00
parent 95022f62a8
commit e8de7b56d9
4 changed files with 24 additions and 18 deletions

View File

@@ -1,10 +1,16 @@
import http from '@/api' import http from '@/api'
import { type Dict } from '@/api/system/dictionary/interface' import { type Dict } from '@/api/system/dictionary/interface'
import {c} from "vite/dist/node/types.d-aGj9QkWt";
//获取字典类型 //获取字典类型
export const getDictTreeList = (params: Dict.ResDictTree) => { export const getDictTreeByCode = (params: Dict.ResDictTree) => {
const code = params.code || '';
return http.get(`/dictTree/getTreeByCode?code=${code}`)
}
export const getDictTreeByName = (params: Dict.ResDictTree) => {
const name = params.name || ''; const name = params.name || '';
return http.get(`/dictTree/getTree?keyword=${name}`, params) return http.get(`/dictTree/getTreeByName?name=${name}`)
} }
//添加字典类型 //添加字典类型

View File

@@ -57,7 +57,7 @@
import { useDictStore } from '@/stores/modules/dict' import { useDictStore } from '@/stores/modules/dict'
import { type ErrorSystem } from '@/api/device/interface/error'; import { type ErrorSystem } from '@/api/device/interface/error';
import ErrorSystemDetailTable from '@/views/machine/errorSystem/components/errorSystemDetailTable.vue'; import ErrorSystemDetailTable from '@/views/machine/errorSystem/components/errorSystemDetailTable.vue';
import {getDictTreeList} from '@/api/system/dictionary/dictTree' import {getDictTreeByCode} from '@/api/system/dictionary/dictTree'
import { type Dict } from '@/api/system/dictionary/interface'; import { type Dict } from '@/api/system/dictionary/interface';
// 定义弹出组件元信息 // 定义弹出组件元信息
const dialogFormRef = ref() const dialogFormRef = ref()
@@ -156,31 +156,31 @@ const handleTableDataUpdate = (newTableData: ErrorSystem.ErrorSystemDetail[]) =>
} }
// 封装提取第二层节点的逻辑 // 封装提取第二层节点的逻辑
const loadSecondLevelOptions = async () => { const loadSecondLevelOptions = async () => {
const dictCode = '误差体系指标项'; // 替换为实际需要的字典代码 const dictCode = 'Err_Sys_Items'; // 替换为实际需要的字典代码
const dictCode2 = '脚本-误差'; // 替换为实际需要的字典代码 const dictCode2 = 'Script_Error'; // 替换为实际需要的字典代码
const resDictTree: Dict.ResDictTree = { const resDictTree: Dict.ResDictTree = {
name: dictCode, name: '',
id: '', id: '',
pid: '', pid: '',
pids: '', pids: '',
code: '', code: dictCode,
sort: 0 sort: 0
}; };
const resDictTree2: Dict.ResDictTree = { const resDictTree2: Dict.ResDictTree = {
name: dictCode2, name: '',
id: '', id: '',
pid: '', pid: '',
pids: '', pids: '',
code: '', code: dictCode2,
sort: 0 sort: 0
}; };
// 并行请求两个字典树列表 // 并行请求两个字典树列表
const [result, result2] = await Promise.all([ const [result, result2] = await Promise.all([
getDictTreeList(resDictTree), getDictTreeByCode(resDictTree),
getDictTreeList(resDictTree2) getDictTreeByCode(resDictTree2)
]); ]);
const allOptions = convertToOptions(result.data as Dict.ResDictTree[]); const allOptions = convertToOptions(result.data as Dict.ResDictTree[]);

View File

@@ -60,7 +60,7 @@ 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'
import type { Dict } from '@/api/system/dictionary/interface' import type { Dict } from '@/api/system/dictionary/interface'
import { getDictTreeList } from '@/api/system/dictionary/dictTree' import { getDictTreeByCode } from '@/api/system/dictionary/dictTree'
import type { CascaderOption } from 'element-plus' import type { CascaderOption } from 'element-plus'
const modeId = ref() const modeId = ref()
const secondLevelOptions: any[] = [] const secondLevelOptions: any[] = []
@@ -123,16 +123,16 @@ const save = () => {
// 打开弹窗,可能是新增,也可能是编辑 // 打开弹窗,可能是新增,也可能是编辑
const open = async (sign: string, row: any, currentMode: string, id: string) => { const open = async (sign: string, row: any, currentMode: string, id: string) => {
const dictCode = '测试脚本字典表' // 替换为实际需要的字典代码 const dictCode = 'Script_Indicator_Items' // 替换为实际需要的字典代码
const resDictTree: Dict.ResDictTree = { const resDictTree: Dict.ResDictTree = {
name: dictCode, name: '',
id: '', id: '',
pid: '', pid: '',
pids: '', pids: '',
code: '', code: dictCode,
sort: 0 sort: 0
} }
const result = await getDictTreeList(resDictTree) const result = await getDictTreeByCode(resDictTree)
const allOptions = convertToOptions(result.data as Dict.ResDictTree[]) const allOptions = convertToOptions(result.data as Dict.ResDictTree[])
secondLevelOptions.push(...(allOptions[0]?.children || [])) secondLevelOptions.push(...(allOptions[0]?.children || []))

View File

@@ -3,7 +3,7 @@
<ProTable <ProTable
ref='proTable' ref='proTable'
:columns='columns' :columns='columns'
:request-api='getDictTreeList' :request-api='getDictTreeByName'
:pagination="false" :pagination="false"
> >
@@ -29,7 +29,7 @@
import {useDictStore} from '@/stores/modules/dict' import {useDictStore} from '@/stores/modules/dict'
import {useHandleData} from '@/hooks/useHandleData' import {useHandleData} from '@/hooks/useHandleData'
import { import {
getDictTreeList, getDictTreeByName,
deleteDictTree, deleteDictTree,
} from '@/api/system/dictionary/dictTree' } from '@/api/system/dictionary/dictTree'
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'