|
@@ -1445,19 +1445,27 @@ import { ElMessage, ElMessageBox, ElDrawer } from 'element-plus';
|
|
|
import * as api from '../list/api';
|
|
|
import { Plus, Document, ArrowDown, Edit, Delete, InfoFilled, QuestionFilled, Search, Rank } from '@element-plus/icons-vue';
|
|
|
import { GetList } from '../../questionBank/classList/api';
|
|
|
-import { GetCompetencyList,GetQuestionList,GenerateQuestions,GetDraftList,SaveDraft,GetDigitalList,CreateConfig,GetConfig,UpdateConfig } from './api';
|
|
|
+import { GetCompetencyList,GetQuestionList,GenerateQuestions,
|
|
|
+ GetDraftList,SaveDraft,GetDigitalList,
|
|
|
+ CreateConfig,GetConfig,UpdateConfig,AddDocument } from './api';
|
|
|
import draggable from 'vuedraggable';
|
|
|
import { updateFieldConfig } from './utils';
|
|
|
import type { ProfileFieldsConfig } from './types';
|
|
|
|
|
|
// 添加 ChatQuestion 接口定义
|
|
|
interface ChatQuestion {
|
|
|
+ id?: number;
|
|
|
title: string;
|
|
|
ability: string;
|
|
|
content: string;
|
|
|
target: string;
|
|
|
weight: number;
|
|
|
maxAnswers: number;
|
|
|
+ source: 'ai_generated' | 'custom_selected'; // 添加题目来源标识
|
|
|
+ question_form?: number;
|
|
|
+ question_form_name?: string;
|
|
|
+ scoring_reference?: string;
|
|
|
+ competency_tags?: any[];
|
|
|
}
|
|
|
|
|
|
// 添加 Paper 接口定义
|
|
@@ -1988,6 +1996,12 @@ const nextStep = async () => {
|
|
|
if (currentStep.value < 3) {
|
|
|
// 如果从第一步进入第二步,更新已选维度到 selectedAbilities
|
|
|
if (currentStep.value === 1) {
|
|
|
+ // 校验是否选择了胜任力标签
|
|
|
+ if (selectedDimensions.value.length === 0) {
|
|
|
+ ElMessage.warning('请至少选择一个胜任力考核维度');
|
|
|
+ return; // 阻止进入下一步
|
|
|
+ }
|
|
|
+
|
|
|
selectedAbilities.value = selectedDimensions.value.map(dimension => ({
|
|
|
label: dimension.name,
|
|
|
value: dimension.name.toLowerCase().replace(/\s+/g, '_'),
|
|
@@ -1997,16 +2011,20 @@ const nextStep = async () => {
|
|
|
isNew: true
|
|
|
}));
|
|
|
}
|
|
|
- // 如果从第二步进入第三步,调用SaveDraft接口保存暂存题目
|
|
|
+ // 如果从第二步进入第三步,分别处理AI生成和自定义选择的题目
|
|
|
if (currentStep.value === 2) {
|
|
|
- try{
|
|
|
- // 调用SaveDraft接口保存暂存题目
|
|
|
- await SaveDraft({
|
|
|
- draft_ids: chatQuestions.value.map((draft: any) => draft.id)
|
|
|
- });
|
|
|
+ // 校验是否选择了面试题目
|
|
|
+ if (chatQuestions.value.length === 0) {
|
|
|
+ ElMessage.warning('请至少添加一个面试题目');
|
|
|
+ return; // 阻止进入下一步
|
|
|
+ }
|
|
|
+
|
|
|
+ try{
|
|
|
+ // 分别处理AI生成的题目和自定义选择的题目
|
|
|
+ await handleQuestionsSeparately();
|
|
|
} catch (error) {
|
|
|
- console.error('保存暂存题目失败:', error);
|
|
|
- ElMessage.error('保存暂存题目失败');
|
|
|
+ console.error('保存题目失败:', error);
|
|
|
+ ElMessage.error('保存题目失败');
|
|
|
return; // 如果保存失败,不进入下一步
|
|
|
}
|
|
|
}
|
|
@@ -2040,6 +2058,12 @@ const prevStep = () => {
|
|
|
|
|
|
// 完成配置
|
|
|
const finishConfig = async () => {
|
|
|
+ // 验证是否选择了面试官
|
|
|
+ if (!selectedInterviewer.value || !selectedInterviewer.value.id) {
|
|
|
+ ElMessage.warning('请选择面试官形象');
|
|
|
+ return; // 阻止继续执行保存操作
|
|
|
+ }
|
|
|
+
|
|
|
// 获取选中的面试官信息
|
|
|
const selectedInterviewerInfo = {
|
|
|
id: selectedInterviewer.value.id,
|
|
@@ -2049,11 +2073,31 @@ const finishConfig = async () => {
|
|
|
|
|
|
// 获取面试设置选项
|
|
|
const interviewSettings = getInterviewSettings();
|
|
|
+ if(getConfigId.value==0){
|
|
|
const response = await CreateConfig({
|
|
|
position_id:route.query.id,
|
|
|
- digital_human_id:selectedInterviewer.value.id,
|
|
|
- })
|
|
|
- console.log(response);
|
|
|
+ digital_human_id:selectedInterviewer.value.id,
|
|
|
+ })
|
|
|
+ if(response.code==2000){
|
|
|
+ ElMessage.success('配置保存成功');
|
|
|
+ showAIVideoDialog.value = false;
|
|
|
+ currentStep.value = 1;
|
|
|
+ }else{
|
|
|
+ ElMessage.error('配置保存失败');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ const response = await UpdateConfig({
|
|
|
+ id:getConfigId.value,
|
|
|
+ digital_human_id:selectedInterviewer.value.id,
|
|
|
+ })
|
|
|
+ if(response.code==2000){
|
|
|
+ ElMessage.success('配置保存成功');
|
|
|
+ showAIVideoDialog.value = false;
|
|
|
+ currentStep.value = 1;
|
|
|
+ }else{
|
|
|
+ ElMessage.error('配置保存失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
console.log('保存时选中的面试官:', selectedInterviewerInfo);
|
|
|
console.log('保存时的面试设置:', interviewSettings);
|
|
|
|
|
@@ -2093,9 +2137,9 @@ const cancelAIVideoConfig = () => {
|
|
|
// 跳转到指定步骤
|
|
|
const jumpToStep = (step: number) => {
|
|
|
// 确保步骤在有效范围内
|
|
|
- if (step >= 1 && step <= 3) {
|
|
|
+/* if (step >= 1 && step <= 3) {
|
|
|
currentStep.value = step;
|
|
|
- }
|
|
|
+ } */
|
|
|
};
|
|
|
|
|
|
// 显示视频宣讲配置弹窗
|
|
@@ -2193,12 +2237,14 @@ const confirmAddQuestion = () => {
|
|
|
|
|
|
// 创建新问题对象
|
|
|
const newQuestion = {
|
|
|
+ id: Date.now(), // 添加唯一ID
|
|
|
title: questionForm.title,
|
|
|
ability: questionForm.ability,
|
|
|
content: questionForm.content,
|
|
|
target: questionForm.target,
|
|
|
weight: questionForm.weight,
|
|
|
- maxAnswers: questionForm.maxAnswers
|
|
|
+ maxAnswers: questionForm.maxAnswers,
|
|
|
+ source: 'custom_selected' as const // 标识为自定义题目
|
|
|
};
|
|
|
|
|
|
// 添加到问题列表
|
|
@@ -2833,6 +2879,10 @@ const editAIVideo = async (step: AIVideoStep) => {
|
|
|
}
|
|
|
|
|
|
if (step.name === 'AI视频') {
|
|
|
+ const response = await GetConfig(route.query.id);
|
|
|
+ if (response && response.data) {
|
|
|
+ getConfigId.value=response.data.id;
|
|
|
+ }
|
|
|
currentEditingStep.value = step;
|
|
|
showAIVideoDialog.value = true;
|
|
|
currentStep.value = 1;
|
|
@@ -2934,6 +2984,48 @@ const handleInterviewerSelect = (avatar: any) => {
|
|
|
ElMessage.success(`已选择面试官:${avatar.name}`);
|
|
|
};
|
|
|
|
|
|
+// 分别处理AI生成的题目和自定义选择的题目
|
|
|
+const handleQuestionsSeparately = async () => {
|
|
|
+ // 分离AI生成的题目和自定义选择的题目
|
|
|
+ const aiGeneratedQuestions = chatQuestions.value.filter(q => q.source === 'ai_generated');
|
|
|
+ const customSelectedQuestions = chatQuestions.value.filter(q => q.source === 'custom_selected');
|
|
|
+
|
|
|
+ console.log('AI生成的题目:', aiGeneratedQuestions);
|
|
|
+ console.log('自定义选择的题目:', customSelectedQuestions);
|
|
|
+
|
|
|
+ // 处理AI生成的题目 - 调用SaveDraft接口
|
|
|
+ if (aiGeneratedQuestions.length > 0) {
|
|
|
+ await SaveDraft({
|
|
|
+ draft_ids: aiGeneratedQuestions.map((draft: any) => draft.id)
|
|
|
+ });
|
|
|
+ console.log('AI生成的题目已保存到草稿');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理自定义选择的题目 - 调用其他接口(这里需要根据实际需求调整)
|
|
|
+ if (customSelectedQuestions.length > 0) {
|
|
|
+ // 构建API请求数据 - 修改为符合API期望的格式
|
|
|
+ const requestData = {
|
|
|
+ position_id: route.query.id,
|
|
|
+ question_id: {
|
|
|
+ question_id: customSelectedQuestions
|
|
|
+ },
|
|
|
+ duration:60,
|
|
|
+ tenant_id: 1
|
|
|
+ };
|
|
|
+ // 这里可以调用专门处理自定义题目的接口
|
|
|
+ // 例如:await SaveCustomQuestions({ question_ids: customSelectedQuestions.map(q => q.id) });
|
|
|
+ console.log('自定义选择的题目需要调用专门的接口处理');
|
|
|
+
|
|
|
+ // 临时处理:也使用SaveDraft接口,但可以在后端根据source字段区分处理
|
|
|
+ const response = await AddDocument(requestData);
|
|
|
+ if (response && response.code === 2000) {
|
|
|
+ ElMessage.success('自定义选择的题目已保存');
|
|
|
+ }else{
|
|
|
+ ElMessage.error('自定义选择的题目保存失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
// 获取面试设置选项的函数
|
|
|
const getInterviewSettings = () => {
|
|
|
const interviewSettings = {
|
|
@@ -3118,7 +3210,8 @@ console.log(selectedQuestions.value);
|
|
|
scoring_reference: question.scoring_reference,
|
|
|
question_form: question.question_form,
|
|
|
weight: 100, // 默认权重
|
|
|
- maxAnswers: 1 // 默认最多回答次数
|
|
|
+ maxAnswers: 1, // 默认最多回答次数
|
|
|
+ source: 'custom_selected' as const // 标识为自定义选择的题目
|
|
|
}));
|
|
|
|
|
|
chatQuestions.value.push(...formattedQuestions);
|
|
@@ -3178,7 +3271,8 @@ console.log(draftResponse);
|
|
|
scoring_reference: question.scoring_reference,
|
|
|
question_form: question.question_form,
|
|
|
weight: 100,
|
|
|
- maxAnswers: 1
|
|
|
+ maxAnswers: 1,
|
|
|
+ source: 'ai_generated' as const // 标识为AI生成的题目
|
|
|
}));
|
|
|
|
|
|
// 清空现有题目并添加新生成的题目
|