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

View File

@ -207,6 +207,14 @@ export const UrlConfig = {
} }
}; };
import CMD from './cmdPlugin/CommandEnum'; 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() { export function getTrainingOperateTypeMap() {
const trainingOperateTypeMap = { const trainingOperateTypeMap = {
Switch: [], Switch: [],

View File

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

View File

@ -1,8 +1,8 @@
export function getBaseUrl() { export function getBaseUrl() {
let BASE_API; let BASE_API;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
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://192.168.8.107:9000'; // 袁琪 // BASE_API = 'http://192.168.8.107:9000'; // 袁琪
// BASE_API = 'http://192.168.8.129:9000'; // 旭强 // BASE_API = 'http://192.168.8.129:9000'; // 旭强
// BASE_API = 'http://192.168.8.119:9000'; // 张赛 // BASE_API = 'http://192.168.8.119:9000'; // 张赛

View File

@ -46,7 +46,6 @@
<div class="btn-buy"> <div class="btn-buy">
<!-- <el-button v-if="!isLocal" :disabled="disabled" type="success" @click="buy">{{ $t('exam.buy') }}</el-button> --> <!-- <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="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="backLessonList">{{ $t('exam.returnCourseList') }}</el-button>
<el-button v-if="$route.query.noPreLogout" type="primary" :disabled="disabled" @click="quit">退出</el-button> <el-button v-if="$route.query.noPreLogout" type="primary" :disabled="disabled" @click="quit">退出</el-button>
</div> </div>
@ -159,15 +158,6 @@ export default {
// }, 100); // }, 100);
this.$messageBox(this.$t('global.buyingTips')); 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() { // distribute() { //
this.disabled = true; this.disabled = true;
if (this.$refs) { if (this.$refs) {

View File

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

View File

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

View File

@ -1,14 +1,14 @@
<template> <template>
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogShow" :before-close="handleCancel" :close-on-click-modal="false"> <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 ref="form" :model="form" :rules="rules" label-width="140px">
<el-form-item :label="$t('publish.trainingType')" prop="course"> <el-form-item :label="$t('publish.trainingType')" prop="trainingType">
<el-select v-model="form.course" :placeholder="$t('publish.selectTypeScope')" :disabled="editOk" style="width:240px;" @change="changeCourse(form.course)"> <el-select v-model="form.trainingType" :placeholder="$t('publish.selectTypeScope')" :disabled="editOk" style="width:240px;" @change="changeCourse">
<el-option v-for="nor in options" :key="nor.id" :label="nor.name" :value="nor.code" :disabled="nor.disabled" /> <el-option v-for="nor in trainingTypeList" :key="nor.value" :label="nor.label" :value="nor.value" :disabled="nor.disabled" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('publish.operationType')"> <el-form-item :label="$t('publish.operationType')" prop="operateType">
<el-select v-model="form.operateType" clearable :placeholder="$t('publish.selectScope')" :disabled="editOk" @change="changeOperation(form.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.id" :label="nor.name" :value="nor.code" :disabled="nor.disabled" /> <el-option v-for="nor in operationTypeList" :key="nor.value" :label="nor.label" :value="nor.value" :disabled="nor.disabled" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('publish.questionNumbers')" prop="number"> <el-form-item :label="$t('publish.questionNumbers')" prop="number">
@ -31,23 +31,29 @@
</template> </template>
<script> <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 { export default {
name: 'EditRule', name: 'EditRule',
props: { props: {
courseId: { operationTypeMap: {
type: String, type: Object,
required:true
},
trainingOperateTypeMap: {
type: Object,
required:true
},
trainingTypeNums: {
type: Object,
required: true required: true
}, },
lineCode: { operationTypeNums: {
type: String, type: Object,
default: '' required: true
},
trainingTypeList: {
type: Array,
required: true
} }
}, },
data() { data() {
@ -82,7 +88,7 @@ export default {
return { return {
title: this.$t('publish.addRules'), title: this.$t('publish.addRules'),
form: { form: {
course: '', trainingType: '',
operateType: '', operateType: '',
number: '', number: '',
mark: 0 mark: 0
@ -91,7 +97,7 @@ export default {
dialogShow: false, dialogShow: false,
editOk: false, editOk: false,
rules: { rules: {
course: [ trainingType: [
{ required: true, message: this.$t('publish.selectTestType'), trigger: 'change' } { required: true, message: this.$t('publish.selectTestType'), trigger: 'change' }
], ],
number: [ number: [
@ -101,94 +107,42 @@ export default {
{ required: true, validator: mark, trigger: 'blur' } { required: true, validator: mark, trigger: 'blur' }
] ]
}, },
options: this.$store.state.exam.courseList,
typeList: [], typeList: [],
operationTypeList: [], operationTypeList: []
trainingOperateTypeMap: {}
}; };
}, },
async mounted() { 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'));
}
},
methods: { methods: {
show(detail) { show(detail) {
if (detail) {
this.title = this.$t('publish.modifyRules');
this.editOk = true;
this.changeCourse(detail.trainingType);
this.form = {
course: detail.trainingType,
operateType: detail.operateType,
number: detail.num,
mark: detail.point
};
this.changeOperation(detail.operateType);
}
this.dialogShow = true; this.dialogShow = true;
}, if (detail) {
checkIncludes(list, obj) { this.$nextTick(() => {
let flag = false; this.$refs.form.resetFields();
list.forEach(item => { this.title = this.$t('publish.modifyRules');
if (item.code === obj.value) { this.editOk = true;
flag = true; this.changeCourse(detail.trainingType);
} this.form = {
}); trainingType: detail.trainingType,
return flag; operateType: detail.operateType,
number: detail.num,
mark: detail.point
};
this.changeOperation(detail.operateType);
});
}
}, },
handleOk() { handleOk() {
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
if (valid) { if (valid) {
this.operationTypeList.forEach(item => {
if (item.code == this.form.operateType) {
this.form.name = item.name;
return;
}
});
if (this.editOk) { if (this.editOk) {
// //
this.$emit('editRuleList', this.form, this.options); this.$emit('editRuleList', this.form);
this.editOk = false;
setTimeout(() => { setTimeout(() => {
this.handleCancel(); this.handleCancel();
}, 300); }, 300);
} else { } else {
// //
this.$emit('addRuleList', this.form, this.options); this.$emit('addRuleList', this.form);
setTimeout(() => { setTimeout(() => {
this.handleCancel(); this.handleCancel();
}, 300); }, 300);
@ -202,104 +156,21 @@ export default {
}, },
handleCancel() { handleCancel() {
this.$refs['form'].resetFields(); this.$refs['form'].resetFields();
this.clearBoth();
this.dialogShow = false; this.dialogShow = false;
this.editOk = false; this.editOk = false;
this.topicNum = 0; this.topicNum = 0;
this.operationTypeList = []; this.operationTypeList = [];
}, },
clearBoth() { changeCourse(val) {
this.form = { this.operationTypeList = this.operationTypeMap[val];
course: '', this.topicNum = this.trainingTypeNums[val];
number: '',
mark: ''
};
}, },
// changeOperation(val) {
async refresh() { if (val) {
await getCourseTypeList({ lessonId: this.courseId }).then(res => { this.topicNum = this.operationTypeNums[this.form.trainingType][val];
const list = []; } else {
res.data.sort(); this.topicNum = this.trainingTypeNums[this.form.trainingType];
res.data.forEach(ele => {
this.typeList.forEach(v => {
if (ele == v.code) {
list.push(v);
}
});
});
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> <template>
<div class="exam-rule"> <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-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>
<el-form-item :label="$t('publish.testScope')" prop="region"> <el-form-item label="归属地图:" prop="mapId">
<el-select v-model="form.region" :placeholder="$t('publish.selectTestScope')" style="width: 100%;" :disabled="isEdit || selectDisable"> <el-select v-model="examData.mapId" placeholder="请选择归属地图" :disabled="isEdit">
<el-option v-for="nor in options" :key="nor.id" :label="nor.name" :value="nor.id" /> <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-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('publish.testDuration')" prop="duration"> <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> <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="$t('publish.testDate')"> <el-form-item :label="$t('publish.testDate')">
<el-col :span="11"> <el-col :span="11">
<el-form-item prop="startDate"> <el-form-item prop="startDate">
<el-date-picker <el-date-picker
v-model="form.startDate" v-model="examData.startDate"
type="datetime" type="datetime"
:placeholder="$t('publish.startTestTime')" :placeholder="$t('publish.startTestTime')"
style="width: 100%;" style="width: 100%;"
value-format="timestamp" value-format="yyyy-MM-dd HH:mm:ss"
:default-value="new Date()" :default-value="new Date()"
:picker-options="pickerOptions" :picker-options="pickerOptions"
@change="handle"
/> />
<!-- :disabled="isEdit" -->
</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="endDate"> <el-form-item prop="endDate">
<el-date-picker <el-date-picker
v-model="form.endDate" v-model="examData.endDate"
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%;"
value-format="timestamp"
:disabled="true"
/> />
<!-- :picker-options="pickerOptions" -->
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-form-item> </el-form-item>
<el-form-item :label="$t('publish.fullScore')" prop="fullMark"> <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>
<el-form-item :label="$t('publish.passingScore')" prop="passMark"> <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> </el-form-item>
<!-- v-if="trialShow" --> <el-form-item v-if="!$route.path.includes('info')" :label="$t('publish.whetherToTry')" required>
<el-form-item :label="$t('publish.whetherToTry')" required>
<el-radio-group v-model="trial"> <el-radio-group v-model="trial">
<el-radio label="1">{{ $t('publish.trialNo') }}</el-radio> <el-radio label="1">{{ $t('publish.trialNo') }}</el-radio>
<el-radio label="2">{{ $t('publish.trialYes') }}</el-radio> <el-radio label="2">{{ $t('publish.trialYes') }}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item :label="$t('publish.testDescription')" prop="desc"> <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-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> </el-form>
</div> </div>
</template> </template>
<script> <script>
import { getPublishLessonList, getLessonProjectListNoPage } from '@/api/jmap/lesson'; import { updateExamRules } from '@/api/management/exam';
import { getExamLessonDetail, updateExamRules } from '@/api/management/exam'; import { getMapListByProjectCode } from '@/api/jmap/map';
import { getSessionStorage } from '@/utils/auth';
import { ProjectCode } from '@/scripts/ProjectConfig';
export default { export default {
name: 'ExamFrom', name: 'ExamFrom',
props: {
examData: {
type: Object,
default() {
return {};
}
}
},
data() { 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 { return {
pickerOptions: { pickerOptions: {
disabledDate(time) { disabledDate(time) {
return time.getTime() < new Date(new Date().toLocaleDateString()).getTime(); return time.getTime() < new Date(new Date().toLocaleDateString()).getTime();
// return time.getTime() < Date.now() - 1 * 24 * 3600 * 1000;
} }
}, },
formDetail: { mapList: [],
name: '', prdList: [{ label: 'ATS现地工作站', value: '01' }, { label: 'ATS行调工作站', value: '02' }],
region: '',
startDate: '',
endDate: '',
desc: '',
type: '',
duration: '',
fullMark: '',
passMark: ''
},
trial: '1', trial: '1',
// trialShow: false,
form: this.$store.state.exam.courseDetail,
options: [], options: [],
selectDisable: false, selectDisable: false,
rules: { rules: {
name: [ name: [
{ required: true, message: this.$t('publish.inputTestName'), trigger: 'blur' } { required: true, message: this.$t('publish.inputTestName'), trigger: 'blur' }
], ],
region: [ prdType: [
{ required: true, message: this.$t('publish.selectTestScope'), trigger: 'change' } { required: true, message: '请选择产品类型', trigger: 'change' }
],
mapId: [
{ required: true, message: '请选择归属地图', trigger: 'change' }
], ],
duration: [ duration: [
{ required: true, validator: duration, trigger: 'blur' } { required: true, message: this.$t('publish.inputTestDuration'), trigger: 'blur' }
], ],
fullMark: [ fullMark: [
{ required: true, validator: fullMark, trigger: 'blur' } { required: true, message: this.$t('publish.inputFullScore'), trigger: 'blur' }
], ],
trial: [ trial: [
{ required: true, message: this.$t('publish.selectWetherTrial'), trigger: 'blur' } { required: true, message: this.$t('publish.selectWetherTrial'), trigger: 'blur' }
], ],
passMark: [ passMark: [
{ required: true, validator: passMark, trigger: 'blur' } { required: true, message: this.$t('publish.inputPassingScore'), trigger: 'blur' }
] ]
} }
}; };
@ -163,106 +119,29 @@ export default {
computed: { computed: {
isEdit() { isEdit() {
return this.$route.params.mode == 'edit'; 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() { created() {
this.refresh(); this.refresh();
}, },
mounted() { mounted() {
// const user = this.$store.state.user;
// const roles = user.roles;
// this.trialShow = roles.indexOf('04') != -1;
this.init();
}, },
methods: { 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) { submit(type) {
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
if (valid) { if (valid) {
const form = Object.assign({}, this.form); // const form = Object.assign({}, this.form);
if (form.startDate) { // if (form.startDate) {
form.startDate = this.getDate(form.startDate); // form.startDate = this.getDate(form.startDate);
} // }
if (form.endDate) { // if (form.endDate) {
form.endDate = this.getDate(form.endDate); // form.endDate = this.getDate(form.endDate);
} // }
form['trial'] = this.trial; // form['trial'] = this.trial;
this.$store.dispatch('exam/setCourseDetail', form); // this.$emit(type, form);
this.$emit(type, form);
} }
}); });
}, },
createQuickly() {
this.submit('createQuickly');
},
getDate(date) { getDate(date) {
const now = new Date(date); const now = new Date(date);
const y = now.getFullYear(); const y = now.getFullYear();
@ -275,47 +154,27 @@ export default {
if (valid) { if (valid) {
const model = { const model = {
id: this.$route.params.ruleId, id: this.$route.params.ruleId,
name: this.form.name, name: this.examData.name,
endTime: this.getDate(this.form.endDate), endTime: this.examData.endDate,
startTime: this.getDate(this.form.startDate), startTime: this.examData.startDate,
trial: this.trial == 2 trial: this.trial == 2
}; };
try { try {
await updateExamRules(model); await updateExamRules(model);
this.$store.dispatch('exam/setCourseDetail', this.form);
this.$message.success(this.$t('publish.updateExamRuleSuccess')); this.$message.success(this.$t('publish.updateExamRuleSuccess'));
// history.go(-1);
} catch (error) { } catch (error) {
this.$messageBox(this.$t('publish.updateExamRuleFailed')); this.$messageBox(this.$t('publish.updateExamRuleFailed'));
} }
} }
}); });
}, },
refresh() { refresh() {
if (this.$route.path.includes('info')) { const project = ProjectCode[getSessionStorage('project')];
getLessonProjectListNoPage().then(response => { getMapListByProjectCode(project).then(resp => {
this.options = response.data; this.mapList = resp.data;
if (parseInt(this.$route.params.lessonId)) { }).catch(e => {
this.form.region = this.$route.params.lessonId; this.$message.error('获取地图列表数据异常:' + e.message);
this.selectDisable = true; });
}
this.$nextTick(() => { this.$refs.form.clearValidate(); });
}).catch(() => {
this.$messageBox(this.$t('publish.refreshFailed'));
});
} 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> <template>
<div class="joylink-card" :class="lessonName ? 'card-box' : ''"> <div class="joylink-card">
<div v-if="lessonName" class="card-title"> <div class="exam-box">
{{ $t('publish.lessonName') }} {{ lessonName }}
</div>
<div class="exam-box" :style="{ 'height': lessonName ? 'calc(100% - 47px)' : '' }">
<el-steps class="steps" :active="display"> <el-steps class="steps" :active="display">
<el-step :title="$t('publish.testDefinitionMaking')" icon="el-icon-edit" /> <el-step :title="$t('publish.testDefinitionMaking')" icon="el-icon-edit" />
<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">
<template v-if="display == 1" class="definition"> <template v-if="display == 1" class="definition">
<exam-from ref="exam" @definition="definition" @createQuickly="createQuicklySave" /> <exam-from ref="exam" :exam-data="examData" />
</template> </template>
<template v-else class="rule"> <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> </template>
</div> </div>
<div class="draft"> <div class="draft">
@ -31,13 +28,10 @@
</template> </template>
<script> <script>
import { getPublishLessonList } from '@/api/jmap/lesson';
import RuleFrom from './rule'; import RuleFrom from './rule';
import ExamFrom from './examFrom'; import ExamFrom from './examFrom';
import { getPublishMapInfo } from '@/api/jmap/map'; import { getExamLessonDetail, createExam } from '@/api/management/exam';
import { getExamLessonDetail, setCourseList } from '@/api/management/exam';
import { UrlConfig } from '@/scripts/ConstDic'; import { UrlConfig } from '@/scripts/ConstDic';
import { getSessionStorage } from '@/utils/auth';
export default { export default {
name: 'ExamRule', name: 'ExamRule',
@ -48,12 +42,19 @@ export default {
data() { data() {
return { return {
display: 1, display: 1,
course: {}, examData: {
lessonName: '', name: '',
formData: {}, mapId: '',
mapId: '', prdType: '',
lineCode: '', startDate: '',
OrganizationList: [] endDate: '',
desc: '',
type: '',
duration: '',
fullMark: '',
passMark: ''
},
ruleList: []
}; };
}, },
computed: { computed: {
@ -73,80 +74,54 @@ export default {
return this.display == 1 && this.$route.params.mode != 'edit' && Number(this.$route.params.ruleId); return this.display == 1 && this.$route.params.mode != 'edit' && Number(this.$route.params.ruleId);
} }
}, },
watch: { created() {
'$store.state.exam.courseDetail': function (val) { if (this.$route.params.ruleId != 0) {
this.OrganizationList.forEach(elem => { getExamLessonDetail(this.$route.params.ruleId).then(res => {
if (elem.id === val.region) { this.examData = {
this.mapId = elem.mapId; name: res.data.name,
getPublishMapInfo(this.mapId).then(res=>{ mapId: res.data.mapId + '',
this.lineCode = res.data.lineCode; 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;
}); });
} }
}, },
created() {
this.loadInitData();
},
methods: { methods: {
loadInitData() { regulation() {
getPublishLessonList().then(response => { this.display = 1;
this.OrganizationList = response.data;
this.OrganizationList.forEach(elem => {
if (elem.id == this.$route.params.lessonId) {
this.lessonName = elem.name;
}
});
});
}, },
async definition(data) { async createQuickly() {
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;
}
});
const resp = await getExamLessonDetail(this.$route.params.ruleId); const resp = await getExamLessonDetail(this.$route.params.ruleId);
const ruleList = resp.data.examDefinitionRulesVOList; const ruleList = resp.data.examDefinitionRulesVOList;
const result = { const result = {
duration: Number(data.duration) * 60, // duration: Number(this.examData.duration) * 60, //
examDefinitionRulesVOList: ruleList, // examDefinitionRulesVOList: ruleList, //
fullPoint: Number(data.fullMark), // fullPoint: Number(this.examData.fullMark), //
lessonId: data.region, // id mapId: this.examData.mapId, // id
name: data.name, // prdType: this.examData.prdType,
passingPoint: Number(data.passMark), // name: this.examData.name, //
remarks: data.desc, // passingPoint: Number(this.examData.passMark), //
endTime: data.endDate, remarks: this.examData.desc, //
startTime: data.startDate, endTime: this.examData.endDate,
type: data.type, // startTime: this.examData.startDate,
trial: data.trial == 2 // type: this.examData.type, //
trial: this.examData.trial == 2 //
}; };
let res = {}; let res = {};
try { try {
res = await setCourseList(result); res = await createExam(result);
this.$message.success({ message: res.message }); this.$message.success({ message: res.message });
this.$store.dispatch('exam/setRuleList', []); // this.$store.dispatch('exam/setRuleList', []); //
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`; const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`;
const lessonId = this.$route.params.lessonId; this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout } });
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) { } catch (error) {
if (error) { if (error) {
this.$messageBox(`${this.$t('publish.saveRuleFailed')} ${error.message}`); 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() { prevStep() {
this.$refs.rule.regulation(); this.$refs.rule.regulation();
}, },
nextStep() { nextStep() {
this.$refs.exam.submitForm(); this.display = 2;
}, },
update() { update() {
this.$refs.exam.updateForm(); this.$refs.exam.updateForm();
@ -181,11 +144,8 @@ export default {
}, },
turnback() { turnback() {
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`; const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`;
const lessonId = this.$route.params.lessonId;
if (this.$route.query.source === 'org') { if (this.$route.query.source === 'org') {
this.$router.go(-1); 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 { } else {
this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} }); this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
} }

View File

@ -1,12 +1,20 @@
<template> <template>
<div class="exam-rule"> <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-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 :data="ruleList" border show-summary style="width: 100%; min-height: 300px;" :summary-method="getSummaries">
<el-table-column prop="name" :label="$t('publish.trainingType')" /> <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="num" :label="$t('publish.questionsNumber')" width="100" />
<el-table-column prop="point" :label="$t('publish.eachScore')" 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"> <el-table-column :label="$t('global.operate')" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" size="small" @click="handleForm(scope)">{{ $t('global.edit') }}</el-button> <el-button type="text" size="small" @click="handleForm(scope)">{{ $t('global.edit') }}</el-button>
@ -16,8 +24,13 @@
</el-table> </el-table>
<edit-rule <edit-rule
ref="addRule" ref="addRule"
:course-id="courseId" :map-id="examData.mapId"
:line-code="lineCode" :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" @addRuleList="addRuleList"
@editRuleList="editRuleList" @editRuleList="editRuleList"
/> />
@ -25,11 +38,11 @@
</template> </template>
<script> <script>
import { getExamLessonDetail, setCourseList } from '@/api/management/exam'; import { createExam } from '@/api/management/exam';
import { UrlConfig, getTrainingOperateTypeMap } from '@/scripts/ConstDic'; import { UrlConfig, getOperateTypeMap } from '@/scripts/ConstDic';
import editRule from './editRule'; import editRule from './editRule';
import LangStorage from '@/utils/lang';
import ConstConfig from '@/scripts/ConstConfig'; import ConstConfig from '@/scripts/ConstConfig';
import { getTrainingTypeAndNumByMapIdAndPrdType } from '@/api/jmap/training';
export default { export default {
name: 'Rule', name: 'Rule',
@ -37,109 +50,82 @@ export default {
editRule editRule
}, },
props: { props: {
course: { examData: {
type: Object, type: Object,
default: null default: null
}, },
lineCode: { ruleList: {
type: String, type: Array,
default: '' default() {
return [];
}
} }
}, },
data() { data() {
return { 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: [], typeList: [],
trainingOperateTypeMap: {} operationTypeMap: {},
trainingOperateTypeMap: {},
trainingTypeNums:{}, //
operationTypeNums: {}, //
trainingTypeList: [] //
}; };
}, },
computed: { computed: {
}, },
watch: { watch: {
}, },
async mounted() { async created() {
this.trainingOperateTypeMap = getTrainingOperateTypeMap(); getTrainingTypeAndNumByMapIdAndPrdType({ mapId: this.examData.mapId, prdType: this.examData.prdType }).then(res => {
await this.getList(); const list = [];
await this.init(); 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: { 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() { handleAdd() {
this.$refs.addRule.show(); this.$refs.addRule.show();
}, },
async creatOk() { async creatOk() {
if (this.ruleList.length) { if (this.ruleList.length) {
let flag = 0; let flag = 0;
this.ruleList.forEach(res => { this.ruleList.forEach(rule => {
flag += Number(res.chapterIdLong); flag = flag + (Number(rule.num) * Number(rule.point));
}); });
if (flag == this.course.fullMark) { if (flag == this.examData.fullMark) {
const result = { const result = {
duration: Number(this.course.duration) * 60, // duration: Number(this.examData.duration) * 60, //
examDefinitionRulesVOList: this.ruleList, // examDefinitionRulesVOList: this.ruleList, //
fullPoint: Number(this.course.fullMark), // fullPoint: Number(this.examData.fullMark), //
lessonId: this.course.region, // id mapId: this.examData.mapId,
name: this.course.name, // prdType: this.examData.prdType,
passingPoint: Number(this.course.passMark), // name: this.examData.name, //
remarks: this.course.desc, // passingPoint: Number(this.examData.passMark), //
endTime: this.course.endDate, remarks: this.examData.desc, //
startTime: this.course.startDate, endTime: this.examData.endDate,
type: this.course.type, // startTime: this.examData.startDate,
trial: this.course.trial == 2 // 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); await this.save(result);
} else { } else {
this.$messageBox(this.$t('publish.addExamRluesError')); this.$messageBox(this.$t('publish.addExamRluesError'));
@ -150,106 +136,103 @@ export default {
}, },
async save(data) { async save(data) {
try { try {
const res = await setCourseList(data); const res = await createExam(data);
this.$message.success({ message: res.message }); this.$message.success({ message: res.message });
this.$store.dispatch('exam/setCourseDetail', this.formDetail); // form
this.$store.dispatch('exam/setRuleList', []); // this.$store.dispatch('exam/setRuleList', []); //
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`; const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`;
const lessonId = this.$route.params.lessonId;
if (this.$route.query.source === 'org') { if (this.$route.query.source === 'org') {
this.$router.go(-1); 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 { } else {
this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} }); this.$router.replace({ path: `${path}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
} }
} catch (error) { } catch (error) {
if (error) { this.$messageBox(`${this.$t('publish.saveRuleFailed')} ${error.message}`);
this.$messageBox(`${this.$t('publish.saveRuleFailed')} ${error.message}`);
} else {
this.$messageBox(`${this.$t('publish.saveRuleFailed')}`);
}
} }
}, },
addRuleList(data, arr) { addRuleList(data) {
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}`;
}
const element = { const element = {
trainingType: data.course, trainingType: data.trainingType,
operateType: data.operateType, operateType: data.operateType,
num: Number(data.number), num: Number(data.number),
point: Number(data.mark), point: Number(data.mark)
name: titleName,
chapterIdLong: Number(data.number) * Number(data.mark)
}; };
this.ruleList.push(element); this.ruleList.push(element);
this.$store.dispatch('exam/setRuleList', this.ruleList);
this.changeCourseDisable(); this.changeCourseDisable();
}, },
// //
changeCourseDisable() { changeCourseDisable() {
const arr = this.$store.state.exam.courseList; // const arr = this.$store.state.exam.courseList;
this.ruleList.forEach(ele => { // this.ruleList.forEach(ele => {
arr.forEach(res => { // arr.forEach(res => {
if (ele.trainingType == res.code && !ele.operateType) { // if (ele.trainingType == res.code && !ele.operateType) {
res.disabled = true; // res.disabled = true;
} // }
}); // });
}); // });
}, },
editRuleList(data, arr) { getOperateName(row) {
let value; const trainingName = ConstConfig.ConstSelect.trainingDeviceType[row.trainingType].label;
arr.forEach(res => { const operateName = getOperateTypeMap(row.trainingType)[row.operateType];
if (res.code == data.course) { return `${trainingName}-${operateName}`;
value = res; },
return value; editRuleList(data) {
}
});
let titleName = value.name;
if (data.name) {
titleName = `${value.name}-${data.name}`;
}
const element = { const element = {
trainingType: data.course, trainingType: data.trainingType,
operateType: data.operateType, operateType: data.operateType,
num: Number(data.number), num: Number(data.number),
point: Number(data.mark), point: Number(data.mark)
name: titleName,
chapterIdLong: data.number * data.mark
}; };
this.ruleList.splice(this.indexCourse, 1, element); this.$set(this.ruleList, this.indexCourse, element);
}, },
handleForm(data) { handleForm(data) {
this.indexCourse = data.$index; this.indexCourse = data.$index;
const list = JSON.stringify(data.row); const list = JSON.stringify(data.row);
const detail = JSON.parse(list); const detail = JSON.parse(list);
var arr = this.$store.state.exam.courseList; // var arr = this.$store.state.exam.courseList;
arr.forEach(res => { // arr.forEach(res => {
if (res.name == detail.name) { // if (res.name == detail.name) {
detail.name = res.id; // detail.name = res.id;
return detail.name; // return detail.name;
} // }
}); // });
this.$refs.addRule.show(detail); this.$refs.addRule.show(detail);
}, },
deleteForm(data) { deleteForm(data) {
const index = data.$index; const index = data.$index;
this.ruleList.splice(index, 1); this.ruleList.splice(index, 1);
this.$refs.addRule.changeListDisabled(data.row.trainingType);
this.$store.dispatch('exam/setRuleList', this.ruleList);
}, },
regulation() { regulation() {
this.$store.dispatch('exam/setRuleList', this.ruleList);
this.$emit('regulation', this.course); 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> <script>
import { getExamList, deleteExam, setExamEfficacy, setExamEffectivey } from '@/api/management/exam'; import { getExamList, deleteExam, setExamEfficacy, setExamEffectivey } from '@/api/management/exam';
import { getPublishLessonList } from '@/api/jmap/lesson';
import { UrlConfig } from '@/scripts/ConstDic'; import { UrlConfig } from '@/scripts/ConstDic';
export default { export default {
@ -24,7 +23,6 @@ export default {
OrderTypeList: [], OrderTypeList: [],
PayTypeList: [], PayTypeList: [],
PayStatusList: [], PayStatusList: [],
OrganizationList: [],
EffectiveTypeList: [], EffectiveTypeList: [],
userId: this.$store.state.user.id, userId: this.$store.state.user.id,
pagerConfig: { pagerConfig: {
@ -37,18 +35,17 @@ export default {
selectCheckShow: false, selectCheckShow: false,
indexShow: true, indexShow: true,
columns: [ 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'), title: this.$t('publish.paperName'),
prop: 'name' 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'), title: this.$t('publish.creator'),
prop: 'creatorNickname' prop: 'creatorNickname'
@ -121,7 +118,7 @@ export default {
type: 'warning', type: 'warning',
handleClick: this.handleEfficacy, handleClick: this.handleEfficacy,
showControl: (row) => { showControl: (row) => {
return !this.$route.query.lessonId && row.status == 1; return row.status == 1;
} }
}, },
{ {
@ -129,7 +126,7 @@ export default {
type: 'primary', type: 'primary',
handleClick: this.handleEffective, handleClick: this.handleEffective,
showControl: (row) => { 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') ? { return this.$route.path.includes('device') ? {
labelWidth: '160px', labelWidth: '160px',
queryObject: { queryObject: {
'lessonId': {
type: this.$route.query.lessonId ? '' : 'select',
label: this.$t('publish.lessonName'),
config: {
data: []
}
},
'name': { 'name': {
type: 'text', type: 'text',
label: this.$t('publish.paperName') label: this.$t('publish.paperName')
} }
}, },
reset: !this.$route.query.lessonId reset: true
} : { } : {
labelWidth: '160px', labelWidth: '160px',
queryObject: { queryObject: {
'lessonId': {
type: this.$route.query.lessonId ? '' : 'select',
label: this.$t('publish.lessonName'),
config: {
data: []
}
},
'name': { 'name': {
type: 'text', type: 'text',
label: this.$t('publish.paperName') label: this.$t('publish.paperName')
@ -186,7 +169,7 @@ export default {
label: this.$t('publish.creator') label: this.$t('publish.creator')
} }
}, },
reset: !this.$route.query.lessonId reset: true
}; };
} }
}, },
@ -194,27 +177,9 @@ export default {
this.loadInitData(); this.loadInitData();
}, },
mounted() { mounted() {
this.$store.dispatch('exam/setCourseDetail', {});
this.$store.dispatch('exam/setRuleList', []);
}, },
methods: { methods: {
loadInitData() { 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.$Dictionary.effectiveType().then(list => {
this.$convertList(list, this.EffectiveTypeList, elem => { this.$convertList(list, this.EffectiveTypeList, elem => {
@ -229,27 +194,22 @@ export default {
} }
}, },
queryFunction(params) { queryFunction(params) {
if (this.$route.query.lessonId) { if (this.$route.path.includes('device')) {
params.lessonId = this.$route.query.lessonId;
} else if (this.$route.path.includes('device')) {
params.mapId = this.$route.query.mapId; params.mapId = this.$route.query.mapId;
} }
return getExamList(params); return getExamList(params);
}, },
handleNormalAdd() { handleNormalAdd() {
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleDraft}`; 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/0`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
this.$router.replace({ path: `${path}/add/0/${lessonId}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
}, },
handleUpdate(index, data) { handleUpdate(index, data) {
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleDraft}`; 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}/0`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
this.$router.replace({ path: `${path}/edit/${data.id}/${lessonId}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
}, },
handleDistribute(index, data) { handleDistribute(index, data) {
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleDraft}`; 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}/0`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
this.$router.replace({ path: `${path}/add/${data.id}/${lessonId}`, query: { mapId: this.$route.query.mapId, noPreLogout: this.$route.query.noPreLogout} });
}, },
// //
deleteList(index, data) { deleteList(index, data) {