平台资源管理员
This commit is contained in:
parent
e6da6ef65f
commit
bf9e7c96ff
|
@ -28,6 +28,7 @@
|
|||
"element-plus": "^2.7.6",
|
||||
"js-cookie": "^3.0.5",
|
||||
"jsencrypt": "^3.3.2",
|
||||
"lodash": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"spark-md5": "^3.0.2",
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
import useUserStore from '@/store/modules/user'
|
||||
|
||||
import array from 'lodash/array'
|
||||
export const hasPermission = (value, def = true) => {
|
||||
// 不传值,默认视为有权限,不做鉴权
|
||||
if (!value) {
|
||||
return def
|
||||
}
|
||||
|
||||
const allCodeList = useUserStore().roles
|
||||
// 如果不是数组,直接判断pinia里的权限数组有没有相同的元素即可
|
||||
if (!Array.isArray(value)) {
|
||||
return allCodeList.includes(value)
|
||||
}
|
||||
// intersection是lodash提供的一个方法,用于返回一个所有给定数组都存在的元素组成的数组
|
||||
return array.intersection(value, allCodeList).length > 0
|
||||
}
|
|
@ -8,7 +8,8 @@
|
|||
}}</el-button>
|
||||
</el-col>
|
||||
<el-col :span="12" class="search-box flex">
|
||||
<el-input v-model="sourceStore.query.fileName" @input="sourceStore.changeName" style="width: 240px" placeholder="请输入关键词" />
|
||||
<el-input v-model="sourceStore.query.fileName" @input="sourceStore.changeName" style="width: 240px"
|
||||
placeholder="请输入关键词" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="resoure-btns">
|
||||
|
@ -58,6 +59,7 @@ const sourceStore = useResoureStore()
|
|||
|
||||
.query-row {
|
||||
justify-content: space-between;
|
||||
|
||||
.row-left {
|
||||
align-items: center;
|
||||
}
|
||||
|
@ -74,6 +76,7 @@ const sourceStore = useResoureStore()
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
.el-button.is-round {
|
||||
padding: 3px 15px;
|
||||
font-size: 13px;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div class="page-right">
|
||||
<!-- 搜索 -->
|
||||
<ResoureSearch #add>
|
||||
<el-button type="primary" round @click="openDialog" class="create-btn">
|
||||
<el-button v-if="hasPermission(['platformmanager'])" type="primary" round @click="openDialog" class="create-btn">
|
||||
<i class="iconfont icon-jiahao"></i>
|
||||
新建资源</el-button>
|
||||
</ResoureSearch>
|
||||
|
@ -26,6 +26,7 @@ import ResoureSearch from './container/resoure-search.vue'
|
|||
import ResoureList from './container/resoure-list.vue'
|
||||
import uploadDialog from '@/components/upload-dialog/index.vue'
|
||||
import uploaderState from '@/store/modules/uploader'
|
||||
import { hasPermission } from '@/utils/hasPermission'
|
||||
|
||||
const sourceStore = useResoureStore()
|
||||
const isDialogOpen = ref(false)
|
||||
|
@ -76,7 +77,6 @@ const submitFile = (data) => {
|
|||
|
||||
|
||||
const fileCallBack = (res) => {
|
||||
console.log(res)
|
||||
if (res.code == 200) {
|
||||
sourceStore.handleQuery()
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
|
|||
import { getSmarttalkPage } from '@/api/file/index'
|
||||
import { tabs, resourceType, resourceFormat } from '@/utils/resourceDict'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { hasPermission } from '@/utils/hasPermission'
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
|
@ -21,11 +22,16 @@ const resourceFormatList = [
|
|||
]
|
||||
|
||||
// 校本资源为学校ID
|
||||
tabs.forEach(item =>{
|
||||
if( item.label == "校本资源"){
|
||||
tabs.forEach((item) => {
|
||||
if (item.label == '校本资源') {
|
||||
item.value = userStore.user.deptId
|
||||
}
|
||||
})
|
||||
tabs.forEach((item, i) => {
|
||||
if (item.label == '平台资源' && !hasPermission(['platformmanager'])) {
|
||||
tabs.splice(i, 1)
|
||||
}
|
||||
})
|
||||
|
||||
const structQuery = {
|
||||
pageNum: 1,
|
||||
|
@ -46,7 +52,7 @@ export default defineStore('resource', {
|
|||
//查询条件
|
||||
query: {
|
||||
textbookId: '',
|
||||
fileSource: '平台',
|
||||
fileSource: tabs[0].value,
|
||||
//资源格式 mp3 ppt ...
|
||||
fileSuffix: -1,
|
||||
// 资源类型 课件 素材 教案
|
||||
|
@ -70,6 +76,7 @@ export default defineStore('resource', {
|
|||
if (data.fileSuffix == -1) {
|
||||
data.fileSuffix = ''
|
||||
}
|
||||
console.log(data, 200)
|
||||
getSmarttalkPage(data).then((res) => {
|
||||
this.result.total = res.total
|
||||
this.result.list = res.rows
|
||||
|
@ -92,8 +99,7 @@ export default defineStore('resource', {
|
|||
},
|
||||
// 关键词搜索
|
||||
changeName() {
|
||||
console.log(this.query.fileName)
|
||||
this.handleQuery()
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue