yujialong 4 years ago
parent 42eca4bfec
commit a9110a48b9
  1. 19
      src/layouts/navbar/index.vue
  2. 3
      src/libs/auth/generateBtnPermission.js
  3. 16
      src/libs/route/addRoutes.js
  4. 9
      src/libs/util.js
  5. 2
      src/pages/client/list/index.vue
  6. 6
      src/pages/quesBank/list/globalQuesBank.vue
  7. 33
      src/pages/quesBank/list/index.vue
  8. 46
      src/pages/quesBank/list/myQuesBank.vue
  9. 8
      src/pages/quesBank/list/quesBankType.vue
  10. 7
      src/pages/setting/person/index.vue
  11. 12
      src/pages/system/list/index.vue
  12. 14
      src/pages/system/list/role.vue
  13. 12
      src/pages/system/list/staff.vue
  14. 28
      src/plugins/auth/index.js
  15. 2
      src/router/permission.js

@ -51,6 +51,7 @@
</template>
<script>
import { mapState } from 'vuex'
import bus from '@/libs/bus';
import Setting from '@/setting';
export default {
@ -60,22 +61,22 @@ export default {
defaultMenus: [
{
icon: 'el-icon-coordinate',
index: '/index',
index: '/index/list',
title: '学校管理'
},
{
icon: 'el-icon-user',
index: '/user',
index: '/user/list',
title: '用户管理'
},
{
icon: 'el-icon-notebook-1',
index: '/quesBank',
index: '/quesBank/list',
title: '题库管理'
},
{
icon: 'el-icon-setting',
index: '/system',
index: '/system/list',
title: '系统设置'
}
],
@ -91,8 +92,11 @@ export default {
for(let i in this.actives){
if(actives[i].includes(this.$route.name)) return `/${i}`
}
return '/' + this.$route.name.replace(/-\w+/,'')
}
return this.$route.path
},
...mapState('auth', [
'routes'
])
},
created() {
this.initMenu()
@ -105,12 +109,13 @@ export default {
methods: {
initMenu(){
if(Setting.dynamicRoute){
let routes = this.$store.state.routes[1].children
let routes = this.routes
let menus = []
this.defaultMenus.map(e => {
routes.find(n => n.path == e.index) && menus.push(e)
})
this.menus = menus
this.active = menus[0].index
}else{
this.menus = this.defaultMenus
}

@ -21,6 +21,7 @@ export default function(data){
})
}
})
store.auth.commit('addBtnAuth',{btns: result})
// console.log(33,result,store)
store.dispatch('auth/addBtnAuth',result)
// console.log('geneBtn:',result)
}

