This commit is contained in:
朱浩 2024-12-11 16:35:52 +08:00
parent 90137bc3a2
commit 10e76add35
9 changed files with 277 additions and 49 deletions

View File

@ -1,7 +1,8 @@
<template> <template>
<div class="book-wrap"> <div class="book-wrap">
<el-scrollbar height="100%"> <el-scrollbar height="100%">
<div class="book-name flex" @click="dialogVisible = true"> <div class="book-name flex" v-if="isStadium"> {{userStore.user.deptName}}</div>
<div v-else class="book-name flex" @click="dialogVisible = true">
<span>{{ curBook.data.itemtitle }}</span> <span>{{ curBook.data.itemtitle }}</span>
<i class="iconfont icon-xiangyou"></i> <i class="iconfont icon-xiangyou"></i>
</div> </div>
@ -46,8 +47,14 @@ import { onMounted, ref, nextTick, toRaw, reactive } from 'vue';
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import { useGetSubject } from '@/hooks/useGetSubject' import { useGetSubject } from '@/hooks/useGetSubject'
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
const BaseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH const BaseUrl = import.meta.env.VITE_APP_BUILD_BASE_PATH
const isStadium = () => {
let roles = userStore.user.roles
return roles.some(item => item.roleKey === 'stadium')
}
// emit // emit
const emit = defineEmits(['nodeClick', 'changeBook']) const emit = defineEmits(['nodeClick', 'changeBook'])
let useSubject = null let useSubject = null
@ -181,7 +188,11 @@ onMounted( async () => {
curBook.data = sessionStore.get('subject.curBook') curBook.data = sessionStore.get('subject.curBook')
} }
else{ else{
if (subjectList.value) {
curBook.data = subjectList.value[0] curBook.data = subjectList.value[0]
}else {
curBook.data = {}
}
} }
// "" // ""

View File

@ -204,7 +204,11 @@ onMounted(async () => {
curBook.data = sessionStore.get('subject.curBook') curBook.data = sessionStore.get('subject.curBook')
} }
else{ else{
if (subjectList.value) {
curBook.data = subjectList.value[0] curBook.data = subjectList.value[0]
}else {
curBook.data = {}
}
} }
// "" // ""

View File

