Commit 5e2315db authored by zhengke's avatar zhengke

修改

parent aef46923
<template> <template>
<div class="flex flex-start window-height"> <div class="flex flex-start window-height">
<div class="q-pa-lg full-height" style="border-right:1px solid #f5f5f5;width:450px;"> <q-splitter v-model="splitterModel" style="height: 100%;width:100%">
<template v-slot:before>
<div class="q-pa-lg full-height">
<q-card class="q-pa-md bg-dark text-white q-mb-lg"> <q-card class="q-pa-md bg-dark text-white q-mb-lg">
<span>{{courseInfo.CourseName}}</span> <span>{{courseInfo.CourseName}}</span>
</q-card> </q-card>
<div class="q-gutter-xs q-pb-lg" style="border-bottom:1px solid #f5f5f5;"> <div class="q-gutter-xs q-pb-lg" style="border-bottom:1px solid #f5f5f5;">
<q-btn color="primary" size="xs" unelevated label="同级目录" @click="addSameLevel"></q-btn> <q-btn color="primary" size="xs" unelevated label="同级目录" @click="addSameLevel"></q-btn>
<q-btn color="primary" size="xs" unelevated label="子目录" @click="addChildLevel"></q-btn> <q-btn color="primary" size="xs" unelevated label="子目录" @click="addChildLevel"></q-btn>
<q-btn color="primary" size="xs" title="向上移动" :disable="!canUp" @click="moveUp" outline icon="iconfont icon-up"></q-btn> <q-btn color="primary" size="xs" title="向上移动" :disable="!canUp" @click="moveUp" outline
<q-btn color="primary" size="xs" title="向下移动" :disable="!canDown" @click="moveDown" outline icon="iconfont icon-down1"></q-btn> icon="iconfont icon-up"></q-btn>
<q-btn color="primary" size="xs" title="向下移动" :disable="!canDown" @click="moveDown" outline
icon="iconfont icon-down1"></q-btn>
<q-btn color="primary" size="xs" title="导入 ..." unelevated label="导入 ..."></q-btn> <q-btn color="primary" size="xs" title="导入 ..." unelevated label="导入 ..."></q-btn>
</div> </div>
<div class="q-mt-lg" style="height:calc(100% - 140px)"> <div class="q-mt-lg" style="height:calc(100% - 140px)">
<q-scroll-area <q-scroll-area :thumb-style="thumbStyle" :content-style="contentStyle"
:thumb-style="thumbStyle" :content-active-style="contentActiveStyle" style="height: 100%; width: 100%;padding-right:10px;">
:content-style="contentStyle" <el-tree ref="chapterTree" :default-expanded-keys="defaultChapterId" @node-click="changeNode"
:content-active-style="contentActiveStyle" v-loading="canOptions" class="chapter-tree" :data="dataList" empty-text="暂无章节数据,请点击”添加同级“开始录入开始吧"
style="height: 100%; width: 100%;" :props="defaultProps" node-key="ChapterId" @node-drag-start="handleDragStart"
> @node-drag-enter="handleDragEnter" @node-drag-leave="handleDragLeave" @node-drag-over="handleDragOver"
<el-tree ref="chapterTree" :default-expanded-keys="defaultChapterId" @node-click="changeNode" v-loading="canOptions" class="chapter-tree" :data="dataList" empty-text="暂无章节数据,请点击”添加同级“开始录入开始吧" :props="defaultProps" node-key="ChapterId" @node-drag-start="handleDragStart" @node-drag-enter="handleDragEnter" @node-drag-leave="handleDragLeave" @node-drag-over="handleDragOver" @node-drag-end="handleDragEnd" @node-drop="handleDrop" draggable :allow-drop="allowDrop" :allow-drag="allowDrag"> @node-drag-end="handleDragEnd" @node-drop="handleDrop" draggable :allow-drop="allowDrop"
:allow-drag="allowDrag">
<div class="row chapter-node full-width" slot-scope="{ node, data }"> <div class="row chapter-node full-width" slot-scope="{ node, data }">
<div class="q-mr-md">{{ data.ChapterNo.length>1?data.ChapterNo:`0${data.ChapterNo}` }}</div> <div class="q-mr-md">{{ data.ChapterNo.length>1?data.ChapterNo:`0${data.ChapterNo}` }}</div>
<div class="col q-mr-xs" v-if="editorNodeId==data.ChapterId"> <div class="col q-mr-xs" v-if="editorNodeId==data.ChapterId">
<input type="text" @click.stop="" @blur="changeChapterName(data)" maxlength="100" @click.native="ChapterNameClick" class="tree-input" v-focus v-model="data.ChapterName" @focus="selectValue($event)" /> <input type="text" @click.stop="" @blur="changeChapterName(data)" maxlength="100"
@click.native="ChapterNameClick" class="tree-input" v-focus v-model="data.ChapterName"
@focus="selectValue($event)" />
</div> </div>
<div class="col q-mr-md ellipsis" v-if="editorNodeId!=data.ChapterId">{{data.ChapterName}}</div> <div class="col q-mr-md ellipsis" v-if="editorNodeId!=data.ChapterId">{{data.ChapterName}}</div>
<div class="oops-box q-mr-xs" v-if="editorNodeId!=data.ChapterId"> <div class="oops-box q-mr-xs" v-if="editorNodeId!=data.ChapterId">
...@@ -40,22 +47,27 @@ ...@@ -40,22 +47,27 @@
</q-scroll-area> </q-scroll-area>
</div> </div>
</div> </div>
</template>
<template v-slot:after>
<div class="col full-height q-pa-lg chapter-content scroll"> <div class="col full-height q-pa-lg chapter-content scroll">
<div v-if="chapter"> <div v-if="chapter">
<div class="text-h6 q-mb-md">章节学习内容</div> <div class="text-h6 q-mb-md">章节学习内容</div>
<div class="row q-mb-md"> <div class="row q-mb-md">
<div class="col q-mr-md"> <div class="col q-mr-md">
<q-input square filled label="消耗分钟" v-model="chapter.StudyMinutes" suffix="分钟" mask="#" fill-mask="0" reverse-fill-mask></q-input> <q-input square filled label="消耗分钟" v-model="chapter.StudyMinutes" suffix="分钟" mask="#" fill-mask="0"
reverse-fill-mask></q-input>
</div> </div>
<div class="col"> <div class="col">
<q-select :options="rateList" option-label="Name" option-value="Id" square filled label="关联等级" v-model="defauRateObj"></q-select> <q-select :options="rateList" option-label="Name" option-value="Id" square filled label="关联等级"
v-model="defauRateObj"></q-select>
</div> </div>
</div> </div>
<!-- <div v-if="chapter.ParentId!=0"> --> <!-- <div v-if="chapter.ParentId!=0"> -->
<div> <div>
<div class="text-h6 q-mb-md">章节学习内容</div> <div class="text-h6 q-mb-md">章节学习内容</div>
<div class="q-mb-md"> <div class="q-mb-md">
<editor v-model="chapter.ChapterContent" @blur="changeContent" placeHolder="请输入章节学习内容" :config="config" ref="chapterContent"></editor> <editor v-model="chapter.ChapterContent" @blur="changeContent" placeHolder="请输入章节学习内容" :config="config"
ref="chapterContent"></editor>
</div> </div>
<div class="text-h6 q-mb-md">教学重点</div> <div class="text-h6 q-mb-md">教学重点</div>
<div class="q-mb-md"> <div class="q-mb-md">
...@@ -63,23 +75,28 @@ ...@@ -63,23 +75,28 @@
</div> </div>
<div class="text-h6 q-mb-md">学生学习要求</div> <div class="text-h6 q-mb-md">学生学习要求</div>
<div class="q-mb-md"> <div class="q-mb-md">
<editor v-model="chapter.Requirement" placeHolder="请输入章节学生学习要求" :config="config" ref="requirement"></editor> <editor v-model="chapter.Requirement" placeHolder="请输入章节学生学习要求" :config="config" ref="requirement">
</editor>
</div> </div>
</div> </div>
<!-- <div v-else class="text-center text-h5 text-grey-4 q-mt-lg">单元节点不支持编辑相关内容</div> --> <!-- <div v-else class="text-center text-h5 text-grey-4 q-mt-lg">单元节点不支持编辑相关内容</div> -->
</div> </div>
</div> </div>
<q-btn round padding="md" v-if="chapter && chapter.ChapterId>0" @click="saveChapterUpdate" :loading="submiting" color="primary" class="fixed-bottom-right" label="保存" style="z-index:9999999;right:20px;bottom:100px;">
</template>
</q-splitter>
<q-btn round padding="md" v-if="chapter && chapter.ChapterId>0" @click="saveChapterUpdate" :loading="submiting"
color="primary" class="fixed-bottom-right" label="保存" style="z-index:9999999;right:20px;bottom:100px;">
<template v-slot:loading> <template v-slot:loading>
<q-spinner-ios /> <q-spinner-ios />
</template> </template>
</q-btn> </q-btn>
</div> </div>
</template> </template>
<script> <script>
import editor from "../../components/editor/UeEditor"; import editor from "../../components/editor/UeEditor";
import { import {
queryChapterTree, queryChapterTree,
saveChapter, saveChapter,
batchUpdateChapterNo, batchUpdateChapterNo,
...@@ -88,10 +105,14 @@ import { ...@@ -88,10 +105,14 @@ import {
queryCourseInfo, queryCourseInfo,
deleteChapters, deleteChapters,
setChaptersRate setChaptersRate
} from "../../api/course/index"; } from "../../api/course/index";
import {compareObject} from '../../utils/validate' import {
import { extend } from 'quasar' compareObject
export default { } from '../../utils/validate'
import {
extend
} from 'quasar'
export default {
meta: { meta: {
title: "课程章节详情" title: "课程章节详情"
}, },
...@@ -124,16 +145,16 @@ export default { ...@@ -124,16 +145,16 @@ export default {
canOptions: true, canOptions: true,
updateChapters: [], updateChapters: [],
editorNodeId: 0, editorNodeId: 0,
canUp:false, canUp: false,
canDown:false, canDown: false,
rateList:[], rateList: [],
defauRateObj:{ defauRateObj: {
Id:8, Id: 8,
Name:"其它" Name: "其它"
}, },
courseInfo:{}, courseInfo: {},
submiting:false, submiting: false,
bakObj:{}, bakObj: {},
contentStyle: { contentStyle: {
backgroundColor: 'rgba(0,0,0,0.02)', backgroundColor: 'rgba(0,0,0,0.02)',
color: '#555' color: '#555'
...@@ -151,12 +172,13 @@ export default { ...@@ -151,12 +172,13 @@ export default {
width: '5px', width: '5px',
opacity: 0.75 opacity: 0.75
}, },
defaultChapterId:0 defaultChapterId: 0,
splitterModel: 30 //左侧默认占据多大
}; };
}, },
created() { created() {
if(this.$route.query.chapter){ if (this.$route.query.chapter) {
this.defaultChapterId=this.$route.query.chapter this.defaultChapterId = this.$route.query.chapter;
} }
if (this.$route.query.courseId) { if (this.$route.query.courseId) {
this.courseId = this.$route.query.courseId; this.courseId = this.$route.query.courseId;
...@@ -173,8 +195,7 @@ export default { ...@@ -173,8 +195,7 @@ export default {
}, 3000); }, 3000);
}, },
methods: { methods: {
changeContent(){ changeContent() {},
},
getCourseInfo() { getCourseInfo() {
queryCourseInfo({ queryCourseInfo({
CourseId: this.courseId CourseId: this.courseId
...@@ -182,25 +203,25 @@ export default { ...@@ -182,25 +203,25 @@ export default {
this.courseInfo = res.Data; this.courseInfo = res.Data;
}) })
}, },
initRateList(){ initRateList() {
getCourseRate({}).then(r=>{ getCourseRate({}).then(r => {
this.rateList=r.Data this.rateList = r.Data
}) })
}, },
ChapterNameClick(){ ChapterNameClick() {
}, },
changeNode(data,node,ev){ changeNode(data, node, ev) {
if(this.chapter && this.chapter.ChapterId>0){ if (this.chapter && this.chapter.ChapterId > 0) {
if(this.defauRateObj.Id!=0){ if (this.defauRateObj.Id != 0) {
this.chapter.CourseRate=this.defauRateObj.Id this.chapter.CourseRate = this.defauRateObj.Id
this.chapter.CourseRateName=this.defauRateObj.Name this.chapter.CourseRateName = this.defauRateObj.Name
} }
if(!compareObject(this.bakObj,this.chapter,false)){ if (!compareObject(this.bakObj, this.chapter, false)) {
this.saveChapterUpdate() this.saveChapterUpdate()
if(this.bakObj.CourseRate!=this.chapter.CourseRate){ if (this.bakObj.CourseRate != this.chapter.CourseRate) {
if(this.chapter.ChildList && this.chapter.ChildList.length>0){ if (this.chapter.ChildList && this.chapter.ChildList.length > 0) {
this.updateRate() this.updateRate()
this.updateRateNode(this.chapter.ChildList) this.updateRateNode(this.chapter.ChildList)
} }
...@@ -208,50 +229,50 @@ export default { ...@@ -208,50 +229,50 @@ export default {
} }
} }
try { try {
data.ChapterContent=decodeURIComponent(data.ChapterContent) data.ChapterContent = decodeURIComponent(data.ChapterContent)
data.Objectives=decodeURIComponent(data.Objectives) data.Objectives = decodeURIComponent(data.Objectives)
data.Requirement=decodeURIComponent(data.Requirement) data.Requirement = decodeURIComponent(data.Requirement)
} catch (error) { } catch (error) {
} }
data.StudyMinutes=data.StudyMinutes.toString() data.StudyMinutes = data.StudyMinutes.toString()
this.chapter=data this.chapter = data
extend(this.bakObj,data) extend(this.bakObj, data)
if(this.$refs.chapterContent){ if (this.$refs.chapterContent) {
this.$refs.chapterContent.reloadNewValue() this.$refs.chapterContent.reloadNewValue()
this.$refs.objectives.reloadNewValue() this.$refs.objectives.reloadNewValue()
this.$refs.requirement.reloadNewValue() this.$refs.requirement.reloadNewValue()
} }
this.checkMove(node) this.checkMove(node)
this.rateList.forEach(x=>{ this.rateList.forEach(x => {
if(x.Id==data.CourseRate){ if (x.Id == data.CourseRate) {
this.defauRateObj=x this.defauRateObj = x
} }
}) })
}, },
updateRate(){ updateRate() {
setChaptersRate({ setChaptersRate({
CourseRate:this.defauRateObj.CourseRate, CourseRate: this.defauRateObj.CourseRate,
CourseId:this.courseId, CourseId: this.courseId,
ChapterNo:this.chapter.ChapterNo+"." ChapterNo: this.chapter.ChapterNo + "."
}).then(r=>{ }).then(r => {
//this.initTree() //this.initTree()
}) })
}, },
updateRateNode(arr){ updateRateNode(arr) {
arr.forEach(x=>{ arr.forEach(x => {
x.CourseRate=this.defauRateObj.Id x.CourseRate = this.defauRateObj.Id
x.CourseRateName=this.defauRateObj.Name x.CourseRateName = this.defauRateObj.Name
if(x.ChildList && x.ChildList.length>0){ if (x.ChildList && x.ChildList.length > 0) {
this.updateRateNode(x.ChildList) this.updateRateNode(x.ChildList)
} }
}) })
}, },
deleteObj(data){ deleteObj(data) {
this.$q.dialog({ this.$q.dialog({
title: '删除确认', title: '删除确认',
message: '删除章节节点将会连同下属章节也会一并删除且无法恢复,你确定要这样执行吗', message: '删除章节节点将会连同下属章节也会一并删除且无法恢复,你确定要这样执行吗',
...@@ -263,18 +284,18 @@ export default { ...@@ -263,18 +284,18 @@ export default {
label: "确认", label: "确认",
flat: true, flat: true,
focus: true, focus: true,
color:"negative" color: "negative"
} }
}).onOk(() => { }).onOk(() => {
deleteChapters({ deleteChapters({
CourseId:this.courseId, CourseId: this.courseId,
ChapterNo:data.ChapterNo+".", ChapterNo: data.ChapterNo + ".",
ChapterId:data.ChapterId ChapterId: data.ChapterId
}).then(r=>{ }).then(r => {
//this.initTree() //this.initTree()
this.$refs.chapterTree.remove(data.ChapterId) this.$refs.chapterTree.remove(data.ChapterId)
this.updateChapters = [] this.updateChapters = []
this.genernalNo("",this.dataList) this.genernalNo("", this.dataList)
if (this.updateChapters && this.updateChapters.length > 0) { if (this.updateChapters && this.updateChapters.length > 0) {
this.batchUpdate() this.batchUpdate()
} }
...@@ -291,20 +312,20 @@ export default { ...@@ -291,20 +312,20 @@ export default {
}) })
}, },
saveChapterUpdate(){ saveChapterUpdate() {
if(!this.submiting){ if (!this.submiting) {
this.submiting=true this.submiting = true
if(this.defauRateObj.Id!=0){ if (this.defauRateObj.Id != 0) {
this.chapter.CourseRate=this.defauRateObj.Id this.chapter.CourseRate = this.defauRateObj.Id
this.chapter.CourseRateName=this.defauRateObj.Name this.chapter.CourseRateName = this.defauRateObj.Name
} }
let msg={} let msg = {}
extend(msg,this.chapter) extend(msg, this.chapter)
msg.ChapterContent=encodeURIComponent(msg.ChapterContent) msg.ChapterContent = encodeURIComponent(msg.ChapterContent)
msg.Objectives=encodeURIComponent(msg.Objectives) msg.Objectives = encodeURIComponent(msg.Objectives)
msg.Requirement=encodeURIComponent(msg.Requirement) msg.Requirement = encodeURIComponent(msg.Requirement)
saveChapter(msg).then(r => { saveChapter(msg).then(r => {
this.submiting=false this.submiting = false
this.$q.notify({ this.$q.notify({
icon: 'iconfont icon-chenggong', icon: 'iconfont icon-chenggong',
color: 'accent', color: 'accent',
...@@ -312,39 +333,39 @@ export default { ...@@ -312,39 +333,39 @@ export default {
message: '数据保存成功!', message: '数据保存成功!',
position: 'top' position: 'top'
}) })
if(this.bakObj.CourseRate!=this.defauRateObj.Id){ if (this.bakObj.CourseRate != this.defauRateObj.Id) {
if(this.chapter.ChildList && this.chapter.ChildList.length>0){ if (this.chapter.ChildList && this.chapter.ChildList.length > 0) {
this.updateRate() this.updateRate()
this.updateRateNode(this.chapter.ChildList) this.updateRateNode(this.chapter.ChildList)
} }
extend(this.bakObj,this.chapter) extend(this.bakObj, this.chapter)
} }
}).catch(e=>{ }).catch(e => {
this.submiting=false this.submiting = false
}) })
} }
}, },
checkMove(node){ checkMove(node) {
let noTemp=node.data.ChapterNo.split('.') let noTemp = node.data.ChapterNo.split('.')
let no=parseInt(noTemp[noTemp.length-1]) let no = parseInt(noTemp[noTemp.length - 1])
let p=node.parent.data let p = node.parent.data
this.canUp=no!=1 this.canUp = no != 1
this.canDown=no!=p.length this.canDown = no != p.length
}, },
moveUp(){ moveUp() {
let data = this.$refs.chapterTree.getCurrentNode() let data = this.$refs.chapterTree.getCurrentNode()
let node=this.$refs.chapterTree.getNode(data.ChapterId) let node = this.$refs.chapterTree.getNode(data.ChapterId)
console.log(data) console.log(data)
if(node){ if (node) {
let noTemp=data.ChapterNo.toString().split('.') let noTemp = data.ChapterNo.toString().split('.')
let no=parseInt(noTemp[noTemp.length-1])-1 let no = parseInt(noTemp[noTemp.length - 1]) - 1
let p=node.parent.data let p = node.parent.data
if(data.ParentId==0){ if (data.ParentId == 0) {
p=this.swapArray(p,no,no-1) p = this.swapArray(p, no, no - 1)
}else{ } else {
p.ChildList=this.swapArray(p.ChildList,no,no-1) p.ChildList = this.swapArray(p.ChildList, no, no - 1)
} }
node.parent.childNodes=this.swapArray(node.parent.childNodes,no,no-1) node.parent.childNodes = this.swapArray(node.parent.childNodes, no, no - 1)
this.updateChapters = [] this.updateChapters = []
this.genernalNo("", this.dataList) this.genernalNo("", this.dataList)
this.checkMove(this.$refs.chapterTree.getNode(data.ChapterId)) this.checkMove(this.$refs.chapterTree.getNode(data.ChapterId))
...@@ -353,20 +374,20 @@ export default { ...@@ -353,20 +374,20 @@ export default {
} }
} }
}, },
moveDown(){ moveDown() {
let data = this.$refs.chapterTree.getCurrentNode() let data = this.$refs.chapterTree.getCurrentNode()
let node=this.$refs.chapterTree.getNode(data.ChapterId) let node = this.$refs.chapterTree.getNode(data.ChapterId)
console.log(data) console.log(data)
if(node){ if (node) {
let noTemp=data.ChapterNo.toString().split('.') let noTemp = data.ChapterNo.toString().split('.')
let no=parseInt(noTemp[noTemp.length-1])-1 let no = parseInt(noTemp[noTemp.length - 1]) - 1
let p=node.parent.data let p = node.parent.data
if(data.ParentId==0){ if (data.ParentId == 0) {
p=this.swapArray(p,no,no+1) p = this.swapArray(p, no, no + 1)
}else{ } else {
p.ChildList=this.swapArray(p.ChildList,no,no+1) p.ChildList = this.swapArray(p.ChildList, no, no + 1)
} }
node.parent.childNodes=this.swapArray(node.parent.childNodes,no,no+1) node.parent.childNodes = this.swapArray(node.parent.childNodes, no, no + 1)
this.updateChapters = [] this.updateChapters = []
this.genernalNo("", this.dataList) this.genernalNo("", this.dataList)
this.checkMove(this.$refs.chapterTree.getNode(data.ChapterId)) this.checkMove(this.$refs.chapterTree.getNode(data.ChapterId))
...@@ -382,13 +403,13 @@ export default { ...@@ -382,13 +403,13 @@ export default {
selectValue(e) { selectValue(e) {
e.currentTarget.select(); e.currentTarget.select();
}, },
changeChapterName(data){ changeChapterName(data) {
this.editorNodeId=0 this.editorNodeId = 0
let msg={ let msg = {
ChapterId:data.ChapterId, ChapterId: data.ChapterId,
ChapterName:data.ChapterName ChapterName: data.ChapterName
} }
updateChapterName(msg).then(r=>{ updateChapterName(msg).then(r => {
}) })
}, },
...@@ -396,18 +417,18 @@ export default { ...@@ -396,18 +417,18 @@ export default {
let temp = this.$refs.chapterTree.getCurrentNode() let temp = this.$refs.chapterTree.getCurrentNode()
if (!temp || temp.ParentId == 0) { if (!temp || temp.ParentId == 0) {
let no = this.dataList && this.dataList.length > 0 ? (this.dataList.length + 1) : 1 let no = this.dataList && this.dataList.length > 0 ? (this.dataList.length + 1) : 1
let t = this.createNewNode(0, no,8,'其它') let t = this.createNewNode(0, no, 8, '其它')
saveChapter(t).then(r => { saveChapter(t).then(r => {
t.ChapterId=r.Data.ChapterId t.ChapterId = r.Data.ChapterId
this.dataList.push(t) this.dataList.push(t)
}) })
} else { } else {
let parentTemp = this.$refs.chapterTree.getNode(temp.ParentId).data let parentTemp = this.$refs.chapterTree.getNode(temp.ParentId).data
let no = parentTemp.ChildList && parentTemp.ChildList.length > 0 ? (parentTemp.ChildList.length + 1) : 1 let no = parentTemp.ChildList && parentTemp.ChildList.length > 0 ? (parentTemp.ChildList.length + 1) : 1
no = parentTemp.ChapterNo + "." + no no = parentTemp.ChapterNo + "." + no
let t=this.createNewNode(parentTemp.ChapterId,no,parentTemp.CourseRate,parentTemp.CourseRateName) let t = this.createNewNode(parentTemp.ChapterId, no, parentTemp.CourseRate, parentTemp.CourseRateName)
saveChapter(t).then(r=>{ saveChapter(t).then(r => {
t.ChapterId=r.Data.ChapterId t.ChapterId = r.Data.ChapterId
parentTemp.ChildList.push(t) parentTemp.ChildList.push(t)
}) })
} }
...@@ -416,9 +437,9 @@ export default { ...@@ -416,9 +437,9 @@ export default {
let temp = this.$refs.chapterTree.getCurrentNode() let temp = this.$refs.chapterTree.getCurrentNode()
if (!temp) { if (!temp) {
let no = this.dataList && this.dataList.length > 0 ? (this.dataList.length + 1) : 1 let no = this.dataList && this.dataList.length > 0 ? (this.dataList.length + 1) : 1
let t = this.createNewNode(0, no, 8,'其它') let t = this.createNewNode(0, no, 8, '其它')
saveChapter(t).then(r => { saveChapter(t).then(r => {
t.ChapterId=r.Data.ChapterId t.ChapterId = r.Data.ChapterId
this.dataList.push(t) this.dataList.push(t)
}) })
} else { } else {
...@@ -427,9 +448,9 @@ export default { ...@@ -427,9 +448,9 @@ export default {
} }
let no = temp.ChildList && temp.ChildList.length > 0 ? (temp.ChildList.length + 1) : 1 let no = temp.ChildList && temp.ChildList.length > 0 ? (temp.ChildList.length + 1) : 1
no = temp.ChapterNo + "." + no no = temp.ChapterNo + "." + no
let t = this.createNewNode(temp.ChapterId, no,temp.CourseRate,temp.CourseRateName) let t = this.createNewNode(temp.ChapterId, no, temp.CourseRate, temp.CourseRateName)
saveChapter(t).then(r => { saveChapter(t).then(r => {
t.ChapterId=r.Data.ChapterId t.ChapterId = r.Data.ChapterId
temp.ChildList.push(t) temp.ChildList.push(t)
}) })
} }
...@@ -478,17 +499,17 @@ export default { ...@@ -478,17 +499,17 @@ export default {
console.log(r); console.log(r);
this.dataList = r.Data this.dataList = r.Data
this.canOptions = false this.canOptions = false
if(this.defaultChapterId!=0){ if (this.defaultChapterId != 0) {
setTimeout(() => { setTimeout(() => {
this.$refs.chapterTree.setCurrentKey(this.defaultChapterId) this.$refs.chapterTree.setCurrentKey(this.defaultChapterId)
let t=this.$refs.chapterTree.getNode(this.defaultChapterId) let t = this.$refs.chapterTree.getNode(this.defaultChapterId)
this.changeNode(t.data,t,null) this.changeNode(t.data, t, null)
}, 1000); }, 1000);
} }
}); });
}, },
createNewNode(pid, no,rate,crn) { createNewNode(pid, no, rate, crn) {
if (this.canOptions) return; if (this.canOptions) return;
let name = "" let name = ""
if (pid == 0) { if (pid == 0) {
...@@ -511,7 +532,7 @@ export default { ...@@ -511,7 +532,7 @@ export default {
StudyMinutes: 0, StudyMinutes: 0,
ChildList: [], ChildList: [],
CourseRate: rate, CourseRate: rate,
CourseRateName:crn CourseRateName: crn
} }
}, },
toChinesNum(num) { toChinesNum(num) {
...@@ -522,7 +543,8 @@ export default { ...@@ -522,7 +543,8 @@ export default {
let strArr = temp.toString().split("").reverse(); let strArr = temp.toString().split("").reverse();
let newNum = ""; let newNum = "";
for (var i = 0; i < strArr.length; i++) { for (var i = 0; i < strArr.length; i++) {
newNum = (i == 0 && strArr[i] == 0 ? "" : (i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? "" : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i]))) + newNum; newNum = (i == 0 && strArr[i] == 0 ? "" : (i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? "" : changeNum[
strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i]))) + newNum;
} }
return newNum; return newNum;
} }
...@@ -556,38 +578,40 @@ export default { ...@@ -556,38 +578,40 @@ export default {
}) })
} }
} }
}; };
</script> </script>
<style> <style>
.chapter-tree .chapter-node .oops-box, .chapter-tree .chapter-node .oops-box,
.chapter-tree .chapter-node:hover .rate-box{ .chapter-tree .chapter-node:hover .rate-box {
display: none; display: none;
} }
.chapter-tree .chapter-node:hover .oops-box, .chapter-tree .chapter-node:hover .oops-box,
.chapter-tree .chapter-node .rate-box { .chapter-tree .chapter-node .rate-box {
display: block; display: block;
} }
.chapter-tree .el-tree-node__content { .chapter-tree .el-tree-node__content {
height: 32px !important; height: 32px !important;
} }
.chapter-tree .el-tree-node__content:hover, .chapter-tree .el-tree-node__content:hover,
.chapter-tree .is-current>.el-tree-node__content { .chapter-tree .is-current>.el-tree-node__content {
background: #eaeff7 !important; background: #eaeff7 !important;
} }
.chapter-tree .el-tree-node__content{ .chapter-tree .el-tree-node__content {
border-radius: 4px; border-radius: 4px;
} }
.chapter-tree .tree-input { .chapter-tree .tree-input {
outline: none; outline: none;
border: none; border: none;
padding: 0 5px; padding: 0 5px;
font-size: 14px; font-size: 14px;
width: 100% width: 100%
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment