微调
This commit is contained in:
@@ -146,7 +146,6 @@ const open = async (sign: string, data: Role.RoleBO, AllFunction: Function.ResFu
|
|||||||
const allIds = getAllIds(AllFunction);
|
const allIds = getAllIds(AllFunction);
|
||||||
// 匹配 roleFunctions 中的 id 并设置 checkedKeys
|
// 匹配 roleFunctions 中的 id 并设置 checkedKeys
|
||||||
const checkedKeys = allIds.filter(id => roleFunctions.some(roleFunc => roleFunc.id === id));
|
const checkedKeys = allIds.filter(id => roleFunctions.some(roleFunc => roleFunc.id === id));
|
||||||
|
|
||||||
// 过滤出叶子节点
|
// 过滤出叶子节点
|
||||||
const leafCheckedKeys = filterLeafNodes(AllFunction, checkedKeys);
|
const leafCheckedKeys = filterLeafNodes(AllFunction, checkedKeys);
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
<el-tabs type="border-card">
|
<el-tabs type="border-card">
|
||||||
<div v-if="activeIndex > 0">
|
<div v-if="activeIndex > 0">
|
||||||
<el-tab-pane v-for="(device, index) in name.slice(0, activeIndex + 1)" :key="index" :label="device">
|
<el-tab-pane v-for="(device, index) in name.slice(0, activeIndex )" :key="index" :label="device">
|
||||||
<template #label>
|
<template #label>
|
||||||
<span class="custom-tabs-label">
|
<span class="custom-tabs-label">
|
||||||
<span>{{ device }}</span>
|
<span>{{ device }}</span>
|
||||||
@@ -102,9 +102,10 @@
|
|||||||
</template>
|
</template>
|
||||||
<script lang="tsx" setup name="channelsTest">
|
<script lang="tsx" setup name="channelsTest">
|
||||||
import { type Device } from '@/api/device/interface/device';
|
import { type Device } from '@/api/device/interface/device';
|
||||||
import { SuccessFilled, Failed } from '@element-plus/icons-vue'
|
import { SuccessFilled, Failed, Message, MessageBox } from '@element-plus/icons-vue'
|
||||||
import { type Ref, ref, toRef, watch } from 'vue'
|
import { type Ref, ref, toRef, watch } from 'vue'
|
||||||
import {dialogBig} from '@/utils/elementBind'
|
import {dialogBig} from '@/utils/elementBind'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||||
const activeIndex = ref(0)
|
const activeIndex = ref(0)
|
||||||
const activeTotalNum = ref(4)
|
const activeTotalNum = ref(4)
|
||||||
const qualified = ref(0)
|
const qualified = ref(0)
|
||||||
@@ -118,6 +119,28 @@ let intervalId: NodeJS.Timeout | null = null;
|
|||||||
// 在 setup 函数中
|
// 在 setup 函数中
|
||||||
const errorStates = ref(new Array(name.value.length).fill(false));
|
const errorStates = ref(new Array(name.value.length).fill(false));
|
||||||
|
|
||||||
|
|
||||||
|
// 定义 TableDataItem 接口
|
||||||
|
interface TableDataItem {
|
||||||
|
id: string;
|
||||||
|
deviceName: string;
|
||||||
|
MonitorIdx: number;
|
||||||
|
UaData?: number | string;
|
||||||
|
UaChannel?: number | string;
|
||||||
|
UbData?: number | string;
|
||||||
|
UbChannel?: number | string;
|
||||||
|
UcData?: number | string;
|
||||||
|
UcChannel?: number | string;
|
||||||
|
IaData?: number | string;
|
||||||
|
IaChannel?: number | string;
|
||||||
|
IbData?: number | string;
|
||||||
|
IbChannel?: number | string;
|
||||||
|
IcData?: number | string;
|
||||||
|
IcChannel?: number | string;
|
||||||
|
Result?: string | string;
|
||||||
|
updateTime?: string;
|
||||||
|
}
|
||||||
|
|
||||||
// 更新错误状态的方法
|
// 更新错误状态的方法
|
||||||
const updateErrorState = (index: number, hasError: boolean) => {
|
const updateErrorState = (index: number, hasError: boolean) => {
|
||||||
errorStates.value[index] = hasError;
|
errorStates.value[index] = hasError;
|
||||||
@@ -361,7 +384,7 @@ const tableData2 = ref<TableDataItem[]>([
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
const tableData3 = ref<TableDataItem[]>([
|
const tableData3 = ref<TableDataItem[]>([
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
updateTime: '2024-10-10 10:30:00',
|
updateTime: '2024-10-10 10:30:00',
|
||||||
deviceName: '大电压大电流',
|
deviceName: '大电压大电流',
|
||||||
@@ -413,7 +436,7 @@ const tableData3 = ref<TableDataItem[]>([
|
|||||||
IaData: 5,
|
IaData: 5,
|
||||||
IaChannel: '合格',
|
IaChannel: '合格',
|
||||||
IbData: 5,
|
IbData: 5,
|
||||||
IbChannel: 1.0001,
|
IbChannel: '合格',
|
||||||
IcData: 5,
|
IcData: 5,
|
||||||
IcChannel: '合格',
|
IcChannel: '合格',
|
||||||
Result: '合格',
|
Result: '合格',
|
||||||
@@ -439,10 +462,38 @@ const tableData3 = ref<TableDataItem[]>([
|
|||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
const tableDataMap = new Map<number, Ref<TableDataItem[]>>([
|
||||||
|
[0, tableData1],
|
||||||
|
[1, tableData2],
|
||||||
|
[2, tableData3],
|
||||||
|
[3, tableData1],
|
||||||
|
[4, tableData1],
|
||||||
|
[5, tableData1],
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
|
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
|
||||||
|
|
||||||
// 打开弹窗,可能是新增,也可能是编辑
|
// 打开弹窗,可能是新增,也可能是编辑
|
||||||
const open = (selection: Device.ResPqDev[]) => {
|
const open = (selection: Device.ResPqDev[]) => {
|
||||||
|
|
||||||
|
const checkStates = selection.map(item => item.checkState);
|
||||||
|
const allCheckStatesEqual = new Set(checkStates).size <= 1;
|
||||||
|
|
||||||
|
if (!allCheckStatesEqual) {
|
||||||
|
ElMessageBox.confirm(
|
||||||
|
'所勾选设备检测状态不一致,请重新选择',
|
||||||
|
'提示',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
name.value = selection.map(item => item.name)
|
name.value = selection.map(item => item.name)
|
||||||
channel.value = selection.map(item => item.devChns)
|
channel.value = selection.map(item => item.devChns)
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
@@ -460,35 +511,6 @@ const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process
|
|||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 定义 TableDataItem 接口
|
|
||||||
interface TableDataItem {
|
|
||||||
id: string;
|
|
||||||
deviceName: string;
|
|
||||||
MonitorIdx: number;
|
|
||||||
UaData?: number;
|
|
||||||
UaChannel?: number | string;
|
|
||||||
UbData?: number;
|
|
||||||
UbChannel?: number | string;
|
|
||||||
UcData?: number;
|
|
||||||
UcChannel?: number | string;
|
|
||||||
IaData?: number;
|
|
||||||
IaChannel?: number | string;
|
|
||||||
IbData?: number;
|
|
||||||
IbChannel?: number | string;
|
|
||||||
IcData?: number;
|
|
||||||
IcChannel?: number | string;
|
|
||||||
Result?: string;
|
|
||||||
updateTime?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const tableDataMap = new Map<number, Ref<TableDataItem[]>>([
|
|
||||||
[0, tableData1],
|
|
||||||
[1, tableData2],
|
|
||||||
[2, tableData3],
|
|
||||||
]);
|
|
||||||
|
|
||||||
const getTableDataForChannel = (index: number): any[] => {
|
const getTableDataForChannel = (index: number): any[] => {
|
||||||
const data = tableDataMap.get(index);
|
const data = tableDataMap.get(index);
|
||||||
return data ? data.value : [];
|
return data ? data.value : [];
|
||||||
@@ -566,28 +588,26 @@ const handleSubmit = () => {
|
|||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
}
|
}
|
||||||
intervalId = setInterval(() => {
|
intervalId = setInterval(() => {
|
||||||
console.log('开始')
|
|
||||||
if (activeIndex.value < name.value.length) {
|
if (activeIndex.value < name.value.length) {
|
||||||
activeIndex.value++;
|
activeIndex.value++;
|
||||||
console.log('active index',activeIndex.value)
|
|
||||||
// 获取当前活动索引对应的 tableData
|
// 获取当前活动索引对应的 tableData
|
||||||
const currentDataRef = tableDataMap.get(activeIndex.value);
|
const currentDataRef = tableDataMap.get(activeIndex.value - 1);
|
||||||
if (currentDataRef) {
|
if (currentDataRef) {
|
||||||
const currentData = currentDataRef.value;
|
const currentData = currentDataRef.value;
|
||||||
// 检查当前数据中有无不合格字段
|
// 检查当前数据中有无不合格字段
|
||||||
const hasError = checkForErrors(currentData);
|
const hasError = checkForErrors(currentData);
|
||||||
if (hasError) {
|
if (hasError) {
|
||||||
|
}else{
|
||||||
qualified.value++;
|
qualified.value++;
|
||||||
}
|
}
|
||||||
updateErrorState(activeIndex.value, hasError);
|
updateErrorState(activeIndex.value - 1, hasError);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('停')
|
|
||||||
clearInterval(intervalId!); // 停止定时器
|
clearInterval(intervalId!); // 停止定时器
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}, 3000); // 每隔3秒显示下一个tab
|
}, 1000); // 每隔3秒显示下一个tab
|
||||||
|
|
||||||
// let timer = setInterval(() => {
|
// let timer = setInterval(() => {
|
||||||
// if (activeIndex.value < activeTotalNum.value) {
|
// if (activeIndex.value < activeTotalNum.value) {
|
||||||
|
|||||||
@@ -781,19 +781,19 @@ const handleTest = async (val:string) => {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success('不合格项复检');
|
ElMessage.success('不合格项复检');
|
||||||
dialogTitle.value = val;
|
dialogTitle.value = val;
|
||||||
testPopup.value?.open(dialogTitle.value,props.isTimeCheck)// 打开对话框
|
testPopup.value?.open(channelsSelection.value,dialogTitle.value,props.isTimeCheck)// 打开对话框
|
||||||
})
|
})
|
||||||
.catch((action: Action) => {
|
.catch((action: Action) => {
|
||||||
ElMessage.success('全部复检');
|
ElMessage.success('全部复检');
|
||||||
dialogTitle.value = val;
|
dialogTitle.value = val;
|
||||||
testPopup.value?.open(dialogTitle.value,props.isTimeCheck) // 打开对话框
|
testPopup.value?.open(channelsSelection.value,dialogTitle.value,props.isTimeCheck) // 打开对话框
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ElMessage.success(val);
|
//ElMessage.success(val);
|
||||||
dialogTitle.value = val;
|
dialogTitle.value = val;
|
||||||
testPopup.value?.open(dialogTitle.value,props.isTimeCheck)
|
testPopup.value?.open(channelsSelection.value,dialogTitle.value,props.isTimeCheck)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
import preTest from './preTest.vue'
|
import preTest from './preTest.vue'
|
||||||
import timeTest from './timeTest.vue'
|
import timeTest from './timeTest.vue'
|
||||||
import channelsTest from './channelsTest.vue'
|
import channelsTest from './channelsTest.vue'
|
||||||
|
import { Device } from '@/api/device/interface/device';
|
||||||
//import SvgIcon from '@/components/SvgIcon.vue';
|
//import SvgIcon from '@/components/SvgIcon.vue';
|
||||||
|
|
||||||
// import preTestIcon from '@/assets/icons/preTest.svg'
|
// import preTestIcon from '@/assets/icons/preTest.svg'
|
||||||
@@ -129,7 +130,23 @@ const detectionOptions = ref([
|
|||||||
const isTimeCheck = ref(false)
|
const isTimeCheck = ref(false)
|
||||||
|
|
||||||
// 打开弹窗,可能是新增,也可能是编辑
|
// 打开弹窗,可能是新增,也可能是编辑
|
||||||
const open = (title: string,time:boolean) => {
|
const open = (selection: Device.ResPqDev[],title: string,time:boolean) => {
|
||||||
|
const checkStates = selection.map(item => item.checkState);
|
||||||
|
const allCheckStatesEqual = new Set(checkStates).size <= 1;
|
||||||
|
|
||||||
|
if (!allCheckStatesEqual) {
|
||||||
|
ElMessageBox.confirm(
|
||||||
|
'所勾选设备检测状态不一致,请重新选择',
|
||||||
|
'提示',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
dialogTitle.value = title;
|
dialogTitle.value = title;
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
isTimeCheck.value = time
|
isTimeCheck.value = time
|
||||||
|
|||||||
@@ -14,13 +14,7 @@
|
|||||||
<el-table-column prop="nextId" label="序号" width="60" />
|
<el-table-column prop="nextId" label="序号" width="60" />
|
||||||
<el-table-column prop="type" label="电能质量检测指标类型" min-width="200">
|
<el-table-column prop="type" label="电能质量检测指标类型" min-width="200">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-cascader :options="options" v-model="row.type"/>
|
<el-cascader :options="options" v-model="row.type" :props="{ checkStrictly: false, emitPath: false }"/>
|
||||||
<!-- <el-select v-model="row.type" placeholder="选择指标类型" >
|
|
||||||
<el-option v-for="item in dictStore.getDictData('Pq_Test_Type')"
|
|
||||||
:key="item.id"
|
|
||||||
:label="item.name"
|
|
||||||
:value="item.id"/>
|
|
||||||
</el-select> -->
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="起止范围" >
|
<el-table-column label="起止范围" >
|
||||||
@@ -64,7 +58,7 @@
|
|||||||
v-for="item in dictStore.getDictData('Condition_Type')"
|
v-for="item in dictStore.getDictData('Condition_Type')"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.id"
|
:value="Number(item.value)"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
@@ -83,7 +77,7 @@
|
|||||||
v-for="item in dictStore.getDictData('Error_Value_Type')"
|
v-for="item in dictStore.getDictData('Error_Value_Type')"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.id"
|
:value="Number(item.value)"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
@@ -104,61 +98,23 @@
|
|||||||
import { useDictStore, } from '@/stores/modules/dict'
|
import { useDictStore, } from '@/stores/modules/dict'
|
||||||
import {CirclePlus, Delete, EditPen,CopyDocument} from '@element-plus/icons-vue'
|
import {CirclePlus, Delete, EditPen,CopyDocument} from '@element-plus/icons-vue'
|
||||||
import { type CascaderOption, type FormItemRule } from 'element-plus';
|
import { type CascaderOption, type FormItemRule } from 'element-plus';
|
||||||
import { onMounted, type PropType, Ref, ref, watch } from 'vue';
|
import { type PropType, type Ref, ref, watch } from 'vue';
|
||||||
import { defineEmits } from 'vue';
|
import { defineEmits } from 'vue';
|
||||||
import ProTable from '@/components/ProTable/index.vue'
|
|
||||||
import {
|
|
||||||
getDictTreeList,
|
|
||||||
} from '@/api/system/dictionary/dictTree'
|
|
||||||
import { type Dict } from '@/api/system/dictionary/interface';
|
|
||||||
const emit = defineEmits(['updateTableData']);
|
const emit = defineEmits(['updateTableData']);
|
||||||
const multipleSelection = ref<number[]>([])
|
const multipleSelection = ref<number[]>([])
|
||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
options: {
|
||||||
|
type: Array as PropType<CascaderOption[]>,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
|
||||||
tableData: {
|
tableData: {
|
||||||
type: Array as PropType<ErrorSystem.ErrorSystemDetail[]>,
|
type: Array as PropType<ErrorSystem.ErrorSystemDetail[]>,
|
||||||
default: () => []
|
default: () => []
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const options: Ref<CascaderOption[]> = ref([]); // 修改这里
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const dictCode = '误差体系指标项'; // 替换为实际需要的字典代码
|
|
||||||
const resDictTree: Dict.ResDictTree = {
|
|
||||||
name: dictCode,
|
|
||||||
id: '',
|
|
||||||
pid: '',
|
|
||||||
pids: '',
|
|
||||||
code: '',
|
|
||||||
sort: 0
|
|
||||||
};
|
|
||||||
const result = await getDictTreeList(resDictTree);
|
|
||||||
const allOptions = convertToOptions(result.data as Dict.ResDictTree[]);
|
|
||||||
|
|
||||||
// 提取第二层节点
|
|
||||||
const secondLevelOptions: any[] = [];
|
|
||||||
allOptions.forEach(option => {
|
|
||||||
if (option.children && option.children.length > 0) {
|
|
||||||
secondLevelOptions.push(...option.children);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 将第二层节点赋值给 options.value
|
|
||||||
options.value = secondLevelOptions;
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
// 转换函数
|
|
||||||
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
|
|
||||||
return dictTree.map(item => ({
|
|
||||||
value: item.id,
|
|
||||||
label: item.name,
|
|
||||||
children: item.children ? convertToOptions(item.children) : undefined
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
// 监听 props.tableData 的变化,确保每次数据变化时都重新设置 nextId
|
// 监听 props.tableData 的变化,确保每次数据变化时都重新设置 nextId
|
||||||
watch(() => props.tableData, async (newTableData) => {
|
watch(() => props.tableData, async (newTableData) => {
|
||||||
for (let i = 0; i < newTableData.length; i++) {
|
for (let i = 0; i < newTableData.length; i++) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
||||||
|
|
||||||
<ErrorSystemDetailTable :tableData="tableData" @updateTableData="handleTableDataUpdate" />
|
<ErrorSystemDetailTable :tableData="tableData" :options="options" @updateTableData="handleTableDataUpdate" />
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div >
|
<div >
|
||||||
@@ -49,22 +49,25 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup name="ErrorSystemDialog">
|
<script lang="ts" setup name="ErrorSystemDialog">
|
||||||
import{ElMessage, type FormInstance,type FormItemRule}from'element-plus'
|
import{type CascaderOption, ElMessage, type FormInstance,type FormItemRule}from'element-plus'
|
||||||
import { defineProps, defineEmits, reactive,watch,ref, Ref, computed } from 'vue';
|
import { defineProps, defineEmits, reactive,watch,ref, type Ref, computed } from 'vue';
|
||||||
import { dialogBig} from '@/utils/elementBind'
|
import { dialogBig} from '@/utils/elementBind'
|
||||||
import { addPqErrSys,updatePqErrSys,getPqErrSysListById} from '@/api/device/error/index'
|
import { addPqErrSys,updatePqErrSys,getPqErrSysListById} from '@/api/device/error/index'
|
||||||
import {CirclePlus, Delete, EditPen,FolderOpened,CopyDocument} from '@element-plus/icons-vue'
|
import {CirclePlus, Delete, EditPen,FolderOpened,CopyDocument} from '@element-plus/icons-vue'
|
||||||
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 { type Dict } from '@/api/system/dictionary/interface';
|
||||||
// 定义弹出组件元信息
|
// 定义弹出组件元信息
|
||||||
const dialogFormRef = ref()
|
const dialogFormRef = ref()
|
||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
const tableData = ref<ErrorSystem.ErrorSystemDetail[]>([]);
|
const tableData = ref<ErrorSystem.ErrorSystemDetail[]>([]);
|
||||||
|
const options: Ref<CascaderOption[]> = ref([]); // 修改这里
|
||||||
const handleTableDataUpdate = (newTableData: ErrorSystem.ErrorSystemDetail[]) => {
|
|
||||||
|
const handleTableDataUpdate = (newTableData: ErrorSystem.ErrorSystemDetail[]) => {
|
||||||
tableData.value = newTableData;
|
tableData.value = newTableData;
|
||||||
};
|
};
|
||||||
|
|
||||||
function useMetaInfo() {
|
function useMetaInfo() {
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
@@ -149,12 +152,47 @@
|
|||||||
console.error('验证过程中出现错误', err)
|
console.error('验证过程中出现错误', err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 封装提取第二层节点的逻辑
|
||||||
|
const loadSecondLevelOptions = async () => {
|
||||||
|
const dictCode = '误差体系指标项'; // 替换为实际需要的字典代码
|
||||||
|
const resDictTree: Dict.ResDictTree = {
|
||||||
|
name: dictCode,
|
||||||
|
id: '',
|
||||||
|
pid: '',
|
||||||
|
pids: '',
|
||||||
|
code: '',
|
||||||
|
sort: 0
|
||||||
|
};
|
||||||
|
const result = await getDictTreeList(resDictTree);
|
||||||
|
const allOptions = convertToOptions(result.data as Dict.ResDictTree[]);
|
||||||
|
|
||||||
|
// 提取第二层节点
|
||||||
|
const secondLevelOptions: any[] = [];
|
||||||
|
allOptions.forEach(option => {
|
||||||
|
if (option.children && option.children.length > 0) {
|
||||||
|
secondLevelOptions.push(...option.children);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 将第二层节点赋值给 options.value
|
||||||
|
options.value = secondLevelOptions;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 转换函数
|
||||||
|
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
|
||||||
|
return dictTree.map(item => ({
|
||||||
|
value: item.id,
|
||||||
|
label: item.name,
|
||||||
|
children: item.children ? convertToOptions(item.children) : undefined
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
// 打开弹窗,可能是新增,也可能是编辑
|
// 打开弹窗,可能是新增,也可能是编辑
|
||||||
const open = async (sign: string, data: ErrorSystem.ErrorSystemList) => {
|
const open = async (sign: string, data: ErrorSystem.ErrorSystemList) => {
|
||||||
titleType.value = sign
|
titleType.value = sign
|
||||||
dialogVisible.value = true
|
// 确保每次打开弹窗时都重新加载数据
|
||||||
|
await loadSecondLevelOptions();
|
||||||
if (data.id) {
|
if (data.id) {
|
||||||
const result = await getPqErrSysListById(data);
|
const result = await getPqErrSysListById(data);
|
||||||
if (result && result.data) {
|
if (result && result.data) {
|
||||||
@@ -167,6 +205,9 @@ const open = async (sign: string, data: ErrorSystem.ErrorSystemList) => {
|
|||||||
}
|
}
|
||||||
// 重置表单
|
// 重置表单
|
||||||
dialogFormRef.value?.resetFields()
|
dialogFormRef.value?.resetFields()
|
||||||
|
dialogVisible.value = true
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user