Compare commits

..

12 Commits

Author SHA1 Message Date
朱浩 3ef73885e1 三方资源加入备课 2024-11-12 15:47:24 +08:00
朱浩 d50327bc17 去除测试 2024-11-12 15:34:14 +08:00
朱浩 77921f7e61 Merge branch 'main' into zhuhao_dev 2024-11-12 14:49:26 +08:00
朱浩 ac1cad8fd0 添加回调 2024-11-12 14:49:16 +08:00
yangws 00b58644b1 Merge pull request 'fix:修改格式;' (#402) from yangws into main
Reviewed-on: #402
2024-11-12 14:48:52 +08:00
小杨 6de59fabfa fix:修改格式; 2024-11-12 14:48:14 +08:00
yangws 28a2f95903 Merge pull request 'fix:修改格式传值;' (#401) from yangws into main
Reviewed-on: #401
2024-11-12 11:04:31 +08:00
小杨 78dce6dc6a fix:修改格式传值; 2024-11-12 11:04:04 +08:00
yangws a79add8625 Merge pull request 'yangws' (#400) from yangws into main
Reviewed-on: #400
2024-11-12 10:45:15 +08:00
小杨 83212f4ec0 Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk into yangws
# Conflicts:
#	src/renderer/src/views/prepare/components/treeLog.vue
2024-11-12 10:44:36 +08:00
小杨 24706b8912 fix:不修改原本树结构; 2024-11-12 10:42:39 +08:00
朱浩 169d6d7c31 Merge pull request 'zhuhao_dev' (#399) from zhuhao_dev into main
Reviewed-on: #399
2024-11-12 10:36:30 +08:00
5 changed files with 365 additions and 16 deletions

View File

@ -53,3 +53,14 @@ export const moveSmarttalk = (params) => {
params params
}) })
} }
export const addFileToPrepareThird = (data) => {
return request({
url: '/smarttalk/file/addFileToPrepareThird',
method: 'post',
headers: {
'Content-Type': 'multipart/form-data'
},
data
})
}

View File