@ -17,6 +17,17 @@ export const useGetSubject = async () =>{
// 根据学科 + 学段 获取所有单元章节 // 根据学科 + 学段 获取所有单元章节
const getSubjectUnit = async () =>{ const getSubjectUnit = async () =>{
if(isStadium(userStore.user)) {
//如果是基地人员直接拿treeData
const unitParams = {
itemgroup: '基地课程',
orderby: 'orderidx asc',
entpid: userStore.user.deptId,
pageSize: 10000
}
const { rows } = await listEvaluation(unitParams)
unitList.value = rows
}else{
if(sessionStore.get('subject.unitList')){ if(sessionStore.get('subject.unitList')){
unitList.value = sessionStore.get('subject.unitList') unitList.value = sessionStore.get('subject.unitList')
} }
@ -34,6 +45,11 @@ export const useGetSubject = async () =>{
} }
await getSubject() await getSubject()
} }
}
const isStadium = (user) => {
let roles = user.roles
return roles.some(item => item.roleKey === 'stadium')
}
// 根据学科 + 学段 获取教材 // 根据学科 + 学段 获取教材
const getSubject = async () =>{ const getSubject = async () =>{
@ -68,6 +84,9 @@ export const useGetSubject = async () =>{
// 单元章节数据转为“树”结构 // 单元章节数据转为“树”结构
const getTreeData = (bookId) =>{ const getTreeData = (bookId) =>{
if (!bookId) {
return unitList.value
}
// 根据当前教材的id 查找出对应的章节 // 根据当前教材的id 查找出对应的章节
let data = unitList.value.filter(item => item.rootid == bookId && item.level == 1) let data = unitList.value.filter(item => item.rootid == bookId && item.level == 1)
data.forEach( item => { data.forEach( item => {

View File

@ -11,7 +11,7 @@
</template> </template>
<div class="head-aside"> <div class="head-aside">
<ul > <ul >
<li :class="computedregistertype==1 || computedregistertype==3?'auth-li':'auth-li pointer-events'" @click="onUserTo('/schoolCertification')" > <li v-if="!isStadium" :class="computedregistertype==1 || computedregistertype==3?'auth-li':'auth-li pointer-events'" @click="onUserTo('/schoolCertification')" >
<i class="iconfont icon-renzheng-" :style="computedregistertype==4?'color:green;':''"></i> <i class="iconfont icon-renzheng-" :style="computedregistertype==4?'color:green;':''"></i>
<span class="mlr-5" v-if="computedregistertype!=4">学校认证</span> <span class="mlr-5" v-if="computedregistertype!=4">学校认证</span>
<span class="mlr-5" v-else>{{ userStore.DeptInfo.register.schoolName }}</span> <span class="mlr-5" v-else>{{ userStore.DeptInfo.register.schoolName }}</span>
@ -19,8 +19,8 @@
</li> </li>
<li v-if="computedregistertype!=4" :class="computedregistertype==1 || computedregistertype==2 ? '':'pointer-events'" @click="onUserTo('/joinSchool')">加入学校</li> <li v-if="computedregistertype!=4" :class="computedregistertype==1 || computedregistertype==2 ? '':'pointer-events'" @click="onUserTo('/joinSchool')">加入学校</li>
<li @click="onUserTo('/profile')">个人中心</li> <li @click="onUserTo('/profile')">个人中心</li>
<li @click="onUserTo('/schoolManagement')">学校管理</li> <li v-if="!isStadium" @click="onUserTo('/schoolManagement')">学校管理</li>
<li @click="onUserTo('/class')">班级中心</li> <li v-if="!isStadium" @click="onUserTo('/class')">班级中心</li>
<li @click="logout">退出登录</li> <li @click="logout">退出登录</li>
</ul> </ul>
</div> </div>
@ -53,7 +53,7 @@
</template> </template>
<script setup> <script setup>
import { ref, watch , reactive, onMounted,computed} from 'vue' import { ref, watch , reactive, onMounted, onBeforeMount, computed} from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { ElMessageBox, ElMessage } from 'element-plus' import { ElMessageBox, ElMessage } from 'element-plus'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
@ -64,6 +64,7 @@ import pkc from "../../../../../package.json"
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
const dev_api = ref(import.meta.env.VITE_APP_BASE_API) const dev_api = ref(import.meta.env.VITE_APP_BASE_API)
const userStore = useUserStore() const userStore = useUserStore()
console.log(userStore)
const router = useRouter() const router = useRouter()
const currentRoute = ref('') const currentRoute = ref('')
const activeId = ref('/home') const activeId = ref('/home')
@ -74,7 +75,19 @@ const version = ref(pkc.version)
const popoverRef = ref('') const popoverRef = ref('')
const headerMenus = [ //
const isStadium = () => {
let user = userStore.user
let roles = user.roles
return roles.some(item => item.roleKey === 'stadium')
}
const headerMenus = isStadium() ?[{
name: '教学实践',
id: 4,
icon: 'icon-jiaoxueshijian',
path: '/prepare'
},]:[
{ {
name: '教学大模型', name: '教学大模型',
id: 1, id: 1,

View File

@ -16,6 +16,7 @@ import router from './router'
import log from 'electron-log/renderer' // 渲染进程日志-文件记录 import log from 'electron-log/renderer' // 渲染进程日志-文件记录
import customComponent from '@/components/common' // 自定义组件 import customComponent from '@/components/common' // 自定义组件
import plugins from './plugins' // plugins插件 import plugins from './plugins' // plugins插件
import useUserStore from '@/store/modules/user'
if(process.env.NODE_ENV != 'development') { // 非开发环境,将日志打印到日志文件 if(process.env.NODE_ENV != 'development') { // 非开发环境,将日志打印到日志文件
Object.assign(console, log.functions) // 渲染进程日志-控制台替换 Object.assign(console, log.functions) // 渲染进程日志-控制台替换
@ -47,3 +48,16 @@ app.use(router)
.use(Icon) .use(Icon)
.use(Directive) .use(Directive)
.mount('#app') .mount('#app')
const isStadium = (user) => {
let roles = user.roles
return roles.some(item => item.roleKey === 'stadium')
}
router.beforeEach((to, from, next) => {
if (to.path === '/model/index') {
isStadium(useUserStore().user) === true ? next('/prepare') :next()
}else {
next()
}
})

View File

@ -101,7 +101,7 @@ const dynamicRoutes = [
{ {
path: '/', path: '/',
component: Layout, component: Layout,
redirect: '/desktop', redirect: '/model/index',
meta: { title: '教学工作台' }, meta: { title: '教学工作台' },
children: [ children: [
{ {

View File

@ -231,7 +231,7 @@ const submitForm = async (formEl) => {
try { try {
await userStore.login(loginForm) await userStore.login(loginForm)
await userStore.getInfo() await userStore.getInfo()
if (userStore.user.edustage || userStore.user.edusubject) { if (userStore.user.edustage || userStore.user.edusubject || isStadium(userStore.user)) {
ElMessage.success('登录成功') ElMessage.success('登录成功')
ipcRenderer && ipcRenderer.send('openMainWindow') ipcRenderer && ipcRenderer.send('openMainWindow')
} else { } else {
@ -244,6 +244,11 @@ const submitForm = async (formEl) => {
}) })
} }
const isStadium = (user) => {
let roles = user.roles
return roles.some(item => item.roleKey === 'stadium')
}
const getCookie = async () => { const getCookie = async () => {
const username = (await getCookieDetail('username'))[0] const username = (await getCookieDetail('username'))[0]
const password = (await getCookieDetail('password'))[0] const password = (await getCookieDetail('password'))[0]

View File

@ -18,7 +18,20 @@
<div class="content-body-left"> <div class="content-body-left">
<div class="content-body-left-title"> <div class="content-body-left-title">
文枢课件 文枢课件
<el-button class="add-btn" size="small" type="primary" @click="createAIPPT">新建</el-button> <!-- <el-button class="add-btn" size="small" type="primary" @click="createAIPPT">新建</el-button>-->
<el-dropdown class="prepare-center-dropdown add-btn">
<el-button type="primary">
新建<el-icon class="el-icon--right"><arrow-down /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="createAIPPT">新建文枢课件</el-dropdown-item>
<el-dropdown-item @click="router.push({path: '/model/design'})">AI一键生成</el-dropdown-item>
<el-dropdown-item @click="openFilePicker">导入PPT</el-dropdown-item>
<input type="file" ref="fileInput" style="display: none;" @change="handleFileChange" accept="application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation">
</el-dropdown-menu>
</template>
</el-dropdown>
</div> </div>
<div class="content-body-left-body"> <div class="content-body-left-body">
<kj-list-item <kj-list-item
@ -59,6 +72,7 @@
</div> </div>
</div> </div>
</el-row> </el-row>
<progress-dialog v-model:visible="pgDialog.visible" v-bind="pgDialog" />
</template> </template>
<script setup> <script setup>
@ -70,14 +84,20 @@ import ChooseTextbook from '@/components/choose-textbook/index.vue'
import KjListItem from '@/views/prepare/container/kj-list-item.vue' import KjListItem from '@/views/prepare/container/kj-list-item.vue'
import FileImage from '@/components/file-image/index.vue' import FileImage from '@/components/file-image/index.vue'
import {creatAPT, getSmarttalkPage} from '@/api/file' import {creatAPT, getSmarttalkPage} from '@/api/file'
import {Flag, Position} from '@element-plus/icons-vue' import {ArrowDown, Flag, Position} from '@element-plus/icons-vue'
import {asyncLocalFile, parseCataByNode} from "@/utils/talkFile"; import {asyncLocalFile, parseCataByNode} from "@/utils/talkFile";
import { dataSetJson } from '@/utils/comm' // id import { dataSetJson } from '@/utils/comm' // id
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import {listEntpcourse} from "@/api/teaching/classwork"; import {listEntpcourse} from "@/api/teaching/classwork";
import {addEntpcoursefileReturnId, getEntpcoursefile} from "@/api/education/entpcoursefile"; import {addEntpcoursefileReturnId, getEntpcoursefile} from "@/api/education/entpcoursefile";
import {createWindow, ipcMsgSend} from "@/utils/tool"; import {createWindow, ipcMsgSend} from "@/utils/tool";
import {ElMessage} from "element-plus"; // import {ElMessage} from "element-plus";
import {PPTXFileToJson} from "@/AixPPTist/src/hooks/useImport";
import * as API_entpcoursefile from "@/api/education/entpcoursefile";
import progressDialog from '@/views/teachingDesign/container/progress-dialog.vue'
import msgUtils from "@/plugins/modal";
import * as commUtils from "@/utils/comm";
import * as Api_server from "@/api/apiService"; //
const router = useRouter() const router = useRouter()
const userStore = useUserStore().user // const userStore = useUserStore().user //
const currentNode = ref({}) const currentNode = ref({})
@ -212,6 +232,153 @@ const createAIPPT = () => {
}) })
} }
const pgDialog = ref({ // -
visible: false,
title: 'PPT解析中...',
width: 300,
showClose: false,
draggable: true,
beforeClose: done => {}, // -
pg: { // -
percentage: 0, //
color: [
{ color: '#1989fa', percentage: 50 }, //
{ color: '#e6a23c', percentage: 80 }, //
{ color: '#5cb87a', percentage: 100 }, // 绿
]
}
})
const fileInput = ref(null)
const openFilePicker = () =>{
fileInput.value.click();
}
const handleFileChange = ()=> {
const file = event.target.files[0];
if (file) {
console.log(file);
createAIPPTByFile(file)
}
}
const createAIPPTByFile = async (file)=> {
pgDialog.value.visible = true
pgDialog.value.pg.percentage = 0
const resPptJson = await PPTXFileToJson(file)
const { def, slides, ...content } = resPptJson
// || 线
let completed = 0
const total = slides.length
for( let o of slides ) {
completed++
await toRousrceUrl(o)
//
pgDialog.value.pg.percentage = Math.floor(completed / total * 100)
}
pgDialog.value.pg.percentage = 0
pgDialog.value.visible = false
listEntpcourse({
evalid: currentNode.value.id,
edituserid: userStore.userId,
pageSize: 500
}).then((response) => {
if (response.rows.length <= 0) return
let resCourse = response.rows[0]
//
let form = {
parentid: 0,
entpid: userStore.deptId,
entpcourseid: resCourse.id,
ppttype: 'file',
title: resCourse.coursetitle,
fileurl: '',
filetype: 'aippt',
datacontent: '',
parentContent: JSON.stringify(content),
filekey: '',
filetag: '',
fileidx: 0,
dflag: 0,
status: '',
edituserid: userStore.userId
}
addEntpcoursefileReturnId(form).then((slideid) => {
creatAPT({
...uploadData.value,
fileId: slideid,
fileFlag: 'aippt',
fileShowName: currentNode.value.itemtitle + '.aippt'
}).then(async (res) => {
const resSlides = slides.map(({id, ...slide}) => JSON.stringify(slide))
let params = {
parentid: slideid,
entpid: resCourse.entpid,
entpcourseid: resCourse.id,
title: '',
filetype: 'slide',
slides: resSlides,
edituserid: userStore.userId
}
const res_3 = await API_entpcoursefile.batchAddNew(params)
if (res_3 && res_3.code == 200) {
msgUtils.msgSuccess('导入PPT课件成功')
currentFileList.value.unshift(res.resData)
await nextTick();
refs.value['kjItemRef'+res.resData.id].openFileWin(res.resData);
} else {
msgUtils.msgWarning('导入PPT课件失败')
}
})
})
})
}
const toRousrceUrl = async (o) => {
if (!!o.src) { // src
const isBase64 = /^data:image\/(\w+);base64,/.test(o.src)
const isBlobUrl = /^blob:/.test(o.src)
// console.log('isBase64', o, isBase64)
if (isBase64) {
const bolb = commUtils.base64ToBlob(o.src)
const fileName = Date.now() + '.png'
const file = commUtils.blobToFile(bolb, fileName)
// o.src = fileName
// console.log('file', file)
const formData = new FormData()
formData.append('file', file)
const res = await Api_server.Other.uploadFile(formData)
if (res && res.code == 200){
const url = res?.url
url &&(o.src = url)
}
} else if (isBlobUrl) { //
const res = await fetch(o.src)
const blob = await res.blob()
const fileName = o.type=='video'? Date.now() + '.mp4':Date.now() + '.mp3'
const file = commUtils.blobToFile(blob, fileName)
// o.src = fileName
// console.log('file', file)
const formData = new FormData()
formData.append('file', file)
const ress = await Api_server.Other.uploadFile(formData)
if (ress && ress.code == 200){
const url = ress?.url
url &&(o.src = url)
}
}
}
if (o?.background?.image) await toRousrceUrl(o.background.image)
if(o?.elements){
for (let element of o.elements) {
await toRousrceUrl(element);
}
}
}
const deleteTalk = (item) => { const deleteTalk = (item) => {
let index = currentFileList.value.indexOf(item) let index = currentFileList.value.indexOf(item)
currentFileList.value.splice(index, 1) currentFileList.value.splice(index, 1)
@ -219,7 +386,6 @@ const deleteTalk = (item) => {
// //
const changeBook = async(data) => { const changeBook = async(data) => {
console.log(data)
let cata = parseCataByNode(data.node) let cata = parseCataByNode(data.node)
currentNode.value = data.node currentNode.value = data.node
uploadData.value.levelFirstId = cata[0] uploadData.value.levelFirstId = cata[0]

View File

@ -603,8 +603,6 @@ export default {
// //
this.pgDialog.pg.percentage = Math.floor(completed / total * 100) this.pgDialog.pg.percentage = Math.floor(completed / total * 100)
} }
console.log('结束', slides)
return
this.pgDialog.pg.percentage = 0 this.pgDialog.pg.percentage = 0
this.pgDialog.visible = false this.pgDialog.visible = false
listEntpcourse({ listEntpcourse({
@ -641,8 +639,6 @@ export default {
}).then(async (res) => { }).then(async (res) => {
const resSlides = slides.map(({id, ...slide}) => JSON.stringify(slide)) const resSlides = slides.map(({id, ...slide}) => JSON.stringify(slide))
console.log(resSlides)
return
let params = { let params = {
parentid: slideid, parentid: slideid,
entpid: resCourse.entpid, entpid: resCourse.entpid,