|
@@ -3,14 +3,21 @@
|
|
|
<vuescroll>
|
|
|
<el-tree :data="treeDatas" :props="defaultProps" :allow-drop="allowDrop" class="tree" node-key="id"
|
|
|
default-expand-all highlight-current @node-drop="handleDrop" @node-click="onNodeClick"
|
|
|
- :draggable="editable" :expand-on-click-node="false" ref="tree">
|
|
|
+ :draggable="Boolean(editable)" :expand-on-click-node="false" ref="tree">
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
<span class="tree-node-lable">
|
|
|
{{data.title}}
|
|
|
<!-- {{data.id}} -->
|
|
|
- <Icon type="md-cube" :title="$t('syllabus.tree.hasResource')" v-if="data.rnodes && data.rnodes.length" />
|
|
|
+ <Icon type="md-cube" color="#00c38d" :title="$t('syllabus.tree.hasResource')" v-if="data.rnodes && data.rnodes.length" />
|
|
|
+ <Icon type="md-git-compare" color="#00c38d" :title="$t('syllabus.tree.hasCoEdit')" v-if="hasEditAuth(data) && isSchool" />
|
|
|
</span>
|
|
|
- <span class="custom-tree-tools" v-if="(hasEditAuth(data) || $access.can('admin.*|Syllabus_Edit'))">
|
|
|
+ <span class="custom-tree-tools" v-if="inShareView && isFirstLevel(data)">
|
|
|
+ <Icon type="md-copy" style="margin-right: 5px;" size="16" />
|
|
|
+ <span style="color: #9f9f9f;font-size: 12px;margin-right: 20px;" @click="onCopyChapter(data)">复制该章节</span>
|
|
|
+ <Icon type="ios-remove-circle-outline" style="margin-right: 5px;" size="16" />
|
|
|
+ <span style="color: #9f9f9f;font-size: 12px;margin-right: 20px;" @click="onIgnoreShare(data)">忽略该章节</span>
|
|
|
+ </span>
|
|
|
+ <span class="custom-tree-tools" v-if="((hasEditAuth(data) || $access.can('admin.*|Syllabus_Edit')) && !inShareView)">
|
|
|
<Icon type="md-create" size="16" :title="$t('syllabus.tree.edit')" @click="onEditItem(node,data,$event)" />
|
|
|
<Icon type="md-add" size="16" :title="$t('syllabus.tree.add')" @click="onAddNode(node,data,$event)" />
|
|
|
<Icon type="md-remove" size="16" :title="$t('syllabus.tree.remove')" @click="remove(node,data)" v-if="!isFirstLevel(data) || (canDeleteChapter(data) && isFirstLevel(data))"/>
|
|
@@ -33,11 +40,26 @@
|
|
|
<Button @click="onSubmitNode" class="modal-btn"
|
|
|
style="width: 88%;margin-left: 6%;margin-bottom: 20px;">{{ $t('syllabus.tree.confirm') }}</Button>
|
|
|
</Modal>
|
|
|
+
|
|
|
+ <!-- 新增或者编辑弹窗 -->
|
|
|
+ <Modal v-model="chapterCopyModal" width="500" footer-hide class="tree-modal add-volume-modal choose-content-modal">
|
|
|
+ <div class="modal-header" slot="header">复制节点</div>
|
|
|
+ <div class="modal-content">
|
|
|
+ <p class="node-title">当前章节: <span class="node-name">{{ curChapter.title }}</span></p>
|
|
|
+ <p class="node-title" style="display: inline-block;">目标册别:</p>
|
|
|
+ <Select v-model="copyTargetVolume" style="width: 300px;">
|
|
|
+ <Option v-for="(item,index) in volumeList" :value="index" :key="index">{{item.name}}</Option>
|
|
|
+ </Select>
|
|
|
+ </div>
|
|
|
+ <Button @click="doCopyChapter" :loading="isCopyBtnLoading" class="modal-btn"
|
|
|
+ style="width: 88%;margin-left: 6%;margin-bottom: 20px;">{{ $t('syllabus.tree.confirm') }}</Button>
|
|
|
+ </Modal>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import '@/utils/Math.uuid'
|
|
|
+ import BlobTool from '@/utils/blobTool.js'
|
|
|
import BaseResource from '@/view/syllabus/newSyllabus/operation/BaseResource'
|
|
|
import BaseKnowledge from '@/view/syllabus/newSyllabus/operation/BaseKnowledge'
|
|
|
import BaseQuestionList from '@/common/BaseQuestionList'
|
|
@@ -60,9 +82,12 @@
|
|
|
},
|
|
|
isEditOrAdd: false,
|
|
|
isLoading: false,
|
|
|
+ isCopyBtnLoading:false,
|
|
|
isRelatedContent: false,
|
|
|
isShowContent: false,
|
|
|
+ chapterCopyModal:false,
|
|
|
isEditItem: false,
|
|
|
+ copyTargetVolume:0,
|
|
|
contentIndex: '1',
|
|
|
currentVolume: null,
|
|
|
currentEditData: null,
|
|
@@ -71,6 +96,10 @@
|
|
|
currentItems: [],
|
|
|
curNode: null,
|
|
|
curData:null,
|
|
|
+ curChapter:{
|
|
|
+ id: null,
|
|
|
+ title: '',
|
|
|
+ },
|
|
|
nodeInfo: {
|
|
|
id: null,
|
|
|
title: '',
|
|
@@ -89,7 +118,8 @@
|
|
|
rnodes:[]
|
|
|
},
|
|
|
isSchool: false,
|
|
|
- flatArr:[]
|
|
|
+ flatArr:[],
|
|
|
+ flatRNodes:[],
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -104,11 +134,9 @@
|
|
|
node:node
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
doShare(data) {
|
|
|
this.$emit('doShare', data)
|
|
|
},
|
|
|
-
|
|
|
/* 禁止一级节点往下级进行拖拽 */
|
|
|
allowDrop(draggingNode, dropNode, dropType) {
|
|
|
if (draggingNode.level === dropNode.level) {
|
|
@@ -145,7 +173,298 @@
|
|
|
this.$parent.hasModify = true
|
|
|
|
|
|
},
|
|
|
-
|
|
|
+ /* 忽略某个章节的分享 */
|
|
|
+ onIgnoreShare(data){
|
|
|
+ this.$Modal.confirm({
|
|
|
+ title: this.$t('syllabus.tree.removeTitle'),
|
|
|
+ content: '确认忽略该章节吗?',
|
|
|
+ onOk: () => {
|
|
|
+ this.$api.syllabus.ShareAgree({
|
|
|
+ "code": this.$store.state.userInfo.TEAMModelId,
|
|
|
+ "id": data.id,
|
|
|
+ "type": "share",
|
|
|
+ "opt": "ignore"
|
|
|
+ }).then(res => {
|
|
|
+ if(res.status === 200){
|
|
|
+ this.$Message.success('操作成功!')
|
|
|
+ this.$parent.getShareVolumeList()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 复制章节到课纲 */
|
|
|
+ onCopyChapter(data){
|
|
|
+ if(this.volumeList.length){
|
|
|
+ this.curChapter = data
|
|
|
+ this.chapterCopyModal = true
|
|
|
+ }else{
|
|
|
+ this.$Message.warning('请先创建您的个人课纲!')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 复制章节的业务逻辑 */
|
|
|
+ async doCopyChapter(){
|
|
|
+ let targetVolume = this.volumeList[this.copyTargetVolume]
|
|
|
+ let allRNodes = this.getAllRNodes(JSON.parse(JSON.stringify(this.curChapter)))
|
|
|
+ let hasItemOrPaper = allRNodes.filter(i => i.type === 'item' || i.type === 'paper').length > 0
|
|
|
+ this.flatRNodes = allRNodes
|
|
|
+ this.isCopyBtnLoading = true
|
|
|
+ this.curChapter.auth = []
|
|
|
+ this.curChapter.pid = targetVolume.id
|
|
|
+ // 在复制章节过程中 如果章节节点以及子节点有关联试题试卷 则需要询问用户是否进行入库操作
|
|
|
+ if(hasItemOrPaper){
|
|
|
+ this.$Modal.confirm({
|
|
|
+ title: '提示',
|
|
|
+ content: '该章节中有关联试题试卷信息,是否需要同步到您的个人试题试卷库?',
|
|
|
+ okText: '同步并复制',
|
|
|
+ cancelText: '不需要',
|
|
|
+ onOk: async () => {
|
|
|
+ let copyResult = await this.doCopyResources(allRNodes,true)
|
|
|
+ console.log('复制后的回调',copyResult)
|
|
|
+ this.sendCopyApi(targetVolume)
|
|
|
+ },
|
|
|
+ onCancel: async () => {
|
|
|
+ let copyResult = await this.doCopyResources(allRNodes,false)
|
|
|
+ console.log('复制后的回调',copyResult)
|
|
|
+ this.sendCopyApi(targetVolume)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ let copyResult = await this.doCopyResources(allRNodes,false)
|
|
|
+ this.sendCopyApi(targetVolume)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 发送复制章节到个人课纲的请求API */
|
|
|
+ sendCopyApi(targetVolume){
|
|
|
+ console.log(JSON.stringify(this.flatRNodes))
|
|
|
+ let upsertParams = [{
|
|
|
+ id: this.curChapter.id,
|
|
|
+ volumeId: targetVolume.id,
|
|
|
+ scope: targetVolume.scope,
|
|
|
+ trees: [this.refreshCopyChapter(this.curChapter)]
|
|
|
+ }]
|
|
|
+ this.$api.syllabus.UpsertTree(upsertParams).then((res) => {
|
|
|
+ if (!res.error && res) {
|
|
|
+ this.$Message.success("复制成功");
|
|
|
+ this.chapterCopyModal = false
|
|
|
+ } else {
|
|
|
+ this.$Message.error("获取数据失败");
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ this.$Message.error(e);
|
|
|
+ }).finally(() => {
|
|
|
+ this.isCopyBtnLoading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 将复制的节点内的创建信息、code等更新为当前用户 */
|
|
|
+ refreshCopyChapter(chapterNode){
|
|
|
+ console.log(this.flatRNodes);
|
|
|
+ let myId = this.$store.state.userInfo.TEAMModelId
|
|
|
+ const fn = (source)=>{
|
|
|
+ source.creatorId = myId
|
|
|
+ if(source.rnodes.length){
|
|
|
+ source.rnodes.forEach(i => {
|
|
|
+ i.cntr = myId
|
|
|
+ i.code = i.code.split('-').length > 1 ? i.code.split('-')[0] + '-' + myId : myId
|
|
|
+ i.link = this.flatRNodes.find(j => j.id === i.id).link
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(source.children.length){
|
|
|
+ source.creatorId = myId
|
|
|
+ source.children.forEach(i => {
|
|
|
+ fn(i)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fn(chapterNode)
|
|
|
+ return chapterNode
|
|
|
+ },
|
|
|
+ /* 复制节点到个人课纲 需要把关联的内容全部拷贝到个人的BLOB容器内 */
|
|
|
+ doCopyResources(rnodes,needSave){
|
|
|
+ return new Promise((r,j) => {
|
|
|
+ let promiseArr = []
|
|
|
+ let tmdId = this.$store.state.userInfo.TEAMModelId
|
|
|
+ console.log(JSON.stringify(this.flatRNodes));
|
|
|
+ rnodes.forEach((file,fileIndex) => {
|
|
|
+ let copyFile = JSON.parse(JSON.stringify(file))
|
|
|
+ if(copyFile.type === 'item'){
|
|
|
+ promiseArr.push(this.copyItemToBlob(copyFile,needSave))
|
|
|
+ // 如果不入库 则需要修改资源的link地址
|
|
|
+ if(!needSave){
|
|
|
+ this.flatRNodes[fileIndex].link = '/syllabus/' + rnodes[fileIndex].id + '/' + rnodes[fileIndex].id + '.json'
|
|
|
+ }
|
|
|
+ }else if(copyFile.type === 'paper'){
|
|
|
+ promiseArr.push(this.copyPaperToBlob(copyFile,needSave))
|
|
|
+ // 如果不入库 则需要修改资源的link地址
|
|
|
+ if(!needSave){
|
|
|
+ this.flatRNodes[fileIndex].link = rnodes[fileIndex].link.replace('paper','syllabus')
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ promiseArr.push(this.copyFileToBlob(copyFile))
|
|
|
+ }
|
|
|
+ this.flatRNodes[fileIndex].code = this.flatRNodes[fileIndex].code.includes('-') ? this.flatRNodes[fileIndex].code.split('-')[0] + '-' + tmdId : tmdId
|
|
|
+ this.flatRNodes[fileIndex].cntr = tmdId
|
|
|
+ })
|
|
|
+ Promise.all(promiseArr).then(result => {
|
|
|
+ r(result)
|
|
|
+ console.log(result)
|
|
|
+ }).catch(err =>{
|
|
|
+ j(err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 根据醍摩豆ID获取对应BLOB个人容器授权信息 */
|
|
|
+ getBlobPrivateSas(tmdId){
|
|
|
+ return new Promise((r,j) => {
|
|
|
+ this.$api.blob.blobSasR({
|
|
|
+ name:tmdId,
|
|
|
+ role:'teacher'
|
|
|
+ }).then(res => {
|
|
|
+ if(!res.error){
|
|
|
+ r(res)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 复制试题到当前用户BLOB */
|
|
|
+ copyItemToBlob(resourceItem,needSave){
|
|
|
+ // console.log(JSON.stringify(rnodes))
|
|
|
+ return new Promise(async (r, j) => {
|
|
|
+ let toPath = needSave ? `item/${resourceItem.id}/` : `syllabus/${resourceItem.id}/`
|
|
|
+ // 是否入库 来决定保存的路径
|
|
|
+ let fromPath = `item/${resourceItem.id}`
|
|
|
+ // 试题的拥有者也就是复制的来源容器
|
|
|
+ let myId = this.$store.state.userInfo.TEAMModelId
|
|
|
+ let fileOwner = resourceItem.code.replace('Item-','')
|
|
|
+ let privateSas = await this.getBlobPrivateSas(fileOwner)
|
|
|
+ let privateBlobTool = new BlobTool(privateSas.url, privateSas.name, '?' + privateSas.sas,'private')
|
|
|
+ // 拿到试题的完整数据 方便保存到COSMOS
|
|
|
+ const itemJsonFile = await this.$evTools.getFullItemByTmdId(fileOwner, resourceItem.link)
|
|
|
+ let file = new File([JSON.stringify(itemJsonFile)],resourceItem.id + ".json", {type: "",});
|
|
|
+ console.log(itemJsonFile);
|
|
|
+ // 先把对应试题目录下的全部复制到校本BLOB 然后再更新添加学段科目等字段后的题目Json文件
|
|
|
+ this.$parent.containerClient.copyFolder(toPath,fromPath,privateBlobTool).then(async res => {
|
|
|
+ try{
|
|
|
+ itemJsonFile.blob = '/' + toPath + resourceItem.id + '.json'
|
|
|
+ itemJsonFile.code = myId
|
|
|
+ itemJsonFile.scope = resourceItem.scope
|
|
|
+ this.$parent.saveExercise(itemJsonFile).then(result => {
|
|
|
+ console.log(result)
|
|
|
+ r(result)
|
|
|
+ })
|
|
|
+ }catch(e){
|
|
|
+ j(e)
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ j(err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 根据关联的试卷资源获取数据库的试卷信息 方便复制的入库问题 */
|
|
|
+ getCosmosPaper(paperResourceItem){
|
|
|
+ console.log(JSON.stringify(paperResourceItem))
|
|
|
+ return new Promise((r,j) => {
|
|
|
+ this.$api.learnActivity.FindExamPaper({
|
|
|
+ id:paperResourceItem.id,
|
|
|
+ code:paperResourceItem.code.replace('Paper-',''),
|
|
|
+ scope:paperResourceItem.scope
|
|
|
+ }).then(res => {
|
|
|
+ if(!res.error && res.papers.length){
|
|
|
+ r(res.papers[0])
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ j(e)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 保存复制的试卷到cosmos */
|
|
|
+ async savePaperToCosmos(paperResourceItem){
|
|
|
+ console.log(JSON.stringify(paperResourceItem))
|
|
|
+ let cosmosPaper = await this.getCosmosPaper(paperResourceItem)
|
|
|
+ cosmosPaper.code = this.$store.state.userInfo.TEAMModelId
|
|
|
+ cosmosPaper.scope = 'pravite'
|
|
|
+ return new Promise(async (r,j) => {
|
|
|
+ let params = {
|
|
|
+ paper: cosmosPaper,
|
|
|
+ option: 'insert'
|
|
|
+ }
|
|
|
+ // 保存试卷到cosmos
|
|
|
+ this.$api.learnActivity.SaveExamPaper(params).then(
|
|
|
+ res => {
|
|
|
+ if (res.error == null) {
|
|
|
+ r(res)
|
|
|
+ } else {
|
|
|
+ r(res.error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ j(err)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 复制试题到当前用户BLOB */
|
|
|
+ copyPaperToBlob(resourceItem,needSave){
|
|
|
+ return new Promise(async (r, j) => {
|
|
|
+ let toPath = needSave ? `paper/${resourceItem.title}/` : `syllabus/${resourceItem.title}/`
|
|
|
+ // 是否入库 来决定保存的路径
|
|
|
+ let fromPath = `paper/${resourceItem.title}`
|
|
|
+ // 试题的拥有者也就是复制的来源容器
|
|
|
+ let myId = this.$store.state.userInfo.TEAMModelId
|
|
|
+ let fileOwner = JSON.parse(JSON.stringify(resourceItem.code)).replace('Paper-','')
|
|
|
+ let privateSas = await this.getBlobPrivateSas(fileOwner)
|
|
|
+ let privateBlobTool = new BlobTool(privateSas.url, privateSas.name, '?' + privateSas.sas,'private')
|
|
|
+ // 拿到试题的完整数据 方便保存到COSMOS
|
|
|
+ const paperJsonFile = await this.$evTools.getFullPaperByTmdId(fileOwner, resourceItem.link)
|
|
|
+ // let file = new File([JSON.stringify(paperJsonFile)],resourceItem.id + ".json", {type: "",});
|
|
|
+ // 先把对应试题目录下的全部复制到校本BLOB 然后再更新添加学段科目等字段后的题目Json文件
|
|
|
+ this.$parent.containerClient.copyFolder(toPath,fromPath,privateBlobTool).then(async res => {
|
|
|
+ try{
|
|
|
+ console.log(JSON.stringify(resourceItem))
|
|
|
+ this.savePaperToCosmos(resourceItem).then(result => {
|
|
|
+ console.log(result)
|
|
|
+ r(result)
|
|
|
+ })
|
|
|
+ }catch(e){
|
|
|
+ j(e)
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ j(err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 复制内容文件到当前用户BLOB */
|
|
|
+ copyFileToBlob(resourceItem){
|
|
|
+ return new Promise(async (r, j) => {
|
|
|
+ // 试题的拥有者也就是复制的来源容器
|
|
|
+ let fileOwner = resourceItem.code.replace('Paper-','')
|
|
|
+ let privateSas = await this.$evTools.getBlobPrivateSas(fileOwner)
|
|
|
+ let fullLink = this.$evTools.getBlobHost() + '/' + fileOwner + resourceItem.link
|
|
|
+ console.log(fullLink)
|
|
|
+ // 拿到试题的完整数据 方便保存到COSMOS
|
|
|
+ this.$parent.containerClient.copyBlob('syllabus/' + resourceItem.title, fullLink, privateSas).then(res => {
|
|
|
+ r(200)
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ j(err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 获取章节下所有的资源节点 */
|
|
|
+ getAllRNodes(chapterNode){
|
|
|
+ let result = []
|
|
|
+ const fn = (source)=>{
|
|
|
+ result.push(...source.rnodes)
|
|
|
+ if(source.children.length){
|
|
|
+ console.log(JSON.stringify(source.children[0].rnodes));
|
|
|
+ source.children.forEach(i => {
|
|
|
+ fn(i)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fn(chapterNode)
|
|
|
+ return result
|
|
|
+ },
|
|
|
// 删除节点操作
|
|
|
remove(node, data) {
|
|
|
let isFirstLevel = this.isFirstLevel(data)
|
|
@@ -168,6 +487,10 @@
|
|
|
this.$parent.modifyIdArr = this.$parent.modifyIdArr.filter(i => i !== data.id)
|
|
|
}
|
|
|
children.splice(index, 1)
|
|
|
+ this.$nextTick().then(() => {
|
|
|
+ const firstNode = document.querySelector('.el-tree-node')
|
|
|
+ firstNode.click();
|
|
|
+ })
|
|
|
this.$Message.success(this.$t('syllabus.tree.removeSucTip'))
|
|
|
} else {
|
|
|
this.$Message.warning(res.error);
|
|
@@ -184,7 +507,6 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
// 点击添加展开弹窗
|
|
|
onAddNode(node,data, e) {
|
|
|
e.stopPropagation() // 防止点击事件穿透到父层
|
|
@@ -196,7 +518,6 @@
|
|
|
this.nodeInfo.title = ''
|
|
|
this.curNode = node
|
|
|
},
|
|
|
-
|
|
|
// 编辑节点操作
|
|
|
onEditItem(node, data, e) {
|
|
|
e.stopPropagation() // 防止点击事件穿透到父层
|
|
@@ -208,7 +529,6 @@
|
|
|
this.nodeInfo.id = node.data.id
|
|
|
this.curNode = node
|
|
|
},
|
|
|
-
|
|
|
/* 根据节点获取它所在的章节信息 */
|
|
|
getChapterByNode(node){
|
|
|
console.log(node)
|
|
@@ -218,7 +538,6 @@
|
|
|
return this.getChapterByNode(node.parent)
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
// 提交编辑或者新增
|
|
|
onSubmitNode() {
|
|
|
if (!this.nodeInfo.title) {
|
|
@@ -248,7 +567,6 @@
|
|
|
this.$emit('addModifyId',this.getChapterIdById(this.curData.id))
|
|
|
this.$Message.success(this.isEditItem ? this.$t('syllabus.tree.editSucTip') : this.$t('syllabus.tree.addSucTip'))
|
|
|
},
|
|
|
-
|
|
|
/* 获取整个树的章节与子节点归属 */
|
|
|
getAllChild(arr){
|
|
|
let result = []
|
|
@@ -260,7 +578,6 @@
|
|
|
})
|
|
|
this.flatArr = result
|
|
|
},
|
|
|
-
|
|
|
/* 递归拉平所有children */
|
|
|
flatChildren(children){
|
|
|
let result = []
|
|
@@ -275,14 +592,13 @@
|
|
|
fn(children)
|
|
|
return result
|
|
|
},
|
|
|
-
|
|
|
/* 根据某个节点ID换取它对应的章节ID */
|
|
|
getChapterIdById(id){
|
|
|
if(this.flatArr.map(i => i.chapterId).includes(id)){
|
|
|
return id
|
|
|
}else{
|
|
|
let targetChapter = this.flatArr.find(i => i.children.includes(id))
|
|
|
- return targetChapter.chapterId
|
|
|
+ return targetChapter ? targetChapter.chapterId : 0
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -301,7 +617,6 @@
|
|
|
// 判断是否为一级节点,如果是二级节点则需要拿对应的一级节点去做判断
|
|
|
let chapterId = nodeData.pid === this.volume.id ? nodeData.id : this.getChapterIdById(nodeData.id)
|
|
|
let chapterNode = this.treeDatas.find(i => i.id === chapterId)
|
|
|
- console.log(this.volume);
|
|
|
return this.volume.creatorId === userId || (chapterNode.auth && chapterNode.auth.length && chapterNode.auth.map(i => i.tmdid).includes(userId))
|
|
|
}
|
|
|
},
|
|
@@ -310,6 +625,13 @@
|
|
|
return nodeData => {
|
|
|
return nodeData.creatorId === this.$store.state.userInfo.TEAMModelId
|
|
|
}
|
|
|
+ },
|
|
|
+ inShareView(){
|
|
|
+ return !this.isSchool && this.$parent.activeTab === 'fromShare'
|
|
|
+ },
|
|
|
+ volumeList(){
|
|
|
+ console.log(this.$parent)
|
|
|
+ return this.$parent.myVolumeList
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -328,13 +650,15 @@
|
|
|
})
|
|
|
},
|
|
|
immediate: true,
|
|
|
- deep:true
|
|
|
+ // deep:true
|
|
|
},
|
|
|
// 监听课纲数据变化
|
|
|
volume: {
|
|
|
handler: function(n, o) {
|
|
|
this.volume = n
|
|
|
- }
|
|
|
+
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
}
|
|
|
}
|
|
|
}
|