资源模块修改

This commit is contained in:
lyc 2024-07-17 09:26:31 +08:00
parent 42f3689066
commit bf9cf39355
6 changed files with 224 additions and 14 deletions

View File

@ -87,14 +87,25 @@ const getSubjectContent = async () => {
entpcourseedituserid: userId, entpcourseedituserid: userId,
pageSize: 500 pageSize: 500
} }
const { rows } = await listEvaluation(params)
evaluationList.value = rows let data;
if (localStorage.getItem('evaluationList')) {
evaluationList.value = JSON.parse(localStorage.getItem('evaluationList'))
data = evaluationList.value
}
else {
const { rows } = await listEvaluation(params)
localStorage.setItem('evaluationList', JSON.stringify(rows))
evaluationList.value = rows
data = rows
}
// //
await getSubject() await getSubject()
// //
volumeOne.value = rows.filter(item => item.level == 1 && item.semester == '上册') volumeOne.value = data.filter(item => item.level == 1 && item.semester == '上册')
// //
volumeTwo.value = rows.filter(item => item.level == 1 && item.semester == '下册') volumeTwo.value = data.filter(item => item.level == 1 && item.semester == '下册')
getTreeData() getTreeData()
} }
@ -214,8 +225,15 @@ const transData = (data) => {
// //
const getSubject = async () => { const getSubject = async () => {
const { rows } = await listEvaluation({ itemkey: "version", pageSize: 500 }) if(localStorage.getItem('subjectList')){
subjectList.value = rows.filter(item => item.edustage == edustage && item.edusubject == edusubject && isHaveUnit(item.id)) subjectList.value = JSON.parse(localStorage.getItem('subjectList'))
}
else{
const { rows } = await listEvaluation({ itemkey: "version", pageSize: 500 })
subjectList.value = rows.filter(item => item.edustage == edustage && item.edusubject == edusubject && isHaveUnit(item.id))
localStorage.setItem('subjectList', JSON.stringify(subjectList.value))
}
// //
curBookName.value = subjectList.value[0].itemtitle curBookName.value = subjectList.value[0].itemtitle
curBookId.value = subjectList.value[0].id curBookId.value = subjectList.value[0].id

View File

@ -0,0 +1,179 @@
<template>
<el-dialog v-model="dialogValue" :show-close="false" width="630" :before-close="beforeClose"
style="border-radius: 5px;padding-top: 0">
<div class="dialog-title flex">
<span>{{ title }}</span>
<span>x</span>
</div>
<div class="book-name flex">
<span>{{ curBookName }}</span>
</div>
<template #footer>
</template>
</el-dialog>
</template>
<script setup>
import { ref, onMounted, nextTick, watch, defineProps, defineEmits } from 'vue'
const props = defineProps({
modelValue: {
type: Boolean,
default: false
},
title: {
type: String,
default: '移动至'
}
})
const dialogValue = ref(false)
//
const subjectList = ref([])
const evaluationList = ref([])
const treeData = ref([])
const defaultProps = {
children: 'children',
label: 'label',
class: 'textbook-tree'
}
//ID
const curBookId = ref(-1)
//
const curBookName = ref('')
//
const volumeOne = ref([])
//
const volumeTwo = ref([])
// ID
const currentNode = ref(0)
//
const currentNodeName = ref('')
//
const defaultExpandedKeys = ref([])
// tree
const refTree = ref(null)
// emit
const emit = defineEmits(['update:modelValue',])
watch(() => props.modelValue, (newVal) => {
dialogValue.value = newVal
})
const getSubjectContent = () => {
evaluationList.value = JSON.parse(localStorage.getItem('evaluationList'))
let data = evaluationList.value
//
getSubject()
//
volumeOne.value = data.filter(item => item.level == 1 && item.semester == '上册')
//
volumeTwo.value = data.filter(item => item.level == 1 && item.semester == '下册')
getTreeData()
}
const getSubject = () => {
subjectList.value = JSON.parse(localStorage.getItem('subjectList'))
//
curBookName.value = subjectList.value[0].itemtitle
curBookId.value = subjectList.value[0].id
}
const getTreeData = () => {
//
let upData = transData(volumeOne.value)
let downData = transData(volumeTwo.value)
treeData.value = upData.length ? upData : downData
defaultExpandedKeys.value = [treeData.value[0].id]
nextTick(() => {
currentNode.value = getLastLevelData(treeData.value)[0].id
currentNodeName.value = getLastLevelData(treeData.value)[0].label
// emitChangeBook()
})
}
const transData = (data) => {
let ary = []
data.forEach(item => {
let obj = {}
if (item.rootid == curBookId.value) {
obj.label = item.itemtitle
obj.id = item.id
let ary2 = []
evaluationList.value.forEach(el => {
let obj2 = {}
if (item.id == el.parentid) {
obj2 = {
label: el.itemtitle,
id: el.id
}
ary2.push(obj2)
}
obj.children = ary2
})
ary.push(obj)
}
})
return ary
}
//
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;
}
//
const beforeClose = (done) => {
emit('update:modelValue', false)
done()
}
onMounted(() => {
getSubjectContent()
})
</script>
<style lang="scss" scoped>
.dialog-title {
justify-content: space-between;
font-size: 16px;
font-weight: 600;
color: #000;
}
.book-name {
justify-content: space-between;
font-size: 14px;
font-weight: 600;
color: #0f0f0f;
padding: 15px 0;
}
</style>

View File

@ -90,7 +90,7 @@ const hanleFileChange = (file) => {
const fileType = file.raw.type const fileType = file.raw.type
if (!(audioTypes.includes(fileType) || videoTypes.includes(fileType) || wordTypes.includes(fileType) || pptTypes.includes(fileType) || pdfTypes.includes(fileType) || zipTypes.includes(fileType) || imgTypes.includes(fileType) || textTypes.includes(fileType))) { if (!(audioTypes.includes(fileType) || videoTypes.includes(fileType) || wordTypes.includes(fileType) || pptTypes.includes(fileType) || pdfTypes.includes(fileType) || zipTypes.includes(fileType) || imgTypes.includes(fileType) || textTypes.includes(fileType))) {
ElMessage.error('文件格式错误! 请上传图片、音频、视频、word、ppt、pdf、text、zip文件!') ElMessage.error('文件格式错误! 请上传图片、音频、视频、word、ppt、pdf、txt、zip文件!')
return false return false
} }
// //
@ -110,7 +110,6 @@ const hanleFileChange = (file) => {
} }
} }
// //
const delFile = (index) => { const delFile = (index) => {
fileList.value.splice(index, 1) fileList.value.splice(index, 1)

View File

@ -179,6 +179,10 @@ export default {
} }
.prepare-body-main-item { .prepare-body-main-item {
position: relative; position: relative;
display: flex;
align-items: center;
border-bottom: 1px solid rgba(131, 131, 127, 0.17);
padding: 10px 0;
.prepare-uploader-progress { .prepare-uploader-progress {
height: 100%; height: 100%;
position: absolute; position: absolute;
@ -189,10 +193,7 @@ export default {
&:hover { &:hover {
background-color: rgba(144, 147, 153, 0.2); background-color: rgba(144, 147, 153, 0.2);
} }
display: flex;
align-items: center;
border-bottom: 1px solid rgba(131, 131, 127, 0.17);
padding: 10px 0;
.prepare-body-main-item-icon { .prepare-body-main-item-icon {
width: 80px; width: 80px;
} }

View File

@ -84,6 +84,7 @@ const useUserStore = defineStore(
this.token = '' this.token = ''
this.roles = [] this.roles = []
this.permissions = [] this.permissions = []
localStorage.clear()
removeToken() removeToken()
resolve() resolve()
}).catch(error => { }).catch(error => {

View File

@ -37,6 +37,10 @@
<i class="iconfont icon-xiazai"></i> <i class="iconfont icon-xiazai"></i>
<span>下载</span> <span>下载</span>
</div> </div>
<div class="item-popover-item" @click="moveFile(item)">
<i class="iconfont icon-xiazai"></i>
<span>移动至</span>
</div>
</div> </div>
</template> </template>
</el-popover> </el-popover>
@ -54,19 +58,22 @@
:page-sizes="[10, 20, 30, 50]" background layout="total, sizes, prev, pager, next, jumper" :page-sizes="[10, 20, 30, 50]" background layout="total, sizes, prev, pager, next, jumper"
:total="sourceStore.result.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" /> :total="sourceStore.result.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
</div> </div>
<MoveFile v-model="moveDialogVisible" />
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import FileImage from '@/components/file-image/index.vue' import FileImage from '@/components/file-image/index.vue'
import { deleteSmarttalk, updateSmarttalk } from '@/api/file' import { deleteSmarttalk, updateSmarttalk } from '@/api/file'
import MoveFile from '@/components/move-file/index.vue'
import { getFileSuffix } from '@/utils/ruoyi' import { getFileSuffix } from '@/utils/ruoyi'
import useResoureStore from '../store' import useResoureStore from '../store'
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
const sourceStore = useResoureStore() const sourceStore = useResoureStore()
const moveDialogVisible = ref(false)
const handleSizeChange = () => { } const handleSizeChange = () => { }
const handleCurrentChange = () => { } const handleCurrentChange = () => { }
@ -109,6 +116,11 @@ const delRow = (item) => {
} }
} }
//
const moveFile = (item) => {
moveDialogVisible.value = true
}
</script> </script>
<style> <style>