This commit is contained in:
joylink_cuiweidong 2020-05-26 18:28:34 +08:00
commit 0ada88bafc
9 changed files with 191 additions and 110 deletions

View File

@ -1,10 +1,70 @@
import request from '@/utils/request';
/** 推送通知消息*/
export function listQuestionPage(data) {
// 分页查询理论试题
export function listQuestionPage(params) {
return request({
// url: `/api/pushMessage`,
// method: 'post',
// data: data
url: `/api/questionBank/questions/paging`,
method: 'get',
params
});
}
// 创建题目
export function createQuestion(data) {
return request({
url: `/api/questionBank/questions`,
method: 'post',
data
});
}
// 删除题目
export function deleteQuestion(questionId) {
return request({
url: `/api/questionBank/questions/${questionId}`,
method: 'delete'
});
}
// 更新题目
export function updateQuestion(questionId, data) {
return request({
url: `/api/questionBank/questions/${questionId}`,
method: 'put',
data
});
}
// 更新正确选项
export function updateAnswer(questionId, data) {
return request({
url: `/api/questionBank/questions/${questionId}/answer`,
method: 'put',
data
});
}
// 更新选项
export function updateOption(optionId, data) {
return request({
url: `/api/questionBank/questions/options/${optionId}`,
method: 'put',
data
});
}
// 获取题目信息
export function getQuestionInfo(questionId) {
return request({
url: `/api/questionBank/questions/${questionId}`,
method: 'get'
});
}
// 根据题目查询选项
export function getOptionsByQuestionId(questionId) {
return request({
url: `/api/questionBank/questions/${questionId}/options`,
method: 'get'
});
}

View File

@ -2,11 +2,11 @@ export function getBaseUrl() {
let BASE_API;
if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪
// BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.41:9000'; // 张赛
// BASE_API = 'http://192.168.3.82:9000'; // 杜康
BASE_API = 'http://192.168.3.82:9000'; // 杜康
// BASE_API = 'http://b29z135112.zicp.vip';
// BASE_API = 'http://2925963m2a.zicp.vip'; // 杜康
// BASE_API = 'http://2i38984j47.qicp.vip'; // 张赛

View File

@ -31,37 +31,37 @@
<script>
export default {
data() {
return {
show: false,
form: {
optionList: []
}
};
},
computed: {
title() {
return '详 情';
},
options() {
return this.form.optionList;
}
},
methods: {
checkType(option, type) {
return option.type == type;
},
appendIndex(str, index) {
return `${index+1}. ${str}`;
},
doShow(node) {
this.form = node.row||{};
this.show = true;
},
doClose(done) {
this.show = false;
}
}
data() {
return {
show: false,
form: {
optionList: []
}
};
},
computed: {
title() {
return '详 情';
},
options() {
return this.form.optionList;
}
},
methods: {
checkType(option, type) {
return option.type == type;
},
appendIndex(str, index) {
return `${index + 1}. ${str}`;
},
doShow(node) {
this.form = node.row || {};
this.show = true;
},
doClose(done) {
this.show = false;
}
}
};
</script>
<style lang="scss" scoped>

View File

@ -11,54 +11,54 @@
<script>
import ItemAnswer from './item-answer';
import { getOptionsByQuestionId} from '@/api/questionBank.js';
import { getOptionsByQuestionId } from '@/api/questionBank.js';
export default {
components: {
ItemAnswer
},
data() {
return {
show: false,
content: '',
optionList: [],
formParam: {}
};
},
computed: {
title() {
return '更新答案';
}
},
methods: {
doShow({index, row}) {
this.formParam = row;
this.content = row.topic;
getOptionsByQuestionId(row.id).then(resp => {
this.optionList = resp.data;
this.optionList.forEach((el, i) => {
if (el.correct) {
this.formParam.answer = i;
}
});
});
this.show = true;
},
doClose(done) {
this.show = false;
},
onAnswerChnage(answer) {
this.optionList.forEach((el, i) => { el.correct = i == answer; });
},
doUpdate() {
const index = this.optionList.findIndex((el, i) => { return i == this.formParam.answer; });
if (index >= 0) {
const answer = this.optionList[index];
this.$emit('updateAnswer', {questionId: answer.questionId, id: answer.id, correct: answer.correct});
}
this.doClose();
}
}
components: {
ItemAnswer
},
data() {
return {
show: false,
content: '',
optionList: [],
formParam: {}
};
},
computed: {
title() {
return '更新答案';
}
},
methods: {
doShow({index, row}) {
this.formParam = row;
this.content = row.topic;
getOptionsByQuestionId(row.id).then(resp => {
this.optionList = resp.data;
this.optionList.forEach((el, i) => {
if (el.correct) {
this.formParam.answer = i;
}
});
});
this.show = true;
},
doClose(done) {
this.show = false;
},
onAnswerChnage(answer) {
this.optionList.forEach((el, i) => { el.correct = i == answer; });
},
doUpdate() {
const index = this.optionList.findIndex((el, i) => { return i == this.formParam.answer; });
if (index >= 0) {
const answer = this.optionList[index];
this.$emit('updateAnswer', {questionId: answer.questionId, id: answer.id, correct: answer.correct});
}
this.doClose();
}
}
};
</script>

View File

@ -9,7 +9,7 @@
<script>
import { UrlConfig } from '@/scripts/ConstDic';
import { listQuestionPage } from '@/api/questionBank.js';
import { listQuestionPage, deleteQuestion, updateQuestion, updateAnswer } from '@/api/questionBank.js';
import DialogUpdateQuestion from './dialog-update-question';
import DialogUpdateAnswer from './dialog-update-answer';
import DialogDetail from './dialog-detail';
@ -48,6 +48,10 @@ export default {
selectCheckShow: false,
indexShow: true,
columns: [
{
title: '题 目',
prop: 'topic'
},
{
title: '类 型',
prop: 'type',
@ -58,10 +62,6 @@ export default {
return '';
}
},
{
title: '题 目',
prop: 'topic'
},
{
title: '答 案',
prop: 'answer',
@ -72,6 +72,11 @@ export default {
return '';
}
},
{
title: '分值',
prop: 'score',
width: '100'
},
{
title: '创建人',
prop: 'createUserName',
@ -130,10 +135,6 @@ export default {
this.$router.push({path: `${UrlConfig.bank.questionCreate}`});
},
doUpdate(index, row) {
this.$router.push({path: `${UrlConfig.bank.questionModify}/${row.id}`});
},
doUpdateQuestion(index, row) {
this.$refs.question.doShow({index, row});
},
@ -152,11 +153,11 @@ export default {
cancelButtonText: '取 消',
type: 'warning'
}).then(() => {
// deleteQuestion(row.id).then(resp => {
// this.reloadTable();
// }).catch(error => {
// this.$message.error(`: ${error.message}`);
// });
deleteQuestion(row.id).then(resp => {
this.reloadTable();
}).catch(error => {
this.$message.error(`删除试题失败: ${error.message}`);
});
}).catch( () => { });
},
@ -165,20 +166,19 @@ export default {
},
updateQuestion(form) {
// updateQuestion(form.id, form).then(resp => {
// this.reloadTable();
// }).catch(error => {
// this.$message.error(`: ${error.message}`);
// });
updateQuestion(form.id, form).then(resp => {
this.reloadTable();
}).catch(error => {
this.$message.error(`修改问题失败: ${error.message}`);
});
},
updateAnswer(form) {
// updateAnswer(form.questionId, form).then(resp => {
// this.reloadTable();
// }).catch(error => {
// this.$message.error(`: ${error.message}`);
// });
updateAnswer(form.questionId, form).then(resp => {
this.reloadTable();
}).catch(error => {
this.$message.error(`修改答案失败: ${error.message}`);
});
},
answerTags(row) {
const answer = [];

View File

@ -32,6 +32,7 @@ export default {
topic: '',
type: 'select',
answer: 0,
score: '',
optionList: []
}
};
@ -61,6 +62,7 @@ export default {
create() {
this.$refs.info.validate().then(valid => {
if (valid) {
// console.log(this.formModel);
createQuestion(this.formModel).then(resp => {
authUtils.setSessionStorage(this.path, JSON.stringify({
type: this.formModel.type

View File

@ -1,6 +1,9 @@
<template>
<div>
<el-form ref="form" :model="option" :rules="rules" label-width="80px">
<el-form-item label="分 值" prop="score">
<el-input v-model="option.score" placeholder="请输入分值" style="width: 200px;" />
</el-form-item>
<el-form-item label="类 型" prop="type">
<el-select v-model="option.type" :disabled="disabled" placeholder="请选择试题类型" @change="onTypeChnage">
<el-option v-for="it in QuestionTypeList" :key="it.value" :label="it.label" :value="it.value" />
@ -87,6 +90,10 @@ export default {
topic: [
{ required: true, message: '请输入试题内容', trigger: 'blur' }
],
score: [
{ required: true, message: '请输入试题分值', trigger: 'blur' },
{ validator: this.validateScore, trigger: 'blur' }
],
type: [
{ required: true, message: '请输入试题类型', trigger: 'change' }
],
@ -112,6 +119,16 @@ export default {
this.option.optionList = this.templateMap[type]();
}
},
validateScore(rule, value, callback) {
if (Number(value) <= 0) {
callback(new Error('请输入正确的分值'));
} else if (Number(value)) {
this.option.score = Number(value);
callback();
} else {
callback(new Error('请输入数字'));
}
},
onAnswerChnage(answer) {
this.option.optionList.forEach((el, i) => { el.correct = i == answer; });
},

View File

@ -28,7 +28,8 @@ export default {
id: '',
topic: '',
type: '',
answer: 0
answer: 0,
score: ''
},
optionList: []
};

View File

@ -3,6 +3,7 @@
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<create-race ref="createRace" :map-list="mapList" @refresh="refresh" />
<input id="competition-manage-url" v-model="url" style="opacity: 0;">
<div id="bm" ref="bm" />
</div>
</template>