Compare commits

...

16 Commits

13 changed files with 699 additions and 226 deletions

View File

@ -3144,7 +3144,7 @@ body{
background-color:var(--toolbar-bg-color); background-color:var(--toolbar-bg-color);
box-shadow:var(--toolbar-box-shadow); box-shadow:var(--toolbar-box-shadow);
border-bottom:var(--toolbar-border-bottom); border-bottom:var(--toolbar-border-bottom);
z-index: 9; z-index: 99999;
} }
#toolbarViewer{ #toolbarViewer{

View File

@ -6,6 +6,7 @@
<script setup> <script setup>
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { getAppInstallUrl } from '@/utils/tool'
const props = defineProps({ const props = defineProps({
url: { url: {
type: String, type: String,
@ -16,7 +17,7 @@ const props = defineProps({
/**pdf文件地址 */ /**pdf文件地址 */
const pdfUrl = ref(''); const pdfUrl = ref('');
/**pdfjs文件地址 */ /**pdfjs文件地址 */
const fileUrl = '/pdfjs-dist/web/viewer.html?file='; const fileUrl = getAppInstallUrl('pdfjs-dist/web/viewer.html', 'user', '\\out\\renderer', true) + "?file=" //
onMounted(() => { onMounted(() => {
/** 将传入的pdf地址进行编码防止中文识别错误 */ /** 将传入的pdf地址进行编码防止中文识别错误 */
pdfUrl.value = fileUrl + encodeURIComponent(props.url) pdfUrl.value = fileUrl + encodeURIComponent(props.url)

View File

@ -77,12 +77,11 @@ const changeBook = (data) => {
curBook.data = data curBook.data = data
sessionStore.set('subject.curBook', data) sessionStore.set('subject.curBook', data)
treeData.value = useSubject.getTreeData(data.id) treeData.value = useSubject.getTreeData(data.id)
sessionStore.set('subject.subjectTree', useSubject.getTreeData(data.id))
// //
nextTick(() =>{ nextTick(() =>{
defaultExpandedKeys.value = [treeData.value[0].id] defaultExpandedKeys.value = [treeData.value[0].id]
curNode.data = getLastLevelData(treeData.value)[0] curNode.data = getLastLevelData(treeData.value)[0]
handleNodeClick(curNode.data) handleNodeClick(curNode.data)
}) })
// //

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog v-model="dialogVisible" append-to-body :show-close="false" width="630" :before-close="beforeClose" <el-dialog v-model="model" append-to-body :show-close="false" width="630"
style="border-radius: 5px;padding-top: 0"> style="border-radius: 5px;padding-top: 0">
<div class="dialog-title flex"> <div class="dialog-title flex">
<span>{{ title }}</span> <span>{{ title }}</span>
@ -7,13 +7,13 @@
</div> </div>
<div class="dialog-content"> <div class="dialog-content">
<div class="book-name flex" @click="bookVisible = true"> <div class="book-name flex" @click="bookVisible = true">
<span>{{ curBookName }}</span> <span>{{ curNode.data.itemtitle }}</span>
<i class="iconfont icon-yidongdaozu"></i> <i class="iconfont icon-yidongdaozu"></i>
</div> </div>
<el-scrollbar height="400px"> <el-scrollbar height="400px">
<div class="book-data"> <div class="book-data">
<el-tree ref="refTree" :data="treeData" :props="defaultProps" node-key="id" <el-tree :data="treeData" :props="defaultProps" node-key="id"
:default-expanded-keys="defaultExpandedKeys" :current-node-key="currentNodeId" highlight-current :default-expanded-keys="defaultExpandedKeys" :current-node-key="curNode.data.id" highlight-current
@node-click="handleNodeClick"> @node-click="handleNodeClick">
<template #default="{ node }"> <template #default="{ node }">
<span :title="node.label" class="tree-label">{{ node.label }}</span> <span :title="node.label" class="tree-label">{{ node.label }}</span>
@ -24,7 +24,7 @@
</div> </div>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button @click="closeDialog">取消</el-button> <el-button @click="model = false">取消</el-button>
<el-button type="primary" @click="onSubmit"> <el-button type="primary" @click="onSubmit">
确定 确定
</el-button> </el-button>
@ -43,9 +43,12 @@
<div class="textbook-container"> <div class="textbook-container">
<el-scrollbar height="450px"> <el-scrollbar height="450px">
<div class="textbook-item flex" v-for="item in subjectList" :class="curBookId == item.id ? 'active-item' : ''" <div class="textbook-item flex" v-for="item in subjectList" :class="curBook.data.id == item.id ? 'active-item' : ''"
:key="item.id" @click="changeBook(item)"> :key="item.id" @click="changeBook(item)">
<img :src="item.avartar" class="textbook-img" alt=""> <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> <span class="book-name">{{ item.itemtitle }}</span>
</div> </div>
</el-scrollbar> </el-scrollbar>
@ -54,9 +57,10 @@
</template> </template>
<script setup> <script setup>
import { ref, reactive, toRaw, onMounted, nextTick, watch } from 'vue' import { ref, reactive, toRaw, onMounted, nextTick } from 'vue'
import useUserStore from '@/store/modules/user' import { sessionStore } from '@/utils/store'
import { listEvaluation } from '@/api/subject' import { useGetSubject } from '@/hooks/useGetSubject'
import { cloneDeep } from 'lodash'
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
@ -68,134 +72,35 @@ const props = defineProps({
default: '移动至' default: '移动至'
} }
}) })
const userStore = useUserStore() const model = defineModel({ type: Boolean, default: false })
const { edustage, edusubject, userId } = userStore.user const BaseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
let useSubject = null
const dialogVisible = ref(false)
const bookVisible = ref(false) const bookVisible = ref(false)
// //
const subjectList = ref([]) const subjectList = ref([])
const evaluationList = ref([])
const treeData = ref([]) const treeData = ref([])
const defaultProps = { const defaultProps = {
children: 'children', children: 'children',
label: 'label', label: 'itemtitle',
class: 'textbook-tree' class: 'textbook-tree'
} }
//ID //
const curBookId = ref(-1) const curBook = reactive({
//
const curBookName = ref('')
//
const volumeOne = ref([])
//
const currentNode = reactive({
data: {} data: {}
}) })
// ID //
const currentNodeId = ref(0) const curNode = reactive({
// data:{}
const currentNodeName = ref('') })
//
let submitNode = null
// //
const defaultExpandedKeys = ref([]) const defaultExpandedKeys = ref([])
// tree
const refTree = ref(null)
// emit // emit
const emit = defineEmits(['update:modelValue', 'onSubmit']) const emit = defineEmits(['onSubmit'])
watch(() => props.modelValue, (newVal) => {
dialogVisible.value = newVal
})
const getSubjectContent = async () => {
const params = {
edusubject,
edustage,
// entpcourseedituserid: userId,
itemgroup: 'textbook',
orderby: 'orderidx asc',
pageSize: 10000
}
let data;
const { rows } = await listEvaluation(params)
localStorage.setItem('evaluationList', JSON.stringify(rows))
evaluationList.value = rows
data = rows
//
getSubject()
//
/**
* 不区分上下册
* 2024/08/20调整
*/
// volumeOne.value = data.filter(item => item.level == 1)
getTreeData()
}
const getSubject = async () => {
if (localStorage.getItem('subjectList')) {
subjectList.value = JSON.parse(localStorage.getItem('subjectList'))
}
else {
const { rows } = await listEvaluation({ itemkey: "version", edusubject, edustage, pageSize: 10000, orderby: 'orderidx asc', })
subjectList.value = rows
localStorage.setItem('subjectList', JSON.stringify(subjectList.value))
}
//
if(!subjectList.value.length) return
curBookName.value = subjectList.value[0].itemtitle
curBookId.value = subjectList.value[0].id
}
const isHaveUnit = (id) => {
return evaluationList.value.some(item => {
return item.rootid == id
})
}
const getTreeData = () => {
//
let upData = transData(evaluationList.value)
if(upData.length){
treeData.value = [...upData]
}
else{
treeData.value = []
return
}
nextTick(() => {
defaultExpandedKeys.value = [treeData.value[0].id]
currentNodeId.value = getLastLevelData(treeData.value)[0].id
currentNodeName.value = getLastLevelData(treeData.value)[0].label
emitChangeBook()
})
}
const emitChangeBook = () => {
let curNode = {
id: currentNodeId.value,
label: currentNodeName.value
}
let parentNode = findParentByChildId(treeData.value, currentNodeId.value)
curNode.parentNode = toRaw(parentNode)
const data = {
textBook: {
curBookId: curBookId.value,
curBookName: curBookName.value
},
node: curNode
}
currentNode.data = data
}
// id // id
const findParentByChildId = (treeData, targetNodeId) => { const findParentByChildId = (treeData, targetNodeId) => {
@ -219,70 +124,32 @@ const findParentByChildId = (treeData, targetNodeId) => {
return null; return null;
} }
const handleNodeClick = (data, node) => { const handleNodeClick = (data) => {
/** /**
* data : 当前节点数据 * data : 当前节点数据
* node : 当前节点对象 包含当前节点所有数据 parent属性 指向父节点Node对象
*/ */
const nodeData = data; let nodeData = cloneDeep(toRaw(data));
const parentNode = node.parent.data; //label label
nodeData.label = nodeData.itemtitle
if (Array.isArray(parentNode)) { // null
nodeData.parentNode = null let parent = {
} id: nodeData.parentid,
else { label: nodeData.parenttitle,
nodeData.parentNode = parentNode itemtitle: nodeData.parenttitle
} }
const parentNode = nodeData.parentid ? parent : null
nodeData.parentNode = parentNode
let curData = { let curData = {
textBook: { textBook: {
curBookId: curBookId.value, curBookId: curBook.data.id,
curBookName: curBookName.value curBookName: curBook.data.itemtitle
}, },
node: toRaw(nodeData) node: nodeData
} }
submitNode = curData
currentNode.data = curData
// emit('nodeClick', curData)
} }
const transData = (data) => {
let ary = []
data.forEach(item => {
let obj = {}
// ID
if (item.rootid == curBookId.value) {
if(item.level == 1){
obj.label = item.itemtitle
obj.id = item.id
obj.itemtitle = item.itemtitle
obj.edudegree = item.edudegree
obj.edustage = item.edustage
obj.edusubject = item.edusubject
let ary2 = []
evaluationList.value.forEach(el => {
let obj2 = {}
if (item.id == el.parentid) {
obj2 = {
label: el.itemtitle,
id: el.id,
itemtitle : el.itemtitle,
edudegree : el.edudegree,
edustage : el.edustage,
edusubject : el.edusubject,
}
ary2.push(obj2)
}
obj.children = ary2
})
ary.push(obj)
}
}
})
return ary
}
// //
const getLastLevelData = (tree) => { const getLastLevelData = (tree) => {
let lastLevelData = []; let lastLevelData = [];
@ -307,33 +174,53 @@ const getLastLevelData = (tree) => {
} }
// //
const changeBook = ({ id, itemtitle }) => { const changeBook = (data) => {
curBookId.value = id curBook.data = data
curBookName.value = itemtitle treeData.value = useSubject.getTreeData(data.id)
getTreeData()
//
nextTick(() =>{
defaultExpandedKeys.value = [treeData.value[0].id]
curNode.data = getLastLevelData(treeData.value)[0]
handleNodeClick(curNode.data)
})
setTimeout(() => { setTimeout(() => {
bookVisible.value = false bookVisible.value = false
}, 0); }, 0);
} }
const onSubmit = () => { const onSubmit = () => {
emit('onSubmit', toRaw(currentNode.data)) emit('onSubmit', submitNode)
closeDialog() model.value = false
} }
const closeDialog = () => { onMounted(async () => {
emit('update:modelValue', false) //
} 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]
}
// // ""
const beforeClose = (done) => { treeData.value = useSubject.getTreeData(curBook.data.id)
emit('update:modelValue', false) nextTick(() =>{
done() //
} 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)
})
onMounted(() => {
getSubjectContent()
}) })
</script> </script>

View File

@ -63,7 +63,6 @@ export const useGetSubject = async () =>{
} }
sessionStore.set('subject.curNode', curNode) sessionStore.set('subject.curNode', curNode)
} }
} }
// 单元章节数据转为“树”结构 // 单元章节数据转为“树”结构
@ -73,9 +72,7 @@ export const useGetSubject = async () =>{
data.forEach( item => { data.forEach( item => {
item.children = unitList.value.filter( item2 => item2.parentid == item.id && item2.level == 2) item.children = unitList.value.filter( item2 => item2.parentid == item.id && item2.level == 2)
}) })
sessionStore.set('subject.subjectTree', data)
return data return data
} }
await getSubjectUnit() await getSubjectUnit()

View File

@ -67,7 +67,7 @@ const title = reactive([
}, },
{ {
name: '教材分析', name: '教材分析',
url: '/teaching/chatwithtextbook', url: '/textbookAnalysis',
img: 'iconfont icon-yanjiushi', img: 'iconfont icon-yanjiushi',
child1: [] child1: []
}, },

View File

@ -175,7 +175,13 @@ function setLayout() {
} }
// //
const changeSubject = async (command) =>{ const changeSubject = async (command) =>{
clearBookInfo() let sessionSubject = {
bookList: null,
curBook: null,
curNode: null,
defaultExpandedKeys: [],
}
sessionStore.set( 'subject', sessionSubject)
const { userId, userName, phonenumber, plainpwd } = userStore.user const { userId, userName, phonenumber, plainpwd } = userStore.user
const data = { const data = {
userId, userId,
@ -184,7 +190,7 @@ const changeSubject = async (command) =>{
edusubject: command.edusubject edusubject: command.edusubject
} }
await updateUserInfo(data) await updateUserInfo(data)
await userStore.login({username: phonenumber, password: plainpwd}) await userStore.login({username: phonenumber ? phonenumber : userName, password: plainpwd})
await userStore.getInfo() await userStore.getInfo()
router.go() router.go()
} }

View File

@ -54,7 +54,13 @@ export const constantRoutes = [
path: '/standardanalysis', path: '/standardanalysis',
component: () => import('@/views/teach/standardAnalysis/index.vue'), component: () => import('@/views/teach/standardAnalysis/index.vue'),
name: 'standardanalysis', name: 'standardanalysis',
meta: {title: '课标分析'}, meta: {title: '课标分析'}
},
{
path: '/textbookAnalysis',
component: () => import('@/views/textbookAnalysis/index.vue'),
name: 'textbookAnalysis',
meta: {title: '教材分析'}
}, },
{ {
path: '/profile', path: '/profile',

View File

@ -49,6 +49,18 @@ export const getStaticUrl = (url = '', type = 'app', exitPath = '', isFile = fal
} }
} }
} }
export const getAppInstallUrl = (url = '', type = 'app', exitPath = '', isFile = false) => {
if (isDev) return url
else { // 生产环境获取-url
switch(type) {
case 'app': return path.join(__dirname, url) // 应用目录
case 'user': return (isFile?'file://':'')+path.join(Remote.app.getAppPath(),exitPath, url) // 用户目录
// case 'user': return (isFile?'file://':'')+path.join(Remote.app.getPath('userData'),exitPath, url) // 用户目录
default: return ''
}
}
}
/** /**
* @description 消息发送-nodejs 消息发送 * @description 消息发送-nodejs 消息发送
* @form src/main/tool.js 来源 * @form src/main/tool.js 来源

View File

@ -66,8 +66,7 @@ const menuList = [{
{ {
name: '教材分析', name: '教材分析',
icon: 'icon-jiaocaixuanze', icon: 'icon-jiaocaixuanze',
isOuter: true, path: '/textbookAnalysis',
path: '/teaching/chatwithtextbook',
id: '1-2' id: '1-2'
}, },
{ {

View File

@ -511,6 +511,7 @@ export default {
}) })
this.currentFileList.splice(index, 1) this.currentFileList.splice(index, 1)
}) })
ElMessage.success('操作成功')
} }
}) })
}, },

View File

@ -70,7 +70,10 @@
</div> </div>
<el-dialog v-model="dialogVisible" title="切换教材" append-to-body width="550"> <el-dialog v-model="dialogVisible" title="切换教材" append-to-body width="550">
<div class="booklist"> <div class="booklist">
<div :class="{'item': true,'active': booksel === idx}" v-for="item,idx in bookList" :key="idx" @click="bookChange(item)">{{item.edustage + item.edusubject}}</div> <div :class="{'item': true,'active': booksel === idx}" v-for="item,idx in bookList" :key="idx" @click="bookChange(item,idx)">
<el-image class="bookimg" :src="item.avartar" />
<div class="bookname">{{item.fileurl.replace('.txt', '')}}</div>
</div>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
@ -237,8 +240,6 @@ const getData = (data) => {
} }
sourceStore.handleQuery() sourceStore.handleQuery()
getlistEvaluationclue(levelFirstId, levelSecondId) getlistEvaluationclue(levelFirstId, levelSecondId)
// ID
localStorage.setItem('unitId', JSON.stringify({ levelFirstId, levelSecondId}))
} }
// //
const getAllSubject = async () => { const getAllSubject = async () => {
@ -252,12 +253,16 @@ const getAllSubject = async () => {
bookList.value.push({...item,avartar: import.meta.env.VITE_APP_BUILD_BASE_PATH + item.avartar}) bookList.value.push({...item,avartar: import.meta.env.VITE_APP_BUILD_BASE_PATH + item.avartar})
} }
}) })
booksel.value = bookList.value.findIndex(item => item.edustage === edustage && item.edusubject === edusubject) const textselidx = bookList.value.findIndex(item => item.edustage === edustage && item.edusubject === edusubject)
booksel.value = textselidx
booktitle.value = bookList.value[textselidx].fileurl.replace('.txt','')
const filePath = import.meta.env.VITE_APP_RES_FILE_PATH + bookList.value[textselidx].fileurl.replace('.txt','.pdf')
await loadPdfAnimation(filePath)
} }
const bookChange = async (item, idx) => { const bookChange = async (item, idx) => {
booksel.value = idx booksel.value = idx
bookInfo.value = {...item} bookInfo.value = {...item}
booktitle.value = `${item.edustage + item.edusubject}课程标准` booktitle.value = item.fileurl.replace('.txt','')
pdfUrl.value = ''; pdfUrl.value = '';
const filepath = import.meta.env.VITE_APP_RES_FILE_PATH + item.fileurl.replace('.txt','.pdf') const filepath = import.meta.env.VITE_APP_RES_FILE_PATH + item.fileurl.replace('.txt','.pdf')
await loadPdfAnimation(filepath) await loadPdfAnimation(filepath)
@ -271,10 +276,6 @@ const loadPdfAnimation = (path) => {
} }
onMounted(async () => { onMounted(async () => {
await getAllSubject(); await getAllSubject();
const { edustage, edusubject } = userStore.user;
booktitle.value = `${edustage + edusubject}课程标准`
const filePath = `${import.meta.env.VITE_APP_RES_FILE_PATH}${edustage}-${edusubject}-课标.pdf`
await loadPdfAnimation(filePath)
if(cardref.value && headref.value){ if(cardref.value && headref.value){
const cardH = cardref.value.offsetHeight; const cardH = cardref.value.offsetHeight;
const headh = headref.value.offsetHeight; const headh = headref.value.offsetHeight;
@ -529,13 +530,22 @@ onMounted(async () => {
padding-top: 1px; padding-top: 1px;
overflow: auto; overflow: auto;
.item{ .item{
width: 100%; width: 162px;
height: auto; height: auto;
padding: 8px 16px; padding: 8px 16px;
background-color: #ffffff; background-color: #ffffff;
border-top: 1px solid #f1f1f1; float: left;
font-size: 14px; .bookimg{
color: #3b3b3b; width: 130px;
height: 180px;
}
.name{
font-size: 14px;
color: #3b3b3b;
}
}
.item:hover{
cursor: pointer;
} }
.active{ .active{
background-color: #409eff; background-color: #409eff;

View File

@ -0,0 +1,555 @@
<template>
<div class="page-con flex" ref="cardref">
<!-- <el-button @click="saveJSON">测试保存</el-button> -->
<div class="page-con-left">
<div class="stand-head" ref="headref">
<div class="stand-head-left">
<el-image class="imges" :src="bookInfo ? bookInfo.avartar : ''" />
</div>
<div class="stand-head-right">
<div class="stand-head-right-tit">{{booktitle}}</div>
<i class="iconfont icon-yidongdaozu stand-head-right-icon" @click="dialogVisible = true"></i>
<div class="stand-head-right-row">
<div class="stand-head-right-row-time">更新2024.9.10</div>
<!-- <el-switch class="stand-head-right-row-switch" v-model="isOpenClass" inline-prompt active-text="公开" inactive-text="非公" /> -->
</div>
</div>
</div>
<div class="stand-down">
<div class="stand-down-search" ref="searchref">
<el-input
v-model="searchInp"
placeholder="搜索课标、学校和老师"
clearable
@input="searchHandel"
/>
<el-select v-model="searchSel" placeholder="请选择" style="width: 140px;padding-left:6px" @change="selectHandel">
<el-option
v-for="item in searchOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
<div class="stand-down-con" :style="{overflow: 'auto',height: listHeight + 'px'}">
<div class="stand-down-con-list" v-for="item,idx in showData" :key="idx">
<div class="stand-down-con-list-icon">
<el-image class="imges" :src="item.userheadimgurl" />
</div>
<div class="stand-down-con-list-txt">
<div class="stand-down-con-list-txt-top">
<div class="stand-down-con-list-txt-top-name">{{item.username}}</div>
<div class="stand-down-con-list-txt-top-tip">{{item.childcount}}</div>
</div>
<div class="stand-down-con-list-txt-down">
<div class="stand-down-con-list-txt-down-tip">{{ item.userentpname }}</div>
<div class="stand-down-con-list-txt-down-tip">{{ item.timeStr }}</div>
</div>
</div>
</div>
</div>
<p v-if="loading">加载中...</p>
<p v-if="noMore">~没有更多了~</p>
</div>
</div>
<div class="page-con-right">
<PDF :url="pdfUrl" v-if="pdfUrl" />
<div class="loading" v-else>
<div class="setup">
<span style="--i:1"></span>
<span style="--i:2"></span>
<span style="--i:3"></span>
<span style="--i:4"></span>
<span style="--i:5"></span>
<span style="--i:6">.</span>
<span style="--i:7">.</span>
<span style="--i:8">.</span>
</div>
</div>
</div>
<el-dialog v-model="dialogVisible" title="切换教材" append-to-body width="550">
<div class="booklist">
<div :class="{'item': true,'active': booksel === idx}" v-for="item,idx in bookList" :key="idx" @click="bookChange(item,idx)">
<el-image class="bookimg" :src="item.avartar" />
<div class="bookname">{{item.fileurl.replace('.txt', '')}}</div>
</div>
</div>
</el-dialog>
</div>
</template>
<script setup>
import { onMounted, ref } from 'vue'
import PDF from '@/components/PdfJs/index.vue'
import { useRoute } from 'vue-router';
import useResoureStore from '../resource/store'
import { listEvaluationclue } from '@/api/teaching/classwork'
import { uploadServer, getJSONFile } from '@/utils/common'
import { ElNotification } from 'element-plus'
import ChooseTextbook from "@/components/choose-textbook/index.vue";
import { listEvaluation } from '@/api/classManage/index'
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
const sourceStore = useResoureStore()
// import { getStaticUrl } from '@/utils/tool'
const route = useRoute();
const pdfUrl = ref('');
const isOpenClass = ref(true);
const searchInp = ref('');
const searchSel = ref('0');
const loading = ref(false);
const noMore = ref(false);
const cardref = ref(null);
const headref = ref(null);
const searchref = ref(null);
const listHeight = ref(0);
const dialogVisible = ref(false);
const booktitle = ref('');
const bookInfo = ref(null);
const booksel = ref(0);
const bookList = ref([])
const searchOptions = [{
value: '0',
label: '按时间',
},{
value: '1',
label: '按内容量',
}];
const standList = ref([]);
const showData = ref([]);
//
const getlistEvaluationclue = (firstid, levelid) => {
const newid = firstid ? firstid : levelid;
listEvaluationclue({evalid: newid, parentid: 0, cluegroup: 'teachresource', orderby: "timestamp desc", pageSize: 100}).then((res) => {
if(res.code === 200){
const newData = formaterTime(res.rows)
standList.value = newData
showData.value = filterList(newData)
}
})
}
const formaterTime = (data) => {
return data.map(item => {
return {
...item,
timeStr: item.timestamp.split(' ')[0].replace('-', '.').replace('-', '.')
}
})
}
//
const filterList = (data) => {
let standData = JSON.parse(JSON.stringify(data));
let arr = [];
if (searchSel.value === '0') {
arr = standData.sort((a, b)=>{
return new Date(b.timestamp) - new Date(a.timestamp);
})
}
else {
arr = standData.sort((a, b)=>{
return b.childcount - a.childcount;
})
}
return arr;
}
//
const searchHandel = (value) => {
const newData = [];
standList.value.map(item => {
const str = JSON.stringify(item)
if(str.indexOf(value) !== -1){
newData.push(item);
}
})
showData.value = newData
}
//
const selectHandel = (value) => {
const filterData = searchInp.value !== '' ? showData.value : standList.value
showData.value = filterList(filterData);
}
//json
const saveJSON = (data) => {
let filename = ''
// const data = {
// name: 'txt',
// class: '2',
// school: '',
// time: '2024-08-09'
// }
// saveJSON(jsonStr);
if (!data) {
console.log('传入的data数据为null');
return;
}
if (!filename) {
filename = `json${Date.now()}.json`
console.log('未传入文件名,采用默认文件名' + filename);
}
let newdata = null;
if (typeof data === 'object') {
newdata = JSON.stringify(data, undefined, 4)
}
// jsonblob
const blob = new Blob([newdata], { type: 'text/json' });
// file
// const file = new File([blob],filename, {type: blob.type})
//
// const formdata = new FormData();
// formdata.append('file', file);
//
//
// uploadServer(formdata).then(res => {
// console.log('+++++++++++++');
// console.log(res.data);
// })
let e = document.createEvent('MouseEvents');
let a = document.createElement('a');
a.download = filename;
a.href = window.URL.createObjectURL(blob);
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':');
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.dispatchEvent(e);
}
//
const getData = (data) => {
const { textBook, node } = data
let textbookId = textBook.curBookId
let levelSecondId = node.id
let levelFirstId
if (node.parentNode) {
levelFirstId = node.parentNode.id
} else {
levelFirstId = node.id
levelSecondId = ''
}
sourceStore.query.levelFirstId = levelFirstId
sourceStore.query.levelSecondId = levelSecondId
sourceStore.query.textbookId = textbookId
sourceStore.nodeData = {
textbookId, //
levelFirstId, //
levelSecondId //
}
sourceStore.handleQuery()
getlistEvaluationclue(levelFirstId, levelSecondId)
}
//
const getAllSubject = async () => {
const { edustage, edusubject } = userStore.user;
const { rows } = await listEvaluation({ itemkey: "version", edustage, edusubject, pageSize: 500 })
rows && rows.map(item => {
if(item.edustage === edustage && item.edusubject === edusubject){
bookInfo.value = {...item,avartar: import.meta.env.VITE_APP_BUILD_BASE_PATH + item.avartar}
}
if(item.fileurl !== ''){
bookList.value.push({...item,avartar: import.meta.env.VITE_APP_BUILD_BASE_PATH + item.avartar})
}
})
const textselidx = bookList.value.findIndex(item => item.edustage === edustage && item.edusubject === edusubject)
booksel.value = textselidx
booktitle.value = bookList.value[textselidx].fileurl.replace('.txt','')
const filePath = import.meta.env.VITE_APP_RES_FILE_PATH + bookList.value[textselidx].fileurl.replace('.txt','.pdf')
await loadPdfAnimation(filePath)
}
const bookChange = async (item, idx) => {
booksel.value = idx
bookInfo.value = {...item}
booktitle.value = item.fileurl.replace('.txt','')
pdfUrl.value = '';
const filepath = import.meta.env.VITE_APP_RES_FILE_PATH + item.fileurl.replace('.txt','.pdf')
await loadPdfAnimation(filepath)
dialogVisible.value = false
}
const loadPdfAnimation = (path) => {
const timer = setTimeout(() => {
pdfUrl.value = path
clearTimeout(timer);
},2000)
}
onMounted(async () => {
await getAllSubject();
if(cardref.value && headref.value){
const cardH = cardref.value.offsetHeight;
const headh = headref.value.offsetHeight;
const searchh = searchref.value.offsetHeight;
listHeight.value = Math.floor(cardH) - Math.floor(headh) - Math.floor(searchh) - 60;
}
window.addEventListener('resize', () => {
if(cardref.value && headref.value){
const cardH = cardref.value.offsetHeight;
const headh = headref.value.offsetHeight;
const searchh = searchref.value.offsetHeight;
listHeight.value = Math.floor(cardH) - Math.floor(headh) - Math.floor(searchh) - 60;
}
})
window.addEventListener('message',(event) => {
// console.log('------------');
const iframeMes = event.data;
if(iframeMes.storageInfo){
// saveJSON(iframeMes.storageInfo);
// console.log(JSON.stringify(iframeMes.storageInfo));
}
if(iframeMes.quoteInfo){
console.log(iframeMes.quoteInfo);
const { textStr, StartStr, EndStr } = iframeMes.quoteInfo;
if(textStr === StartStr || textStr === EndStr){
ElNotification({
title: '引用内容',
message: textStr,
duration: 0,
type: 'info',
offset: 120
})
//
console.log('无需替换------',textStr);
return
}
let midStr = ''
if(StartStr === '' && EndStr === '' && textStr === '') return
if(StartStr === '' && EndStr !== '') {
midStr = textStr.replace(EndStr,'eeeeee').split('eeeeee')[0]
}else if(StartStr !== '' && EndStr === ''){
midStr = textStr.replace(StartStr,'ssssss').split('ssssss')[1]
}else{
midStr = textStr.replace(StartStr, 'ssssss').replace(EndStr,'eeeeee').split('ssssss')[1].split('eeeeee')[0];
}
ElNotification({
title: '引用内容',
message: StartStr + midStr + EndStr,
duration: 0,
type: 'info',
offset: 120
})
console.log('中间文字------',midStr);
console.log('转换后整体文字------',StartStr + midStr + EndStr);
}
})
// const isDev = process.env.NODE_ENV == 'development'
// if (isDev)
// pdfUrl.value = '/'+getStaticUrl('aaa.pdf', 'user', 'selfFile', true)
// else
// pdfUrl.value = getStaticUrl(route.query.path, 'user', 'selfFile', true)
// console.log('',pdfUrl.value);
})
</script>
<style scoped lang="scss">
.page-con {
padding-top: 20px;
height: 100%;
&-left{
width: 300px;
height: auto;
background: #ffffff;
border-radius: 10px;
}
&-right{
display: flex;
flex-direction: column;
flex: 1;
margin-left: 20px;
height: 100%;
background: #ffffff;
overflow: hidden;
border-radius: 10px;
box-shadow: 0px 0px 20px 0px rgba(99, 99, 99, 0.06);
}
.loading {
display: flex;
align-items: center;
justify-content:center;
min-height: 100vh;
.setup {
position: relative;
-webkit-box-reflect: below -12px linear-gradient(transparent, rgba(0, 0, 0, 0.2))
}
.setup span {
position: relative;
display: inline-block;
color: #409eff;
font-size: 26px;
animation: animate 1s ease-in-out infinite;
animation-delay: calc(.1s*var(--i))
}
}
@keyframes animate {
0% {
transform: translateY(0px)
}
20% {
transform: translateY(-24px)
}
40%,
100% {
transform: translateY(0px)
}
}
}
.stand-head{
width: 100%;
padding: 6px;
border-radius: 6px;
position: relative;
&-left{
width: 48px;
height: 66px;
border-radius: 2px;
overflow: hidden;
.imges{
width: 48px;
height: 66px;
}
}
&-right{
position: absolute;
width: 100%;
height: auto;
padding-left: 60px;
padding-right: 6px;
left: 0;
top: 6px;
z-index: 2;
&-tit{
width: 100%;
font-size: 15px;
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: #3b3b3b;
text-align: left;
}
&-icon{
position: absolute;
right: 12px;
top: 0px;
z-index: 3;
color: var(--el-color-primary);
}
&-row{
width: 100%;
height: 32px;
display: flex;
justify-content: space-between;
margin-top: 12px;
&-time{
font-size: var(--el-font-size-extra-small);
color: var(--el-color-info-rgb);
line-height: 32px;
}
&-switch{
height: 32px;
}
}
}
}
.stand-down{
width: 100%;
height: auto;
padding-top: 20px;
padding-right: 6px;
&-search{
width: 100%;
height: 32px;
display: flex;
justify-content: space-between;
align-items: center;
}
&-con{
width: 100%;
&-list{
width: 100%;
height: auto;
position: relative;
padding: 8px 0;
border-top: 1px dashed #e1e1e1;
&-icon{
width: 48px;
height: 48px;
border-radius: 50%;
position: absolute;
left: 0;
top: 8px;
z-index: 2;
overflow: hidden;
.imges{
width: 48px;
height: 48px;
}
}
&-txt{
width: 100%;
min-height: 48px;
padding-left: 56px;
padding-right: 12px;
&-top,&-down{
width: 100%;
min-height: 24px;
display: flex;
justify-content: space-between;
align-items: center;
&-name{
font-size: 14px;
color: #3b3b3b;
font-weight: 600;
}
&-tip{
font-size: 12px;
color: #787878;
text-align: left;
}
}
&-down{
margin-top: 4px;
}
}
}
&-list:first-of-type{
border: 0;
}
}
}
.booklist{
width: 100%;
height: 500px;
padding-top: 1px;
overflow: auto;
.item{
width: 162px;
height: auto;
padding: 8px 16px;
background-color: #ffffff;
float: left;
.bookimg{
width: 130px;
height: 180px;
}
.name{
font-size: 14px;
color: #3b3b3b;
}
}
.item:hover{
cursor: pointer;
}
.active{
background-color: #409eff;
color: #ffffff;
}
}
</style>