feat: 工况库

This commit is contained in:
JiangSheng
2025-11-13 14:33:24 +08:00
parent 0afa8fad54
commit e6fc0f3443
5 changed files with 54 additions and 3 deletions

View File

@@ -17,6 +17,7 @@
</template> </template>
<template #footer> <template #footer>
<div> <div>
<el-button @click="onCancelFun">取消</el-button>
<el-button type="primary" @click="onConfirmFun">确定</el-button> <el-button type="primary" @click="onConfirmFun">确定</el-button>
</div> </div>
</template> </template>
@@ -29,6 +30,7 @@ import Dialog from '@/components/common/dialog/index.vue';
import type { FormInstance, FormRules } from 'element-plus'; import type { FormInstance, FormRules } from 'element-plus';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import type { Pool } from './types'; import type { Pool } from './types';
import type { sassFalse } from 'sass-embedded';
const { t } = useI18n(); const { t } = useI18n();
interface Props { interface Props {
@@ -100,6 +102,9 @@ const rules = reactive<FormRules<RuleForm>>({
], ],
}); });
const onCancelFun = () => {
visible.value = false;
};
const onConfirmFun = async () => { const onConfirmFun = async () => {
if (!formRef.value) { if (!formRef.value) {
return; return;

View File

@@ -43,6 +43,7 @@
</template> </template>
<template #footer> <template #footer>
<div> <div>
<el-button @click="onCancelFun">取消</el-button>
<el-button type="primary" @click="onConfirmFun">确定</el-button> <el-button type="primary" @click="onConfirmFun">确定</el-button>
</div> </div>
</template> </template>
@@ -131,6 +132,9 @@ const onUploadChangeFun: UploadProps['onChange'] = (uploadFile:any, uploadFiles:
form.value.fileList = uploadFiles; form.value.fileList = uploadFiles;
form.value.file = uploadFile.raw || uploadFile; // 用于上传 form.value.file = uploadFile.raw || uploadFile; // 用于上传
}; };
const onCancelFun = () => {
visible.value = false;
};
const onConfirmFun = async () => { const onConfirmFun = async () => {
if (!formRef.value) { if (!formRef.value) {
return; return;

View File

@@ -257,7 +257,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, nextTick, onMounted, ref, type Ref } from 'vue'; import { computed, nextTick, onMounted, ref, type Ref } from 'vue';
import { ElMessageBox, ElMessage } from 'element-plus'; import { ElMessageBox, ElMessage } from 'element-plus';
import { clone, cloneDeep, groupBy, isEqual } from 'lodash-es'; import { clone, cloneDeep, groupBy, isEqual, uniqBy } from 'lodash-es';
import { onBeforeRouteLeave, useRouter } from 'vue-router'; import { onBeforeRouteLeave, useRouter } from 'vue-router';
import loadcaseProTable from '@/components/loadCaseTable/commonTable/loadcaseProTable.vue'; import loadcaseProTable from '@/components/loadCaseTable/commonTable/loadcaseProTable.vue';
import loadCaseTable from '@/components/common/treeCaseTable/loadCaseTable.vue'; import loadCaseTable from '@/components/common/treeCaseTable/loadCaseTable.vue';
@@ -504,6 +504,40 @@ const updateTaskPoolFun = async (formData: any) => {
refreshVersionFun(); refreshVersionFun();
} }
}; };
const dedupeTreeFun = (nodes: any[]) => {
const flattenAll = (arr: any[]) => {
const out: any[] = [];
const walk = (list: any[]) => {
(list || []).forEach((it: any) => {
if (!it) return;
out.push(it);
if (it.children && it.children.length) {
walk(it.children);
}
});
};
walk(arr);
return out;
};
const flatInsert = flattenAll(nodes);
const uniqueFlatInsert = uniqBy(flatInsert, 'fakeId');
const map: Record<string, any> = {};
uniqueFlatInsert.forEach((node: any) => {
map[node.fakeId] = { ...cloneDeep(node), children: [] };
});
const roots: any[] = [];
uniqueFlatInsert.forEach((node: any) => {
const cur = map[node.fakeId];
if (cur.parentId && map[cur.parentId]) {
map[cur.parentId].children.push(cur);
} else {
roots.push(cur);
}
});
return roots;
};
const formatAddFun = (insertRecords: TreeNode[], updateRecords: TreeNode[]) => { const formatAddFun = (insertRecords: TreeNode[], updateRecords: TreeNode[]) => {
const { visibleData } = getVxeRef()?.getTableData(); const { visibleData } = getVxeRef()?.getTableData();
let nodes: any[] = []; let nodes: any[] = [];
@@ -545,7 +579,7 @@ const formatAddFun = (insertRecords: TreeNode[], updateRecords: TreeNode[]) => {
} }
}); });
}; };
formatAdd(insertRecords); formatAdd(dedupeTreeFun(insertRecords));
nodes = nodes.filter((item) => !item.isTemp); nodes = nodes.filter((item) => !item.isTemp);
tasks = tasks.filter((item) => !item.isTemp); tasks = tasks.filter((item) => !item.isTemp);
@@ -907,7 +941,7 @@ const queryVersionsFun = async () => {
}; };
const res: any = await getTaskPoolVersionsApi(req); const res: any = await getTaskPoolVersionsApi(req);
if (res.code === 200 && res.data && Array.isArray(res.data) && res.data.length > 0) { if (res.code === 200 && res.data && Array.isArray(res.data) && res.data.length > 0) {
versionList.value = res.data.reverse(); versionList.value = res.data;
if (versionList.value.length > 0) { if (versionList.value.length > 0) {
currentPoolBriefVersion.value = versionList.value[0]; currentPoolBriefVersion.value = versionList.value[0];
} }

View File

@@ -17,6 +17,7 @@
</template> </template>
<template #footer> <template #footer>
<div> <div>
<el-button @click="onCancelFun">取消</el-button>
<el-button type="primary" @click="onConfirmFun">确定</el-button> <el-button type="primary" @click="onConfirmFun">确定</el-button>
</div> </div>
</template> </template>
@@ -81,6 +82,9 @@ const rules = reactive<FormRules<RuleForm>>({
{ required: true, message: t('知识库.请输入名称'), trigger: 'blur' }, { required: true, message: t('知识库.请输入名称'), trigger: 'blur' },
], ],
}); });
const onCancelFun = () => {
visible.value = false;
};
const onConfirmFun = async () => { const onConfirmFun = async () => {
if (!formRef.value) { if (!formRef.value) {
return; return;

View File

@@ -21,6 +21,7 @@
</template> </template>
<template #footer> <template #footer>
<div> <div>
<el-button @click="onCancelFun">取消</el-button>
<el-button type="primary" @click="onConfirmFun">确定</el-button> <el-button type="primary" @click="onConfirmFun">确定</el-button>
</div> </div>
</template> </template>
@@ -113,6 +114,9 @@ const onFormChangeFun = (data:any) => {
} }
}; };
const tableFormRef = ref<any>(); const tableFormRef = ref<any>();
const onCancelFun = () => {
visible.value = false;
};
const onConfirmFun = async () => { const onConfirmFun = async () => {
const valid = await tableFormRef.value?.validateFun(); const valid = await tableFormRef.value?.validateFun();
if (valid) { if (valid) {