@ -2,14 +2,10 @@ import store from '@/store'
import router from '@/router'
import generateBtnPermission from '../auth/generateBtnPermission'
const infoSidebar = ['information','content']
const matchSidebar = ['matchintro','matchprogress','matchsignup']
const newRoutes = []
function createMeta(item){
let meta = { title: item.name }
infoSidebar.includes(item.component) && (meta.sidebar = 'info')
matchSidebar.includes(item.component) && (meta.sidebar = 'match')
return meta
}
@ -20,7 +16,7 @@ function createRoute(data){
newRoutes.push({
name: e.component,
path: e.component,
component: () => import(`@/pages/${e.component}.vue`),
component: () => import(`@/pages${e.component}`),
meta
})
}
@ -31,11 +27,11 @@ function createRoute(data){
export default function(data,path){
generateBtnPermission(data)
createRoute(data)
let routes = router.options.routes
routes[1].children = [...routes[1].children,...newRoutes]
store.auth.commit("addRoutes", { routes })
router.addRoutes(routes)
// let routes = router.options.routes
// routes[1].children = [...routes[1].children,...newRoutes]
store.dispatch('auth/addRoutes',newRoutes)
// router.addRoutes(routes)
setTimeout(() => {
!newRoutes.find(n => n.name == 'dashboard') && router.push(newRoutes[0].path)
!newRoutes.find(n => n.name == '/index/list') && router.push(newRoutes[0].path)
},10)
}

@ -73,6 +73,11 @@ const util = {
if('jpg,jpeg,png,gif,svg,psd'.includes(ext)) return true
return false
},
// 传入文件后缀判断是否是pdf以外的文档
isDoc(ext) {
if(!util.isVideo(ext) && !util.isAudio(ext) && !util.isImg(ext) && ext != 'pdf') return true
return false
},
// 循环去除html标签
removeHtmlTag(list,attr) {
list.map(n => {
@ -80,6 +85,10 @@ const util = {
})
return list
},
// 传入文件名获取文件后缀
getFileExt(fileName) {
return fileName.substring(fileName.lastIndexOf('.') + 1)
},
}
export default util

@ -74,7 +74,7 @@
:inactive-value="1"
style="margin: 0 10px 0 5px"
@change="switchOff($event,scope.row,scope.$index)"
v-auth="'dashboard:禁用'"
v-auth="'/index/list:禁用'"
></el-switch>
</template>
</el-table-column>

@ -35,7 +35,7 @@
<div class="p-title">题目列表</div>
<div>
<el-button type="primary" size="small" round @click="delAllData" v-auth>批量取消共享</el-button>
<el-button type="primary" size="small" round @click="delAllData" v-auth="'/quesBank/list:公共题库:批量取消共享'">批量取消共享</el-button>
</div>
</div>
<el-table :data="listData" class="table" stripe header-align="center" row-key="id" @selection-change="handleSelectionChange">
@ -51,8 +51,8 @@
<el-table-column prop="createUser" label="创建人" width="100" align="center"></el-table-column>
<el-table-column label="操作" align="center" width="120">
<template slot-scope="scope">
<el-button type="text" @click="show(scope.row)" v-auth>查看</el-button>
<el-button type="text" @click="delData(scope.row)" v-auth>取消共享</el-button>
<el-button type="text" @click="show(scope.row)" v-auth="'/quesBank/list:公共题库:查看'">查看</el-button>
<el-button type="text" @click="delData(scope.row)" v-auth="'/quesBank/list:公共题库:取消共享'">取消共享</el-button>
</template>
</el-table-column>
</el-table>

@ -4,12 +4,14 @@
<a class="item" v-for="(item,index) in tabs" :key="index" :class="{active: index == active}" @click="tabChange(index)">{{item}}</a>
</div>
<ques-bank-type v-if="active == 'type'"></ques-bank-type>
<my-ques-bank v-else-if="active == 'my'"></my-ques-bank>
<global-ques-bank v-else></global-ques-bank>
<ques-bank-type v-if="active == 'type'" v-auth="'题库管理:题库分类'"></ques-bank-type>
<my-ques-bank v-else-if="active == 'my'" v-auth="'题库管理:我上传的题库'"></my-ques-bank>
<global-ques-bank v-else v-auth="'题库管理:公共题库'"></global-ques-bank>
</div>
</template>
<script>
import { mapState } from 'vuex'
import Setting from '@/setting'
import quesBankType from './quesBankType'
import myQuesBank from './myQuesBank'
import globalQuesBank from './globalQuesBank'
@ -21,7 +23,7 @@ export default {
type: '题库分类',
my: '我上传的题库',
global: '公共题库'
}
},
};
},
components: {
@ -29,12 +31,31 @@ export default {
myQuesBank,
globalQuesBank,
},
mounted() {
computed: {
...mapState('auth', [
'btns'
])
},
created() {
Setting.dynamicRoute && this.initTabs()
},
methods: {
tabChange(index){
this.active = index
},
initTabs(){
let tab1 = this.btns.includes('题库管理:题库分类')
let tab2 = this.btns.includes('题库管理:我上传的题库')
let tab3 = this.btns.includes('题库管理:公共题库')
if(!tab1 && tab2){
this.active = 'my'
}else if(!tab1 && !tab2 && tab3){
this.active = 'global'
}
if(!tab1) delete this.tabs.type
if(!tab2) delete this.tabs.my
if(!tab3) delete this.tabs.global
}
}
};

@ -28,36 +28,10 @@
<div class="p-title">题目列表</div>
<div>
<el-button
type="primary"
size="small"
round
@click="addTopics"
>单题上传</el-button>
<el-button
type="primary"
size="small"
round
@click="showimportVisible"
>批量上传</el-button>
<el-button
type="primary"
size="small"
round
@click="shareDataBatch"
>批量共享</el-button>
<!-- <el-button
type="primary"
size="small"
round
@click="cancelShareBatch"
>取消共享</el-button> -->
<el-button
type="primary"
size="small"
round
@click="delAllData"
>批量删除</el-button>
<el-button type="primary" size="small" round @click="addTopics" v-auth="'/quesBank/list:我上传的题库:单题上传'">单题上传</el-button>
<el-button type="primary" size="small" round @click="showimportVisible" v-auth="'/quesBank/list:我上传的题库:批量上传'">批量上传</el-button>
<el-button type="primary" size="small" round @click="shareDataBatch" v-auth="'/quesBank/list:我上传的题库:批量共享'">批量共享</el-button>
<el-button type="primary" size="small" round @click="delAllData" v-auth="'/quesBank/list:我上传的题库:批量删除'">批量删除</el-button>
</div>
</div>
@ -91,11 +65,11 @@
<el-table-column prop="createTime" label="上传时间" width="140" align="center"></el-table-column>
<el-table-column label="操作" width="230">
<template slot-scope="scope">
<el-button type="text" @click="show(scope.row)">查看</el-button>
<el-button type="text" @click="edit(scope.row)">修改</el-button>
<el-button type="text" @click="delData(scope.row)">删除</el-button>
<el-button v-if="!scope.row.myShare" type="text" @click="share(scope.row)">共享</el-button>
<el-button v-else type="text" @click="cancelShare(scope.row)">取消共享</el-button>
<el-button type="text" @click="show(scope.row)" v-auth="'/quesBank/list:我上传的题库:查看'">查看</el-button>
<el-button type="text" @click="edit(scope.row)" v-auth="'/quesBank/list:我上传的题库:修改'">修改</el-button>
<el-button type="text" @click="delData(scope.row)" v-auth="'/quesBank/list:我上传的题库:删除'">删除</el-button>
<el-button v-if="!scope.row.myShare" type="text" @click="share(scope.row)" v-auth="'/quesBank/list:我上传的题库:共享'">共享</el-button>
<el-button v-else type="text" @click="cancelShare(scope.row)" v-auth="'/quesBank/list:我上传的题库:共享'">取消共享</el-button>
</template>
</el-table-column>
</el-table>
@ -342,7 +316,7 @@ export default {
this.$message.error('请先选择数据!')
}
},
downLoad() {
downLoad() {
location.href = 'http://39.108.250.202/cjEnterprise/题库导入模板.xlsx'
},
showimportVisible() {

@ -17,7 +17,7 @@
<div class="p-title">分类管理</div>
<div>
<el-button type="primary" size="small" round @click="addFirst" v-auth>添加一级分类</el-button>
<el-button type="primary" size="small" round @click="addFirst" v-auth="'/quesBank/list:题库分类:添加一级分类'">添加一级分类</el-button>
</div>
</div>
<el-table :data="listData" class="table" stripe header-align="center" row-key="cid" :tree-props="treeProps" :indent="9">
@ -28,9 +28,9 @@
</el-table-column>
<el-table-column label="操作" width="200">
<template slot-scope="scope">
<el-button type="text" v-if="scope.row.parentId == 0" @click="addSecond(scope.row)" v-auth>添加</el-button>
<el-button type="text" @click="editType(scope.row)" v-auth>编辑</el-button>
<el-button type="text" @click="handleDelete(scope.row)" v-auth>删除</el-button>
<el-button type="text" v-if="scope.row.parentId == 0" @click="addSecond(scope.row)" v-auth="'/quesBank/list:题库分类:添加'">添加</el-button>
<el-button type="text" @click="editType(scope.row)" v-auth="'/quesBank/list:题库分类:编辑'">编辑</el-button>
<el-button type="text" @click="handleDelete(scope.row)" v-auth="'/quesBank/list:题库分类:删除'">删除</el-button>
</template>
</el-table-column>
</el-table>

@ -136,12 +136,12 @@
</el-select>
</div>
<div class="block">
<!-- <div class="block">
<p class="block-left">当前所在学校</p>
<el-select v-model="personalInformation.clientId" filterable placeholder="请选择学校">
<el-option v-for="(item,index) in schoolList" :key="index" :label="item.clientName" :value="item.id"></el-option>
</el-select>
</div>
</div> -->
</div>
</div>
@ -386,6 +386,7 @@ export default {
.then(res => {
this.personalInformation = res.data.userInfo
this.personalInformation.countries = '中国'
this.personalInformation.clientName = this.schoolList.find(n => n.id == this.personalInformation.clientId).clientName
this.curPassword = this.personalInformation.password
this.$nextTick(() => {
if(this.personalInformation.provinceId){
@ -450,7 +451,7 @@ export default {
phone: personalInformation.phone,
provinceId: personalInformation.provinceId,
clientId: personalInformation.clientId,
clientName: this.schoolList.find(n => n.id == personalInformation.clientId).clientName,
clientName: personalInformation.clientName,
sex: personalInformation.sex,
userId: personalInformation.userId,
userName: personalInformation.userName,

@ -14,6 +14,7 @@
</template>
<script>
import { mapState } from 'vuex'
import Setting from '@/setting';
import staff from './staff.vue';
import role from './role.vue';
@ -21,7 +22,6 @@ export default {
data() {
return {
activeName: 'staff',
userId: this.$store.state.userId,
tabs: {
staff: '员工管理',
role: '角色权限'
@ -33,6 +33,11 @@ export default {
staff,
role
},
computed: {
...mapState('auth', [
'btns'
])
},
created() {
Setting.dynamicRoute && this.initTabs()
},
@ -41,9 +46,8 @@ export default {
this.activeName = index
},
initTabs(){
let btnPermissions = this.$store.state.btnPermissions
let showStaff = btnPermissions.includes('系统设置:员工管理')
let showRole = btnPermissions.includes('系统设置:角色权限')
let showStaff = this.btns.includes('系统设置:员工管理')
let showRole = this.btns.includes('系统设置:角色权限')
if(!showStaff || !showRole){
this.showTabs = false

@ -16,8 +16,8 @@
<div class="p-title">角色列表</div>
<div>
<el-button type="primary" size="small" round @click="addRole" v-auth="'system:角色权限:新增角色'">新增角色</el-button>
<el-button type="primary" size="small" round @click="delAllSelection" v-auth="'system:角色权限:批量删除'">批量删除</el-button>
<el-button type="primary" size="small" round @click="addRole" v-auth="'/system/list:角色权限:新增角色'">新增角色</el-button>
<el-button type="primary" size="small" round @click="delAllSelection" v-auth="'/system/list:角色权限:批量删除'">批量删除</el-button>
</div>
</div>
<el-table :data="roleData" class="table" stripe header-align="center" @selection-change="handleSelectionChange" :row-key="getRowKeys">
@ -33,11 +33,11 @@
</el-table-column>
<el-table-column label="操作" width="180">
<template slot-scope="scope">
<el-button type="text" @click="showRole(scope.row)" v-auth="'system:角色权限:查看'">查看</el-button>
<!-- <template v-if="scope.row.id != 1"> -->
<el-button type="text" @click="editRole(scope.row)" v-auth="'system:角色权限:编辑'">编辑</el-button>
<el-button type="text" @click="handleDelete(scope.row)" v-auth="'system:角色权限:删除'">删除</el-button>
<!-- </template> -->
<el-button type="text" @click="showRole(scope.row)" v-auth="'/system/list:角色权限:查看'">查看</el-button>
<template v-if="scope.row.id != 1">
<el-button type="text" @click="editRole(scope.row)" v-auth="'/system/list:角色权限:编辑'">编辑</el-button>
<el-button type="text" @click="handleDelete(scope.row)" v-auth="'/system/list:角色权限:删除'">删除</el-button>
</template>
</template>
</el-table-column>
</el-table>

@ -13,9 +13,9 @@
<el-input placeholder="请输入员工姓名/工号" v-model="keyword" prefix-icon="el-icon-search" clearable></el-input>
</div>
<div>
<el-button type="primary" size="small" round @click="addTeacher" v-auth="'system:员工管理:新增员工'">新增员工</el-button>
<el-button type="primary" size="small" round @click="batchImport" v-auth="'system:员工管理:批量导入'">批量导入</el-button>
<el-button type="primary" size="small" round @click="delAllSelection" v-auth="'system:员工管理:批量删除'">批量删除</el-button>
<el-button type="primary" size="small" round @click="addTeacher" v-auth="'/system/list:员工管理:新增员工'">新增员工</el-button>
<el-button type="primary" size="small" round @click="batchImport" v-auth="'/system/list:员工管理:批量导入'">批量导入</el-button>
<el-button type="primary" size="small" round @click="delAllSelection" v-auth="'/system/list:员工管理:批量删除'">批量删除</el-button>
</div>
</div>
<el-table :data="listData" class="table" stripe header-align="center" @selection-change="handleSelectionChange">
@ -40,9 +40,9 @@
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button type="text" @click="showTeacher(scope.row)" v-auth="'system:员工管理:查看'">查看</el-button>
<el-button type="text" @click="editTeacher(scope.row)" v-auth="'system:员工管理:编辑'">编辑</el-button>
<el-button type="text" @click="delTeacher(scope.row)" v-auth="'system:员工管理:删除'">删除</el-button>
<el-button type="text" @click="showTeacher(scope.row)" v-auth="'/system/list:员工管理:查看'">查看</el-button>
<el-button type="text" @click="editTeacher(scope.row)" v-auth="'/system/list:员工管理:编辑'">编辑</el-button>
<el-button type="text" @click="delTeacher(scope.row)" v-auth="'/system/list:员工管理:删除'">删除</el-button>
</template>
</el-table-column>
</el-table>

@ -3,23 +3,25 @@
* 当传入的权限当前用户没有时会移除该组件
* 用例<Tag v-auth">text</Tag> 或者:<Tag v-auth="'user:编辑'">text</Tag>
* */
import store from '@/store';
import store from '@/store'
import Setting from '@/setting'
export default {
inserted (el, binding, vnode) {
let btnText = ''
if(binding.value){
btnText = binding.value
}else{
btnText = `${vnode.context.$route.name}:${el.innerText}`
}
const btnPermissions = store.state.auth.btns;
// console.log(22,btnText,btnPermissions)
if(Setting.dynamicRoute){
let btnText = ''
if(binding.value){
btnText = binding.value
}else{
btnText = `${vnode.context.$route.path}:${el.innerText}`
}
const btnPermissions = store.state.auth.btns
if (btnText && btnPermissions && btnPermissions.length) {
const isPermission = btnPermissions.includes(btnText);
if (!isPermission) {
el.parentNode && el.parentNode.removeChild(el);
if (btnText && btnPermissions && btnPermissions.length) {
const isPermission = btnPermissions.includes(btnText)
if (!isPermission) {
el.parentNode && el.parentNode.removeChild(el)
}
}
}
}

@ -29,4 +29,4 @@ router.beforeEach((to, from, next) => {
}
});
Setting.dynamicRoute && generateRoutes()
// Setting.dynamicRoute && generateRoutes()
Loading…
Cancel
Save