lyc-dev #59

Merged
lyc merged 6 commits from lyc-dev into main 2024-07-24 15:27:58 +08:00
5 changed files with 49 additions and 21 deletions
Showing only changes of commit bf9e7c96ff - Show all commits

View File

@ -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",

View File

@ -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
}

View File

@ -8,12 +8,13 @@
}}</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">
<el-col :span="24" class="query-row flex">
<div class="flex row-left"> <el-select v-model="sourceStore.query.fileSuffix" @change="sourceStore.changeSuffix"
<div class="flex row-left"> <el-select v-model="sourceStore.query.fileSuffix" @change="sourceStore.changeSuffix"
style="width: 110px">
<el-option v-for="item in sourceStore.resourceFormatList" :key="item.value" :label="item.label"
:value="item.value" />
@ -22,7 +23,7 @@
<el-button v-for="item in sourceStore.resourceTypeList" :key="item.id"
:type="sourceStore.query.fileFlag == item.value ? 'primary' : ''" round
@click="sourceStore.changeType(item.value)">{{
item.label }}</el-button>
item.label }}</el-button>
</div>
<div>
<slot name="add" />
@ -58,7 +59,8 @@ const sourceStore = useResoureStore()
.query-row {
justify-content: space-between;
.row-left{
.row-left {
align-items: center;
}
}
@ -74,7 +76,8 @@ const sourceStore = useResoureStore()
}
}
.el-button.is-round{
.el-button.is-round {
padding: 3px 15px;
font-size: 13px;
}

View File

@ -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()
}

View File

@ -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,10 +22,15 @@ const resourceFormatList = [
]
// 校本资源为学校ID
tabs.forEach(item =>{
if( item.label == "校本资源"){
item.value = userStore.user.deptId
}
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 = {
@ -41,12 +47,12 @@ export default defineStore('resource', {
searchKey: '',
//节点数据
nodeData:{},
nodeData: {},
loading: false,
//查询条件
query: {
textbookId: '',
fileSource: '平台',
fileSource: tabs[0].value,
//资源格式 mp3 ppt ...
fileSuffix: -1,
// 资源类型 课件 素材 教案
@ -66,10 +72,11 @@ export default defineStore('resource', {
handleQuery() {
try {
this.loading = true
let data = {...this.query}
if(data.fileSuffix == -1){
let data = { ...this.query }
if (data.fileSuffix == -1) {
data.fileSuffix = ''
}
console.log(data, 200)
getSmarttalkPage(data).then((res) => {
this.result.total = res.total
this.result.list = res.rows
@ -86,14 +93,13 @@ export default defineStore('resource', {
this.query.fileFlag = val
this.handleQuery()
},
changeSuffix(val){
changeSuffix(val) {
this.query.fileSuffix = val
this.handleQuery()
},
// 关键词搜索
changeName(){
console.log(this.query.fileName)
changeName() {
this.handleQuery()
},
}
}
})