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", "element-plus": "^2.7.6",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",
"jsencrypt": "^3.3.2", "jsencrypt": "^3.3.2",
"lodash": "^4.17.21",
"pinia": "^2.1.7", "pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1", "pinia-plugin-persistedstate": "^3.2.1",
"spark-md5": "^3.0.2", "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-button>
</el-col> </el-col>
<el-col :span="12" class="search-box flex"> <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-col>
</el-row> </el-row>
<el-row class="resoure-btns"> <el-row class="resoure-btns">
<el-col :span="24" class="query-row flex"> <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"> style="width: 110px">
<el-option v-for="item in sourceStore.resourceFormatList" :key="item.value" :label="item.label" <el-option v-for="item in sourceStore.resourceFormatList" :key="item.value" :label="item.label"
:value="item.value" /> :value="item.value" />
@ -22,7 +23,7 @@
<el-button v-for="item in sourceStore.resourceTypeList" :key="item.id" <el-button v-for="item in sourceStore.resourceTypeList" :key="item.id"
:type="sourceStore.query.fileFlag == item.value ? 'primary' : ''" round :type="sourceStore.query.fileFlag == item.value ? 'primary' : ''" round
@click="sourceStore.changeType(item.value)">{{ @click="sourceStore.changeType(item.value)">{{
item.label }}</el-button> item.label }}</el-button>
</div> </div>
<div> <div>
<slot name="add" /> <slot name="add" />
@ -58,7 +59,8 @@ const sourceStore = useResoureStore()
.query-row { .query-row {
justify-content: space-between; justify-content: space-between;
.row-left{
.row-left {
align-items: center; align-items: center;
} }
} }
@ -70,11 +72,12 @@ const sourceStore = useResoureStore()
margin: 0 10px; margin: 0 10px;
} }
} }
} }
.el-button.is-round{
.el-button.is-round {
padding: 3px 15px; padding: 3px 15px;
font-size: 13px; font-size: 13px;
} }

View File

@ -6,7 +6,7 @@
<div class="page-right"> <div class="page-right">
<!-- 搜索 --> <!-- 搜索 -->
<ResoureSearch #add> <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> <i class="iconfont icon-jiahao"></i>
新建资源</el-button> 新建资源</el-button>
</ResoureSearch> </ResoureSearch>
@ -26,6 +26,7 @@ import ResoureSearch from './container/resoure-search.vue'
import ResoureList from './container/resoure-list.vue' import ResoureList from './container/resoure-list.vue'
import uploadDialog from '@/components/upload-dialog/index.vue' import uploadDialog from '@/components/upload-dialog/index.vue'
import uploaderState from '@/store/modules/uploader' import uploaderState from '@/store/modules/uploader'
import { hasPermission } from '@/utils/hasPermission'
const sourceStore = useResoureStore() const sourceStore = useResoureStore()
const isDialogOpen = ref(false) const isDialogOpen = ref(false)
@ -76,7 +77,6 @@ const submitFile = (data) => {
const fileCallBack = (res) => { const fileCallBack = (res) => {
console.log(res)
if (res.code == 200) { if (res.code == 200) {
sourceStore.handleQuery() sourceStore.handleQuery()
} }

View File

@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
import { getSmarttalkPage } from '@/api/file/index' import { getSmarttalkPage } from '@/api/file/index'
import { tabs, resourceType, resourceFormat } from '@/utils/resourceDict' import { tabs, resourceType, resourceFormat } from '@/utils/resourceDict'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { hasPermission } from '@/utils/hasPermission'
const userStore = useUserStore() const userStore = useUserStore()
@ -21,10 +22,15 @@ const resourceFormatList = [
] ]
// 校本资源为学校ID // 校本资源为学校ID
tabs.forEach(item =>{ tabs.forEach((item) => {
if( item.label == "校本资源"){ if (item.label == '校本资源') {
item.value = userStore.user.deptId item.value = userStore.user.deptId
} }
})
tabs.forEach((item, i) => {
if (item.label == '平台资源' && !hasPermission(['platformmanager'])) {
tabs.splice(i, 1)
}
}) })
const structQuery = { const structQuery = {
@ -39,14 +45,14 @@ export default defineStore('resource', {
resourceFormatList, resourceFormatList,
searchKey: '', searchKey: '',
//节点数据 //节点数据
nodeData:{}, nodeData: {},
loading: false, loading: false,
//查询条件 //查询条件
query: { query: {
textbookId: '', textbookId: '',
fileSource: '平台', fileSource: tabs[0].value,
//资源格式 mp3 ppt ... //资源格式 mp3 ppt ...
fileSuffix: -1, fileSuffix: -1,
// 资源类型 课件 素材 教案 // 资源类型 课件 素材 教案
@ -66,10 +72,11 @@ export default defineStore('resource', {
handleQuery() { handleQuery() {
try { try {
this.loading = true this.loading = true
let data = {...this.query} let data = { ...this.query }
if(data.fileSuffix == -1){ if (data.fileSuffix == -1) {
data.fileSuffix = '' data.fileSuffix = ''
} }
console.log(data, 200)
getSmarttalkPage(data).then((res) => { getSmarttalkPage(data).then((res) => {
this.result.total = res.total this.result.total = res.total
this.result.list = res.rows this.result.list = res.rows
@ -86,14 +93,13 @@ export default defineStore('resource', {
this.query.fileFlag = val this.query.fileFlag = val
this.handleQuery() this.handleQuery()
}, },
changeSuffix(val){ changeSuffix(val) {
this.query.fileSuffix = val this.query.fileSuffix = val
this.handleQuery() this.handleQuery()
}, },
// 关键词搜索 // 关键词搜索
changeName(){ changeName() {
console.log(this.query.fileName)
this.handleQuery() this.handleQuery()
}, }
} }
}) })