|
@@ -1408,13 +1408,13 @@
|
|
|
<el-dialog
|
|
|
title="选择题目"
|
|
|
v-model="showQuestionSelectDialog"
|
|
|
- width="70%"
|
|
|
+ width="30%"
|
|
|
:close-on-click-modal="false"
|
|
|
class="question-select-dialog"
|
|
|
>
|
|
|
<div class="question-select-content">
|
|
|
<!-- 搜索栏 -->
|
|
|
- <div class="search-bar">
|
|
|
+ <!-- <div class="search-bar">
|
|
|
<div class="search-inputs">
|
|
|
<el-input
|
|
|
v-model="questionSearchKeyword"
|
|
@@ -1441,10 +1441,10 @@
|
|
|
<el-option label="单选题" :value="1" />
|
|
|
</el-select>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
|
|
|
<!-- 题目列表 -->
|
|
|
- <div class="question-lists">
|
|
|
+ <!-- <div class="question-lists">
|
|
|
<el-table
|
|
|
:data="questionList"
|
|
|
style="width: 100%"
|
|
@@ -1453,11 +1453,7 @@
|
|
|
<el-table-column type="selection" width="55" />
|
|
|
<el-table-column prop="question" label="题目标题" />
|
|
|
<el-table-column prop="question_form_name" label="题目类型" width="100"/>
|
|
|
- <!-- <el-table-column prop="content" label="面试内容" show-overflow-tooltip />
|
|
|
- <el-table-column prop="target" label="对话目标" show-overflow-tooltip /> -->
|
|
|
</el-table>
|
|
|
-
|
|
|
- <!-- 分页 -->
|
|
|
<div class="pagination-container">
|
|
|
<el-pagination
|
|
|
v-model:current-page="questionListQuery.page"
|
|
@@ -1469,7 +1465,26 @@
|
|
|
@current-change="handleQuestionPageChange"
|
|
|
/>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
+ <el-tree
|
|
|
+ ref="treeRef"
|
|
|
+ :data="treeData"
|
|
|
+ node-key="id"
|
|
|
+ :props="defaultProps"
|
|
|
+ default-expand-all
|
|
|
+ highlight-current
|
|
|
+ @node-click="handleNodeClick"
|
|
|
+ >
|
|
|
+ <template #default="{ node, data }">
|
|
|
+ <div class="custom-tree-node">
|
|
|
+ <div class="node-label" style="display: flex;align-items: center;">
|
|
|
+ <el-icon><Folder /></el-icon>
|
|
|
+ <span class="ml-2">{{ data.title }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-tree>
|
|
|
+
|
|
|
</div>
|
|
|
|
|
|
<template #footer>
|
|
@@ -2500,7 +2515,6 @@ const handleQPageChange = (page: number) => {
|
|
|
};
|
|
|
|
|
|
const confirmSelect = async () => {
|
|
|
-
|
|
|
const selectedQuestionIds =selectedQuestions.value.map((item:any) => item.id);
|
|
|
console.log('selectedQuestionIds', selectedQuestionIds);
|
|
|
if (selectedQuestionIds.length === 0) {
|
|
@@ -2522,9 +2536,13 @@ const confirmSelect = async () => {
|
|
|
|
|
|
ElMessage.success('问题添加成功');
|
|
|
QuestionSelectDialog.value = false;
|
|
|
- } catch (error) {
|
|
|
+ } catch (error: any) {
|
|
|
console.error('添加问题失败:', error);
|
|
|
- ElMessage.error('添加问题失败,请重试');
|
|
|
+ if (error.code === 4000) {
|
|
|
+ ElMessage.warning('该题目已绑定,请选择其他题目');
|
|
|
+ } else {
|
|
|
+ ElMessage.error('添加问题失败,请重试');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -4760,6 +4778,7 @@ const editAIVideo = async (step: AIVideoStep) => {
|
|
|
questionListpage.page=res.data.page;
|
|
|
questionListpage.pageSize=res.data.limit;
|
|
|
totalQuestions2.value=res.data.total;
|
|
|
+ getDFTreeData();
|
|
|
showQuestionSelectDialog.value = true;
|
|
|
}
|
|
|
})
|
|
@@ -5512,41 +5531,63 @@ const cancelQuestionSelect = () => {
|
|
|
questionSearchKeyword.value = '';
|
|
|
};
|
|
|
|
|
|
-// 确认选择题目
|
|
|
-const confirmQuestionSelect = () => {
|
|
|
+const confirmQuestionSelect = async () => {
|
|
|
+ // 1. 验证是否选择了题目
|
|
|
if (selectedQuestions.value.length === 0) {
|
|
|
ElMessage.warning('请至少选择一个题目');
|
|
|
return;
|
|
|
}
|
|
|
-console.log(selectedQuestions.value);
|
|
|
- // 将选中的题目转换为正确的数据结构后添加到chatQuestions列表中
|
|
|
- const formattedQuestions = selectedQuestions.value.map((question:any) => ({
|
|
|
- id: question.id || Date.now(), // 确保有唯一ID
|
|
|
- title: question.question || question.title,
|
|
|
- ability: question.ability || '未设置',
|
|
|
- content: question.content || question.question,
|
|
|
- target: question.target || '未设置',
|
|
|
- competency_tags: question.competency_tags || [],
|
|
|
- question_form_name: question.question_form_name,
|
|
|
- scoring_reference: question.scoring_reference,
|
|
|
- question_form: question.question_form,
|
|
|
- is_required_correct: question.is_required_correct,
|
|
|
- weight: 100, // 默认权重
|
|
|
- maxAnswers: 1, // 默认最多回答次数
|
|
|
- enable_follow_up:true,
|
|
|
- options: question.options || [],
|
|
|
- source: 'custom_selected' as const // 标识为自定义选择的题目
|
|
|
-
|
|
|
- }));
|
|
|
-
|
|
|
- chatQuestions.value.push(...formattedQuestions);
|
|
|
-
|
|
|
- // 关闭对话框并重置状态
|
|
|
- showQuestionSelectDialog.value = false;
|
|
|
- selectedQuestions.value = [];
|
|
|
- questionSearchKeyword.value = '';
|
|
|
-
|
|
|
-/* ElMessage.success(`已添加${selectedQuestions.value.length}个题目`); */
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 2. 获取选中题目的ID列表
|
|
|
+ const selectedQuestionIds = selectedQuestions.value.map(item => item.id);
|
|
|
+
|
|
|
+ // 3. 调用AddDocument接口进行绑定
|
|
|
+ await AddDocument({
|
|
|
+ position_id: route.query.id,
|
|
|
+ question_id: selectedQuestionIds,
|
|
|
+ duration: 60, // 默认时长
|
|
|
+ tenant_id: "1"
|
|
|
+ });
|
|
|
+
|
|
|
+ // 4. 将选中的题目添加到本地列表中
|
|
|
+ const formattedQuestions = selectedQuestions.value.map((question: any) => ({
|
|
|
+ id: question.id,
|
|
|
+ title: question.question || question.title,
|
|
|
+ ability: question.ability || '未设置',
|
|
|
+ content: question.content || question.question,
|
|
|
+ target: question.target || '未设置',
|
|
|
+ competency_tags: question.competency_tags || [],
|
|
|
+ question_form_name: question.question_form_name,
|
|
|
+ scoring_reference: question.scoring_reference,
|
|
|
+ question_form: question.question_form,
|
|
|
+ is_required_correct: question.is_required_correct,
|
|
|
+ weight: 100,
|
|
|
+ maxAnswers: 1,
|
|
|
+ enable_follow_up: true,
|
|
|
+ options: question.options || [],
|
|
|
+ source: 'custom_selected' as const
|
|
|
+ }));
|
|
|
+
|
|
|
+ chatQuestions.value.push(...formattedQuestions);
|
|
|
+
|
|
|
+ // 5. 关闭对话框并重置状态
|
|
|
+ showQuestionSelectDialog.value = false;
|
|
|
+ selectedQuestions.value = [];
|
|
|
+ questionSearchKeyword.value = '';
|
|
|
+
|
|
|
+ // 6. 显示成功提示
|
|
|
+ ElMessage.success('题目添加成功');
|
|
|
+
|
|
|
+ } catch (error: any) {
|
|
|
+ console.error('添加题目失败:', error);
|
|
|
+ showQuestionSelectDialog.value = false;
|
|
|
+ if (error.code === 4000) {
|
|
|
+ ElMessage.warning('该题目已绑定,请选择其他题目');
|
|
|
+ } else {
|
|
|
+ ElMessage.error('添加题目失败,请重试');
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
// 字段配置数据
|
|
@@ -6526,6 +6567,110 @@ const getTreeData = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+/* 得分题 */
|
|
|
+const treeData = ref([]);
|
|
|
+const defaultProps = {
|
|
|
+ children: 'children',
|
|
|
+ label: 'title'
|
|
|
+}
|
|
|
+const handleNodeClick = async (data: any) => {
|
|
|
+ try {
|
|
|
+ // 如果点击的是分类节点(没有 tag_ 前缀的 id)
|
|
|
+ if (data.id.startsWith('category_')) {
|
|
|
+ const categoryId = data.id.replace('category_', '');
|
|
|
+ const response = await GetQuestionList({
|
|
|
+ page: 1,
|
|
|
+ limit: 1000, // 设置较大的限制以获取所有题目
|
|
|
+ question_category: categoryId,
|
|
|
+ question_form: questionListQuery.question_form
|
|
|
+ });
|
|
|
+
|
|
|
+ if (response && response.data) {
|
|
|
+ // 更新题目列表显示
|
|
|
+ questionList.value = response.data.items;
|
|
|
+ questionListpage.page = response.data.page;
|
|
|
+ questionListpage.pageSize = response.data.limit;
|
|
|
+ totalQuestions2.value = response.data.total;
|
|
|
+
|
|
|
+ // 自动选中所有题目
|
|
|
+ const table = document.querySelector('.el-table__header-wrapper');
|
|
|
+ if (table) {
|
|
|
+ const checkAll = table.querySelector('.el-checkbox');
|
|
|
+ if (checkAll) {
|
|
|
+ (checkAll as any).__vueParentComponent.emit('change', true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新选中的题目列表
|
|
|
+ selectedQuestions.value = response.data.items;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果点击的是标签节点
|
|
|
+ else if (data.id.startsWith('tag_')) {
|
|
|
+ const tagId = data.id.replace('tag_', '');
|
|
|
+ const response = await GetQuestionList({
|
|
|
+ page: 1,
|
|
|
+ limit: 1000,
|
|
|
+ question_tags: tagId,
|
|
|
+ question_form: questionListQuery.question_form
|
|
|
+ });
|
|
|
+
|
|
|
+ if (response && response.data) {
|
|
|
+ // 更新题目列表显示
|
|
|
+ questionList.value = response.data.items;
|
|
|
+ questionListpage.page = response.data.page;
|
|
|
+ questionListpage.pageSize = response.data.limit;
|
|
|
+ totalQuestions2.value = response.data.total;
|
|
|
+
|
|
|
+ // 自动选中所有题目
|
|
|
+ const table = document.querySelector('.el-table__header-wrapper');
|
|
|
+ if (table) {
|
|
|
+ const checkAll = table.querySelector('.el-checkbox');
|
|
|
+ if (checkAll) {
|
|
|
+ (checkAll as any).__vueParentComponent.emit('change', true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新选中的题目列表
|
|
|
+ selectedQuestions.value = response.data.items;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取题目列表失败:', error);
|
|
|
+ ElMessage.error('获取题目列表失败');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const getDFTreeData = () => {
|
|
|
+ GetDocumentTree({}).then((ret: any) => {
|
|
|
+ console.log('ret', ret);
|
|
|
+ const responseData = ret.data;
|
|
|
+ GetCategoryList({}).then((res: any) => {
|
|
|
+ console.log('res', res);
|
|
|
+ const categoryList = res.data.items.filter((item: any) =>
|
|
|
+ !['技术能力', '服务意识', '职业素质','基本常识','色盲检测','内容铺垫','红线题','健康情况','综合素质题'].includes(item.name)
|
|
|
+ );
|
|
|
+ GetTagList({}).then((res: any) => {
|
|
|
+ console.log('res', res);
|
|
|
+ const tagList = res.data.items;
|
|
|
+
|
|
|
+ // 创建根节点
|
|
|
+ const rootNode = [
|
|
|
+ ...categoryList.map((item: any) => ({
|
|
|
+ id: `category_${item.id}`,
|
|
|
+ title: item.name,
|
|
|
+ children: tagList.filter((tag: any) => tag.category_id === item.id).map((tag: any) => ({
|
|
|
+ id: `tag_${tag.id}`,
|
|
|
+ title: tag.name,
|
|
|
+ chinese_explanation: tag.chinese_explanation || ''
|
|
|
+ }))
|
|
|
+ }))
|
|
|
+ ];
|
|
|
+ treeData.value = rootNode;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|