试卷考试添加倒计时,倒计时结束提交试卷&试卷规则调整

This commit is contained in:
fan 2023-05-20 16:10:54 +08:00
parent 2d1558b011
commit 516a3a4041
9 changed files with 434 additions and 336 deletions

View File

@ -269,12 +269,12 @@ export function generateExam(pcId) {
} }
/** 删除用户试卷 */ /** 删除用户试卷 */
export function deleteUserExam(param) { // export function deleteUserExam(param) {
return request({ // return request({
url: `/api/v2/paper/user/${puId}`, // url: `/api/v2/paper/user/${puId}`,
method: 'method' // method: 'DELETE'
}); // });
} // }
/** /**
* @param {Number} puId 用户试卷Id * @param {Number} puId 用户试卷Id

View File

@ -27,7 +27,7 @@ export function handlerUrl() {
// BASE_API = 'https://joylink.club/jlcloud'; // BASE_API = 'https://joylink.club/jlcloud';
// BASE_API = 'https://test.joylink.club/jlcloud'; // BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://114.116.51.125/jlcloud'; // BASE_API = 'http://114.116.51.125/jlcloud';
// BASE_API = 'http://192.168.3.90:9000'; // 周寅 BASE_API = 'http://192.168.3.47:9000'; // 周寅
// BASE_API = 'http://192.168.3.94:9000'; // 旭强 // BASE_API = 'http://192.168.3.94:9000'; // 旭强
// BASE_API = 'http://192.168.3.15:9000'; // 张赛 // BASE_API = 'http://192.168.3.15:9000'; // 张赛
// BASE_API = 'http://192.168.3.5:9000'; // 夏增彬 // BASE_API = 'http://192.168.3.5:9000'; // 夏增彬

View File

@ -3,6 +3,7 @@
<div class="header"> <div class="header">
<div>满分: {{ composition.fullScore }}</div> <div>满分: {{ composition.fullScore }}</div>
<div>考试时间: {{ composition.validDuration }}分钟</div> <div>考试时间: {{ composition.validDuration }}分钟</div>
<div>剩余时间{{ countdown }}</div>
</div> </div>
<!-- <div class="legend-area"> <!-- <div class="legend-area">
<div class="legend"> <div class="legend">
@ -82,11 +83,16 @@ export default {
questionStateList: [[], []], questionStateList: [[], []],
currentQuestionIndex: 0, currentQuestionIndex: 0,
currentQuestionType: 1, // 1-, 2- currentQuestionType: 1, // 1-, 2-
examSceneRuleMap: {} examSceneRuleMap: {},
examStartTime: 0,
serverStartTime: 0,
examInterval: null,
countdown: '00:00:00'
}; };
}, },
beforeDestroy() { beforeDestroy() {
this.$store.dispatch('trainingNew/setExamSwitch', false); this.$store.dispatch('trainingNew/setExamSwitch', false);
if (this.examInterval) { clearInterval(this.examInterval); }
}, },
mounted() { mounted() {
EventBus.$on('trainExamSubmit', (data) => { EventBus.$on('trainExamSubmit', (data) => {
@ -124,6 +130,36 @@ export default {
}); });
} }
}); });
this.serverStartTime = data.systemTime;
this.examStartTime = new Date().getTime();
let hours = Math.floor(this.composition.validDuration / 60);
let mins = this.composition.validDuration % 60;
if (hours < 10) { hours = '0' + hours; }
if (mins < 10) { mins = '0' + mins; }
this.countdown = `${hours}:${mins}:00`;
this.examInterval = setInterval(() => {
const nowTime = new Date().getTime();
const downTime = this.composition.validDuration * 60 * 1000 + this.examStartTime - nowTime;
if (downTime <= 0) {
clearInterval(this.examInterval);
this.countdown = '00:00:00';
this.$alert('考试时间已到,点击确定提交试卷', '提示', {
confirmButtonText: '确定',
showClose: false,
callback: () => {
this.execSubmit();
}
});
return;
}
let hours = Math.floor(downTime / (1000 * 60 * 60));
let mins = Math.floor((downTime - (hours * 100 * 60 * 60)) / (1000 * 60));
let seconds = Math.floor((downTime - (hours * 100 * 60 * 60) - (mins * 1000 * 60 )) / 1000);
if (hours < 10) { hours = '0' + hours; }
if (mins < 10) { mins = '0' + mins; }
if (seconds < 10) { seconds = '0' + seconds; }
this.countdown = `${hours}:${mins}:${seconds}`;
}, 1000);
this.paper = data.paper; this.paper = data.paper;
this.questionList = [ this.questionList = [
data.questionList.filter(e => e.type === 1), data.questionList.filter(e => e.type === 1),
@ -175,30 +211,34 @@ export default {
this.currentQuestionIndex--; this.currentQuestionIndex--;
} }
}, },
submitExam() { execSubmit() {
const execSubmit = () => { submitPaper(this.paper.id).then(resp => {
submitPaper(this.paper.id).then(resp => { const { score, passScore, commonScore, trainingScore } = resp.data;
const { score, passScore, commonScore, trainingScore } = resp.data; const pass = score >= passScore;
const pass = score >= passScore; this.$alert(
this.$alert( `${pass ? '恭喜您考试合格' : '考试不通过'}
`${pass ? '恭喜您考试合格' : '考试不通过'}
总分: ${score} 总分: ${score}
理论: ${commonScore} 理论: ${commonScore}
实训: ${trainingScore}`, 实训: ${trainingScore}`,
'考试结果' '考试结果'
).then(() => { ).then(() => {
this.show = false; this.show = false;
this.$store.dispatch('trainingNew/setExamSwitch', false); this.$store.dispatch('trainingNew/setExamSwitch', false);
});
}); });
}; });
},
submitExam() {
if (this.examInterval) {
clearInterval(this.examInterval);
this.countdown = '00:00:00';
}
const finished = this.questionStateList.every(list => list.every(item => item === true)); const finished = this.questionStateList.every(list => list.every(item => item === true));
if (!finished) { if (!finished) {
this.$confirm('您还有题目未答完, 确认交卷吗?').then(() => { this.$confirm('您还有题目未答完, 确认交卷吗?').then(() => {
execSubmit(); this.execSubmit();
}); });
} else { } else {
execSubmit(); this.execSubmit();
} }
} }
} }

View File

@ -81,7 +81,6 @@ export default {
mapId: this.$route.query.mapId, mapId: this.$route.query.mapId,
findState: 3 findState: 3
}).then(resp => { }).then(resp => {
console.log(resp);
this.paperList = resp.data.list; this.paperList = resp.data.list;
}); });
}, },

View File

@ -1,91 +1,102 @@
<template> <template>
<el-dialog <el-dialog
v-dialogDrag v-dialogDrag
:title="title" :title="title"
width="600px" width="600px"
:visible.sync="dialogShow" :visible.sync="dialogShow"
:before-close="handleCancel" :before-close="handleCancel"
:close-on-click-modal="false" :close-on-click-modal="false"
> >
<el-form ref="form" :model="form" :rules="rules" label-width="140px"> <el-form ref="form" :model="form" :rules="rules" label-width="140px">
<el-form-item label="试题类型" prop="type"> <el-form-item label="试题类型" prop="type">
<el-select v-model="form.type" placeholder="请选择试题类型" style="width:240px;" @change="clearSubtype"> <el-select v-model="form.type" placeholder="请选择试题类型" style="width:240px;" @change="clearSubtype">
<el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="规则类型" prop="subtype"> <el-form-item label="规则类型" prop="subtype">
<el-select <el-select
v-model="form.subtype" v-model="form.subtype"
placeholder="请选择规则类型" placeholder="请选择规则类型"
style="width:240px;" style="width:240px;"
@change="subTypesChange" @change="subTypesChange"
> >
<el-option v-for="item in subtypes" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in subtypes" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="标签" required> <el-form-item v-if="form.subtype === 4" label="客户端" prop="trainingClient">
<el-select v-model="form.tags" @change="getQuestionAmount"> <el-select
<el-option v-for="item in labels" :key="item.value" :label="item.label" :value="item.value" /> v-model="form.trainingClient"
</el-select> placeholder="请选择客户端"
</el-form-item> style="width:240px;"
<el-form-item v-if="form.subtype === 5" label="场景实训"> @change="trainingClientChange"
<el-row style="border: 1px solid #DCDFE6;width: 400px;"> >
<el-col :span="12" style="border-right: 1px solid #DCDFE6;overflow: hidden;text-align: center;" <el-option v-for="item in clients" :key="item.value" :label="item.label" :value="item.value" />
>场景实训名称</el-col </el-select>
> </el-form-item>
<el-col :span="12" style="text-align: center;">扮演角色</el-col> <el-form-item label="操作" required>
</el-row> <el-select v-model="form.tags" @change="getQuestionAmount">
<template v-for="scene in sceneTrainMap"> <el-option v-for="item in labels" :key="item.value" :label="item.label" :value="item.value" />
<el-row :key="scene.id" style="border: 1px solid #DCDFE6;width: 400px;border-top: 0;"> </el-select>
<el-col :span="12" style="border-right: 1px solid #DCDFE6;overflow: hidden;"> </el-form-item>
<el-radio v-model="scene.check" :label="true" style="margin-left: 10px;">{{ <el-form-item v-if="form.subtype === 5" label="场景实训">
scene.name <el-row style="border: 1px solid #DCDFE6;width: 400px;">
}}</el-radio> <el-col
</el-col> :span="12"
<el-col :span="12"> style="border-right: 1px solid #DCDFE6;overflow: hidden;text-align: center;"
<el-select >场景实训名称</el-col>
v-model="scene.cosplayId" <el-col :span="12" style="text-align: center;">扮演角色</el-col>
:disabled="!scene.check" </el-row>
size="mini" <template v-for="scene in sceneTrainMap">
style="margin-left: 10px;" <el-row :key="scene.id" style="border: 1px solid #DCDFE6;width: 400px;border-top: 0;">
placeholder="请选择扮演角色" <el-col :span="12" style="border-right: 1px solid #DCDFE6;overflow: hidden;">
> <el-radio v-model="scene.check" :label="true" style="margin-left: 10px;">{{
<el-option scene.name
v-for="item in totalMemberList" }}</el-radio>
v-show="scene.playerIdList.includes(item.value)" </el-col>
:key="item.value" <el-col :span="12">
:label="item.label" <el-select
:value="item.value" v-model="scene.cosplayId"
/> :disabled="!scene.check"
</el-select> size="mini"
</el-col> style="margin-left: 10px;"
</el-row> placeholder="请选择扮演角色"
</template> >
</el-form-item> <el-option
<el-form-item v-show="form.subtype !== 5" label="题目数量" prop="amount"> v-for="item in totalMemberList"
<el-input-number v-show="scene.playerIdList.includes(item.value)"
v-model="form.amount" :key="item.value"
:min="0" :label="item.label"
style="width: 200px; float: left; margin-right: 10px;" :value="item.value"
/> />
<span style="width: 190px; float: left;"> </el-select>
{{ $t('publish.allNumberTipOne') }} {{ topicNum }} {{ $t('publish.allNumberTipTwo') }} </el-col>
</span> </el-row>
</el-form-item> </template>
<el-form-item :label="$t('publish.scorePerQuestion')" prop="score"> </el-form-item>
<el-input-number v-model="form.score" :precision="0" :min="0" style="width:200px" /> <el-form-item v-show="form.subtype !== 5" label="题目数量" prop="amount">
</el-form-item> <el-input-number
</el-form> v-model="form.amount"
<div slot="footer" class="dialog-footer"> :min="0"
<el-button @click="handleCancel">{{ $t('global.cancel') }}</el-button> style="width: 200px; float: left; margin-right: 10px;"
<el-button type="primary" @click="handleOk">{{ $t('global.confirm') }}</el-button> />
</div> <span style="width: 190px; float: left;">
</el-dialog> {{ $t('publish.allNumberTipOne') }} {{ topicNum }} {{ $t('publish.allNumberTipTwo') }}
</span>
</el-form-item>
<el-form-item :label="$t('publish.scorePerQuestion')" prop="score">
<el-input-number v-model="form.score" :precision="0" :min="0" style="width:200px" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="handleCancel">{{ $t('global.cancel') }}</el-button>
<el-button type="primary" @click="handleOk">{{ $t('global.confirm') }}</el-button>
</div>
</el-dialog>
</template> </template>
<script> <script>
import { getQuestionAmount, queryTagList } from '@/api/management/exam' import { getQuestionAmount, queryTagList } from '@/api/management/exam';
import { getPublishTrainingListInOrg } from '@/api/jmap/training' import { getPublishTrainingListInOrg } from '@/api/jmap/training';
export default { export default {
name: 'EditRule', name: 'EditRule',
@ -93,53 +104,59 @@ export default {
ruleList: { ruleList: {
type: Array, type: Array,
default() { default() {
return [] return [];
}, }
}, },
examData: { examData: {
type: Object, type: Object,
default() { default() {
return {} return {};
}, }
}, },
totalMemberList: { totalMemberList: {
type: Array, type: Array,
default() { default() {
return [] return [];
}, }
}, },
mapOptionList: {
type: Array,
default() {
return [];
}
}
}, },
data() { data() {
var number = (rule, value, message) => { var number = (rule, value, message) => {
if (this.form.subtype !== 5) { if (this.form.subtype !== 5) {
if (!value) { if (!value) {
return message(new Error(this.$t('publish.inputQuestionNumber'))) return message(new Error(this.$t('publish.inputQuestionNumber')));
} }
setTimeout(() => { setTimeout(() => {
if (Number(value) == 0) { if (Number(value) == 0) {
message(new Error(this.$t('publish.inputQuestionNumberError'))) message(new Error(this.$t('publish.inputQuestionNumberError')));
} else if (!Number(value)) { } else if (!Number(value)) {
message(new Error(this.$t('publish.inputValidNumber'))) message(new Error(this.$t('publish.inputValidNumber')));
} else if (Number(value) > this.topicNum) { } else if (Number(value) > this.topicNum) {
message(new Error(this.$t('publish.inputNumberError'))) message(new Error(this.$t('publish.inputNumberError')));
} else { } else {
message() message();
} }
}, 100) }, 100);
} else { } else {
message() message();
} }
} };
var score = (rule, value, message) => { var score = (rule, value, message) => {
if (!value) { if (!value) {
return message(new Error(this.$t('publish.inputScorePerQuestion'))) return message(new Error(this.$t('publish.inputScorePerQuestion')));
} else { } else {
message() message();
} }
} };
const tagsValidator = (rule, value, message) => { const tagsValidator = (rule, value, message) => {
message() message();
} };
return { return {
form: { form: {
id: '', id: '',
@ -148,7 +165,9 @@ export default {
tags: '', tags: '',
amount: 1, amount: 1,
score: 1, score: 1,
trainingClient: ''
}, },
clients: [],
sceneInfo: [], sceneInfo: [],
labels: [], labels: [],
topicNum: 0, topicNum: 0,
@ -161,48 +180,62 @@ export default {
amount: [{ required: true, validator: number, trigger: 'blur' }], amount: [{ required: true, validator: number, trigger: 'blur' }],
score: [{ required: true, validator: score, trigger: 'blur' }], score: [{ required: true, validator: score, trigger: 'blur' }],
tags: [{ validator: tagsValidator, trigger: 'blur' }], tags: [{ validator: tagsValidator, trigger: 'blur' }],
}, trainingClient: [{ required: true, message:'请选择实训客户端', trigger: 'change' }]
} }
};
}, },
computed: { computed: {
types() { types() {
return [{ value: 1, label: '理论题' }, { value: 2, label: '实训题' }] return [{ value: 1, label: '理论题' }, { value: 2, label: '实训题' }];
}, },
subtypes() { subtypes() {
const data = { const data = {
'1': [{ value: 1, label: '单选题' }, { value: 2, label: '多选题' }, { value: 3, label: '判断题' }], '1': [{ value: 1, label: '单选题' }, { value: 2, label: '多选题' }, { value: 3, label: '判断题' }],
'2': [{ value: 4, label: '单操实训' }, { value: 5, label: '场景实训' }], '2': [{ value: 4, label: '单操实训' }, { value: 5, label: '场景实训' }]
} };
return data[this.form.type] return data[this.form.type];
}, },
title() { title() {
return this.isEditMode ? this.$t('publish.modifyRules') : this.$t('publish.addRules') return this.isEditMode ? this.$t('publish.modifyRules') : this.$t('publish.addRules');
}, }
}, },
methods: { methods: {
show(detail) { show(detail) {
this.dialogShow = true this.dialogShow = true;
const mapDetail = this.mapOptionList.find(item => item.id === this.examData.mapId);
if (mapDetail && mapDetail.lineCode === '14') {
this.clients = [
{ label: '轨道详览', value: 'troDetailWork' },
{ label: '现地客户端', value: 'localWork' }
];
} else {
this.clients = [
{ label: '行调客户端', value: 'dispatchWork' },
{ label: '现地客户端', value: 'localWork' }
];
}
console.log(this.clients, '*******');
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.form.resetFields() this.$refs.form.resetFields();
if (detail) { if (detail) {
this.isEditMode = true this.isEditMode = true;
this.index = detail.index this.index = detail.index;
this.sceneInfo = detail.sceneInfo || [] this.sceneInfo = detail.sceneInfo || [];
this.form = { this.form = {
type: detail.type, type: detail.type,
subtype: detail.subtype, subtype: detail.subtype,
amount: detail.amount, amount: detail.amount,
score: detail.score, score: detail.score,
id: detail.id || '', id: detail.id || '',
tags: detail.tags ? detail.tags[0] : '', tags: detail.tags ? detail.tags[0] : ''
} };
this.fillLabelsOption().then(() => { this.fillLabelsOption().then(() => {
this.getQuestionAmount() this.getQuestionAmount();
}) });
} else { } else {
this.isEditMode = false this.isEditMode = false;
} }
}) });
}, },
isDuplicated() { isDuplicated() {
const isDuplicated = const isDuplicated =
@ -214,13 +247,18 @@ export default {
rule.tags && rule.tags &&
this.form.tags && this.form.tags &&
rule.tags.includes(this.form.tags) rule.tags.includes(this.form.tags)
) );
return isDuplicated return isDuplicated;
}, },
subTypesChange(val) { subTypesChange(val) {
this.form.tags = '' this.form.tags = '';
this.fillLabelsOption() this.fillLabelsOption();
this.getQuestionAmount() this.getQuestionAmount();
},
trainingClientChange(val) {
this.form.tags = '';
this.fillLabelsOption();
this.getQuestionAmount();
}, },
fillLabelsOption() { fillLabelsOption() {
const param = { const param = {
@ -228,24 +266,26 @@ export default {
groupType: this.form.type, groupType: this.form.type,
mapId: this.examData.mapId, mapId: this.examData.mapId,
subType: this.form.subtype, subType: this.form.subtype,
} trainingClient: this.form.trainingClient || null
};
return queryTagList(param).then(resp => { return queryTagList(param).then(resp => {
this.labels = [{ label: '无', value: '' }, ...resp.data.map(item => ({ label: item, value: item }))] this.labels = [{ label: '无', value: '' }, ...resp.data.map(item => ({ label: item, value: item }))];
}) });
}, },
getQuestionAmount(e) { getQuestionAmount(e) {
if (!(this.form.type && this.form.subtype)) return if (!(this.form.type && this.form.subtype)) return;
const param = { const param = {
orgId: this.$store.state.user.companyId, orgId: this.$store.state.user.companyId,
groupType: this.form.type, groupType: this.form.type,
subType: this.form.subtype, subType: this.form.subtype,
mapId: this.examData.mapId, mapId: this.examData.mapId,
} trainingClient: this.form.trainingClient || null
};
if (this.form.tags !== '') { if (this.form.tags !== '') {
param.tags = this.form.tags param.tags = this.form.tags;
} }
if (this.form.subtype === 5) { if (this.form.subtype === 5) {
const data = { mapId: this.examData.mapId, type: 'scene', labels: [this.form.tags] } const data = { mapId: this.examData.mapId, type: 'scene', labels: [this.form.tags] };
getPublishTrainingListInOrg(data) getPublishTrainingListInOrg(data)
.then(response => { .then(response => {
if (response.data && response.data.length) { if (response.data && response.data.length) {
@ -254,50 +294,50 @@ export default {
check: false, check: false,
name: scene.name, name: scene.name,
playerIdList: JSON.parse(scene.playerIdJson), playerIdList: JSON.parse(scene.playerIdJson),
cosplayId: '', cosplayId: ''
}) });
}) });
this.sceneInfo && this.sceneInfo &&
this.sceneInfo.forEach(scene => { this.sceneInfo.forEach(scene => {
this.sceneTrainMap[scene.publishTrainId].check = true this.sceneTrainMap[scene.publishTrainId].check = true;
this.sceneTrainMap[scene.publishTrainId].cosplayId = scene.cosplayId this.sceneTrainMap[scene.publishTrainId].cosplayId = scene.cosplayId;
}) });
} }
}) })
.catch(() => { .catch(() => {
this.$message.error('获取场景实训列表失败!') this.$message.error('获取场景实训列表失败!');
}) });
} else { } else {
getQuestionAmount(param).then(resp => { getQuestionAmount(param).then(resp => {
this.topicNum = resp.data this.topicNum = resp.data;
}) });
} }
}, },
clearSubtype() { clearSubtype() {
this.form.subtype = '' this.form.subtype = '';
this.form.tags = '' this.form.tags = '';
this.labels = [{ label: '无', value: '' }] this.labels = [{ label: '无', value: '' }];
}, },
handleSceneData() { handleSceneData() {
let validFlag = true let validFlag = true;
if (this.form.subtype === 5) { if (this.form.subtype === 5) {
this.sceneInfo = [] this.sceneInfo = [];
for (const sceneId in this.sceneTrainMap) { for (const sceneId in this.sceneTrainMap) {
const scene = this.sceneTrainMap[sceneId] const scene = this.sceneTrainMap[sceneId];
if (scene.check && scene.cosplayId) { if (scene.check && scene.cosplayId) {
this.sceneInfo.push({ publishTrainId: sceneId, cosplayId: scene.cosplayId }) this.sceneInfo.push({ publishTrainId: sceneId, cosplayId: scene.cosplayId });
} else if (scene.check && !scene.cosplayId) { } else if (scene.check && !scene.cosplayId) {
validFlag = false validFlag = false;
} }
} }
this.form.amount = this.sceneInfo.length this.form.amount = this.sceneInfo.length;
} }
if (!validFlag) { if (!validFlag) {
this.$message.warning('请选择场景实训的扮演角色!') this.$message.warning('请选择场景实训的扮演角色!');
} else if (!this.form.amount) { } else if (!this.form.amount) {
this.$message.warning('请选择场景实训!') this.$message.warning('请选择场景实训!');
} }
return validFlag return validFlag;
}, },
handleOk() { handleOk() {
this.handleSceneData() && this.handleSceneData() &&
@ -305,25 +345,25 @@ export default {
if (valid) { if (valid) {
if (this.ruleList.length > 0 && !this.isEditMode) { if (this.ruleList.length > 0 && !this.isEditMode) {
if (this.isDuplicated()) { if (this.isDuplicated()) {
this.$message.warning('与已有规则重复, 请重新选择') this.$message.warning('与已有规则重复, 请重新选择');
return return;
} }
} }
this.$emit( this.$emit(
'submit', 'submit',
{ ...this.form, sceneInfo: this.sceneInfo, topicNum: this.topicNum }, { ...this.form, sceneInfo: this.sceneInfo, topicNum: this.topicNum },
this.isEditMode this.isEditMode
) );
this.handleCancel() this.handleCancel();
} }
}) });
}, },
handleCancel() { handleCancel() {
this.topicNum = 0 this.topicNum = 0;
this.dialogShow = false this.dialogShow = false;
}, }
}, }
} };
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
/deep/ { /deep/ {

View File

@ -1,148 +1,148 @@
<template> <template>
<div class="exam-rule"> <div class="exam-rule">
<el-form ref="form" :model="examData" :rules="rules" label-width="120px" class="demo-form"> <el-form ref="form" :model="examData" :rules="rules" label-width="120px" class="demo-form">
<el-form-item label="关联线路" prop="mapId" required> <el-form-item label="关联线路" prop="mapId" required>
<el-select v-model="examData.mapId"> <el-select v-model="examData.mapId">
<el-option <el-option
v-for="option in mapOptionList" v-for="option in mapOptionList"
:key="option.value" :key="option.value"
:label="option.label" :label="option.label"
:value="option.value" :value="option.value"
></el-option> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('publish.testName')" prop="name"> <el-form-item :label="$t('publish.testName')" prop="name">
<el-input v-model="examData.name" :maxlength="50" :placeholder="$t('publish.inputTestName')" /> <el-input v-model="examData.name" :maxlength="50" :placeholder="$t('publish.inputTestName')" />
</el-form-item> </el-form-item>
<el-form-item label="简介" prop="profile"> <el-form-item label="简介" prop="profile">
<el-input v-model="examData.profile" :maxlength="100" placeholder="请输入简介" /> <el-input v-model="examData.profile" :maxlength="100" placeholder="请输入简介" />
</el-form-item> </el-form-item>
<el-form-item :label="$t('publish.testDuration')" prop="validDuration"> <el-form-item :label="$t('publish.testDuration')" prop="validDuration">
<el-input-number <el-input-number
v-model="examData.validDuration" v-model="examData.validDuration"
placeholder="请输入" placeholder="请输入"
style="float: left; width: calc(100% - 80px);" style="float: left; width: calc(100% - 80px);"
:min="1" :min="1"
/> />
<span style="width:80px; display: block;float: left; text-align: center;" <span
>&nbsp;{{ $t('publish.durationMinutes') }}</span style="width:80px; display: block;float: left; text-align: center;"
> >&nbsp;{{ $t('publish.durationMinutes') }}</span>
</el-form-item> </el-form-item>
<el-form-item label="开放时间要求" prop="haveDate"> <el-form-item label="开放时间要求" prop="haveDate">
<el-switch v-model="haveDate" /> <el-switch v-model="haveDate" />
</el-form-item> </el-form-item>
<el-form-item v-if="haveDate" :label="$t('publish.testDate')"> <el-form-item v-if="haveDate" :label="$t('publish.testDate')">
<el-col :span="11"> <el-col :span="11">
<el-form-item prop="startTime"> <el-form-item prop="startTime">
<el-date-picker <el-date-picker
v-model="examData.startTime" v-model="examData.startTime"
type="datetime" type="datetime"
:placeholder="$t('publish.startTestTime')" :placeholder="$t('publish.startTestTime')"
style="width: 100%;" style="width: 100%;"
value-format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
:default-value="new Date()" :default-value="new Date()"
:picker-options="pickerOptions" :picker-options="pickerOptions"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col class="line" :span="2">-</el-col> <el-col class="line" :span="2">-</el-col>
<el-col :span="11"> <el-col :span="11">
<el-form-item prop="endTime"> <el-form-item prop="endTime">
<el-date-picker <el-date-picker
v-model="examData.endTime" v-model="examData.endTime"
value-format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
type="datetime" type="datetime"
:placeholder="$t('publish.endTestTime')" :placeholder="$t('publish.endTestTime')"
style="width: 100%;" style="width: 100%;"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item :label="$t('publish.fullScore')" prop="fullScore"> <el-form-item :label="$t('publish.fullScore')" prop="fullScore">
<el-input-number v-model="examData.fullScore" placeholder="" :min="1" @change="fullScoreChange" /> <el-input-number v-model="examData.fullScore" placeholder="" :min="1" @change="fullScoreChange" />
</el-form-item> </el-form-item>
<el-form-item :label="$t('publish.passingScore')" prop="passScore"> <el-form-item :label="$t('publish.passingScore')" prop="passScore">
<el-input-number v-model="examData.passScore" placeholder="" :min="1" /> <el-input-number v-model="examData.passScore" placeholder="" :min="1" />
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
</template> </template>
<script> <script>
import { queryMapListByUser } from '@/api/jmap/map'
export default { export default {
name: 'ExamFrom', name: 'ExamFrom',
props: { props: {
examData: { examData: {
type: Object, type: Object,
default() { default() {
return {} return {};
}, }
}, },
}, mapOptionList: {
data() { type: Array,
var checkendTime = (rule, value, message) => { default() {
if (this.examData.startTime && value) { return [];
const startTime = new Date(this.examData.startTime).getTime() }
const endTime = new Date(value).getTime() }
if (startTime > endTime) { },
message(new Error('开始时间必须小于截止时间')) data() {
} else { var checkendTime = (rule, value, message) => {
message() if (this.examData.startTime && value) {
} const startTime = new Date(this.examData.startTime).getTime();
} else { const endTime = new Date(value).getTime();
message() if (startTime > endTime) {
} message(new Error('开始时间必须小于截止时间'));
} } else {
var checkPassScore = (rule, value, message) => { message();
if (value > this.examData.fullScore) { }
message(new Error('及格分必须小于等于满分')) } else {
} else { message();
message() }
} };
} var checkPassScore = (rule, value, message) => {
return { if (value > this.examData.fullScore) {
pickerOptions: { message(new Error('及格分必须小于等于满分'));
disabledDate(time) { } else {
return time.getTime() < new Date(new Date().toLocaleDateString()).getTime() message();
}, }
}, };
haveDate: false, return {
mapOptionList: [], pickerOptions: {
selectDisable: false, disabledDate(time) {
rules: { return time.getTime() < new Date(new Date().toLocaleDateString()).getTime();
mapId: [{ required: true, message: '请选择线路', trigger: 'blur' }], }
name: [{ required: true, message: this.$t('publish.inputTestName'), trigger: 'blur' }], },
validDuration: [{ required: true, message: this.$t('publish.inputTestDuration'), trigger: 'blur' }], haveDate: false,
fullScore: [{ required: true, message: this.$t('publish.inputFullScore'), trigger: 'blur' }], selectDisable: false,
passScore: [ rules: {
{ required: true, message: this.$t('publish.inputPassingScore'), trigger: 'blur' }, mapId: [{ required: true, message: '请选择线路', trigger: 'blur' }],
{ validator: checkPassScore, trigger: 'blur' }, name: [{ required: true, message: this.$t('publish.inputTestName'), trigger: 'blur' }],
], validDuration: [{ required: true, message: this.$t('publish.inputTestDuration'), trigger: 'blur' }],
endTime: [{ validator: checkendTime, trigger: 'change' }], fullScore: [{ required: true, message: this.$t('publish.inputFullScore'), trigger: 'blur' }],
}, passScore: [
} { required: true, message: this.$t('publish.inputPassingScore'), trigger: 'blur' },
}, { validator: checkPassScore, trigger: 'blur' }
computed: { ],
isEdit() { endTime: [{ validator: checkendTime, trigger: 'change' }]
return this.$route.params.mode === 'edit' }
}, };
}, },
created() { computed: {
queryMapListByUser().then(resp => { isEdit() {
this.mapOptionList = resp.data.map(item => ({ label: item.name, value: Number(item.id) })) return this.$route.params.mode === 'edit';
}) }
}, },
mounted() {}, mounted() {},
methods: { methods: {
checkForm() { checkForm() {
return this.$refs['form'].validate() return this.$refs['form'].validate();
}, },
fullScoreChange() { fullScoreChange() {
this.$refs.form.validateField('passScore') this.$refs.form.validateField('passScore');
}, }
}, }
} };
</script> </script>
<style rel="stylesheet/scss" lang="scss" scoped> <style rel="stylesheet/scss" lang="scss" scoped>
.exam-rule { .exam-rule {

View File

@ -6,11 +6,12 @@
<el-step :title="$t('publish.examRuleMaking')" icon="el-icon-setting" /> <el-step :title="$t('publish.examRuleMaking')" icon="el-icon-setting" />
</el-steps> </el-steps>
<div class="joylink-card forms"> <div class="joylink-card forms">
<exam-from v-show="currentStep === 1" ref="exam" :exam-data="examData" /> <exam-from v-show="currentStep === 1" ref="exam" :map-option-list="mapOptionList" :exam-data="examData" />
<rule-from <rule-from
v-show="currentStep === 2" v-show="currentStep === 2"
ref="rule" ref="rule"
:is-edit-mode="isEditMode" :is-edit-mode="isEditMode"
:map-option-list="mapOptionList"
:rule-list="ruleList" :rule-list="ruleList"
:exam-data="examData" :exam-data="examData"
/> />
@ -35,7 +36,7 @@
import RuleFrom from './rule'; import RuleFrom from './rule';
import ExamFrom from './examFrom'; import ExamFrom from './examFrom';
import { getPaperDetail } from '@/api/management/exam'; import { getPaperDetail } from '@/api/management/exam';
import { queryMapListByUser } from '@/api/jmap/map';
import { createPaper, editPaper } from '@/api/management/exam'; import { createPaper, editPaper } from '@/api/management/exam';
export default { export default {
@ -57,7 +58,8 @@ export default {
passScore: 60, passScore: 60,
mapId: '' mapId: ''
}, },
ruleList: [] ruleList: [],
mapOptionList: []
}; };
}, },
computed: { computed: {
@ -93,6 +95,9 @@ export default {
}); });
}); });
} }
queryMapListByUser().then(resp => {
this.mapOptionList = resp.data.map(item => ({ label: item.name, value: Number(item.id) }));
});
}, },
methods: { methods: {
prevStep() { prevStep() {

View File

@ -52,7 +52,14 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<edit-rule ref="addRule" :rule-list="ruleList" :exam-data="examData" :total-member-list="totalMemberList" @submit="handleRuleSubmit" /> <edit-rule
ref="addRule"
:rule-list="ruleList"
:map-option-list="mapOptionList"
:exam-data="examData"
:total-member-list="totalMemberList"
@submit="handleRuleSubmit"
/>
</div> </div>
</template> </template>
@ -77,6 +84,12 @@ export default {
}, },
isEditMode: { isEditMode: {
type: Boolean type: Boolean
},
mapOptionList: {
type: Array,
default() {
return [];
}
} }
}, },
data() { data() {
@ -132,7 +145,10 @@ export default {
amount: formData.amount, amount: formData.amount,
score: formData.score, score: formData.score,
topicNum: formData.topicNum, topicNum: formData.topicNum,
tags: [formData.tags] tags: [formData.tags],
subTypeParam: {
client: formData.trainingClient
}
}; };
if (formData.subtype === 5 && formData.sceneInfo && formData.sceneInfo.length) { if (formData.subtype === 5 && formData.sceneInfo && formData.sceneInfo.length) {
data.sceneInfo = formData.sceneInfo; data.sceneInfo = formData.sceneInfo;
@ -142,7 +158,6 @@ export default {
} else { } else {
this.ruleList.push(data); this.ruleList.push(data);
} }
console.log(this.ruleList, '333333333333');
}, },
deleteRule(data) { deleteRule(data) {
const index = data.$index; const index = data.$index;

View File

@ -114,7 +114,6 @@ export default {
getRelatedFunctionList(mapId) { getRelatedFunctionList(mapId) {
queryMapFunctionList({mapId: mapId, detail: true}).then(resp => { queryMapFunctionList({mapId: mapId, detail: true}).then(resp => {
this.functionList = resp.data; this.functionList = resp.data;
console.log(resp);
}).catch(() => { }).catch(() => {
this.$message.error('获取地图功能列表失败!'); this.$message.error('获取地图功能列表失败!');
}); });