调整代码

This commit is contained in:
fan 2019-10-22 14:28:22 +08:00
parent 6d665acbb5
commit a49b195090
8 changed files with 244 additions and 189 deletions

View File

@ -4,8 +4,8 @@ export function getBaseUrl() {
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.3.5:9000'; // 袁琪 BASE_API = 'http://192.168.3.5:9000'; // 袁琪
BASE_API = 'http://192.168.3.6:9000'; // 旭强 // BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.41:9000'; // 王兴杰 // BASE_API = 'http://192.168.3.41:9000'; // 王兴杰
} else { } else {
BASE_API = process.env.VUE_APP_BASE_API; BASE_API = process.env.VUE_APP_BASE_API;

View File

@ -47,6 +47,7 @@
<el-button v-if="hasPermssion" type="primary" @click="distribute">{{ $t('exam.distributePermission') }}</el-button> <el-button v-if="hasPermssion" type="primary" @click="distribute">{{ $t('exam.distributePermission') }}</el-button>
<el-button v-if="hasPermssion" type="primary" @click="transfer">{{ $t('global.transferQRCode') }}</el-button> <el-button v-if="hasPermssion" type="primary" @click="transfer">{{ $t('global.transferQRCode') }}</el-button>
<el-button v-if="isAddRule" type="primary" @click="checkCourse">{{ $t('exam.viewCoursePapers') }}</el-button> <el-button v-if="isAddRule" type="primary" @click="checkCourse">{{ $t('exam.viewCoursePapers') }}</el-button>
<el-button type="primary" @click="backLessonList">返回课程列表</el-button>
</div> </div>
</el-card> </el-card>
</template> </template>
@ -195,6 +196,9 @@ export default {
if (expand instanceof Array) { if (expand instanceof Array) {
this.expandList = expand; this.expandList = expand;
} }
},
backLessonList() {
this.$router.push({ path: `${UrlConfig.trainingPlatform.examHome}/${this.$route.params.subSystem}`});
} }
} }
}; };

View File

@ -1,12 +1,26 @@
<template> <template>
<div> <div>
<transition> <el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: (height-125) +'px' }">
<router-view :style="{ position:'relative', left:widthLeft+'px', width: (width - widthLeft)+'px'}" :product-list="productList" /> <el-tree
</transition> ref="tree"
</div> :data="treeList"
node-key="id"
:props="defaultProps"
highlight-current
:span="22"
:filter-node-method="filterNode"
:default-expanded-keys="expandList"
@node-click="clickEvent"
/>
</el-scrollbar>
<transition>
<router-view :style="{ position:'relative', left:widthLeft+'px', width: (width - widthLeft)+'px'}" :product-list="productList" />
</transition>
</div>
</template> </template>
<script> <script>
import { getLessonTree } from '@/api/jmap/lessondraft';
export default { export default {
name: 'LessonDetail', name: 'LessonDetail',
data() { data() {
@ -14,8 +28,21 @@ export default {
}; };
}, },
computed: {
width() {
return this.$store.state.app.width - 481 - this.widthLeft;
},
height() {
return this.$store.state.app.height - 90;
}
},
mounted() {
this.initPageData();
},
methods: { methods: {
initPageData() {
getLessonTree(this.$route.query.lessonId);
}
} }
}; };
</script> </script>

View File

