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

195 lines
7.2 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-08-08 14:32:32 +08:00
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
2019-10-31 10:09:43 +08:00
<update-operate ref="updateLesson" :title="$t('publish.updateLesson')" @create="handleUpdate" />
<key-generation ref="keyGeneration" :map-list="mapList" @reloadTable="reloadTable" />
2019-08-08 14:32:32 +08:00
</div>
2019-07-26 13:32:43 +08:00
</template>
<script>
2019-10-31 10:09:43 +08:00
import { publishLessonList, delPublishLesson, putLessonOnLine, putLessonOffLine, updatePublishLesson } from '@/api/jmap/lesson';
2019-08-08 14:32:32 +08:00
import localStore from 'storejs';
import UpdateOperate from './draft.vue';
import KeyGeneration from './generate';
2019-11-08 13:41:22 +08:00
import { getPublishMapListOnline } from '@/api/jmap/map';
2019-07-26 13:32:43 +08:00
2019-08-08 14:32:32 +08:00
export default {
2019-10-31 10:09:43 +08:00
name: 'PublishMap',
components:{
UpdateOperate,
KeyGeneration
2019-10-31 10:09:43 +08:00
},
data() {
return {
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
mapList:[],
2019-10-31 10:09:43 +08:00
queryForm: {
labelWidth: '80px',
reset: true,
queryObject: {
name: {
type: 'text',
label: this.$t('global.name')
},
2019-11-08 10:21:54 +08:00
mapId: {
type: 'select',
label: this.$t('publish.belongsToMap'),
config: {
data: []
}
2019-10-31 10:09:43 +08:00
}
}
2019-07-26 13:32:43 +08:00
2019-10-31 10:09:43 +08:00
},
queryList: {
query: publishLessonList,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: this.$t('global.name'),
prop: 'name'
},
2019-11-08 10:21:54 +08:00
{
title: this.$t('publish.belongsToMap'),
prop: 'mapId',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.mapId, this.mapList, ['id', 'name']); },
tagType: (row) => { return 'success'; }
},
2019-10-31 10:09:43 +08:00
{
title: this.$t('publish.lessonIntroduction'),
prop: 'remarks'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '250',
buttons: [
{
name: this.$t('global.putaway'),
handleClick: this.handlePutaway,
type: '',
showControl: (row) => { return row.status != 1; }
},
{
name: this.$t('global.soldOut'),
handleClick: this.handleSoldOut,
type: 'warning',
showControl: (row) => { return row.status == 1; }
},
{
name: this.$t('global.edit'),
handleClick: this.handleEdit,
type: 'primary',
showControl: () => { return this.isShow != -1; }
},
{
name: this.$t('global.delete'),
handleClick: this.handleDelete,
type: 'danger',
showControl: () => { return this.isShow != -1; }
}
]
}
],
actions: [
{ text: '一键生成课程&试卷', handler: this.handleGenerate }
2019-10-31 10:09:43 +08:00
]
},
2019-07-26 13:32:43 +08:00
2019-10-31 10:09:43 +08:00
currentModel: {}
};
},
computed: {
isShow() {
return this.$store.getters['roles'].indexOf('05');
}
},
created() {
this.loadInitData();
},
methods: {
loadInitData() {
2019-11-08 10:21:54 +08:00
this.mapList = [];
2019-11-08 13:41:22 +08:00
getPublishMapListOnline().then(resp => {
2019-11-08 10:21:54 +08:00
this.mapList = resp.data;
this.mapList.forEach(elem => {
this.queryForm.queryObject.mapId.config.data.push({value: elem.id, label: elem.name});
});
});
2019-10-31 10:09:43 +08:00
},
// 编辑
handleEdit(index, row) {
this.$refs.updateLesson.doShow(row);
},
// 确认编辑
handleUpdate(data) {
updatePublishLesson(data).then(response => {
this.reloadTable();
this.$message.success(this.$t('publish.updateSuccess'));
}).catch(() => {
this.$messageBox(this.$t('error.updateFailed'));
});
},
// 删除
handleDelete(index, row) {
this.$confirm(this.$t('publish.wellDelType'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
delPublishLesson(row.id).then(response => {
this.$message.success(this.$t('publish.deleteSuccess'));
this.reloadTable();
localStore.remove('mapId');
2020-05-14 17:24:35 +08:00
}).catch((error) => {
2019-10-31 10:09:43 +08:00
this.reloadTable();
2020-05-14 17:24:35 +08:00
this.$messageBox(this.$t('error.deleteFailed') + ':' + error.message);
2019-10-31 10:09:43 +08:00
});
}).catch(() => { });
},
handlePutaway(index, row) {
this.$confirm(this.$t('publish.wellPutawayTraining'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
putLessonOnLine(row.id).then(response => {
this.$message.success(this.$t('publish.operationSuccess'));
this.reloadTable();
}).catch(() => {
this.reloadTable();
this.$messageBox(this.$t('error.operationFailure'));
});
}).catch(() => { });
},
2019-07-26 13:32:43 +08:00
2019-10-31 10:09:43 +08:00
handleSoldOut(index, row) {
this.$confirm(this.$t('publish.wellSoldOutTraining'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
putLessonOffLine(row.id).then(response => {
this.$message.success(this.$t('publish.operationSuccess'));
this.reloadTable();
}).catch(() => {
this.reloadTable();
this.$messageBox(this.$t('error.operationFailure'));
});
}).catch(() => { });
},
reloadTable() {
this.queryList.reload();
},
handleGenerate() {
this.$refs.keyGeneration.doShow();
2019-10-31 10:09:43 +08:00
}
}
2019-08-08 14:32:32 +08:00
};
</script>