@ -0,0 +1,308 @@
<template>
<div class="book-wrap">
<el-scrollbar height="100%">
<div class="book-name flex" @click="dialogVisible = true">
<span>{{ curBook.data.itemtitle }}</span>
<i class="iconfont icon-xiangyou"></i>
</div>
<div class="book-list" v-loading="treeLoading">
<el-tree :data="treeData" accordion :props="defaultProps" node-key="id"
:default-expanded-keys="defaultExpandedKeys" :current-node-key="curNode.data.id" highlight-current
@node-click="handleNodeClick">
<template #default="{ node }">
<span :title="node.label" class="tree-label">{{ node.label }}</span>
</template>
</el-tree>
</div>
</el-scrollbar>
</div>
<!--弹窗 选择教材-->
<el-dialog v-model="dialogVisible" append-to-body :show-close="false" width="550"
style="border-radius: 10px; padding: 10px 15px;">
<template #header>
<div class="choose-book-header flex">
<span>切换教材</span>
<i class="iconfont icon-guanbi" @click="dialogVisible = false"></i>
</div>
</template>
<div class="textbook-container">
<el-scrollbar height="450px">
<div class="textbook-item flex" v-for="item in subjectList" :class="curBook.data.id == item.id ? 'active-item' : ''"
:key="item.id" @click="changeBook(item)">
<img v-if="item.avartar" :src="item.avartar.indexOf('http') === 0 ? item.avartar : BaseUrl + item.avartar" class="textbook-img" alt="">
<div v-else class="textbook-img">
<i class="iconfont icon-jiaocaixuanze" style="font-size: 40px;"></i>
</div>
<span class="book-name">{{ item.itemtitle }}</span>
</div>
</el-scrollbar>
</div>
</el-dialog>
</template>
<script setup>
import { onMounted, ref, nextTick, toRaw, reactive } from 'vue';
import { cloneDeep } from 'lodash'
import { sessionStore } from '@/utils/store'
import { useGetSubject } from '@/hooks/useGetSubject'
const BaseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
// emit
const emit = defineEmits(['nodeClick', 'changeBook'])
let useSubject = null
const subjectList = ref([])
const dialogVisible = ref(false)
//
const treeData = ref([])
const defaultProps = {
children: 'children',
label: 'itemtitle',
class: 'textbook-tree'
}
//
const curBook = reactive({
data: {}
})
//
const curNode = reactive({
data:{}
})
const treeLoading = ref(false)
//
const defaultExpandedKeys = ref([])
//
const changeBook = (data) => {
curBook.data = data
treeData.value = useSubject.getTreeData(data.id)
//
nextTick(() =>{
defaultExpandedKeys.value = [treeData.value[0].id]
curNode.data = getLastLevelData(treeData.value)[0]
handleNodeClick(curNode.data)
})
//
setTimeout(() => {
dialogVisible.value = false
}, 100);
}
const getLastLevelData = (tree) => {
let lastLevelData = [];
//
function traverseTree(nodes) {
nodes.forEach((node) => {
//
if (node.children && node.children.length > 0) {
traverseTree(node.children);
} else {
//
lastLevelData.push(node);
}
});
}
//
traverseTree(tree);
//
return lastLevelData;
}
// id
const findParentByChildId = (treeData, targetNodeId) => {
//
//
for (let node of treeData) {
// ID
if (node.children && node.children.some(child => child.id === targetNodeId)) {
// ID ID
return node;
}
//
if (node.children) {
let parentNode = findParentByChildId(node.children, targetNodeId);
if (parentNode) {
return parentNode;
}
}
}
// null
return null;
}
const handleNodeClick = (data) => {
/**
* data : 当前节点数据
*/
let nodeData = cloneDeep(toRaw(data));
//label label
nodeData.label = nodeData.itemtitle
// null
let parent = {
id: nodeData.parentid,
label: nodeData.parenttitle,
itemtitle: nodeData.parenttitle
}
const parentNode = nodeData.parentid ? parent : null
nodeData.parentNode = parentNode
let curData = {
textBook: {
curBookId: curBook.data.id,
curBookName: curBook.data.itemtitle,
curBookImg: BaseUrl + curBook.data.avartar,
curBookPath: curBook.data.fileurl
},
node: nodeData
}
// :electron-store
emit('nodeClick', curData)
}
onMounted( async () => {
treeLoading.value = true
try{
useSubject = await useGetSubject()
subjectList.value = sessionStore.get('subject.bookList')
//
if(sessionStore.get('subject.curBook')){
curBook.data = sessionStore.get('subject.curBook')
}
else{
curBook.data = subjectList.value[0]
}
// ""
treeData.value = useSubject.getTreeData(curBook.data.id)
nextTick(() =>{
//
if(sessionStore.get('subject.curNode')){
defaultExpandedKeys.value = sessionStore.get('subject.defaultExpandedKeys')
curNode.data = sessionStore.get('subject.curNode')
}else{
defaultExpandedKeys.value = [treeData.value[0].id]
curNode.data = getLastLevelData(treeData.value)[0]
}
handleNodeClick(curNode.data)
})
} finally{
treeLoading.value = false
}
})
</script>
<style lang="scss" scoped>
.book-wrap {
width: 300px;
height: 100%;
background: #ffffff;
border-radius: 10px;
box-shadow: 0px 0px 20px 0px rgba(99, 99, 99, 0.06);
display: flex;
flex-direction: column;
position: relative;
.book-name {
background-color: #ffffff;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 45px;
padding: 0 15px;
z-index: 1;
justify-content: space-between;
align-items: center;
color: #3b3b3b;
cursor: pointer;
border-bottom: solid #f4f5f7 1px;
font-size: 15px;
font-weight: 600;
border-radius: 10px 10px 0 0;
}
.book-list {
padding: 45px 10px 0 10px;
flex: 1;
}
}
:deep(.choose-dialog) {
border-radius: 10px;
}
.choose-book-header {
justify-content: space-between;
font-size: 15px;
font-weight: bold;
.icon-guanbi {
font-size: 20px;
cursor: pointer;
}
}
.textbook-container {
.textbook-item {
padding: 10px 20px;
align-items: center;
border-radius: 5px;
cursor: pointer;
.book-name {
margin-left: 20px;
color: #3b3b3b;
font-size: 13px;
}
&:hover {
background: #f4f7f9;
}
}
.active-item {
background-color: #f4f7f9;
.book-name {
color: #368fff;
font-weight: bold
}
}
.textbook-img {
width: 55px;
height: 70px;
display: flex;
align-items: center;
justify-content: center;
}
}
:deep(.el-tree-node) {
.el-tree-node__content {
height: 40px;
border-radius: 10px;
&:hover {
background-color: #eaf3ff;
}
}
}
.tree-label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
:deep(.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content) {
background-color: #eaf3ff !important;
color: #409EFF
}
</style>

View File