@ -1,168 +1,186 @@
<template> <template>
<el-card class="map-list-main" v-loading="loading"> <el-card v-loading="loading" class="map-list-main">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>{{$t('lesson.courseList')}}</span> <span>{{ $t('lesson.courseList') }}</span>
<el-button type="text" @click="publishCreate" style="float: right; padding: 3px 0">{{$t('lesson.createNewCoursesFromRelease')}}</el-button> <el-button type="text" style="float: right; padding: 3px 0" @click="publishCreate">{{ $t('lesson.createNewCoursesFromRelease') }}</el-button>
</div> </div>
<el-input :placeholder="this.$t('global.filteringKeywords')" v-model="filterText" clearable> </el-input> <el-input v-model="filterText" :placeholder="this.$t('global.filteringKeywords')" clearable />
<el-scrollbar wrapClass="scrollbar-wrapper" :style="{height: (height - 55) + 'px'}"> <el-scrollbar wrap-class="scrollbar-wrapper" :style="{height: (height - 55) + 'px'}">
<el-tree ref="lessonTree" :data="treeData" :props="defaultProps" :filter-node-method="filterNode" <el-tree
@node-contextmenu="showContextMenu" draggable :allow-drop="allowDrop" :allow-drag="allowDrag" ref="lessonTree"
@node-drag-end="handleDragEnd" expand-on-click-node highlight-current @node-click="clickEvent" :span=22> :data="treeData"
<span slot-scope="{ node, data }"> :props="defaultProps"
<span v-if="node.data.type === 'skin'" class="el-icon-news"></span> :filter-node-method="filterNode"
<span v-if="node.data.type === 'lesson'" class="el-icon-tickets"></span> draggable
<span v-if="node.data.type === 'chapter'" class="el-icon-document"></span> :allow-drop="allowDrop"
<span>&nbsp;{{ node.label }}</span> :allow-drag="allowDrag"
</span> expand-on-click-node
</el-tree> highlight-current
</el-scrollbar> :span="22"
<tree-operate-menu ref="treeOperateMenu" :point="point" :selected="selected" @refresh="refresh" @node-contextmenu="showContextMenu"
@lessonCreate="lessonCreate" @chapterCreate="chapterCreate" @treeSort="treeSort"></tree-operate-menu> @node-drag-end="handleDragEnd"
</el-card> @node-click="clickEvent"
>
<span slot-scope="{ node }">
<span v-if="node.data.type === 'skin'" class="el-icon-news" />
<span v-if="node.data.type === 'lesson'" class="el-icon-tickets" />
<span v-if="node.data.type === 'chapter'" class="el-icon-document" />
<span>&nbsp;{{ node.label }}</span>
</span>
</el-tree>
</el-scrollbar>
<tree-operate-menu
ref="treeOperateMenu"
:point="point"
:selected="selected"
@refresh="refresh"
@lessonCreate="lessonCreate"
@chapterCreate="chapterCreate"
@treeSort="treeSort"
/>
</el-card>
</template> </template>
<script> <script>
import { getLessonTree, dragSortLessonChapter } from '@/api/jmap/lessondraft' import { getLessonTree, dragSortLessonChapter } from '@/api/jmap/lessondraft';
import { DeviceMenu } from '@/scripts/ConstDic'; import { DeviceMenu } from '@/scripts/ConstDic';
import TreeOperateMenu from './operateMenu'; import TreeOperateMenu from './operateMenu';
import FilterCity from '@/views/components/filterCity'; import FilterCity from '@/views/components/filterCity';
export default { export default {
name: 'TrainingOperate', name: 'TrainingOperate',
components: { components: {
TreeOperateMenu, TreeOperateMenu
}, },
props: { props: {
height: { height: {
type: Number type: Number
} }
}, },
data() { data() {
return { return {
loading: true, loading: true,
defaultProps: { defaultProps: {
children: 'children', children: 'children',
label: 'name' label: 'name'
}, },
filterText: '', filterText: '',
node: {}, node: {},
selected: {}, selected: {},
menuoper: {}, menuoper: {},
treeData: [], treeData: [],
point: { point: {
x: 0, x: 0,
y: 0 y: 0
} }
} };
}, },
watch: { watch: {
filterText(val) { filterText(val) {
this.$refs.lessonTree.filter(val); this.$refs.lessonTree.filter(val);
} }
}, },
mounted() { mounted() {
this.refresh(); this.refresh();
}, },
methods: { methods: {
filterNode(value, data) { filterNode(value, data) {
if (!value) return true; if (!value) return true;
return data.name.indexOf(value) !== -1; return data.name.indexOf(value) !== -1;
}, },
allowDrop(draggingNode, dropNode, type) { allowDrop(draggingNode, dropNode, type) {
if (draggingNode && draggingNode.data.type === 'chapter') { if (draggingNode && draggingNode.data.type === 'chapter') {
return dropNode && dropNode.data.type === 'chapter'; return dropNode && dropNode.data.type === 'chapter';
} else if (draggingNode && draggingNode.data.type === 'training') { } else if (draggingNode && draggingNode.data.type === 'training') {
return dropNode && dropNode.data.type === 'training' && type !== 'inner' && draggingNode.parent == dropNode.parent; return dropNode && dropNode.data.type === 'training' && type !== 'inner' && draggingNode.parent == dropNode.parent;
} }
}, },
allowDrag(draggingNode) { allowDrag(draggingNode) {
return draggingNode && (draggingNode.data.type === 'chapter' || draggingNode.data.type === 'training'); return draggingNode && (draggingNode.data.type === 'chapter' || draggingNode.data.type === 'training');
}, },
handleDragEnd(draggingNode, dropNode, dropType, ev) { handleDragEnd(draggingNode, dropNode, dropType, ev) {
if (draggingNode && dropNode && dropType !== 'none') { if (draggingNode && dropNode && dropType !== 'none') {
let lesson = this.getLeesonId(dropNode); const lesson = this.getLeesonId(dropNode);
let lessonId = lesson.data.id; const lessonId = lesson.data.id;
let model = { const model = {
location: dropType, location: dropType,
sourceId: draggingNode.data.id, sourceId: draggingNode.data.id,
sourceType: draggingNode.data.type, sourceType: draggingNode.data.type,
targetId: dropNode.data.id, targetId: dropNode.data.id,
targetType: dropNode.data.type, targetType: dropNode.data.type,
lessonId: lessonId, lessonId: lessonId,
chapterId: dropNode.parent.data.id chapterId: dropNode.parent.data.id
} };
let that = this; dragSortLessonChapter(model).then(response => {
dragSortLessonChapter(model).then(response => { });
}) }
} },
}, getLeesonId(node) {
getLeesonId(node) { if (node.parent.parent !== null) {
if (null !== node.parent.parent) { return this.getLeesonId(node.parent);
return this.getLeesonId(node.parent); } else {
} else { return node;
return node; }
} },
}, showContextMenu(e, obj, node, vueElem) {
showContextMenu(e, obj, node, vueElem) { if (obj && (obj.type == 'lesson' || obj.type == 'chapter')) {
if (obj && (obj.type == 'lesson' || obj.type == 'chapter')) { e.preventDefault();
e.preventDefault(); this.point = {
this.point = { x: e.clientX,
x: e.clientX, y: e.clientY
y: e.clientY };
} this.node = node;
this.node = node; this.selected = obj;
this.selected = obj; const menu = DeviceMenu.Lesson;
let menu = DeviceMenu.Lesson; this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu });
this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu }); }
} },
}, clickEvent(obj, node, vueElem) {
clickEvent(obj, node, vueElem) { this.$store.dispatch('menuOperation/setPopMenu', { position: null, menu: null });
this.$store.dispatch('menuOperation/setPopMenu', { position: null, menu: null }); if (obj.type === 'skin') {
if (obj.type === 'skin') { this.$emit('lessonCreate', node);
this.$emit('lessonCreate', node); } else if (obj.type === 'lesson') {
} else if (obj.type === 'lesson') { this.$emit('lessonEdit', node);
this.$emit('lessonEdit', node); } else if (obj.type === 'chapter') {
} else if (obj.type === 'chapter') { this.$emit('chapterEdit', node);
this.$emit('chapterEdit', node); }
} },
}, chapterCreate() {
chapterCreate() { this.$emit('chapterCreate', this.node);
this.$emit('chapterCreate', this.node); },
}, lessonCreate() {
lessonCreate() { this.$emit('lessonCreate', this.node);
this.$emit('lessonCreate', this.node); },
}, publishCreate() {
publishCreate() { this.$emit('publishCreate', this.node);
this.$emit('publishCreate', this.node); },
}, treeSort() {
treeSort() { this.$emit('treeSort', this.node);
this.$emit('treeSort', this.node); },
}, convertTreeData(list) {
convertTreeData(list) { const tree = [];
let tree = []; if (list && list.length) {
if (list && list.length) { /* 去除列表的training节点*/
/*去除列表的training节点*/ list.forEach(elem => {
list.forEach(elem => { elem.children = this.convertTreeData(elem.children);
elem.children = this.convertTreeData(elem.children); if (elem.type !== 'training') {
if (elem.type !== 'training') { tree.push(elem);
tree.push(elem); }
} });
}) }
} return tree;
return tree; },
}, refresh() {
refresh() { this.loading = true;
this.loading = true; getLessonTree().then(response => {
getLessonTree().then(response => { this.treeData = this.convertTreeData(response.data);
this.treeData = this.convertTreeData(response.data); this.$nextTick(() => { this.loading = false; });
this.$nextTick(() => { this.loading = false; }); }).catch(() => {
}).catch(error => { this.$messageBox(this.$t('error.refreshFailed'));
this.$messageBox(this.$t('error.refreshFailed')); this.loading = false;
this.loading = false; });
}); }
} }
} };
}
</script> </script>
<style> <style>
.el-tree-node.is-current>.el-tree-node__content { .el-tree-node.is-current>.el-tree-node__content {

View File

@ -31,7 +31,7 @@
</el-scrollbar> </el-scrollbar>
</el-card> </el-card>
<div class="draft"> <div class="draft">
<el-button type="primary" @click="goBack">{{$t('global.back')}}</el-button> <el-button type="primary" @click="goBack">{{ $t('global.back') }}</el-button>
</div> </div>
</div> </div>
</template> </template>
@ -61,20 +61,21 @@ export default {
let tree = []; let tree = [];
if (data && list && list.length) { if (data && list && list.length) {
list.forEach(elem => { list.forEach(elem => {
if (elem.children){ if (elem.children) {
elem.children.forEach( item => { elem.children.forEach( item => {
if (data.id == item.id) { if (data.id == item.id) {
tree = [elem]; tree = [elem];
} }
}) });
} }
}); });
} }
return tree; return tree;
}, },
initData(data) { initData(data) {
getLessonTree({ mapId: '' }).then(response => { getLessonTree(data.id).then(response => {
this.treeData = this.convertTreeData(response.data, data); // this.treeData = this.convertTreeData(response.data, data);
this.treeData = response.data;
}).catch(() => { }).catch(() => {
this.$messageBox(this.$t('error.refreshFailed')); this.$messageBox(this.$t('error.refreshFailed'));
}); });
@ -92,11 +93,11 @@ export default {
return draggingNode && (draggingNode.data.type === 'chapter' || draggingNode.data.type === 'training'); return draggingNode && (draggingNode.data.type === 'chapter' || draggingNode.data.type === 'training');
}, },
getLeesonId(node) { getLeesonId(node) {
if (node.parent.data.type === 'lesson'){ if (node.parent.data.type === 'lesson') {
return node.parent.data.id; return node.parent.data.id;
}else { } else {
return this.getLeesonId(node.parent) return this.getLeesonId(node.parent);
} }
}, },
handleDragEnd(draggingNode, dropNode, dropType, ev) { handleDragEnd(draggingNode, dropNode, dropType, ev) {
if (draggingNode && dropNode && dropType !== 'none') { if (draggingNode && dropNode && dropType !== 'none') {
@ -116,9 +117,9 @@ export default {
}); });
} }
}, },
goBack() { goBack() {
this.$router.go(-1); this.$router.go(-1);
} }
} }
}; };
</script> </script>

