【修改】文件夹出题加上原始文件夹回显
This commit is contained in:
@@ -149,7 +149,7 @@
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChangeQuestion">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="试题编号" align="center" key="id" prop="quId" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="试题编号" align="center" key="id" prop="quNum" :show-overflow-tooltip="true"/>
|
||||
<el-table-column label="专业" align="center" prop="specialtyName" width="120" />
|
||||
<el-table-column
|
||||
label="课程"
|
||||
|
@@ -434,6 +434,7 @@
|
||||
:close-on-click-modal="false"
|
||||
draggable
|
||||
>
|
||||
<div style="margin-bottom: 10px; font-weight: bold;">答案目录</div>
|
||||
<el-tree
|
||||
:data="fileTreeData"
|
||||
node-key="id"
|
||||
@@ -441,6 +442,15 @@
|
||||
@node-click="handleFileNodeClick"
|
||||
default-expand-all
|
||||
/>
|
||||
<div style="margin: 20px 0 10px; font-weight: bold;">原始目录</div>
|
||||
<el-tree
|
||||
:data="fileTreeStu"
|
||||
node-key="id"
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
@node-click="handleFileNodeStuClick"
|
||||
default-expand-all
|
||||
/>
|
||||
|
||||
</el-dialog>
|
||||
|
||||
|
||||
@@ -456,6 +466,7 @@ import * as SpecialtyApi from '@/api/points'
|
||||
defineOptions({ name: 'ChoiceForm' })
|
||||
// 定义一个缓存对象
|
||||
const nodeListCache: Record<number, any> = {};
|
||||
const stuListCache: Record<number, any> = {};
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
@@ -466,6 +477,7 @@ const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
|
||||
const fileTreeDialogVisible = ref(false);
|
||||
const fileTreeData = ref<Tree[]>([]);
|
||||
const fileTreeStu = ref<Tree[]>([]);
|
||||
const currentEditingRow = ref<any>(null); // 当前点击的行
|
||||
|
||||
|
||||
@@ -516,12 +528,15 @@ const openFileTree = (row: any) => {
|
||||
console.log("111")
|
||||
const quId = kaodianData.value.quId;
|
||||
const cached = nodeListCache[quId];
|
||||
const cachedstu = stuListCache[quId]
|
||||
if (!cached) {
|
||||
ElMessage.warning('暂无缓存的文件结构');
|
||||
return;
|
||||
}
|
||||
|
||||
fileTreeData.value.push(...handleTree(cached))
|
||||
fileTreeData.value.push(...handleTree(cached))
|
||||
fileTreeStu.value.push(...handleTree(cachedstu))
|
||||
|
||||
currentEditingRow.value = row;
|
||||
fileTreeDialogVisible.value = true;
|
||||
};
|
||||
@@ -537,6 +552,19 @@ const handleFileNodeClick = (data) => {
|
||||
}
|
||||
fileTreeDialogVisible.value = false
|
||||
}
|
||||
|
||||
|
||||
const handleFileNodeStuClick = (data) => {
|
||||
const pathArray = findFilePathById(fileTreeStu.value, data.id)
|
||||
if (!pathArray) return
|
||||
|
||||
const fullPath = pathArray.join('\\')
|
||||
if (currentEditingRow.value) {
|
||||
currentEditingRow.value.content = fullPath
|
||||
currentEditingRow.value.attribute = data.attribute || ''
|
||||
}
|
||||
fileTreeDialogVisible.value = false
|
||||
}
|
||||
const findFilePathById = (
|
||||
tree: any[],
|
||||
targetId: number,
|
||||
@@ -660,6 +688,7 @@ const setKaodianRow =async () => {
|
||||
const quId = kaodianData.value.quId;
|
||||
if (quId) {
|
||||
nodeListCache[quId] = res.nodeList;
|
||||
stuListCache[quId]=res.stuList;
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user