【修改】ps出题界面完善
This commit is contained in:
@@ -239,11 +239,11 @@
|
||||
|
||||
<div class="block" style="height: 300px;width: 100% ;">
|
||||
<el-table
|
||||
:data="kaodianList"
|
||||
:data="flatkaodianList"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column type="index" label="序号" width="60" />
|
||||
<el-table-column prop="label" label="值" width="90" />
|
||||
<el-table-column prop="label" label="值" />
|
||||
<el-table-column prop="rate" label="权值" width="180" />
|
||||
</el-table>
|
||||
</div>
|
||||
@@ -273,10 +273,10 @@
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div style="flex: 1; overflow: auto; border: 1px solid #eee; padding: 8px;">
|
||||
<h3>考生表格(右侧)</h3>
|
||||
<el-table :data="flatPointList" style="width: 100%; min-width: 300px;">
|
||||
<el-table :data="flatPointList" style="width: 100%; min-width: 300px;" :row-key="(row) => row.id">
|
||||
<el-table-column prop="label" label="值" />
|
||||
|
||||
<el-table-column prop="rate" label="权值">
|
||||
@@ -288,11 +288,11 @@
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="sort" label="排序" />
|
||||
<el-table-column label="操作" width="60">
|
||||
<template #default="{ row }">
|
||||
<template #default="{ $index }">
|
||||
<span
|
||||
@click="removePoint(row)"
|
||||
@click="removePoint($index)"
|
||||
style="cursor: pointer; font-weight: bold; font-size: 18px;"
|
||||
title="点击删除"
|
||||
>—</span>
|
||||
@@ -334,12 +334,13 @@
|
||||
<div class="block">
|
||||
<el-table :data="formData.fileUploads" style="width: 100%">
|
||||
<el-table-column type="index" label="#" width="50" />
|
||||
<el-table-column label="文件名称" width="250">
|
||||
<el-table-column label="文件名称" width="250" >
|
||||
<template #default="scope">
|
||||
<el-input
|
||||
v-model="scope.row.fileName"
|
||||
size="small"
|
||||
placeholder="请输入文件名称"
|
||||
disabled
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -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<number, any> = {};
|
||||
@@ -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 }
|
||||
);
|
||||
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
Reference in New Issue
Block a user