—
@@ -334,12 +334,13 @@
-
+
@@ -442,8 +443,6 @@ import FileForm from './components/FileForm.vue';
import { defaultProps, handleTree } from '@/utils/tree'
import * as SpecialtyApi from '@/api/points'
import { toRaw } from 'vue';
-
-
defineOptions({ name: 'ChoiceForm' })
// 定义一个缓存对象
const stuListCache: Record = {};
@@ -632,8 +631,8 @@ function buildTreeFromFlatList(flatList) {
}
// 定义右侧表格数据,初始时根据 pointList 构造
-const flatPointList = ref<{ key: string; label: string; rate: number }[]>([]);
-
+const flatPointList = ref<{ key: string; label: string; rate: number ,sort:number}[]>([]);
+const flatkaodianList = ref<{ key: string; label: string; rate: number }[]>([]);
function flattenPsVoList(list, parentPath = '') {
@@ -648,12 +647,47 @@ function flattenPsVoList(list, parentPath = '') {
key: item.key, // 一定要有 key
label: `${currentPath}: ${symbol}`,
rate: 1,
+ sort:item.sort
});
}
});
return result;
}
-
+function flattenPsVoListOther(list, parentPath = '') {
+ const result = [];
+
+ list.forEach(item => {
+ // 构建当前路径:使用keyName作为节点名称
+ const currentPath = parentPath
+ ? `${parentPath} -> ${item.key}`
+ : item.key;
+
+ // 处理值显示(类似原函数的symbol逻辑)
+ const valueDisplay = item.value === 'true'
+ ? '✅'
+ : item.value === 'false'
+ ? '❌'
+ : item.value ;
+
+ // 只有叶子节点(没有children属性)才添加到结果
+ // 根据您的数据结构,type=1可能是叶子节点的标识
+ if (!item.children || item.children.length === 0) {
+ result.push({
+ key: item.id, // 使用id作为唯一key
+ label: `${currentPath}: ${valueDisplay}`,
+ rate: item.rate || 1, // 使用原始rate或默认1
+ rawData: item // 保留原始数据便于后续操作
+ });
+ }
+
+ // 如果有children则递归处理
+ if (item.children && item.children.length > 0) {
+ result.push(...flattenPsVoListOther(item.children, currentPath));
+ }
+ });
+
+ return result;
+}
// 可自定义树节点渲染,显示key + value
@@ -710,8 +744,9 @@ const rightHandleClick = (tab, e) => {
// 发起考点请求
QuestionApi.getPsPointByQuId(kaodianData.value.quId).then(res => {
// res 是接口返回的数据数组
- kaodianList.value = res.answerList;
- console.log(kaodianList.value +"kaodianList.value ")
+ answerList.value = res.answerList;
+ kaodianList.value = res.pointList;
+ pointList.value = res.pointList;
});
}
}
@@ -876,7 +911,7 @@ const open = async (queryParams: any ,type: string, id?: number) => {
try {
const res = await QuestionApi.getQuestion(id);
-// 默认两个类型
+// 默认三个类型
const fileTypes = ['0','1', '2'];
// 后端返回的上传文件列表(可能为空)
@@ -1054,6 +1089,7 @@ const handleNodeClick = (data, node) => {
key: data.key,
label: label,
rate: 1,
+ sort:data.sort
});
}
@@ -1088,6 +1124,13 @@ watch(
},
{ immediate: true }
);
+watch(
+ () => kaodianList.value,
+ (val) => {
+ flatkaodianList.value = flattenPsVoListOther(val);
+ },
+ { immediate: true }
+);