View File

@ -43,6 +43,7 @@
<el-button type="success" @click="buy">{{ $t('teach.buy') }}</el-button> <el-button type="success" @click="buy">{{ $t('teach.buy') }}</el-button>
<el-button v-if="hasPermssion" type="primary" @click="distribute">{{ $t('teach.permissionDistribute') }}</el-button> <el-button v-if="hasPermssion" type="primary" @click="distribute">{{ $t('teach.permissionDistribute') }}</el-button>
<el-button v-if="hasPermssion" type="primary" @click="transfer">{{ $t('teach.authorityTransferred') }}</el-button> <el-button v-if="hasPermssion" type="primary" @click="transfer">{{ $t('teach.authorityTransferred') }}</el-button>
<el-button type="primary" @click="backLessonList">返回课程列表</el-button>
</div> </div>
</el-card> </el-card>
</template> </template>
@ -201,6 +202,9 @@ export default {
}).catch(() => { }); }).catch(() => { });
} }
} }
},
backLessonList() {
this.$router.push({ path: `${UrlConfig.trainingPlatform.teachHome}/${this.$route.params.subSystem}`});
} }
} }
}; };

View File

@ -37,6 +37,7 @@
<script> <script>
import { getSubSystemDetail } from '@/api/trainingPlatform'; import { getSubSystemDetail } from '@/api/trainingPlatform';
import { UrlConfig } from '@/router/index'; import { UrlConfig } from '@/router/index';
import localStore from 'storejs';
export default { export default {
name: 'TeachHome', name: 'TeachHome',

View File

@ -116,12 +116,12 @@ export default {
getSubSystemInfo(obj.id).then(resp => { getSubSystemInfo(obj.id).then(resp => {
switch (resp.data.type) { switch (resp.data.type) {
case 'Exam': case 'Exam':
this.setLocalRoute(`${UrlConfig.trainingPlatform.course}/${obj.id}`); this.setLocalRoute(`${UrlConfig.trainingPlatform.examHome}/${obj.id}`);
// this.$router.push({ path: `${UrlConfig.trainingPlatform.course}/${obj.id}`}); // this.$router.push({ path: `${UrlConfig.trainingPlatform.course}/${obj.id}`});
this.$router.push({ path: `${UrlConfig.trainingPlatform.examHome}/${obj.id}`}); this.$router.push({ path: `${UrlConfig.trainingPlatform.examHome}/${obj.id}`});
break; break;
case 'Lesson': case 'Lesson':
this.setLocalRoute(`${UrlConfig.trainingPlatform.teachDetail}/${obj.id}`); this.setLocalRoute(`${UrlConfig.trainingPlatform.teachHome}/${obj.id}`);
// this.$router.push({ path: `${UrlConfig.trainingPlatform.teachDetail}/${obj.id}`}); // this.$router.push({ path: `${UrlConfig.trainingPlatform.teachDetail}/${obj.id}`});
this.$router.push({ path: `${UrlConfig.trainingPlatform.teachHome}/${obj.id}`}); this.$router.push({ path: `${UrlConfig.trainingPlatform.teachHome}/${obj.id}`});
break; break;