|
@@ -17,7 +17,7 @@
|
|
<span style="color: #F0F0F0;font-size: 18px;font-weight: bolder;">个人课纲</span>
|
|
<span style="color: #F0F0F0;font-size: 18px;font-weight: bolder;">个人课纲</span>
|
|
</div>
|
|
</div>
|
|
<Button @click="onSaveSyllabus" class="btn-save-modify" icon="md-folder"
|
|
<Button @click="onSaveSyllabus" class="btn-save-modify" icon="md-folder"
|
|
- v-if="$access.can('admin.*|Syllabus_Edit') && hasModify">存储变更</Button>
|
|
|
|
|
|
+ v-if="(hasSyllabusAuth || hasEditAuth(curNode)) && hasModify">存储变更</Button>
|
|
</div>
|
|
</div>
|
|
<div class="syllabus-content">
|
|
<div class="syllabus-content">
|
|
<div class="syllabus-left">
|
|
<div class="syllabus-left">
|
|
@@ -26,9 +26,9 @@
|
|
<span>册别清单</span>
|
|
<span>册别清单</span>
|
|
<span class="syllabus-content-header-tools">
|
|
<span class="syllabus-content-header-tools">
|
|
<Icon type="md-search" @click="doSearchVolume" />
|
|
<Icon type="md-search" @click="doSearchVolume" />
|
|
- <Icon type="md-create" @click="doEditVolume" v-if="$access.can('admin.*|Syllabus_Edit')"/>
|
|
|
|
- <Icon type="md-trash" @click="doDeleteVolume" v-if="$access.can('admin.*|Syllabus_Edit')"/>
|
|
|
|
- <Icon type="md-add" @click="doAddVolume" v-if="$access.can('admin.*|Syllabus_Edit')"/>
|
|
|
|
|
|
+ <Icon type="md-create" @click="doEditVolume" v-if="hasSyllabusAuth"/>
|
|
|
|
+ <Icon type="md-trash" @click="doDeleteVolume" v-if="hasSyllabusAuth"/>
|
|
|
|
+ <Icon type="md-add" @click="doAddVolume" v-if="hasSyllabusAuth"/>
|
|
</span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div style="width: 90%;" v-else>
|
|
<div style="width: 90%;" v-else>
|
|
@@ -56,13 +56,13 @@
|
|
<div class="syllabus-content-header">
|
|
<div class="syllabus-content-header">
|
|
<span>课纲目录</span>
|
|
<span>课纲目录</span>
|
|
<span class="syllabus-content-header-tools">
|
|
<span class="syllabus-content-header-tools">
|
|
- <Icon type="md-add" @click="isAddTreeModal = true" v-if="$access.can('admin.*|Syllabus_Edit')"/>
|
|
|
|
|
|
+ <Icon type="md-add" @click="isAddTreeModal = true" v-if="hasSyllabusAuth"/>
|
|
</span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="syllabus-tree-box">
|
|
<div class="syllabus-tree-box">
|
|
<EmptyData :top="-240" v-if="!treeOrigin.length"></EmptyData>
|
|
<EmptyData :top="-240" v-if="!treeOrigin.length"></EmptyData>
|
|
<Tree ref="treeRef" :treeData="treeOrigin" :volume="curVolume"
|
|
<Tree ref="treeRef" :treeData="treeOrigin" :volume="curVolume"
|
|
- :editable="$access.can('admin.*|Syllabus_Edit')" @onNodeClick="onNodeClick" @doShare="doShare" @addModifyId="addModifyId"v-else></Tree>
|
|
|
|
|
|
+ :editable="hasSyllabusAuth || hasEditAuth(curNode)" @onNodeClick="onNodeClick" @doShare="doShare" @addModifyId="addModifyId"v-else></Tree>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="syllabus-right">
|
|
<div class="syllabus-right">
|
|
@@ -70,7 +70,7 @@
|
|
<span>关联资源</span>
|
|
<span>关联资源</span>
|
|
<span class="syllabus-content-header-tools">
|
|
<span class="syllabus-content-header-tools">
|
|
<!-- <Icon type="md-add" @click="onAddResource" v-if="curNode.id"/> -->
|
|
<!-- <Icon type="md-add" @click="onAddResource" v-if="curNode.id"/> -->
|
|
- <Dropdown @on-click="onAddResource" v-if="curNode.id">
|
|
|
|
|
|
+ <Dropdown @on-click="onAddResource" v-if="curNode.id && (hasSyllabusAuth || hasEditAuth(curNode))">
|
|
<a href="javascript:void(0)" style="color: #ddd;">
|
|
<a href="javascript:void(0)" style="color: #ddd;">
|
|
添加资源
|
|
添加资源
|
|
<Icon type="ios-arrow-down"></Icon>
|
|
<Icon type="ios-arrow-down"></Icon>
|
|
@@ -312,11 +312,13 @@
|
|
"id": "",
|
|
"id": "",
|
|
"pid": "",
|
|
"pid": "",
|
|
"title": "",
|
|
"title": "",
|
|
|
|
+ "creatorId": this.$store.state.userInfo.TEAMModelId,
|
|
"type": 1,
|
|
"type": 1,
|
|
"children": [],
|
|
"children": [],
|
|
"rnodes": []
|
|
"rnodes": []
|
|
},
|
|
},
|
|
- modifyIdArr:[]
|
|
|
|
|
|
+ modifyIdArr:[],
|
|
|
|
+ flatArr:[]
|
|
}
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
@@ -452,6 +454,9 @@
|
|
}).then((res) => {
|
|
}).then((res) => {
|
|
if (res) {
|
|
if (res) {
|
|
this.volumeList.splice(this.activeVolumeIndex, 1);
|
|
this.volumeList.splice(this.activeVolumeIndex, 1);
|
|
|
|
+ this.treeOrigin = []
|
|
|
|
+ this.curNode.rnodes = []
|
|
|
|
+ this.curNode.id = ''
|
|
this.$Message.success("删除成功");
|
|
this.$Message.success("删除成功");
|
|
this.onVolumeClick(this.volumeList.length ? this.volumeList[this
|
|
this.onVolumeClick(this.volumeList.length ? this.volumeList[this
|
|
.activeVolumeIndex] : null, this.activeVolumeIndex)
|
|
.activeVolumeIndex] : null, this.activeVolumeIndex)
|
|
@@ -474,6 +479,10 @@
|
|
}).then(res => {
|
|
}).then(res => {
|
|
if (!res.error) {
|
|
if (!res.error) {
|
|
this.treeOrigin = res.tree
|
|
this.treeOrigin = res.tree
|
|
|
|
+ this.getAllChild(this.treeOrigin.map(i => {
|
|
|
|
+ i.trees[0].auth = i.auth
|
|
|
|
+ return i.trees[0]
|
|
|
|
+ }))
|
|
} else {
|
|
} else {
|
|
this.$Message.warning(res.error);
|
|
this.$Message.warning(res.error);
|
|
this.treeOrigin = []
|
|
this.treeOrigin = []
|
|
@@ -488,6 +497,7 @@
|
|
onAddTreeNode() {
|
|
onAddTreeNode() {
|
|
this.nodeInfo.id = this.$tools.guid()
|
|
this.nodeInfo.id = this.$tools.guid()
|
|
this.nodeInfo.pid = this.curVolume.id
|
|
this.nodeInfo.pid = this.curVolume.id
|
|
|
|
+ this.nodeInfo.creatorId = this.$store.state.userInfo.TEAMModelId
|
|
// 统一传给树形组件的数据结构
|
|
// 统一传给树形组件的数据结构
|
|
this.treeOrigin.push({
|
|
this.treeOrigin.push({
|
|
auth:null,
|
|
auth:null,
|
|
@@ -846,7 +856,7 @@
|
|
"status": 1,
|
|
"status": 1,
|
|
"name": this.addVolumeForm.name || this.getDefaultVolumeName,
|
|
"name": this.addVolumeForm.name || this.getDefaultVolumeName,
|
|
"creatorId": this.$store.state.userInfo.TEAMModelId,
|
|
"creatorId": this.$store.state.userInfo.TEAMModelId,
|
|
- "school": this.$store.state.userInfo.schoolCode,
|
|
|
|
|
|
+ "school": this.isSchool ? this.$store.state.userInfo.schoolCode : '',
|
|
"scope": this.curScope,
|
|
"scope": this.curScope,
|
|
"syllabusIds":[]
|
|
"syllabusIds":[]
|
|
}
|
|
}
|
|
@@ -854,6 +864,7 @@
|
|
addVolumeParams.id = this.curVolume.id
|
|
addVolumeParams.id = this.curVolume.id
|
|
addVolumeParams.name = this.curVolume.name
|
|
addVolumeParams.name = this.curVolume.name
|
|
addVolumeParams.syllabusIds = this.allChapterIds || []
|
|
addVolumeParams.syllabusIds = this.allChapterIds || []
|
|
|
|
+ addVolumeParams.creatorId = this.curVolume.creatorId
|
|
}
|
|
}
|
|
// 发送新增或者编辑册别请求
|
|
// 发送新增或者编辑册别请求
|
|
this.$api.syllabus.SaveOrUpdateVolume(addVolumeParams).then(res => {
|
|
this.$api.syllabus.SaveOrUpdateVolume(addVolumeParams).then(res => {
|
|
@@ -872,6 +883,45 @@
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /* 获取整个树的章节与子节点归属 */
|
|
|
|
+ getAllChild(arr){
|
|
|
|
+ let result = []
|
|
|
|
+ arr.forEach(item => {
|
|
|
|
+ result.push({
|
|
|
|
+ chapterId:item.id,
|
|
|
|
+ children:this.flatChildren(item.children)
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ this.flatArr = result
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /* 递归拉平所有children */
|
|
|
|
+ flatChildren(children){
|
|
|
|
+ let result = []
|
|
|
|
+ const fn = (source)=>{
|
|
|
|
+ source.forEach(i => {
|
|
|
|
+ result.push(i.id)
|
|
|
|
+ if(i.children.length){
|
|
|
|
+ fn(i.children)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ fn(children)
|
|
|
|
+ return result
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /* 根据某个节点ID换取它对应的章节ID */
|
|
|
|
+ getChapterIdById(id){
|
|
|
|
+ if(this.flatArr.map(i => i.chapterId).includes(id)){
|
|
|
|
+ return id
|
|
|
|
+ }else{
|
|
|
|
+ console.log(this.flatArr)
|
|
|
|
+ console.log(id);
|
|
|
|
+ let targetChapter = this.flatArr.find(i => i.children.includes(id))
|
|
|
|
+ return targetChapter.chapterId
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -906,6 +956,20 @@
|
|
return item => {
|
|
return item => {
|
|
return item.type !== 'item' && item.type !== 'paper' && item.type !== 'link'
|
|
return item.type !== 'item' && item.type !== 'paper' && item.type !== 'link'
|
|
}
|
|
}
|
|
|
|
+ },
|
|
|
|
+ hasEditAuth(){
|
|
|
|
+ return nodeData => {
|
|
|
|
+ if(!nodeData.id) return false
|
|
|
|
+ let userId = this.$store.state.userInfo.TEAMModelId
|
|
|
|
+ // 判断是否为一级节点,如果是二级节点则需要拿对应的一级节点去做判断
|
|
|
|
+ let chapterId = nodeData.pid === this.curVolume.id ? nodeData.id : this.getChapterIdById(nodeData.id)
|
|
|
|
+ let chapterNode = this.treeOrigin.find(i => i.id === chapterId)
|
|
|
|
+ return this.curVolume.creatorId === userId || (chapterNode.auth && chapterNode.auth.length && chapterNode.auth.map(i => i.tmdid).includes(userId))
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 是否可以操作课纲模块(个人课纲或者管理员或者有课纲权限)
|
|
|
|
+ hasSyllabusAuth(){
|
|
|
|
+ return !this.isSchool || this.$access.can('admin.*|Syllabus_Edit')
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
}
|