【修改】ps出题界面完善
This commit is contained in:
@@ -239,11 +239,11 @@
|
|||||||
|
|
||||||
<div class="block" style="height: 300px;width: 100% ;">
|
<div class="block" style="height: 300px;width: 100% ;">
|
||||||
<el-table
|
<el-table
|
||||||
:data="kaodianList"
|
:data="flatkaodianList"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
<el-table-column type="index" label="序号" width="60" />
|
<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-column prop="rate" label="权值" width="180" />
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
@@ -276,7 +276,7 @@
|
|||||||
|
|
||||||
<div style="flex: 1; overflow: auto; border: 1px solid #eee; padding: 8px;">
|
<div style="flex: 1; overflow: auto; border: 1px solid #eee; padding: 8px;">
|
||||||
<h3>考生表格(右侧)</h3>
|
<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="label" label="值" />
|
||||||
|
|
||||||
<el-table-column prop="rate" label="权值">
|
<el-table-column prop="rate" label="权值">
|
||||||
@@ -288,11 +288,11 @@
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column prop="sort" label="排序" />
|
||||||
<el-table-column label="操作" width="60">
|
<el-table-column label="操作" width="60">
|
||||||
<template #default="{ row }">
|
<template #default="{ $index }">
|
||||||
<span
|
<span
|
||||||
@click="removePoint(row)"
|
@click="removePoint($index)"
|
||||||
style="cursor: pointer; font-weight: bold; font-size: 18px;"
|
style="cursor: pointer; font-weight: bold; font-size: 18px;"
|
||||||
title="点击删除"
|
title="点击删除"
|
||||||
>—</span>
|
>—</span>
|
||||||
@@ -334,12 +334,13 @@
|
|||||||
<div class="block">
|
<div class="block">
|
||||||
<el-table :data="formData.fileUploads" style="width: 100%">
|
<el-table :data="formData.fileUploads" style="width: 100%">
|
||||||
<el-table-column type="index" label="#" width="50" />
|
<el-table-column type="index" label="#" width="50" />
|
||||||
<el-table-column label="文件名称" width="250">
|
<el-table-column label="文件名称" width="250" >
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="scope.row.fileName"
|
v-model="scope.row.fileName"
|
||||||
size="small"
|
size="small"
|
||||||
placeholder="请输入文件名称"
|
placeholder="请输入文件名称"
|
||||||
|
disabled
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -442,8 +443,6 @@ import FileForm from './components/FileForm.vue';
|
|||||||
import { defaultProps, handleTree } from '@/utils/tree'
|
import { defaultProps, handleTree } from '@/utils/tree'
|
||||||
import * as SpecialtyApi from '@/api/points'
|
import * as SpecialtyApi from '@/api/points'
|
||||||
import { toRaw } from 'vue';
|
import { toRaw } from 'vue';
|
||||||
|
|
||||||
|
|
||||||
defineOptions({ name: 'ChoiceForm' })
|
defineOptions({ name: 'ChoiceForm' })
|
||||||
// 定义一个缓存对象
|
// 定义一个缓存对象
|
||||||
const stuListCache: Record<number, any> = {};
|
const stuListCache: Record<number, any> = {};
|
||||||
@@ -632,8 +631,8 @@ function buildTreeFromFlatList(flatList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 定义右侧表格数据,初始时根据 pointList 构造
|
// 定义右侧表格数据,初始时根据 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 = '') {
|
function flattenPsVoList(list, parentPath = '') {
|
||||||
@@ -648,12 +647,47 @@ function flattenPsVoList(list, parentPath = '') {
|
|||||||
key: item.key, // 一定要有 key
|
key: item.key, // 一定要有 key
|
||||||
label: `${currentPath}: ${symbol}`,
|
label: `${currentPath}: ${symbol}`,
|
||||||
rate: 1,
|
rate: 1,
|
||||||
|
sort:item.sort
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return result;
|
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
|
// 可自定义树节点渲染,显示key + value
|
||||||
@@ -710,8 +744,9 @@ const rightHandleClick = (tab, e) => {
|
|||||||
// 发起考点请求
|
// 发起考点请求
|
||||||
QuestionApi.getPsPointByQuId(kaodianData.value.quId).then(res => {
|
QuestionApi.getPsPointByQuId(kaodianData.value.quId).then(res => {
|
||||||
// res 是接口返回的数据数组
|
// res 是接口返回的数据数组
|
||||||
kaodianList.value = res.answerList;
|
answerList.value = res.answerList;
|
||||||
console.log(kaodianList.value +"kaodianList.value ")
|
kaodianList.value = res.pointList;
|
||||||
|
pointList.value = res.pointList;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -876,7 +911,7 @@ const open = async (queryParams: any ,type: string, id?: number) => {
|
|||||||
try {
|
try {
|
||||||
const res = await QuestionApi.getQuestion(id);
|
const res = await QuestionApi.getQuestion(id);
|
||||||
|
|
||||||
// 默认两个类型
|
// 默认三个类型
|
||||||
const fileTypes = ['0','1', '2'];
|
const fileTypes = ['0','1', '2'];
|
||||||
|
|
||||||
// 后端返回的上传文件列表(可能为空)
|
// 后端返回的上传文件列表(可能为空)
|
||||||
@@ -1054,6 +1089,7 @@ const handleNodeClick = (data, node) => {
|
|||||||
key: data.key,
|
key: data.key,
|
||||||
label: label,
|
label: label,
|
||||||
rate: 1,
|
rate: 1,
|
||||||
|
sort:data.sort
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1088,6 +1124,13 @@ watch(
|
|||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
watch(
|
||||||
|
() => kaodianList.value,
|
||||||
|
(val) => {
|
||||||
|
flatkaodianList.value = flattenPsVoListOther(val);
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
Reference in New Issue
Block a user