rt-sim-training-client/src/views/publish/examRule/index.vue

333 lines
14 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-10-31 14:47:05 +08:00
<div class="joylink-card">
<div v-if="lessonName" class="card-title">
2019-08-29 17:16:33 +08:00
<b>{{ $t('publish.lessonName') }} {{ lessonName }}</b>
2019-08-08 14:32:32 +08:00
</div>
2019-10-31 14:47:05 +08:00
<div :style="{ 'height': lessonName ? 'calc(100% - 47px)' : '100%' }">
<el-scrollbar wrap-class="scrollbar-wrapper">
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
2019-08-08 14:32:32 +08:00
</el-scrollbar>
</div>
2019-10-31 14:47:05 +08:00
</div>
2019-07-26 13:32:43 +08:00
</template>
<script>
2019-08-08 14:32:32 +08:00
import { getExamList, deleteExam, setExamEfficacy, setExamEffectivey } from '@/api/management/exam';
2019-10-22 13:40:42 +08:00
import { getPublishLessonList } from '@/api/jmap/lesson';
import { UrlConfig } from '@/scripts/ConstDic';
2019-07-26 13:32:43 +08:00
2019-08-08 14:32:32 +08:00
export default {
2019-10-31 14:47:05 +08:00
name: 'List',
data() {
return {
BizTypeList: [],
OrderTypeList: [],
PayTypeList: [],
PayStatusList: [],
OrganizationList: [],
EffectiveTypeList: [],
userId: this.$store.state.user.id,
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
lessonName: '',
queryList: {
query: this.queryFunction,
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: this.$t('publish.creator'),
prop: 'creatorNickname'
2019-10-31 14:47:05 +08:00
},
{
title: this.$t('global.isTry'),
prop: 'trial',
type: 'tag',
columnValue: (row) => { return this.$ConstSelect.translate(row.trial, 'Whether'); },
tagType: (row) => {
switch (row.trial) {
case true: return 'success';
case false: return 'danger';
}
}
},
{
title: this.$t('global.duration'),
prop: 'duration',
type: 'tag',
columnValue: (row) => { return this.durationField(row.duration); },
tagType: (row) => { return ''; }
},
{
title: this.$t('publish.examTime'),
prop: 'startTime',
type: 'formatter',
format: 'yyyy-MM-dd hh:ss'
},
{
title: this.$t('publish.fullMark'),
prop: 'fullPoint'
},
{
title: this.$t('publish.passScore'),
prop: 'passingPoint'
},
{
title: this.$t('global.status'),
prop: 'status',
type: 'tag',
2020-07-08 10:43:56 +08:00
columnValue: (row) => { return row.status == '1' ? '有效' : row.overdue ? '过期' : '下架'; },
2019-10-31 14:47:05 +08:00
tagType: (row) => {
switch (row.status) {
case '1': return 'success';
default: return 'danger';
}
}
},
{
type: 'button',
title: this.$t('global.operate'),
width: '380',
buttons: [
{
name: this.$t('global.fastCreate'),
type: 'primary',
handleClick: this.handleDistribute,
showControl: (row) => { return row.bizType !== '02'; }
},
{
name: this.$t('global.edit'),
type: 'primary',
showControl: (row) => { return row.creatorId == this.userId; },
handleClick: this.handleUpdate
},
{
name: this.$t('global.soldOut'),
type: 'warning',
handleClick: this.handleEfficacy,
showControl: (row) => {
return !this.$route.query.lessonId && row.status == 1;
}
},
{
name: this.$t('global.putaway'),
type: 'primary',
handleClick: this.handleEffective,
showControl: (row) => {
return (this.$route.query.lessonId ? row.creatorId == this.userId : true) && row.status != 1;
}
},
{
name: this.$t('global.delete'),
type: 'danger',
handleClick: this.deleteList,
showControl: (row) => { return row.creatorId == this.userId; }
}
]
}
],
actions: [
{ text: this.$t('global.add'), btnCode: 'employee_insert', handler: this.handleNormalAdd },
2020-08-17 18:12:51 +08:00
{ text: this.$t('global.back'), show: !this.$route.path.includes('device'), btnCode: 'employee_back', handler: this.handlerBack }
2019-10-31 14:47:05 +08:00
]
}
};
},
2020-08-17 18:12:51 +08:00
computed: {
queryForm() {
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
} : {
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')
},
'creatorName': {
type: 'text',
label: this.$t('publish.creator')
}
},
reset: !this.$route.query.lessonId
};
}
},
2019-10-31 14:47:05 +08:00
created() {
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;
}
2020-08-17 18:12:51 +08:00
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 });
}
2019-10-31 14:47:05 +08:00
});
});
2019-07-26 13:32:43 +08:00
2019-10-31 14:47:05 +08:00
this.$Dictionary.effectiveType().then(list => {
this.$convertList(list, this.EffectiveTypeList, elem => {
return true;
});
});
},
durationField(fieldValue) {
if (fieldValue) {
const time = Number(fieldValue) / 60;
return `${time} ${this.$t('publish.durationMinutes')}`;
}
},
queryFunction(params) {
if (this.$route.query.lessonId) {
params.lessonId = this.$route.query.lessonId;
2020-08-17 18:12:51 +08:00
} else if (this.$route.path.includes('device')) {
params.mapId = this.$route.query.mapId;
2019-10-31 14:47:05 +08:00
}
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.push({ path: `${path}/add/0/${lessonId}`, query: {noPreLogout: this.$route.query.noPreLogout} });
2019-10-31 14:47:05 +08:00
},
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.push({ path: `${path}/edit/${data.id}/${lessonId}`, query: {noPreLogout: this.$route.query.noPreLogout} });
2019-10-31 14:47:05 +08:00
},
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.push({ path: `${path}/add/${data.id}/${lessonId}`, query: {noPreLogout: this.$route.query.noPreLogout} });
2019-10-31 14:47:05 +08:00
},
// 删除
deleteList(index, data) {
this.$confirm(this.$t('publish.wellDelPaper'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
deleteExam(data).then(res => {
this.queryList.reload();
this.$message({
type: 'success',
message: this.$t('publish.setSuccess')
});
}).catch(res => {
if (res.code == '500009') {
this.$message({ type: 'warning', message: this.$t('error.paperHasUseNotDel') });
} else {
this.$message({ type: 'error', message: this.$t('error.deleteException') });
}
});
}).catch(() => { });
},
// 下架
handleEfficacy(index, data) {
this.$confirm(this.$t('publish.wellSoldOutPaper'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
setExamEfficacy(data).then(res => {
this.queryList.reload();
this.$message({
type: 'success',
message: this.$t('publish.setSuccess')
});
}).catch(res => {
this.$message({ type: 'warning', message: `${this.$t('error.setFailed')}${res.message}` });
});
}).catch(() => { });
},
// 上架
handleEffective(index, data) {
this.$confirm(this.$t('publish.wellPutawayPaper'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
setExamEffectivey(data).then(res => {
this.queryList.reload();
this.$message({
type: 'success',
message: this.$t('publish.setSuccess')
});
}).catch(res => {
this.$message({ type: 'warning', message: `${this.$t('error.setFailed')}${res.message}` });
});
}).catch(() => { });
},
handlerBack() {
this.$router.back();
}
}
2019-08-08 14:32:32 +08:00
};
2019-07-26 13:32:43 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
2019-10-31 14:47:05 +08:00
.joylink-card {
height: 100%;
}
.card-title{
text-align: center;
height: 47px;
line-height: 47px;
border-bottom: 1px solid #e6e6e6;
}
2019-07-26 13:32:43 +08:00
/deep/ {
.is-always-shadow {
box-shadow: none;
border-bottom: none;
}
}
2019-08-08 14:32:32 +08:00
</style>