@ -19,13 +19,12 @@
</template> </template>
<script setup> <script setup>
import { ref, defineExpose } from 'vue' import { ref, defineExpose,defineEmits } from 'vue'
import ChooseTextbook from '@/components/choose-textbook/index.vue' import ChooseTextbook from './chooseTextbook.vue'
const emit = defineEmits(['onsuccess']) const emit = defineEmits(['onsuccess'])
const dialogVisible = ref(false) const dialogVisible = ref(false)
const getNodeInfo = ref([]) const getNodeInfo = ref({})
const openDialog = () => { const openDialog = () => {
dialogVisible.value = true dialogVisible.value = true
@ -36,7 +35,7 @@
const recursive = (currentNode) => { const recursive = (currentNode) => {
// //
if (currentNode.parentNode) { if (currentNode.parentNode) {
obj.unshift(Object.assign({curentId: currentNode.id,title:currentNode.itemtitle}, currentNode.parentNode)) obj.unshift({id: currentNode.id,title:currentNode.itemtitle})
recursive(currentNode.parentNode) recursive(currentNode.parentNode)
} else { } else {
obj.unshift({id: currentNode.id,title:currentNode.itemtitle}) obj.unshift({id: currentNode.id,title:currentNode.itemtitle})
@ -47,7 +46,11 @@
} }
const nodeClick = (data) => { const nodeClick = (data) => {
getNodeInfo.value = getFullObj(data.node) getNodeInfo.value = {
textbookId:data.node.rootid,
cataList:getFullObj(data.node)
}
console.log(getNodeInfo.value,'log')
} }
const save = () => { const save = () => {

View File

@ -2,7 +2,6 @@
<div v-loading="isLoading" class="page-resource flex"> <div v-loading="isLoading" class="page-resource flex">
<ChooseTextbook @node-click="nodeClick" /> <ChooseTextbook @node-click="nodeClick" />
<div class="page-center-wrap"> <div class="page-center-wrap">
<el-button @click="openChapter" type="primary">打开章节</el-button>
<el-tabs v-model="activeAptTab" style="height: 100%;"> <el-tabs v-model="activeAptTab" style="height: 100%;">
<el-tab-pane label="教学课件" name="教学课件" class="prepare-center-jxkj"> <el-tab-pane label="教学课件" name="教学课件" class="prepare-center-jxkj">
<div class="prepare-center-header"> <div class="prepare-center-header">
@ -141,8 +140,6 @@
<!-- 上课配置 --> <!-- 上课配置 -->
<class-start ref="calssRef" @close="closeChange"/> <class-start ref="calssRef" @close="closeChange"/>
<PptDialog @add-success="addAiPPT" :currentNode="currentNode" :uploadData="uploadData" v-model="pptDialog"/> <PptDialog @add-success="addAiPPT" :currentNode="currentNode" :uploadData="uploadData" v-model="pptDialog"/>
<!-- 章节弹窗 -->
<TreeLog ref="treelogRef"/>
<!-- <button @click="test">test</button> --> <!-- <button @click="test">test</button> -->
</template> </template>
<script setup> <script setup>
@ -637,7 +634,7 @@ export default {
}, },
async nodeClick(data) { async nodeClick(data) {
console.log(data,'data'); console.log(data,'data');
if (this.currentNode.id === data.node.id) return if (this.currentNode.id === data.node.id) return
this.curBookImg = data.textBook.curBookImg this.curBookImg = data.textBook.curBookImg
this.curBookPath = data.textBook.curBookPath this.curBookPath = data.textBook.curBookPath
@ -796,11 +793,6 @@ export default {
'&reservId=' + '&reservId=' +
id id
}) })
},
//
openChapter(){
//
this.$refs.treelogRef.openDialog()
} }
} }
} }

View File

@ -50,6 +50,10 @@
</div> </div>
</div> </div>
</div> </div>
<el-button v-loading="item.loading" size="small" plain round type="primary" @click.stop="openChapter(item)">
<i class="iconfont icon-jiahao"></i>
备课</el-button
>
</li> </li>
</ul> </ul>
</el-scrollbar> </el-scrollbar>
@ -66,17 +70,20 @@
/> />
</div> </div>
<FilePreview ref="thirdPreview" v-model="isViewImg"></FilePreview> <FilePreview ref="thirdPreview" v-model="isViewImg"></FilePreview>
<TreeLog ref="treelogRef" @onsuccess="addToPrepare"/>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
// import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { Clock,View,Folder,Search } from '@element-plus/icons-vue' import { Clock,View,Folder,Search } from '@element-plus/icons-vue'
import FileImage from '@/components/file-image/index.vue' import FileImage from '@/components/file-image/index.vue'
import FilePreview from '@/components/thirdFile-preview/index.vue' import FilePreview from '@/components/thirdFile-preview/index.vue'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import useResoureStore from '../store' import useResoureStore from '../store'
import { addFileToPrepareThird } from '@/api/file'
import TreeLog from '@/views/prepare/components/treeLog.vue'
const userstore = useUserStore() const userstore = useUserStore()
const sourceStore = useResoureStore() const sourceStore = useResoureStore()
@ -85,6 +92,9 @@ const sourceStore = useResoureStore()
// //
const isViewImg = ref(false) const isViewImg = ref(false)
const thirdPreview = ref() const thirdPreview = ref()
const treelogRef = ref()
const currentItem = ref()
const loading = ref(false)
// change // change
const handleSizeChange = (limit) => { const handleSizeChange = (limit) => {
@ -114,6 +124,31 @@ const handleRow = (item) => {
isViewImg.value = true isViewImg.value = true
thirdPreview.value.init(item.itemId) thirdPreview.value.init(item.itemId)
} }
const openChapter = (item)=>{
currentItem.value = item
//
treelogRef.value.openDialog()
}
const addToPrepare = (data) => {
console.log(data)
let chapterArr = []
for (let i = 0; i < data.cataList.length; i++) {
chapterArr.push({id: data.cataList[i].id,name: data.cataList[i].title})
}
let postData = {
itemId: currentItem.value.itemId,
textBookId: data.textbookId,
chapter: JSON.stringify(chapterArr)
}
currentItem.value.loading = true
addFileToPrepareThird(postData).then((res) => {
currentItem.value.loading = false
console.log(res)
if (res.code === 200) {
ElMessage.success("加入备课成功")
}
})
}
</script> </script>
<style lang="scss"> <style lang="scss">