微调
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig">
|
||||
<div class="table-container">
|
||||
<el-table :data="errorData"
|
||||
<el-table :data="errorData.value"
|
||||
height="500"
|
||||
:header-cell-style="rowClass"
|
||||
:cell-style="{ textAlign: 'center' }"
|
||||
@@ -37,10 +37,12 @@
|
||||
import type { ErrorSystem } from '@/api/device/interface/error'
|
||||
import errorDataList from '@/api/device/error/errorData'
|
||||
import type { TableColumnCtx } from 'element-plus'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
|
||||
const errorData = errorDataList.errordetail
|
||||
const dictStore = useDictStore()
|
||||
const errorData = ref<ErrorSystem.Error_detail[]>([]);
|
||||
const dialogTitle = ref()
|
||||
|
||||
const devLevelName = ref<string>('') // 假设 devLevelName 是一个 ref
|
||||
function useMetaInfo() {
|
||||
const dialogVisible = ref(false)
|
||||
const formContent = ref<ErrorSystem.ErrorSystemList>({
|
||||
@@ -76,50 +78,58 @@ const rowClass = ({ row, column, rowIndex, columnIndex }: { row: any; column: an
|
||||
return res
|
||||
}
|
||||
|
||||
const spanMethod = ({
|
||||
|
||||
const spanMethod = computed(() => {
|
||||
return devLevelName.value === 'A级' ? spanAMethod : spanSMethod
|
||||
})
|
||||
|
||||
const spanAMethod = ({
|
||||
row,
|
||||
column,
|
||||
rowIndex,
|
||||
columnIndex,
|
||||
}: SpanMethodProps) => {
|
||||
if (columnIndex === 0) {
|
||||
if (rowIndex <= 1 || rowIndex === 7 || rowIndex == 20) {
|
||||
if (rowIndex <= 1 || rowIndex === 7 || rowIndex == 20) {//0电压偏差,1频率偏差,7闪变,20功率,简单的跨两列
|
||||
return {
|
||||
rowspan: 1,
|
||||
colspan: 2,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 2) {
|
||||
if (rowIndex === 2) {//2三相不平衡跨三行两列
|
||||
return {
|
||||
rowspan: 3, // 不显示该单元格
|
||||
rowspan: 3,
|
||||
colspan: 2,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 3 || rowIndex === 4 || rowIndex === 6 || rowIndex >= 9 && rowIndex <= 15 || rowIndex >= 17 && rowIndex <= 19 || rowIndex === 22 || rowIndex === 24) {
|
||||
if (rowIndex === 3 || rowIndex === 4 || rowIndex === 6 ||
|
||||
rowIndex >= 9 && rowIndex <= 15 ||
|
||||
rowIndex >= 17 && rowIndex <= 19 ||
|
||||
rowIndex === 22 || rowIndex === 24) {//这些行不显示
|
||||
return {
|
||||
rowspan: 0, // 不显示该单元格
|
||||
rowspan: 0,
|
||||
colspan: 0,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 5 || rowIndex === 23) {
|
||||
if (rowIndex === 5 || rowIndex === 23) {//5电压波动,23电压暂降暂升中断跨两列
|
||||
return {
|
||||
rowspan: 2,
|
||||
colspan: 1,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 8) {
|
||||
if (rowIndex === 8) {//谐波和间谐波跨八行两列
|
||||
return {
|
||||
rowspan: 8,
|
||||
colspan: 2,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 16) {
|
||||
if (rowIndex === 16) {//高频次谐波跨八行两列
|
||||
return {
|
||||
rowspan: 4,
|
||||
colspan: 2,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 21 || rowIndex === 22) {
|
||||
if (rowIndex === 21 || rowIndex === 22) {//电流跨两行两列
|
||||
return {
|
||||
rowspan: 2,
|
||||
colspan: 2,
|
||||
@@ -134,28 +144,18 @@ const spanMethod = ({
|
||||
}
|
||||
}
|
||||
}
|
||||
if (columnIndex === 2) {
|
||||
if (rowIndex === 2 || rowIndex === 8 || rowIndex === 10 || rowIndex === 12 || rowIndex === 14 || rowIndex === 16 || rowIndex === 18 || rowIndex === 21) {
|
||||
if (columnIndex === 2 || columnIndex === 3) {
|
||||
if (rowIndex === 2 || rowIndex === 8 || rowIndex === 10 ||
|
||||
rowIndex === 12 || rowIndex === 14 || rowIndex === 16 ||
|
||||
rowIndex === 18 || rowIndex === 21) {
|
||||
return {
|
||||
rowspan: 2,
|
||||
colspan: 1,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 3 || rowIndex === 9 || rowIndex === 11 || rowIndex === 13 || rowIndex === 15 || rowIndex === 17 || rowIndex === 19 || rowIndex === 22) {
|
||||
return {
|
||||
rowspan: 0,
|
||||
colspan: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (columnIndex === 3) {
|
||||
if (rowIndex === 2 || rowIndex === 8 || rowIndex === 10 || rowIndex === 12 || rowIndex === 14 || rowIndex === 16 || rowIndex === 18 || rowIndex === 21) {
|
||||
return {
|
||||
rowspan: 2,
|
||||
colspan: 1,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 3 || rowIndex === 9 || rowIndex === 11 || rowIndex === 13 || rowIndex === 15 || rowIndex === 17 || rowIndex === 19 || rowIndex === 22) {
|
||||
if (rowIndex === 3 || rowIndex === 9 || rowIndex === 11 ||
|
||||
rowIndex === 13 || rowIndex === 15 || rowIndex === 17 ||
|
||||
rowIndex === 19 || rowIndex === 22) {
|
||||
return {
|
||||
rowspan: 0,
|
||||
colspan: 0,
|
||||
@@ -164,10 +164,111 @@ const spanMethod = ({
|
||||
}
|
||||
};
|
||||
|
||||
// 关闭弹窗
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
|
||||
const spanSMethod = ({
|
||||
row,
|
||||
column,
|
||||
rowIndex,
|
||||
columnIndex,
|
||||
}: SpanMethodProps) => {
|
||||
if (columnIndex === 0) {
|
||||
if (rowIndex <= 1 || rowIndex === 8 || rowIndex == 17) {//0电压偏差,1频率偏差,7闪变,20功率,简单的跨两列
|
||||
return {
|
||||
rowspan: 1,
|
||||
colspan: 2,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 2) {//2三相不平衡跨三行两列
|
||||
return {
|
||||
rowspan: 3,
|
||||
colspan: 2,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 3 || rowIndex === 4 || rowIndex === 6 || rowIndex === 7 ||
|
||||
rowIndex >= 10 && rowIndex <= 12 ||
|
||||
rowIndex >= 14 && rowIndex <= 16 ||
|
||||
rowIndex === 19 || rowIndex === 21 || rowIndex === 22) {//这些行不显示
|
||||
return {
|
||||
rowspan: 0,
|
||||
colspan: 0,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 5 || rowIndex === 20) {//5电压波动,23电压暂降暂升中断跨两行
|
||||
return {
|
||||
rowspan: 3,
|
||||
colspan: 1,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 9 || rowIndex === 13) {//谐波和间谐波跨八行两列
|
||||
return {
|
||||
rowspan: 4,
|
||||
colspan: 2,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 18 ) {//电流跨两行两列
|
||||
return {
|
||||
rowspan: 2,
|
||||
colspan: 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (columnIndex === 1) {
|
||||
if (rowIndex === 6 || rowIndex === 21) {
|
||||
return {
|
||||
rowspan: 2,
|
||||
colspan: 1,
|
||||
}
|
||||
}
|
||||
if (rowIndex <= 4 || rowIndex >= 7 && rowIndex <= 19 || rowIndex === 22) {
|
||||
return {
|
||||
rowspan: 0,
|
||||
colspan: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (columnIndex === 2) {
|
||||
if (rowIndex === 2 || rowIndex === 6 || rowIndex === 9 ||
|
||||
rowIndex === 11 || rowIndex === 13 || rowIndex === 15 ||
|
||||
rowIndex === 18 || rowIndex === 21) {
|
||||
return {
|
||||
rowspan: 2,
|
||||
colspan: 1,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 3 || rowIndex === 7 ||
|
||||
rowIndex === 10 || rowIndex === 12 ||
|
||||
rowIndex === 14 || rowIndex === 16 ||
|
||||
rowIndex === 19 || rowIndex === 22) {
|
||||
return {
|
||||
rowspan: 0,
|
||||
colspan: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
if(columnIndex === 3){
|
||||
if (rowIndex === 2 || rowIndex === 6 || rowIndex === 9 ||
|
||||
rowIndex === 11 || rowIndex === 13 ||rowIndex === 15 ||
|
||||
rowIndex === 18 || rowIndex === 21){
|
||||
return {
|
||||
rowspan: 2,
|
||||
colspan: 1,
|
||||
}
|
||||
}
|
||||
if (rowIndex === 3 || rowIndex === 7 || rowIndex === 10 ||
|
||||
rowIndex === 12 || rowIndex === 14 ||rowIndex === 16 ||
|
||||
rowIndex === 19 || rowIndex === 22){
|
||||
return {
|
||||
rowspan: 0,
|
||||
colspan: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 关闭弹窗
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (sign: string, data: ErrorSystem.ErrorSystemList) => {
|
||||
@@ -175,6 +276,15 @@ const open = async (sign: string, data: ErrorSystem.ErrorSystemList) => {
|
||||
dialogVisible.value = true
|
||||
if (data.id) {
|
||||
formContent.value = data as ErrorSystem.ErrorSystemList;
|
||||
|
||||
devLevelName.value = dictStore.getDictData('Dev_Level').find(item => item.id === data.devLevel)?.name || '';;
|
||||
|
||||
if(devLevelName.value === 'A级'){
|
||||
errorData.value = errorDataList.errorADetail as unknown as ErrorSystem.Error_detail[];
|
||||
}else{
|
||||
errorData.value = errorDataList.errorSDetail as unknown as ErrorSystem.Error_detail[];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,55 +155,55 @@ const handleTableDataUpdate = (newTableData: ErrorSystem.ErrorSystemDetail[]) =>
|
||||
}
|
||||
}
|
||||
// 封装提取第二层节点的逻辑
|
||||
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 loadSecondLevelOptions = async () => {
|
||||
const dictCode = '误差体系指标项'; // 替换为实际需要的字典代码
|
||||
const dictCode2 = '脚本-误差'; // 替换为实际需要的字典代码
|
||||
|
||||
// 提取第二层节点
|
||||
const secondLevelOptions: any[] = [];
|
||||
allOptions.forEach(option => {
|
||||
if (option.children && option.children.length > 0) {
|
||||
secondLevelOptions.push(...option.children);
|
||||
}
|
||||
});
|
||||
// 将第二层节点赋值给 options.value
|
||||
errorOptions.value = secondLevelOptions;
|
||||
const resDictTree: Dict.ResDictTree = {
|
||||
name: dictCode,
|
||||
id: '',
|
||||
pid: '',
|
||||
pids: '',
|
||||
code: '',
|
||||
sort: 0
|
||||
};
|
||||
|
||||
const resDictTree2: Dict.ResDictTree = {
|
||||
name: dictCode2,
|
||||
id: '',
|
||||
pid: '',
|
||||
pids: '',
|
||||
code: '',
|
||||
sort: 0
|
||||
};
|
||||
|
||||
// 并行请求两个字典树列表
|
||||
const [result, result2] = await Promise.all([
|
||||
getDictTreeList(resDictTree),
|
||||
getDictTreeList(resDictTree2)
|
||||
]);
|
||||
|
||||
const allOptions = convertToOptions(result.data as Dict.ResDictTree[]);
|
||||
const allOptions2 = convertToOptions(result2.data as Dict.ResDictTree[]);
|
||||
|
||||
// 提取第二层节点
|
||||
const secondLevelOptions: any[] = [];
|
||||
allOptions.forEach(option => {
|
||||
if (option.children && option.children.length > 0) {
|
||||
secondLevelOptions.push(...option.children);
|
||||
}
|
||||
});
|
||||
|
||||
const secondLevelOptions2: any[] = [];
|
||||
allOptions2.forEach(option => {
|
||||
if (option.children && option.children.length > 0) {
|
||||
secondLevelOptions2.push(...option.children);
|
||||
}
|
||||
});
|
||||
|
||||
const dictCode2 = '脚本-误差'; // 替换为实际需要的字典代码
|
||||
const resDictTree2: Dict.ResDictTree = {
|
||||
name: dictCode2,
|
||||
id: '',
|
||||
pid: '',
|
||||
pids: '',
|
||||
code: '',
|
||||
sort: 0
|
||||
};
|
||||
const result2 = await getDictTreeList(resDictTree2);
|
||||
const allOptions2 = convertToOptions(result2.data as Dict.ResDictTree[]);
|
||||
|
||||
// 提取第二层节点
|
||||
const secondLevelOptions2: any[] = [];
|
||||
allOptions2.forEach(option => {
|
||||
if (option.children && option.children.length > 0) {
|
||||
secondLevelOptions2.push(...option.children);
|
||||
}
|
||||
});
|
||||
// 将第二层节点赋值给 options.value
|
||||
scriptOptions.value = secondLevelOptions2;
|
||||
// 将第二层节点赋值给 options.value
|
||||
errorOptions.value = secondLevelOptions;
|
||||
scriptOptions.value = secondLevelOptions2;
|
||||
};
|
||||
|
||||
// 转换函数
|
||||
@@ -216,26 +216,28 @@ const handleTableDataUpdate = (newTableData: ErrorSystem.ErrorSystemDetail[]) =>
|
||||
}));
|
||||
};
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (sign: string, data: ErrorSystem.ErrorSystemList) => {
|
||||
titleType.value = sign
|
||||
// 确保每次打开弹窗时都重新加载数据
|
||||
await loadSecondLevelOptions();
|
||||
if (data.id) {
|
||||
const result = await getPqErrSysListById(data);
|
||||
if (result && result.data) {
|
||||
formContent.value = result.data as ErrorSystem.ErrorSystemList;
|
||||
|
||||
tableData.value = formContent.value.pqErrSysDtlsList || []
|
||||
}
|
||||
} else {
|
||||
titleType.value = sign;
|
||||
|
||||
resetFormContent()
|
||||
// 并行执行两个异步操作
|
||||
const loadOptionsPromise = loadSecondLevelOptions();
|
||||
const fetchDataPromise = data.id ? getPqErrSysListById(data) : Promise.resolve(null);
|
||||
|
||||
const [_, result] = await Promise.all([loadOptionsPromise, fetchDataPromise]);
|
||||
|
||||
if (result && result.data) {
|
||||
formContent.value = result.data as ErrorSystem.ErrorSystemList;
|
||||
tableData.value = formContent.value.pqErrSysDtlsList || [];
|
||||
} else {
|
||||
resetFormContent();
|
||||
}
|
||||
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
dialogVisible.value = true
|
||||
}
|
||||
dialogFormRef.value?.resetFields();
|
||||
dialogVisible.value = true;
|
||||
};
|
||||
|
||||
|
||||
// 对外映射
|
||||
|
||||
Reference in New Issue
Block a user