|
|
|
@ -1,11 +1,14 @@ |
|
|
|
<!-- src/components/Question/QuestionSearch.vue --> |
|
|
|
<template> |
|
|
|
<div class="question-search-container"> |
|
|
|
<div class="top"> |
|
|
|
<h2>题库管理</h2> |
|
|
|
</div> |
|
|
|
<!-- 搜索区域容器 --> |
|
|
|
<div class="search-area"> |
|
|
|
<!-- 题目类型筛选项 --> |
|
|
|
<div class="search-item"> |
|
|
|
<label>题目类型</label> |
|
|
|
<h3>题目类型</h3> |
|
|
|
<select v-model="searchForm.questionType"> |
|
|
|
<option value="">全部</option> |
|
|
|
<option>股票知识</option> |
|
|
|
@ -15,13 +18,13 @@ |
|
|
|
|
|
|
|
<!-- 题干关键词搜索项 --> |
|
|
|
<div class="search-item"> |
|
|
|
<label>题干查找</label> |
|
|
|
<h3>题干查找</h3> |
|
|
|
<input type="text" placeholder="请输入题干关键词" v-model="searchForm.keyword" /> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 课程推荐筛选项 --> |
|
|
|
<div class="search-item"> |
|
|
|
<label>推荐系列</label> |
|
|
|
<h3>推荐系列</h3> |
|
|
|
<select v-model="searchForm.course"> |
|
|
|
<option value="">全部</option> |
|
|
|
<option>量能擒牛</option> |
|
|
|
@ -39,7 +42,7 @@ |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 新增题目弹窗 --> |
|
|
|
<div v-if="showAddModal" class="modal-overlay" @click.self="closeModal"> |
|
|
|
<div v-if="showAddModal" class="modal-overlay"> |
|
|
|
<div class="modal-content" @click.stop> |
|
|
|
<div class="modal-header"> |
|
|
|
<h3>新增题目</h3> |
|
|
|
@ -98,7 +101,6 @@ |
|
|
|
<div class="form-row"> |
|
|
|
<label>推荐系列</label> |
|
|
|
<select v-model="newQuestion.recommendedCourse"> |
|
|
|
<option value="">请选择</option> |
|
|
|
<option value="量能擒牛">量能擒牛</option> |
|
|
|
<option value="价格破译">价格破译</option> |
|
|
|
<option value="量价时空综合">量价时空综合</option> |
|
|
|
@ -137,7 +139,7 @@ export default { |
|
|
|
optionD: '', |
|
|
|
correctAnswer: 'A', |
|
|
|
questionTypeName: '股票知识', |
|
|
|
recommendedCourse: '' |
|
|
|
recommendedCourse: '量能擒牛' |
|
|
|
}, |
|
|
|
currentPage: 1, // 当前页码 |
|
|
|
total: 0 // 总记录数 |
|
|
|
@ -192,7 +194,7 @@ export default { |
|
|
|
const list = response.data.data.list || []; |
|
|
|
|
|
|
|
const totalRaw = response.data.data.total; |
|
|
|
const total = Number.isFinite(Number(totalRaw)) ? Number(totalRaw) : 0; |
|
|
|
const total = Number.isFinite(Number(totalRaw)) ? Number(totalRaw) : 1; |
|
|
|
|
|
|
|
const resultData = { list, total }; |
|
|
|
|
|
|
|
@ -210,7 +212,7 @@ export default { |
|
|
|
async addQuestion() { |
|
|
|
// 表单验证 |
|
|
|
if (!this.newQuestion.stem || !this.newQuestion.optionA || !this.newQuestion.optionB || |
|
|
|
!this.newQuestion.optionC || !this.newQuestion.optionD || !this.newQuestion.correctAnswer) { |
|
|
|
!this.newQuestion.optionC || !this.newQuestion.optionD || !this.newQuestion.correctAnswer || !this.newQuestion.recommendedCourse) { |
|
|
|
alert('请填写所有必填项!'); |
|
|
|
return; |
|
|
|
} |
|
|
|
@ -228,8 +230,7 @@ export default { |
|
|
|
params.append('question_type_id', this.newQuestion.questionTypeName === '股票知识' ? 1 : 2); |
|
|
|
params.append('course_recommendation_id', |
|
|
|
this.newQuestion.recommendedCourse === '量能擒牛' ? 1 : |
|
|
|
this.newQuestion.recommendedCourse === '价格破译' ? 2 : |
|
|
|
this.newQuestion.recommendedCourse === '量价时空综合' ? 3 : ''); |
|
|
|
this.newQuestion.recommendedCourse === '价格破译' ? 2 : 3 ); |
|
|
|
|
|
|
|
// 发送请求 |
|
|
|
// const response = await axios.post('/admin/questions/update', params, { |
|
|
|
@ -267,7 +268,39 @@ export default { |
|
|
|
|
|
|
|
async exportExcel() { |
|
|
|
try{ |
|
|
|
const response = await axios.post('http://192.168.40.41:8000/admin/questions/export',{},{responseType: 'blob'}); |
|
|
|
// 构造包含筛选条件的导出参数 |
|
|
|
const exportParams = {}; |
|
|
|
|
|
|
|
// 添加题目类型筛选条件 |
|
|
|
const questionTypeIdMap = { |
|
|
|
'股票知识': 1, |
|
|
|
'企业文化': 2 |
|
|
|
}; |
|
|
|
if (this.searchForm.questionType) { |
|
|
|
exportParams.question_type_id = questionTypeIdMap[this.searchForm.questionType]; |
|
|
|
} |
|
|
|
|
|
|
|
// 添加推荐系列筛选条件 |
|
|
|
const courseRecommendationIdMap = { |
|
|
|
'量能擒牛': 1, |
|
|
|
'价格破译': 2, |
|
|
|
'量价时空综合': 3 |
|
|
|
}; |
|
|
|
if (this.searchForm.course) { |
|
|
|
exportParams.course_recommendation_id = courseRecommendationIdMap[this.searchForm.course]; |
|
|
|
} |
|
|
|
|
|
|
|
// 添加题干关键词筛选条件 |
|
|
|
if (this.searchForm.keyword) { |
|
|
|
exportParams.stem = this.searchForm.keyword; |
|
|
|
} |
|
|
|
|
|
|
|
// 发送导出请求,包含筛选条件 |
|
|
|
const response = await axios.post( |
|
|
|
'http://192.168.40.41:8000/admin/questions/export', |
|
|
|
exportParams, |
|
|
|
{ responseType: 'blob' } |
|
|
|
); |
|
|
|
const url = window.URL.createObjectURL(new Blob([response.data])); |
|
|
|
const link = document.createElement('a'); |
|
|
|
link.href = url; |
|
|
|
@ -297,7 +330,7 @@ export default { |
|
|
|
optionD: '', |
|
|
|
correctAnswer: 'A', |
|
|
|
questionTypeName: '股票知识', |
|
|
|
recommendedCourse: '' |
|
|
|
recommendedCourse: '量能擒牛' |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -305,6 +338,9 @@ export default { |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|
.top{ |
|
|
|
padding: 20px 0px; |
|
|
|
} |
|
|
|
/* 弹窗样式 */ |
|
|
|
.modal-overlay { |
|
|
|
position: fixed; |
|
|
|
|