This commit is contained in:
fan 2020-05-27 14:57:34 +08:00
commit 6a1215621d
11 changed files with 278 additions and 232 deletions

View File

@ -27,27 +27,9 @@ export function deleteQuestion(questionId) {
}
// 更新题目
export function updateQuestion(questionId, data) {
export function updateOption(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}`,
url: `/api/questionBank/questions/${data.id}`,
method: 'put',
data
});
@ -61,10 +43,3 @@ export function getQuestionInfo(questionId) {
});
}
// 根据题目查询选项
export function getOptionsByQuestionId(questionId) {
return request({
url: `/api/questionBank/questions/${questionId}/options`,
method: 'get'
});
}

View File

@ -1,70 +0,0 @@
<template>
<el-dialog v-dialogDrag :close-on-click-moda="false" :title="title" :visible.sync="show" width="40%" :close-on-click-modal="false" :before-close="doClose">
<div class="ql-editor notes" v-html="$escapeHTML(`${formParam.topic}`)" />
<item-answer v-model="formParam.answer" :option-list="optionList" :type="formParam.type" @change="onAnswerChnage" />
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doUpdate"> </el-button>
<el-button @click="show = false"> </el-button>
</span>
</el-dialog>
</template>
<script>
import ItemAnswer from './item-answer';
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();
}
}
};
</script>
<style lang="scss" scoped>
.notes {
padding: 0 0 20px 0;
color: #6666;
}
</style>

View File

@ -1,42 +0,0 @@
<template>
<el-dialog v-dialogDrag :close-on-click-moda="false" :title="title" :visible.sync="show" width="40%" :close-on-click-modal="false" :before-close="doClose">
<quill-editor v-model="content" placeholder="请输入内容" />
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doInput"> </el-button>
<el-button @click="show = false"> </el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data() {
return {
show: false,
content: '',
formParam: null
};
},
computed: {
title() {
return '更新题目';
}
},
methods: {
doShow({index, row}) {
this.formParam = row;
this.content = row.topic;
this.show = true;
},
doClose(done) {
this.show = false;
},
doInput() {
this.formParam.topic = this.content;
this.$emit('updateQuestion', this.formParam);
this.doClose();
}
}
};
</script>

View File

@ -1,23 +1,17 @@
<template>
<div>
<query-list-page ref="user" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<dialog-update-question ref="question" @updateQuestion="updateQuestion" />
<dialog-update-answer ref="answer" @updateAnswer="updateAnswer" />
<dialog-detail ref="detail" />
</div>
</template>
<script>
import { UrlConfig } from '@/scripts/ConstDic';
import { listQuestionPage, deleteQuestion, updateQuestion, updateAnswer } from '@/api/questionBank.js';
import DialogUpdateQuestion from './dialog-update-question';
import DialogUpdateAnswer from './dialog-update-answer';
import { listQuestionPage, deleteQuestion } from '@/api/questionBank.js';
import DialogDetail from './dialog-detail';
export default {
components: {
DialogUpdateQuestion,
DialogUpdateAnswer,
DialogDetail
},
data() {
@ -72,11 +66,6 @@ export default {
return '';
}
},
{
title: '分值',
prop: 'score',
width: '100'
},
// {
// title: '',
// prop: 'createUserName',
@ -88,22 +77,8 @@ export default {
width: '420',
buttons: [
{
name: '更新题目',
handleClick: this.doUpdateQuestion,
// showControl: (row) => { return row.createUserId == this.userId; },
type: 'success'
},
{
name: '更新选项',
handleClick: this.doupdateAnswers,
// showControl: (row) => { return row.createUserId == this.userId && row.type != 'judge'; },
type: 'success'
},
{
name: '更新答案',
handleClick: this.doUpdateAnswer,
// showControl: (row) => { return row.createUserId == this.userId; },
type: 'success'
name: '编辑',
handleClick: this.edit
},
{
name: '删 除',
@ -114,7 +89,6 @@ export default {
{
name: '预 览',
handleClick: this.doDetail
// showControl: (row) => { return row.createUserId != this.userId; }
}
]
}
@ -135,18 +109,10 @@ export default {
this.$router.push({path: `${UrlConfig.bank.questionCreate}`});
},
doUpdateQuestion(index, row) {
this.$refs.question.doShow({index, row});
},
doupdateAnswers(index, row) {
edit(index, row) {
this.$router.push({path: `${UrlConfig.bank.questionUpdate}/${row.id}`});
},
doUpdateAnswer(index, row) {
this.$refs.answer.doShow({index, row});
},
doDelete(index, row) {
this.$confirm('删除试题,是否继续?', '提 示', {
confirmButtonText: '确 定',
@ -165,21 +131,6 @@ export default {
this.$refs.detail.doShow({index, row});
},
updateQuestion(form) {
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}`);
});
},
answerTags(row) {
const answer = [];
row.optionList.forEach((el, i) => {

View File

@ -32,7 +32,6 @@ export default {
topic: '',
type: 'select',
answer: 0,
score: '',
optionList: []
}
};

View File

@ -1,11 +1,8 @@
<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-select v-model="option.type" :disabled="update" placeholder="请选择试题类型" @change="onTypeChnage">
<el-option v-for="it in QuestionTypeList" :key="it.value" :label="it.label" :value="it.value" />
</el-select>
</el-form-item>
@ -36,10 +33,6 @@ export default {
ItemAnswer
},
props: {
disabled: {
type: Boolean,
default: false
},
option: {
type: Object,
required: true
@ -51,6 +44,10 @@ export default {
remove: {
type: Boolean,
default: false
},
update: {
type: Boolean,
default: false
}
},
data() {
@ -90,10 +87,6 @@ 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' }
],
@ -119,16 +112,6 @@ 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

@ -2,24 +2,25 @@
<div class="page">
<div class="page__container">
<el-card class="page__container-body">
<item-options :option-list="optionList" :type="formModel.type" @modify="doModify" />
<question-form ref="info" :option="formModel" :remove="true" :update="true" @modify="doModify" />
</el-card>
</div>
<div class="page__container-footer">
<el-button type="primary" :is-create="true" @click="update"> </el-button>
<el-button @click="back"> </el-button>
</div>
<dialog-modify-rich ref="rich" @update="update" />
<dialog-modify-rich ref="rich" />
</div>
</template>
<script>
import ItemOptions from './item-options';
import QuestionForm from './question-form.vue';
import DialogModifyRich from './dialog-modify-rich';
import { getQuestionInfo, getOptionsByQuestionId, updateOption } from '@/api/questionBank.js';
import { getQuestionInfo, updateOption } from '@/api/questionBank.js';
export default {
components: {
ItemOptions,
QuestionForm,
DialogModifyRich
},
data() {
@ -27,9 +28,9 @@ export default {
formModel: {
id: '',
topic: '',
type: '',
type: 'select',
answer: 0,
score: ''
optionList: []
},
optionList: []
};
@ -51,9 +52,7 @@ export default {
loadInitData() {
getQuestionInfo(this.questionId).then(resp => {
this.formModel = resp.data;
getOptionsByQuestionId(this.questionId).then(resp => {
this.optionList = resp.data;
});
this.formModel.answer = this.formModel.optionList.findIndex(ele => ele.correct);
});
},
doBack() {
@ -62,11 +61,16 @@ export default {
doModify(node) {
this.$refs.rich.doShow(node);
},
update(data) {
updateOption(data.id, data).then(resp => {
update() {
this.$refs.info.validate().then(valid => {
if (valid) {
updateOption(this.formModel).then(resp => {
this.doBack();
}).catch(error => {
this.$message.error(`更新选项失败: ${error.message}`);
this.$message.error(`创建试题失败: ${error.message}`);
});
}
}).catch(error => { this.$message.warning(error.message); });
},
back() {
this.$router.go(-1);

View File

@ -133,8 +133,14 @@ export default {
},
doRecord(index, row) {
// row.id
let raceInfo;
this.raceList.forEach(each=>{
if (each.id == row.raceId) {
raceInfo = each;
}
});
practiceRecordNotify(83).then(resp => {
const query = { mapId: row.mapId, group: resp.data, scriptId: row.id, lang:row.lang, lineCode:this.$route.query.lineCode};
const query = { mapId: raceInfo.mapId, group: resp.data, scriptId: row.id, lineCode:raceInfo.lineCode};
this.$router.push({ path: `${UrlConfig.practiceDisplayNew}/practice`, query });
launchFullscreen();
}).catch(error => {

View File

@ -52,6 +52,20 @@
<menu-script v-if="isScript" ref="menuScript" :offset-bottom="offsetBottom" :group="group" :data-error="dataError" />
<menu-practice
v-if="isPractice"
ref="menuPractice"
:group="group"
:offset="offset"
:offset-bottom="offsetBottom"
:show-station="showStation"
:station-list="stationList"
:show-select-station="showSelectStation"
:data-error="dataError"
@switchMode="switchMode"
@switchStationMode="switchStationMode"
/>
<menu-train-list v-if="isDemon" @setCenter="setCenter" />
<menu-schema
@ -96,6 +110,7 @@ import MenuDemon from '@/views/newMap/displayNew/menuDemon';
import MenuSchema from '@/views/newMap/displayNew/menuSchema';
import MenuSystemTime from '@/views/newMap/displayNew/menuSystemTime';
import MenuScript from '@/views/newMap/displayNew/menuScript';
import MenuPractice from '@/views/newMap/displayNew/menuPractice';
import Scheduling from './demon/scheduling';
import { mapGetters } from 'vuex';
import { getTrainingStepsDetailNew, getTrainingDetailNew } from '@/api/jmap/training';
@ -128,6 +143,7 @@ export default {
MenuSchema,
MenuSystemTime,
MenuTrainList,
MenuPractice,
// Jl3dSimulation,
Jl3dDrive,
Jl3dDevice,
@ -223,6 +239,9 @@ export default {
isScript() {
return this.mode === 'script';
},
isPractice() {
return this.mode === 'practice';
},
isScreen() {
return this.model === 'dp';
},
@ -426,6 +445,8 @@ export default {
await this.initLoadDemonData();
} else if (this.isScript) {
await this.initLoadTaskData();
} else if (this.isPractice) {
await this.initPracticeData();
} else {
await this.initLoadLessonOrExamData();
}
@ -481,6 +502,18 @@ export default {
this.endViewLoading();
}
},
//
async initPracticeData() {
this.$store.dispatch('training/end', TrainingMode.NORMAL);
this.$store.dispatch('training/changeOperateMode', { mode: OperateMode.NORMAL }); //
this.switchMode('01');
if (parseInt(this.mapId)) {
await this.loadNewMapDataByGroup(this.group);
} else {
this.endViewLoading();
}
},
//
async selectQuest(row, id, mapLocation, roleName) {
try {

View File

@ -0,0 +1,206 @@
<template>
<div class="menuPractice">
<div class="practice-schema" :style="{top: offset+'px'}">
<el-select v-model="swch" size="small" :placeholder="$t('display.schema.selectProduct')" @change="switchMode">
<el-option v-for="item in swchList" :key="item.value" :label="item.name" :value="item.value" />
</el-select>
<el-select v-if="showSelectStation&&swch=='01'" v-model="showStationContent" style="width: 100px;" size="small" @change="switchStationModeInfo">
<el-option v-for="item in stationList" :key="item.value" :label="item.name" :value="item.value" />
</el-select>
</div>
<div class="practice-bottom" :style="{bottom: offsetBottom + 'px'}">
<el-button-group>
<!-- v-if="!isScriptCommand" -->
<!-- v-if="!isScriptCommand" -->
<el-button type="success" :disabled="isDisable || dataError" @click="selectBeginTime">按计划行车</el-button>
<el-button type="danger" :disabled="!isDisable" @click="end">退出计划</el-button>
<el-button type="primary" @click="back">返回</el-button>
</el-button-group>
</div>
<set-time ref="setTime" @ConfirmSelectBeginTime="start" />
</div>
</template>
<script>
import SetTime from '@/views/newMap/displayNew/demon/setTime';
import { ranAsPlan, exitRunPlan } from '@/api/simulation';
import { Notification } from 'element-ui';
export default {
name: 'MenuPractice',
components:{
SetTime
},
props: {
group: {
type: String,
required: true
},
offset: {
type: Number,
required: true
},
offsetBottom: {
type: Number,
required: true
},
dataError: {
type: Boolean,
default() {
return false;
}
},
showSelectStation: {
type: Boolean,
default() {
return false;
}
},
showStation: {
type: String,
default() {
return '';
}
},
stationList: {
type: Array,
default() {
return [];
}
}
},
data() {
return {
isDisable: false,
swch: '01',
showStationContent:'',
swchList: [
{ value: '01', name: '现地' },
{ value: '02', name: '行调' }
]
};
},
watch:{
'showStation':function(val) {
this.showStationContent = this.showStation;
}
},
methods:{
back() {
this.$store.dispatch('training/over').then(() => {
history.go(-1);
Notification.closeAll();
});
},
selectBeginTime() {
this.$refs.setTime.doShow();
},
start(model) {
this.isDisable = true;
const data = {
time: model.initTime
// loadNumber:this.trainList.length
};
// const data = {
// time: model.initTime
// };
// if (this.$route.query.prdType === '04') {
// data.loadNumber = model.loadNum;
// }
ranAsPlan(data, this.group).then(res => {
this.$store.dispatch('training/simulationStart').then(() => {
this.$store.dispatch('map/setRunPlanStatus', true);
this.$store.dispatch('training/setInitTime', +new Date(`${new Date().toLocaleDateString()} ${model.initTime}`));
this.$store.dispatch('map/setShowCentralizedStationNum');
});
}).catch((error) => {
this.isDisable = false;
if (error.code == '5001') {
this.$messageBox(this.$t('error.mapDataError') + '' + this.$t('error.startSimulationFailed'));
} else if (error.code == '5002') {
this.$messageBox(this.$t('error.runningChartDataError') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '5003') {
this.$messageBox(this.$t('error.runningChartIsNotLoaded') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '5004') {
this.$messageBox(this.$t('error.runningDataError') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '5000') {
this.$messageBox(this.$t('error.systemError') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '4000') {
this.$messageBox(this.$t('error.simulationDoesNotExist') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '4001') {
this.$messageBox(this.$t('error.simulationOperationIsNotDefined') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '4002') {
this.$messageBox(this.$t('error.simulationOperationProcessingMethodNotFound') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '4003') {
this.$messageBox(this.$t('error.simulationOperationFailed') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '4004') {
this.$messageBox(this.$t('error.operationConflict') + ',' + this.$t('error.startSimulationFailed'));
}
});
},
switchMode(swch) {
this.$emit('switchMode', swch);
this.switchModeInner(swch);
},
switchModeInner(swch) {
let showMode = '03';
if (swch == '01') {
showMode = '03';
} else if (swch == '02') {
showMode = '02';
}
const nameList = Object.keys(this.$store.state.map.map || {});
let list = [];
nameList.forEach(item => {
if (item !== 'skinVO') {
const data = this.$store.state.map.map[item];
if (data && data.constructor === Array) {
list = [...list, ...data];
}
}
});
this.$jlmap.updateShowMode(list, showMode);
if (swch == '02') {
this.switchStationMode('');
} else {
this.switchStationMode(null);
}
},
switchStationModeInfo(val) {
this.showStationContent = val;
this.$emit('switchStationMode', val);
},
switchStationMode(val) {
this.$emit('switchStationMode', val);
},
end() {
this.isDisable = false;
exitRunPlan(this.group).then(() => {
this.$store.dispatch('training/over').then(() => {
this.$store.dispatch('training/setMapDefaultState').then(() => {
this.$store.dispatch('map/setRunPlanStatus', false);
this.$store.dispatch('map/clearJlmapTrainView');
this.$store.dispatch('map/setTrainWindowShow', false);
});
});
}).catch(() => {
this.isDisable = true;
this.$messageBox(this.$t('display.demon.endSimulationFail'));
});
}
}
};
</script>
<style lang="scss" scoped>
.practice-schema {
z-index: 9;
display: inline;
position: absolute;
right: 15px;
}
.practice-bottom {
position: absolute;
float: right;
right: 15px;
bottom: 15px;
}
</style>

View File

@ -48,6 +48,7 @@ export default {
this.$route.params.mode == 'dp' ||
this.$route.params.mode == 'plan' ||
this.$route.params.mode == 'script' ||
this.$route.params.mode == 'practice' ||
!this.$route.params.mode;
},
pause() {