This commit is contained in:
ival 2021-03-29 11:32:00 +08:00
commit 45027796e7
13 changed files with 341 additions and 719 deletions

View File

@ -150,3 +150,11 @@ export function sendCommandTrain(group, data) {
data
});
}
/** 根据地图id和产品类型查询实训类型及数量 */
export function getTrainingTypeAndNumByMapIdAndPrdType(params) {
return request({
url: `/api/v1/training/trainingTypeAndQuantity`,
method: 'get',
params
});
}

View File

@ -1,21 +1,13 @@
import request from '@/utils/request';
/** 创建对应课程考题 */
export function setCourseList(data) {
export function createExam(data) {
return request({
url: `/api/exam`,
method: 'post',
data: data
});
}
/** 贵州装备 创建对应课程考题 */
export function setCourseListGzb(data) {
return request({
url: `/api/exam/project/GZB`,
method: 'post',
data: data
});
}
/** 获取对应课程下类型 */
export function getCourseTypeList(data) {

View File

@ -207,6 +207,14 @@ export const UrlConfig = {
}
};
import CMD from './cmdPlugin/CommandEnum';
export function getOperateTypeMap(trainingType) {
const map = {};
let val;
for (val in CMD[trainingType]) {
map[CMD[trainingType][val].value] = CMD[trainingType][val].label;
}
return map;
}
export function getTrainingOperateTypeMap() {
const trainingOperateTypeMap = {
Switch: [],

View File

@ -9,7 +9,6 @@ const exam = {
totalTime: 0, // 考试总时间
timeInterval: null, // 计时器
ruleList: [], // 考试规则列表
courseDetail: {}, // 课程详情
courseList: [] // 课程列表
},
getters: {
@ -53,9 +52,6 @@ const exam = {
setRuleList: (state, ruleList) => {
state.ruleList = ruleList;
},
setCourseDetail: (state, courseDetail) => {
state.courseDetail = courseDetail;
},
setCourse: (state, courseList) => {
state.courseList = courseList;
},
@ -95,9 +91,6 @@ const exam = {
setRuleList({ commit }, ruleList) {
commit('setRuleList', ruleList);
},
setCourseDetail({ commit }, courseDetail) {
commit('setCourseDetail', courseDetail);
},
setCourse({ commit }, course) {
commit('setCourse', course);
},

View File

@ -1,8 +1,8 @@
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://joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.8.107:9000'; // 袁琪
// BASE_API = 'http://192.168.8.129:9000'; // 旭强
// BASE_API = 'http://192.168.8.119:9000'; // 张赛

View File

@ -46,7 +46,6 @@
<div class="btn-buy">
<!-- <el-button v-if="!isLocal" :disabled="disabled" type="success" @click="buy">{{ $t('exam.buy') }}</el-button> -->
<el-button v-if="hasPermssion && !isLocal" :disabled="disabled" type="primary" @click="distribute">{{ $t('exam.distributePermission') }}</el-button>
<el-button v-if=" isAdmin&& !$route.query.noPreLogout && !courseModel.systemFault" :disabled="disabled" type="primary" @click="checkCourse">{{ $t('exam.viewCoursePapers') }}</el-button>
<el-button v-if="!$route.query.noPreLogout" type="primary" :disabled="disabled" @click="backLessonList">{{ $t('exam.returnCourseList') }}</el-button>
<el-button v-if="$route.query.noPreLogout" type="primary" :disabled="disabled" @click="quit">退出</el-button>
</div>
@ -159,15 +158,6 @@ export default {
// }, 100);
this.$messageBox(this.$t('global.buyingTips'));
},
checkCourse() {
this.loading = true;
const path = `${this.$route.path.match(/(\/.*)\/course/)[1]}${UrlConfig.examRuleManage}`;
this.$router.push({
path: path,
query: { lessonId: this.courseModel.id },
noPreLogout: this.$route.query.noPreLogout
});
},
distribute() { //
this.disabled = true;
if (this.$refs) {

View File

@ -144,12 +144,10 @@ export default {
};
},
mounted() {
if (this.project) {
getPostByProjectCode(this.projectCode).then(resp => {
this.postId = resp.data.id;
});
this.handleCurrentChange();
}
},
methods: {
commitComment() {

View File

@ -74,15 +74,15 @@ export default {
title: '试卷名称',
prop: 'name'
},
{
title: '课程名称',
prop: 'lessonId',
type: 'tag',
columnValue: (row) => {
return this.$convertField(row.lessonId, this.lessonList || [], ['id', 'name']);
},
tagType: (row) => { }
},
// {
// title: '',
// prop: 'lessonId',
// type: 'tag',
// columnValue: (row) => {
// return this.$convertField(row.lessonId, this.lessonList || [], ['id', 'name']);
// },
// tagType: (row) => { }
// },
{
title: '班级',
prop: 'clsIds',

View File

@ -1,14 +1,14 @@
<template>
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogShow" :before-close="handleCancel" :close-on-click-modal="false">
<el-form ref="form" :model="form" :rules="rules" label-width="140px">
<el-form-item :label="$t('publish.trainingType')" prop="course">
<el-select v-model="form.course" :placeholder="$t('publish.selectTypeScope')" :disabled="editOk" style="width:240px;" @change="changeCourse(form.course)">
<el-option v-for="nor in options" :key="nor.id" :label="nor.name" :value="nor.code" :disabled="nor.disabled" />
<el-form-item :label="$t('publish.trainingType')" prop="trainingType">
<el-select v-model="form.trainingType" :placeholder="$t('publish.selectTypeScope')" :disabled="editOk" style="width:240px;" @change="changeCourse">
<el-option v-for="nor in trainingTypeList" :key="nor.value" :label="nor.label" :value="nor.value" :disabled="nor.disabled" />
</el-select>
</el-form-item>
<el-form-item :label="$t('publish.operationType')">
<el-select v-model="form.operateType" clearable :placeholder="$t('publish.selectScope')" :disabled="editOk" @change="changeOperation(form.operateType)">
<el-option v-for="nor in operationTypeList" :key="nor.id" :label="nor.name" :value="nor.code" :disabled="nor.disabled" />
<el-form-item :label="$t('publish.operationType')" prop="operateType">
<el-select v-model="form.operateType" clearable :placeholder="$t('publish.selectScope')" :disabled="editOk" @change="changeOperation">
<el-option v-for="nor in operationTypeList" :key="nor.value" :label="nor.label" :value="nor.value" :disabled="nor.disabled" />
</el-select>
</el-form-item>
<el-form-item :label="$t('publish.questionNumbers')" prop="number">
@ -31,23 +31,29 @@
</template>
<script>
import { getLessonTypeNum, getCourseTypeList } from '@/api/management/exam';
import { getDetailList } from '@/api/management/dictionary';
import { getCmdList } from '@/api/management/dictionary';
import ConstConfig from '@/scripts/ConstConfig';
import Cookies from 'js-cookie';
import { getTrainingOperateTypeMap } from '@/scripts/ConstDic';
export default {
name: 'EditRule',
props: {
courseId: {
type: String,
operationTypeMap: {
type: Object,
required:true
},
trainingOperateTypeMap: {
type: Object,
required:true
},
trainingTypeNums: {
type: Object,
required: true
},
lineCode: {
type: String,
default: ''
operationTypeNums: {
type: Object,
required: true
},
trainingTypeList: {
type: Array,
required: true
}
},
data() {
@ -82,7 +88,7 @@ export default {
return {
title: this.$t('publish.addRules'),
form: {
course: '',
trainingType: '',
operateType: '',
number: '',
mark: 0
@ -91,7 +97,7 @@ export default {
dialogShow: false,
editOk: false,
rules: {
course: [
trainingType: [
{ required: true, message: this.$t('publish.selectTestType'), trigger: 'change' }
],
number: [
@ -101,94 +107,42 @@ export default {
{ required: true, validator: mark, trigger: 'blur' }
]
},
options: this.$store.state.exam.courseList,
typeList: [],
operationTypeList: [],
trainingOperateTypeMap: {}
operationTypeList: []
};
},
async mounted() {
await this.getList();
await this.refresh();
this.trainingOperateTypeMap = getTrainingOperateTypeMap();
const lineCode = this.lineCode;
const res = await getCmdList(lineCode, {});
const trainingOperateList = [];
const trainingOperateConfigList = [];
const operateTypeMap = {
Switch: [],
Section: [],
Signal: [],
Stand: [],
Station: [],
ControlConvertMenu: [],
TrainWindow: [],
LimitControl: [],
Driver: []
};
if (res && res.code === 200) {
res.data.forEach(item => {
this.trainingOperateTypeMap[item.operateObject].forEach(ele => {
if (ele.value == item.operate && !this.checkIncludes(operateTypeMap[item.operateObject], ele)) {
operateTypeMap[item.operateObject].push({name: ele.label, code: ele.value});
}
});
if (!trainingOperateList.includes(item.operateObject)) {
trainingOperateList.push(item.operateObject);
const objectLabel = ConstConfig.ConstSelect.trainingDeviceType[item.operateObject] || {};
trainingOperateConfigList.push({code: item.operateObject, name: Cookies.get('user_lang') == 'en' ? objectLabel.enlabel : objectLabel.label});
}
});
this.options = trainingOperateConfigList;
this.trainingOperateTypeMap = operateTypeMap;
} else {
this.$message.error(this.$t('error.failedToObtainTrainingType'));
}
},
mounted() {},
methods: {
show(detail) {
this.dialogShow = true;
if (detail) {
this.$nextTick(() => {
this.$refs.form.resetFields();
this.title = this.$t('publish.modifyRules');
this.editOk = true;
this.changeCourse(detail.trainingType);
this.form = {
course: detail.trainingType,
trainingType: detail.trainingType,
operateType: detail.operateType,
number: detail.num,
mark: detail.point
};
this.changeOperation(detail.operateType);
}
this.dialogShow = true;
},
checkIncludes(list, obj) {
let flag = false;
list.forEach(item => {
if (item.code === obj.value) {
flag = true;
}
});
return flag;
}
},
handleOk() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.operationTypeList.forEach(item => {
if (item.code == this.form.operateType) {
this.form.name = item.name;
return;
}
});
if (this.editOk) {
//
this.$emit('editRuleList', this.form, this.options);
this.editOk = false;
this.$emit('editRuleList', this.form);
setTimeout(() => {
this.handleCancel();
}, 300);
} else {
//
this.$emit('addRuleList', this.form, this.options);
this.$emit('addRuleList', this.form);
setTimeout(() => {
this.handleCancel();
}, 300);
@ -202,104 +156,21 @@ export default {
},
handleCancel() {
this.$refs['form'].resetFields();
this.clearBoth();
this.dialogShow = false;
this.editOk = false;
this.topicNum = 0;
this.operationTypeList = [];
},
clearBoth() {
this.form = {
course: '',
number: '',
mark: ''
};
changeCourse(val) {
this.operationTypeList = this.operationTypeMap[val];
this.topicNum = this.trainingTypeNums[val];
},
//
async refresh() {
await getCourseTypeList({ lessonId: this.courseId }).then(res => {
const list = [];
res.data.sort();
res.data.forEach(ele => {
this.typeList.forEach(v => {
if (ele == v.code) {
list.push(v);
changeOperation(val) {
if (val) {
this.topicNum = this.operationTypeNums[this.form.trainingType][val];
} else {
this.topicNum = this.trainingTypeNums[this.form.trainingType];
}
});
});
this.options = list;
this.changeCourseDisable();
}).catch(() => {
this.$messageBox(this.$t('publish.refreshFailed'));
});
},
async getList() {
this.typeList = [];
await getDetailList('training_type').then(res => {
this.typeList = res.data;
}).catch((error) => { console.log(error.message); });
},
async changeCourse(val) {
const param = {
lessonId: this.courseId,
trainingType: val,
operateType: ''
};
this.operationTypeList = this.trainingOperateTypeMap[val];
if (this.operationTypeList) {
this.operationTypeList.forEach(item => {
item.disabled = false;
this.changeOperationDisabled(); //
});
}
this.form.operateType = '';
const resp = await getLessonTypeNum(param);
if (resp.code == 200) {
this.topicNum = resp.data;
return this.topicNum;
}
},
async changeOperation(val) {
const param = {
lessonId: this.courseId,
trainingType: this.form.course,
operateType: val
};
const resp = await getLessonTypeNum(param);
if (resp.code == 200) {
this.topicNum = resp.data;
return this.topicNum;
}
},
//
changeCourseDisable() {
const arr = this.$store.state.exam.ruleList;
arr.forEach(ele => {
this.options.forEach(res => {
// operateType
if (ele.trainingType == res.code && !ele.operateType) {
res.disabled = true;
}
});
});
},
changeOperationDisabled() {
const arr = this.$store.state.exam.ruleList;
arr.forEach(ele => {
this.operationTypeList.forEach(res => {
if (ele.operateType == res.code) {
res.disabled = true;
}
});
});
},
changeListDisabled(val) {
this.options.forEach(res => {
if (res.code == val) {
res.disabled = false;
}
});
}
}
};

View File

@ -1,161 +1,117 @@
<template>
<div class="exam-rule">
<el-form ref="form" :model="form" :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="$t('publish.testName')" prop="name">
<el-input v-model="form.name" :placeholder="$t('publish.inputTestName')" />
<el-input v-model="examData.name" :placeholder="$t('publish.inputTestName')" />
</el-form-item>
<el-form-item :label="$t('publish.testScope')" prop="region">
<el-select v-model="form.region" :placeholder="$t('publish.selectTestScope')" style="width: 100%;" :disabled="isEdit || selectDisable">
<el-option v-for="nor in options" :key="nor.id" :label="nor.name" :value="nor.id" />
<el-form-item label="归属地图:" prop="mapId">
<el-select v-model="examData.mapId" placeholder="请选择归属地图" :disabled="isEdit">
<el-option v-for="map in mapList" :key="map.id" :label="map.name" :value="map.id" />
</el-select>
</el-form-item>
<el-form-item label="产品类型:" prop="prdType">
<el-select v-model="examData.prdType" placeholder="请选择产品类型" :disabled="isEdit">
<el-option v-for="prd in prdList" :key="prd.value" :label="prd.label" :value="prd.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('publish.testDuration')" prop="duration">
<el-input-number v-model="form.duration" placeholder="请输入" style="float: left; width: calc(100% - 80px);" :disabled="isEdit" :min="1" />
<el-input-number v-model="examData.duration" placeholder="请输入" style="float: left; width: calc(100% - 80px);" :disabled="isEdit" :min="1" />
<span style="width:80px; display: block;float: left; text-align: center;">&nbsp;{{ $t('publish.durationMinutes') }}</span>
</el-form-item>
<el-form-item :label="$t('publish.testDate')">
<el-col :span="11">
<el-form-item prop="startDate">
<el-date-picker
v-model="form.startDate"
v-model="examData.startDate"
type="datetime"
:placeholder="$t('publish.startTestTime')"
style="width: 100%;"
value-format="timestamp"
value-format="yyyy-MM-dd HH:mm:ss"
:default-value="new Date()"
:picker-options="pickerOptions"
@change="handle"
/>
<!-- :disabled="isEdit" -->
</el-form-item>
</el-col>
<el-col class="line" :span="2">-</el-col>
<el-col :span="11">
<el-form-item prop="endDate">
<el-date-picker
v-model="form.endDate"
v-model="examData.endDate"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
:placeholder="$t('publish.endTestTime')"
style="width: 100%;"
value-format="timestamp"
:disabled="true"
/>
<!-- :picker-options="pickerOptions" -->
</el-form-item>
</el-col>
</el-form-item>
<el-form-item :label="$t('publish.fullScore')" prop="fullMark">
<el-input-number v-model="form.fullMark" placeholder="" :disabled="isEdit" :min="1" />
<el-input-number v-model="examData.fullMark" placeholder="" :disabled="isEdit" :min="1" />
</el-form-item>
<el-form-item :label="$t('publish.passingScore')" prop="passMark">
<el-input-number v-model="form.passMark" placeholder="" :disabled="isEdit" :min="1" />
<el-input-number v-model="examData.passMark" placeholder="" :disabled="isEdit" :min="1" />
</el-form-item>
<!-- v-if="trialShow" -->
<el-form-item :label="$t('publish.whetherToTry')" required>
<el-form-item v-if="!$route.path.includes('info')" :label="$t('publish.whetherToTry')" required>
<el-radio-group v-model="trial">
<el-radio label="1">{{ $t('publish.trialNo') }}</el-radio>
<el-radio label="2">{{ $t('publish.trialYes') }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('publish.testDescription')" prop="desc">
<el-input v-model="form.desc" type="textarea" :placeholder="$t('publish.inputTestDescription')" :disabled="isEdit" />
<el-input v-model="examData.desc" type="textarea" :placeholder="$t('publish.inputTestDescription')" :disabled="isEdit" />
</el-form-item>
<!-- <el-form-item>
<el-button type="primary" @click="updateForm" v-if="isEdit">{{ $t('error.edit') }}</el-button>
<el-button type="primary" @click="submitForm" v-else>{{ $t('error.nextStep') }}</el-button>
</el-form-item> -->
</el-form>
</div>
</template>
<script>
import { getPublishLessonList, getLessonProjectListNoPage } from '@/api/jmap/lesson';
import { getExamLessonDetail, updateExamRules } from '@/api/management/exam';
import { updateExamRules } from '@/api/management/exam';
import { getMapListByProjectCode } from '@/api/jmap/map';
import { getSessionStorage } from '@/utils/auth';
import { ProjectCode } from '@/scripts/ProjectConfig';
export default {
name: 'ExamFrom',
props: {
examData: {
type: Object,
default() {
return {};
}
}
},
data() {
var fullMark = (rule, value, callback) => {
if (!value) {
return callback(new Error(this.$t('publish.inputFullScore')));
}
setTimeout(() => {
if (!Number(value)) {
callback(new Error(this.$t('publish.inputNumericType')));
} else {
callback();
}
}, 100);
};
var passMark = (rule, value, callback) => {
if (!value) {
return callback(new Error(this.$t('publish.inputPassingScore')));
}
setTimeout(() => {
if (!Number(value)) {
callback(new Error(this.$t('publish.inputNumericType')));
} else {
if (Number(value) > this.form.fullMark) {
callback(new Error(this.$t('publish.inputScoreError')));
} else {
callback();
}
}
}, 100);
};
var duration = (rule, value, callback) => {
if (!value) {
return callback(new Error(this.$t('publish.inputTestDuration')));
}
setTimeout(() => {
if (!Number(value)) {
callback(new Error(this.$t('publish.inputNumericType')));
} else {
callback();
}
}, 100);
};
return {
pickerOptions: {
disabledDate(time) {
return time.getTime() < new Date(new Date().toLocaleDateString()).getTime();
// return time.getTime() < Date.now() - 1 * 24 * 3600 * 1000;
}
},
formDetail: {
name: '',
region: '',
startDate: '',
endDate: '',
desc: '',
type: '',
duration: '',
fullMark: '',
passMark: ''
},
mapList: [],
prdList: [{ label: 'ATS现地工作站', value: '01' }, { label: 'ATS行调工作站', value: '02' }],
trial: '1',
// trialShow: false,
form: this.$store.state.exam.courseDetail,
options: [],
selectDisable: false,
rules: {
name: [
{ required: true, message: this.$t('publish.inputTestName'), trigger: 'blur' }
],
region: [
{ required: true, message: this.$t('publish.selectTestScope'), trigger: 'change' }
prdType: [
{ required: true, message: '请选择产品类型', trigger: 'change' }
],
mapId: [
{ required: true, message: '请选择归属地图', trigger: 'change' }
],
duration: [
{ required: true, validator: duration, trigger: 'blur' }
{ required: true, message: this.$t('publish.inputTestDuration'), trigger: 'blur' }
],
fullMark: [
{ required: true, validator: fullMark, trigger: 'blur' }
{ required: true, message: this.$t('publish.inputFullScore'), trigger: 'blur' }
],
trial: [
{ required: true, message: this.$t('publish.selectWetherTrial'), trigger: 'blur' }
],
passMark: [
{ required: true, validator: passMark, trigger: 'blur' }
{ required: true, message: this.$t('publish.inputPassingScore'), trigger: 'blur' }
]
}
};
@ -163,106 +119,29 @@ export default {
computed: {
isEdit() {
return this.$route.params.mode == 'edit';
},
isClassShow() {
return this.$store.state.user.companyId && this.$store.state.user.companyAdmin;
}
},
watch: {
'form.startDate': function (val) {
if (val) {
this.form.endDate = val + Number(this.form.duration * 60000);
} else {
this.form.endDate = '';
}
},
'form.duration': function (val) {
if (this.form.startDate) {
this.form.endDate = this.form.startDate + Number(val * 60000);
} else {
this.form.endDate = '';
}
}
},
created() {
this.refresh();
},
mounted() {
// const user = this.$store.state.user;
// const roles = user.roles;
// this.trialShow = roles.indexOf('04') != -1;
this.init();
},
methods: {
setData(data) {
this.form = {
name: data.name,
region: data.region,
startDate: Date.parse(new Date(data.startDate)),
endDate: Date.parse(new Date(data.endDate)),
desc: data.desc,
type: data.type,
duration: Number(data.duration),
fullMark: data.fullMark,
passMark: data.passMark
};
},
handle() {
var startAt = new Date(this.form.startDate) * 1000 / 1000;
if (startAt < Date.now()) {
this.form.startDate = new Date().getTime();
}
},
init() {
this.$nextTick(() => {
if (this.$route.params.ruleId != 0) {
getExamLessonDetail(this.$route.params.ruleId).then(res => {
this.formDetail = {
name: res.data.name,
region: `${res.data.lessonId}`,
startDate: Date.parse(new Date(res.data.startTime)),
endDate: Date.parse(new Date(res.data.endTime)),
desc: res.data.remarks,
type: res.data.type,
duration: Number(res.data.duration) / 60,
fullMark: res.data.fullPoint,
passMark: res.data.passingPoint
};
if (!this.form.name) {
this.$store.dispatch('exam/setCourseDetail', this.formDetail);
this.form = this.formDetail;
} else {
this.$store.dispatch('exam/setCourseDetail', this.form);
}
});
}
this.$refs.form.clearValidate();
});
},
submitForm() {
this.submit('definition');
},
submit(type) {
this.$refs['form'].validate((valid) => {
if (valid) {
const form = Object.assign({}, this.form);
if (form.startDate) {
form.startDate = this.getDate(form.startDate);
}
if (form.endDate) {
form.endDate = this.getDate(form.endDate);
}
form['trial'] = this.trial;
this.$store.dispatch('exam/setCourseDetail', form);
this.$emit(type, form);
// const form = Object.assign({}, this.form);
// if (form.startDate) {
// form.startDate = this.getDate(form.startDate);
// }
// if (form.endDate) {
// form.endDate = this.getDate(form.endDate);
// }
// form['trial'] = this.trial;
// this.$emit(type, form);
}
});
},
createQuickly() {
this.submit('createQuickly');
},
getDate(date) {
const now = new Date(date);
const y = now.getFullYear();
@ -275,47 +154,27 @@ export default {
if (valid) {
const model = {
id: this.$route.params.ruleId,
name: this.form.name,
endTime: this.getDate(this.form.endDate),
startTime: this.getDate(this.form.startDate),
name: this.examData.name,
endTime: this.examData.endDate,
startTime: this.examData.startDate,
trial: this.trial == 2
};
try {
await updateExamRules(model);
this.$store.dispatch('exam/setCourseDetail', this.form);
this.$message.success(this.$t('publish.updateExamRuleSuccess'));
// history.go(-1);
} catch (error) {
this.$messageBox(this.$t('publish.updateExamRuleFailed'));
}
}
});
},
refresh() {
if (this.$route.path.includes('info')) {
getLessonProjectListNoPage().then(response => {
this.options = response.data;
if (parseInt(this.$route.params.lessonId)) {
this.form.region = this.$route.params.lessonId;
this.selectDisable = true;
}
this.$nextTick(() => { this.$refs.form.clearValidate(); });
}).catch(() => {
this.$messageBox(this.$t('publish.refreshFailed'));
const project = ProjectCode[getSessionStorage('project')];
getMapListByProjectCode(project).then(resp => {
this.mapList = resp.data;
}).catch(e => {
this.$message.error('获取地图列表数据异常:' + e.message);
});
} else {
getPublishLessonList().then(response => {
this.options = response.data;
if (parseInt(this.$route.params.lessonId)) {
this.form.region = this.$route.params.lessonId;
this.selectDisable = true;
}
this.$nextTick(() => { this.$refs.form.clearValidate(); });
}).catch(() => {
this.$messageBox(this.$t('publish.refreshFailed'));
});
}
}
}
};

View File

@ -1,19 +1,16 @@
<template>
<div class="joylink-card" :class="lessonName ? 'card-box' : ''">
<div v-if="lessonName" class="card-title">
{{ $t('publish.lessonName') }} {{ lessonName }}
</div>
<div class="exam-box" :style="{ 'height': lessonName ? 'calc(100% - 47px)' : '' }">
<div class="joylink-card">
<div class="exam-box">
<el-steps class="steps" :active="display">
<el-step :title="$t('publish.testDefinitionMaking')" icon="el-icon-edit" />
<el-step :title="$t('publish.examRuleMaking')" icon="el-icon-setting" />
</el-steps>
<div class="joylink-card forms">
<template v-if="display == 1" class="definition">
<exam-from ref="exam" @definition="definition" @createQuickly="createQuicklySave" />
<exam-from ref="exam" :exam-data="examData" />
</template>
<template v-else class="rule">
<rule-from ref="rule" :course="course" :line-code="lineCode" @regulation="regulation" />
<rule-from ref="rule" :rule-list="ruleList" :exam-data="examData" @regulation="regulation" />
</template>
</div>
<div class="draft">
@ -31,13 +28,10 @@
</template>
<script>
import { getPublishLessonList } from '@/api/jmap/lesson';
import RuleFrom from './rule';
import ExamFrom from './examFrom';
import { getPublishMapInfo } from '@/api/jmap/map';
import { getExamLessonDetail, setCourseList } from '@/api/management/exam';
import { getExamLessonDetail, createExam } from '@/api/management/exam';
import { UrlConfig } from '@/scripts/ConstDic';
import { getSessionStorage } from '@/utils/auth';
export default {
name: 'ExamRule',
@ -48,12 +42,19 @@ export default {
data() {
return {
display: 1,
course: {},
lessonName: '',
formData: {},
examData: {
name: '',
mapId: '',
lineCode: '',
OrganizationList: []
prdType: '',
startDate: '',
endDate: '',
desc: '',
type: '',
duration: '',
fullMark: '',
passMark: ''
},
ruleList: []
};
},
computed: {
@ -73,80 +74,54 @@ export default {
return this.display == 1 && this.$route.params.mode != 'edit' && Number(this.$route.params.ruleId);
}
},
watch: {
'$store.state.exam.courseDetail': function (val) {
this.OrganizationList.forEach(elem => {
if (elem.id === val.region) {
this.mapId = elem.mapId;
getPublishMapInfo(this.mapId).then(res=>{
this.lineCode = res.data.lineCode;
});
}
});
}
},
created() {
this.loadInitData();
if (this.$route.params.ruleId != 0) {
getExamLessonDetail(this.$route.params.ruleId).then(res => {
this.examData = {
name: res.data.name,
mapId: res.data.mapId + '',
prdType: res.data.prdType,
startDate: res.data.startTime,
endDate: res.data.endTime,
desc: res.data.remarks,
type: res.data.type,
duration: Number(res.data.duration) / 60,
fullMark: res.data.fullPoint,
passMark: res.data.passingPoint
};
this.ruleList = res.data.examDefinitionRulesVOList;
});
}
},
methods: {
loadInitData() {
getPublishLessonList().then(response => {
this.OrganizationList = response.data;
this.OrganizationList.forEach(elem => {
if (elem.id == this.$route.params.lessonId) {
this.lessonName = elem.name;
}
});
});
regulation() {
this.display = 1;
},
async definition(data) {
this.course = data;
this.formData = {};
this.display = 2;
this.OrganizationList.forEach(elem => {
if (elem.id == data.region) {
this.mapId = elem.mapId;
}
});
const res = await getPublishMapInfo(this.mapId);
if (res.data) {
this.lineCode = res.data.lineCode;
}
},
async createQuicklySave(data) {
this.OrganizationList.forEach(elem => {
if (elem.id == data.region) {
this.mapId = elem.mapId;
}
});
async createQuickly() {
const resp = await getExamLessonDetail(this.$route.params.ruleId);
const ruleList = resp.data.examDefinitionRulesVOList;
const result = {
duration: Number(data.duration) * 60, //
duration: Number(this.examData.duration) * 60, //
examDefinitionRulesVOList: ruleList, //
fullPoint: Number(data.fullMark), //
lessonId: data.region, // id
name: data.name, //
passingPoint: Number(data.passMark), //
remarks: data.desc, //
endTime: data.endDate,
startTime: data.startDate,
type: data.type, //
trial: data.trial == 2 //
fullPoint: Number(this.examData.fullMark), //
mapId: this.examData.mapId, // id
prdType: this.examData.prdType,
name: this.examData.name, //
passingPoint: Number(this.examData.passMark), //
remarks: this.examData.desc, //
endTime: this.examData.endDate,
startTime: this.examData.startDate,
type: this.examData.type, //
trial: this.examData.trial == 2 //
};
let res = {};
try {
res = await setCourseList(result);
res = await createExam(result);
this.$message.success({ message: res.message });
this.$store.dispatch('exam/setRuleList', []); //
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`;
const lessonId = this.$route.params.lessonId;
this.$store.dispatch('exam/setCourseDetail', {});
if (parseInt(lessonId)) {
this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, lessonId: lessonId, noPreLogout: this.$route.query.noPreLogout } });
} else {
this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout } });
}
} catch (error) {
if (error) {
this.$messageBox(`${this.$t('publish.saveRuleFailed')} ${error.message}`);
@ -155,23 +130,11 @@ export default {
}
}
},
regulation(data) {
this.formData = data;
this.display = 1;
this.$nextTick(() => {
if (this.$refs.exam) {
this.$refs.exam.setData(this.formData);
}
});
},
createQuickly() {
this.$refs.exam.createQuickly();
},
prevStep() {
this.$refs.rule.regulation();
},
nextStep() {
this.$refs.exam.submitForm();
this.display = 2;
},
update() {
this.$refs.exam.updateForm();
@ -181,11 +144,8 @@ export default {
},
turnback() {
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`;
const lessonId = this.$route.params.lessonId;
if (this.$route.query.source === 'org') {
this.$router.go(-1);
} else if (parseInt(lessonId)) {
this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, lessonId: lessonId, noPreLogout: this.$route.query.noPreLogout } });
} else {
this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
}

View File

@ -1,12 +1,20 @@
<template>
<div class="exam-rule">
<span>{{ $t('publish.fullScoreTips') }} {{ course.fullMark }} {{ $t('publish.scorePoints') }}</span>
<span>{{ $t('publish.fullScoreTips') }} {{ examData.fullMark }} {{ $t('publish.scorePoints') }}</span>
<el-button class="addList" size="small" @click="handleAdd">{{ $t('publish.addRules') }}</el-button>
<el-table :data="ruleList" border show-summary style="width: 100%; min-height: 300px;">
<el-table-column prop="name" :label="$t('publish.trainingType')" />
<el-table :data="ruleList" border show-summary style="width: 100%; min-height: 300px;" :summary-method="getSummaries">
<el-table-column prop="name" :label="$t('publish.trainingType')">
<template slot-scope="scope">
<span>{{ getOperateName(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column prop="num" :label="$t('publish.questionsNumber')" width="100" />
<el-table-column prop="point" :label="$t('publish.eachScore')" width="100" />
<el-table-column prop="chapterIdLong" :label="$t('publish.totalScore')" width="100" />
<el-table-column :label="$t('publish.totalScore')" width="100">
<template slot-scope="scope">
<span>{{ Number(scope.row.num) * Number(scope.row.point) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('global.operate')" width="100">
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleForm(scope)">{{ $t('global.edit') }}</el-button>
@ -16,8 +24,13 @@
</el-table>
<edit-rule
ref="addRule"
:course-id="courseId"
:line-code="lineCode"
:map-id="examData.mapId"
:operation-type-map="operationTypeMap"
:training-operate-type-map="trainingOperateTypeMap"
:training-type-nums="trainingTypeNums"
:operation-type-nums="operationTypeNums"
:training-type-list="trainingTypeList"
:prd-type="examData.prdType"
@addRuleList="addRuleList"
@editRuleList="editRuleList"
/>
@ -25,11 +38,11 @@
</template>
<script>
import { getExamLessonDetail, setCourseList } from '@/api/management/exam';
import { UrlConfig, getTrainingOperateTypeMap } from '@/scripts/ConstDic';
import { createExam } from '@/api/management/exam';
import { UrlConfig, getOperateTypeMap } from '@/scripts/ConstDic';
import editRule from './editRule';
import LangStorage from '@/utils/lang';
import ConstConfig from '@/scripts/ConstConfig';
import { getTrainingTypeAndNumByMapIdAndPrdType } from '@/api/jmap/training';
export default {
name: 'Rule',
@ -37,109 +50,82 @@ export default {
editRule
},
props: {
course: {
examData: {
type: Object,
default: null
},
lineCode: {
type: String,
default: ''
ruleList: {
type: Array,
default() {
return [];
}
}
},
data() {
return {
ruleList: this.$store.state.exam.ruleList,
courseId: this.course.region,
formDetail: {
name: '',
region: '',
startDate: '',
endDate: '',
desc: '',
type: '',
duration: '',
fullMark: '',
passMark: ''
},
form: {
course: '',
number: '',
mark: ''
},
typeList: [],
trainingOperateTypeMap: {}
operationTypeMap: {},
trainingOperateTypeMap: {},
trainingTypeNums:{}, //
operationTypeNums: {}, //
trainingTypeList: [] //
};
},
computed: {
},
watch: {
},
async mounted() {
this.trainingOperateTypeMap = getTrainingOperateTypeMap();
await this.getList();
await this.init();
async created() {
getTrainingTypeAndNumByMapIdAndPrdType({ mapId: this.examData.mapId, prdType: this.examData.prdType }).then(res => {
const list = [];
this.trainingTypeNums = {};
const operateTypeMap = {};
this.operationTypeNums = res.data;
let val;
for (val in ConstConfig.ConstSelect.trainingDeviceType) {
if (res.data[val]) {
list.push({ value: val, label: ConstConfig.ConstSelect.trainingDeviceType[val].label});
this.trainingTypeNums[val] = 0;
const operateLabelMap = getOperateTypeMap(val);
operateTypeMap[val] = [];
let item;
for (item in res.data[val]) {
this.trainingTypeNums[val] += res.data[val][item];
operateTypeMap[val].push({ value: item, label:operateLabelMap[item] });
}
}
}
this.trainingTypeList = list;
this.operationTypeMap = operateTypeMap;
}).catch(() => {
this.$messageBox(this.$t('publish.refreshFailed'));
});
},
methods: {
async getList() {
this.typeList = [];
for (const val in ConstConfig.ConstSelect.trainingDeviceType) {
this.typeList.push({name: LangStorage.getLang() == 'en' ? ConstConfig.ConstSelect.trainingDeviceType[val].enlabel : ConstConfig.ConstSelect.trainingDeviceType[val].label, code: val});
}
},
async init() {
if (this.$route.params.ruleId != 0 && this.ruleList.length == 0) {
await getExamLessonDetail(this.$route.params.ruleId).then(res => {
if (res.code == 200) {
const arr = res.data.examDefinitionRulesVOList;
arr.forEach((ele, index) => {
this.typeList.forEach(v => {
if (ele.trainingType == v.code) {
arr[index].name = v.name;
if (ele.operateType) {
this.trainingOperateTypeMap[ele.trainingType].forEach(item => {
if (item.code == ele.operateType) {
arr[index].name = `${v.name}-${item.name || item.label}`;
return;
}
});
}
}
});
});
this.ruleList = arr;
this.$store.dispatch('exam/setRuleList', this.ruleList);
this.ruleList.forEach(res => {
res.chapterIdLong = Number(res.num) * Number(res.point);
});
this.changeCourseDisable();
}
});
}
},
handleAdd() {
this.$refs.addRule.show();
},
async creatOk() {
if (this.ruleList.length) {
let flag = 0;
this.ruleList.forEach(res => {
flag += Number(res.chapterIdLong);
this.ruleList.forEach(rule => {
flag = flag + (Number(rule.num) * Number(rule.point));
});
if (flag == this.course.fullMark) {
if (flag == this.examData.fullMark) {
const result = {
duration: Number(this.course.duration) * 60, //
duration: Number(this.examData.duration) * 60, //
examDefinitionRulesVOList: this.ruleList, //
fullPoint: Number(this.course.fullMark), //
lessonId: this.course.region, // id
name: this.course.name, //
passingPoint: Number(this.course.passMark), //
remarks: this.course.desc, //
endTime: this.course.endDate,
startTime: this.course.startDate,
type: this.course.type, //
trial: this.course.trial == 2 //
fullPoint: Number(this.examData.fullMark), //
mapId: this.examData.mapId,
prdType: this.examData.prdType,
name: this.examData.name, //
passingPoint: Number(this.examData.passMark), //
remarks: this.examData.desc, //
endTime: this.examData.endDate,
startTime: this.examData.startDate,
type: this.examData.type, //
trial: this.examData.trial == 2 //
};
if (this.course.classes) { result['classes'] = this.course.classes.map(ele => { return {id: ele}; }); }
await this.save(result);
} else {
this.$messageBox(this.$t('publish.addExamRluesError'));
@ -150,106 +136,103 @@ export default {
},
async save(data) {
try {
const res = await setCourseList(data);
const res = await createExam(data);
this.$message.success({ message: res.message });
this.$store.dispatch('exam/setCourseDetail', this.formDetail); // form
this.$store.dispatch('exam/setRuleList', []); //
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`;
const lessonId = this.$route.params.lessonId;
if (this.$route.query.source === 'org') {
this.$router.go(-1);
} else if (parseInt(lessonId)) {
this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, lessonId: lessonId, noPreLogout: this.$route.query.noPreLogout } });
} else {
this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
}
} catch (error) {
if (error) {
this.$messageBox(`${this.$t('publish.saveRuleFailed')} ${error.message}`);
} else {
this.$messageBox(`${this.$t('publish.saveRuleFailed')}`);
}
}
},
addRuleList(data, arr) {
let value;
arr.forEach(res => {
if (res.code == data.course) {
value = res;
return value;
}
});
let titleName = value.name;
if (data.name) {
titleName = `${value.name}-${data.name}`;
}
addRuleList(data) {
const element = {
trainingType: data.course,
trainingType: data.trainingType,
operateType: data.operateType,
num: Number(data.number),
point: Number(data.mark),
name: titleName,
chapterIdLong: Number(data.number) * Number(data.mark)
point: Number(data.mark)
};
this.ruleList.push(element);
this.$store.dispatch('exam/setRuleList', this.ruleList);
this.changeCourseDisable();
},
//
changeCourseDisable() {
const arr = this.$store.state.exam.courseList;
this.ruleList.forEach(ele => {
arr.forEach(res => {
if (ele.trainingType == res.code && !ele.operateType) {
res.disabled = true;
}
});
});
// const arr = this.$store.state.exam.courseList;
// this.ruleList.forEach(ele => {
// arr.forEach(res => {
// if (ele.trainingType == res.code && !ele.operateType) {
// res.disabled = true;
// }
// });
// });
},
editRuleList(data, arr) {
let value;
arr.forEach(res => {
if (res.code == data.course) {
value = res;
return value;
}
});
let titleName = value.name;
if (data.name) {
titleName = `${value.name}-${data.name}`;
}
getOperateName(row) {
const trainingName = ConstConfig.ConstSelect.trainingDeviceType[row.trainingType].label;
const operateName = getOperateTypeMap(row.trainingType)[row.operateType];
return `${trainingName}-${operateName}`;
},
editRuleList(data) {
const element = {
trainingType: data.course,
trainingType: data.trainingType,
operateType: data.operateType,
num: Number(data.number),
point: Number(data.mark),
name: titleName,
chapterIdLong: data.number * data.mark
point: Number(data.mark)
};
this.ruleList.splice(this.indexCourse, 1, element);
this.$set(this.ruleList, this.indexCourse, element);
},
handleForm(data) {
this.indexCourse = data.$index;
const list = JSON.stringify(data.row);
const detail = JSON.parse(list);
var arr = this.$store.state.exam.courseList;
arr.forEach(res => {
if (res.name == detail.name) {
detail.name = res.id;
return detail.name;
}
});
// var arr = this.$store.state.exam.courseList;
// arr.forEach(res => {
// if (res.name == detail.name) {
// detail.name = res.id;
// return detail.name;
// }
// });
this.$refs.addRule.show(detail);
},
deleteForm(data) {
const index = data.$index;
this.ruleList.splice(index, 1);
this.$refs.addRule.changeListDisabled(data.row.trainingType);
this.$store.dispatch('exam/setRuleList', this.ruleList);
},
regulation() {
this.$store.dispatch('exam/setRuleList', this.ruleList);
this.$emit('regulation', this.course);
},
getSummaries({ columns, data }) {
const sums = [];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计';
return;
} else if (index === 1) {
const values = data.map(item => Number(item.num));
sums[1] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
} else if ( index === 3) {
const values = data.map(item => Number(item.num) * Number(item.point));
sums[3] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0) + '分';
}
});
return sums;
}
}
};

View File

@ -13,7 +13,6 @@
<script>
import { getExamList, deleteExam, setExamEfficacy, setExamEffectivey } from '@/api/management/exam';
import { getPublishLessonList } from '@/api/jmap/lesson';
import { UrlConfig } from '@/scripts/ConstDic';
export default {
@ -24,7 +23,6 @@ export default {
OrderTypeList: [],
PayTypeList: [],
PayStatusList: [],
OrganizationList: [],
EffectiveTypeList: [],
userId: this.$store.state.user.id,
pagerConfig: {
@ -37,18 +35,17 @@ export default {
selectCheckShow: false,
indexShow: true,
columns: [
{
title: this.$t('publish.lessonName'),
prop: 'lessonId',
type: 'tag',
show: !this.$route.query.lessonId,
columnValue: (row) => { return this.$convertField(row.lessonId, this.OrganizationList, ['id', 'name']); },
tagType: (row) => { return ''; }
},
{
title: this.$t('publish.paperName'),
prop: 'name'
},
{
title: '产品类型',
prop: 'prdType',
type: 'tag',
columnValue: (row) => { if (row.prdType === '01') { return '现地工作站'; } else if (row.prdType === '02') { return '行调工作站'; } },
tagType: (row) => { return ''; }
},
{
title: this.$t('publish.creator'),
prop: 'creatorNickname'
@ -121,7 +118,7 @@ export default {
type: 'warning',
handleClick: this.handleEfficacy,
showControl: (row) => {
return !this.$route.query.lessonId && row.status == 1;
return row.status == 1;
}
},
{
@ -129,7 +126,7 @@ export default {
type: 'primary',
handleClick: this.handleEffective,
showControl: (row) => {
return (this.$route.query.lessonId ? row.creatorId == this.userId : true) && row.status != 1;
return row.status != 1;
}
},
{
@ -154,29 +151,15 @@ export default {
return this.$route.path.includes('device') ? {
labelWidth: '160px',
queryObject: {
'lessonId': {
type: this.$route.query.lessonId ? '' : 'select',
label: this.$t('publish.lessonName'),
config: {
data: []
}
},
'name': {
type: 'text',
label: this.$t('publish.paperName')
}
},
reset: !this.$route.query.lessonId
reset: true
} : {
labelWidth: '160px',
queryObject: {
'lessonId': {
type: this.$route.query.lessonId ? '' : 'select',
label: this.$t('publish.lessonName'),
config: {
data: []
}
},
'name': {
type: 'text',
label: this.$t('publish.paperName')
@ -186,7 +169,7 @@ export default {
label: this.$t('publish.creator')
}
},
reset: !this.$route.query.lessonId
reset: true
};
}
},
@ -194,27 +177,9 @@ export default {
this.loadInitData();
},
mounted() {
this.$store.dispatch('exam/setCourseDetail', {});
this.$store.dispatch('exam/setRuleList', []);
},
methods: {
loadInitData() {
this.queryForm.queryObject.lessonId.config.data.length = 0;
getPublishLessonList().then(response => {
this.OrganizationList = response.data;
this.OrganizationList.forEach(elem => {
if (elem.id == this.$route.query.lessonId) {
this.lessonName = elem.name;
}
if (this.$route.path.includes('device')) {
if (elem.mapId === this.$route.query.mapId) {
this.queryForm.queryObject.lessonId.config.data.push({ value: elem.id, label: elem.name });
}
} else {
this.queryForm.queryObject.lessonId.config.data.push({ value: elem.id, label: elem.name });
}
});
});
this.$Dictionary.effectiveType().then(list => {
this.$convertList(list, this.EffectiveTypeList, elem => {
@ -229,27 +194,22 @@ export default {
}
},
queryFunction(params) {
if (this.$route.query.lessonId) {
params.lessonId = this.$route.query.lessonId;
} else if (this.$route.path.includes('device')) {
if (this.$route.path.includes('device')) {
params.mapId = this.$route.query.mapId;
}
return getExamList(params);
},
handleNormalAdd() {
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleDraft}`;
const lessonId = this.$route.query.lessonId ? this.$route.query.lessonId : 0;
this.$router.replace({ path: `${path}/add/0/${lessonId}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
this.$router.replace({ path: `${path}/add/0/0`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
},
handleUpdate(index, data) {
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleDraft}`;
const lessonId = this.$route.query.lessonId ? this.$route.query.lessonId : 0;
this.$router.replace({ path: `${path}/edit/${data.id}/${lessonId}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
this.$router.replace({ path: `${path}/edit/${data.id}/0`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
},
handleDistribute(index, data) {
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleDraft}`;
const lessonId = this.$route.query.lessonId ? this.$route.query.lessonId : 0;
this.$router.replace({ path: `${path}/add/${data.id}/${lessonId}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
this.$router.replace({ path: `${path}/add/${data.id}/0`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
},
//
deleteList(index, data) {