|
@@ -547,33 +547,39 @@
|
|
|
|
|
|
// 构建提交数据
|
|
|
let answerContent = '';
|
|
|
+ let answerOptions = [];
|
|
|
|
|
|
if (this.currentAnswer.questionType === 0) {
|
|
|
// 开放题直接使用文本答案
|
|
|
answerContent = this.currentAnswer.answer;
|
|
|
+ answerOptions = []; // 开放题没有选项
|
|
|
} else if (this.currentAnswer.questionType === 1 || this.currentAnswer.questionType === 3) {
|
|
|
// 单选题或看图答题,获取选项ID而不是索引
|
|
|
const selectedIndex = this.currentAnswer.answer;
|
|
|
const selectedOption = this.currentQuestion.options[selectedIndex];
|
|
|
- console.log('selectedOption',selectedOption);
|
|
|
+ console.log('selectedOption', selectedOption);
|
|
|
// 使用选项的ID或其他唯一标识符
|
|
|
- answerContent = selectedOption.id ? selectedOption.id.toString() : selectedIndex.toString();
|
|
|
+ const optionId = selectedOption.id ? selectedOption.id : selectedIndex;
|
|
|
+ answerContent = optionId.toString();
|
|
|
+ answerOptions = [optionId]; // 单选题,将选项ID放入数组
|
|
|
} else if (this.currentAnswer.questionType === 2) {
|
|
|
- // 多选题,将选项ID数组转为逗号分隔的字符串
|
|
|
+ // 多选题,将选项ID数组转为数组格式
|
|
|
const selectedIndices = this.currentAnswer.answer;
|
|
|
const selectedOptionIds = selectedIndices.map(index => {
|
|
|
const option = this.currentQuestion.options[index];
|
|
|
// 使用选项的ID或其他唯一标识符
|
|
|
return option.id ? option.id : index;
|
|
|
});
|
|
|
- answerContent = selectedOptionIds.join(',');
|
|
|
+ answerContent = selectedOptionIds.join(','); // 保持原有的逗号分隔字符串格式
|
|
|
+ answerOptions = selectedOptionIds; // 多选题,直接使用选项ID数组
|
|
|
}
|
|
|
|
|
|
const submitData = {
|
|
|
job_id: JSON.parse(uni.getStorageSync('selectedJob')).id,
|
|
|
applicant_id: JSON.parse(uni.getStorageSync('userInfo')).id,
|
|
|
- question_id: this.currentAnswer.questionId,
|
|
|
- answer_content: answerContent,
|
|
|
+ job_position_question_id: this.currentAnswer.questionId,
|
|
|
+ // answer_content: answerContent,
|
|
|
+ answer_options: answerOptions, // 使用数组格式
|
|
|
answer_duration: this.currentAnswer.answerDuration || 0,
|
|
|
tenant_id: 1
|
|
|
};
|