fixAuth
yujialong 2 years ago
parent a0fb8bbcb1
commit e3473f4cb9
  1. 16
      src/directive/auth/index.js
  2. 34
      src/libs/auth/generateBtnPermission.js
  3. 4
      src/setting.js
  4. 3
      src/views/course/AddCurriculum.vue
  5. 8
      src/views/course/Curriculum.vue
  6. 22
      src/views/order/AddOrder.vue
  7. 22
      src/views/theoreticalCourse/list/buildPlatform/index.vue
  8. 22
      src/views/theoreticalCourse/list/courseManagement/index.vue

@ -9,18 +9,12 @@ import Setting from '@/setting'
export default { export default {
inserted (el, binding, vnode) { inserted (el, binding, vnode) {
if (!Setting.dynamicRoute) return false if (!Setting.dynamicRoute) return false
let btnText = '' const val = binding.value
// 如果有传值,就取传的值,否则,就取页面路由和按钮名字拼接起来 const text = val && val.includes('/') ? val : vnode.context.$route.path + ':' + (val || el.innerText)
if(binding.value){ const { btns } = store.state
btnText = binding.value if (text && btns && btns.length) {
}else{
btnText = `${vnode.context.$route.path}:${el.innerText}`
}
const btnPermissions = store.state.btns
if (btnText && btnPermissions && btnPermissions.length) {
const isPermission = btnPermissions.includes(btnText)
// 如果按钮集合里没有该权限,就把该按钮给去除 // 如果按钮集合里没有该权限,就把该按钮给去除
if (!isPermission) { if (!btns.includes(text)) {
el.parentNode && el.parentNode.removeChild(el) el.parentNode && el.parentNode.removeChild(el)
} }
} }

@ -2,23 +2,19 @@
* @description 生成按钮级别权限组 * @description 生成按钮级别权限组
* */ * */
import store from '@/store'; import store from '@/store'
export default function(data){
let result = [] const result = []
data.map(e => { // 递归组合权限
e.children.map(n => { function createAuth(data, auth) {
if(n.children.length){ data.map(e => {
result.push(`${e.path}:${n.name}`) const text = (auth ? auth + ':' : '') + (auth ? e.name : e.path) // 第一级是路由,取path,子级取name
n.children.map(j => { result.push(text)
e.path ? result.push(`${e.path}:${n.name}:${j.name}`) : result.push(`${n.path}:${j.name}`) e.children && e.children.length && createAuth(e.children, text)
j.children.map(k => { })
e.path ? result.push(`${e.path}:${n.name}:${j.name}:${k.name}`) : result.push(`${n.path}:${j.name}:${k.name}`) }
})
}) export default function(data) {
}else{ createAuth(data)
result.push(`${e.path}:${n.name}`) store.commit('addBtnAuth', result)
}
})
})
store.commit('addBtnAuth', result)
} }

@ -11,7 +11,7 @@ if (isDev) {
jumpPath = 'http://192.168.31.125:8087/' // 本地调试-需要启动本地判分点系统 jumpPath = 'http://192.168.31.125:8087/' // 本地调试-需要启动本地判分点系统
host = 'http://121.37.12.51/' host = 'http://121.37.12.51/'
// host = 'https://huorantech.cn/' // host = 'https://huorantech.cn/'
// host = 'http://192.168.31.151:9000/'// 榕 host = 'http://192.168.31.51:9000/'// 榕
// host = 'http://192.168.31.137:9000/'// 赓 // host = 'http://192.168.31.137:9000/'// 赓
} else if (isPro) { } else if (isPro) {
jumpPath = 'https://www.huorantech.cn/judgmentPoint/' jumpPath = 'https://www.huorantech.cn/judgmentPoint/'
@ -45,7 +45,7 @@ const Setting = {
isDev, isDev,
isPro, isPro,
// 是否使用动态路由 // 是否使用动态路由
dynamicRoute: false, dynamicRoute: true,
/** /**
* @description 默认密码 * @description 默认密码
*/ */

@ -668,15 +668,14 @@ export default {
checkeds.push(e) checkeds.push(e)
} }
}) })
if (item.systemId == this.curSystem) this.checkAll = true
} else { } else {
res.map(e => { res.map(e => {
const i = checkeds.findIndex(n => n.projectId == e.projectId && n.systemId == e.systemId) const i = checkeds.findIndex(n => n.projectId == e.projectId && n.systemId == e.systemId)
i === -1 || checkeds.splice(i, 1) i === -1 || checkeds.splice(i, 1)
}) })
if (item.systemId == this.curSystem) this.checkAll = false
} }
this.checkedAll = JSON.parse(JSON.stringify(checkeds)) // this.checkedAll = JSON.parse(JSON.stringify(checkeds)) //
this.getProject(item)
}).catch(err => {}) }).catch(err => {})
}, },
// //

@ -93,9 +93,9 @@
<el-table-column label="上架/下架" align="center"> <el-table-column label="上架/下架" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
v-model="scope.row.isEnable" v-model="scope.row.isShelves"
:active-value="0" :active-value="1"
:inactive-value="1" :inactive-value="0"
@change="changeSwitch($event, scope.row)" @change="changeSwitch($event, scope.row)"
v-auth="'/curriculum:上下架'"> v-auth="'/curriculum:上下架'">
</el-switch> </el-switch>
@ -294,7 +294,7 @@ export default {
}, },
// //
changeSwitch(value, row) { changeSwitch(value, row) {
this.$post(`${this.api.isShelves}?cid=${row.cid}&isEnable=${value}`).then((res) => { this.$post(`${this.api.isShelves}?cid=${row.cid}&isShelves=${value}`).then((res) => {
this.getData(); this.getData();
this.$message.success("修改上下架状态成功!"); this.$message.success("修改上下架状态成功!");
}).catch((res) => { }).catch((res) => {

@ -800,7 +800,8 @@ export default {
searchTimer: null, searchTimer: null,
titlesw:'', titlesw:'',
orderRepeat: [], orderRepeat: [],
repeatMsg: '' repeatMsg: '',
clients: []
}; };
}, },
watch: { watch: {
@ -819,6 +820,7 @@ export default {
}, },
async created() { async created() {
this.getTeam() this.getTeam()
this.getClients()
this.token = sessionStorage.getItem("token"); this.token = sessionStorage.getItem("token");
// //
if (this.$route.query.val == 'isAdd') { if (this.$route.query.val == 'isAdd') {
@ -984,11 +986,23 @@ export default {
console.log("🚀 ~ file: AddOrder.vue ~ line 979 ~ setStartDate ~ this.coursePermissions ", this.coursePermissions ) console.log("🚀 ~ file: AddOrder.vue ~ line 979 ~ setStartDate ~ this.coursePermissions ", this.coursePermissions )
this.dataPlatformPermissions = list.filter(i => i.authority === 0); this.dataPlatformPermissions = list.filter(i => i.authority === 0);
}, },
//
getClients() {
this.$post(this.api.queryCustomer, {
countries: this.form.countries,
provinceId: '',
cityId: '',
searchContent: '',
page: 1,
size: 1000
}).then(res => {
this.clients = res.message.list
}).catch(res => {})
},
// //
refreshCache() { refreshCache() {
const { customerId } = this.form const { customerId } = this.form
const clients = this.$refs.client.listData const curClient = this.clients.find(e => e.customerId == customerId)
const curClient = clients.find(e => e.customerId == customerId)
this.$post(`${this.api.refreshCache}?schoolId=${curClient ? curClient.schoolId : ''}`).then(res => {}).catch(res => {}) this.$post(`${this.api.refreshCache}?schoolId=${curClient ? curClient.schoolId : ''}`).then(res => {}).catch(res => {})
}, },
// //
@ -1131,7 +1145,7 @@ export default {
let param = { let param = {
pageSize: 10, pageSize: 10,
pageNum: this.coursePage, pageNum: this.coursePage,
isEnable: 0, // isShelves: 1, //
curriculumName: this.curriculumName curriculumName: this.curriculumName
}; };
this.dataLoading = true; this.dataLoading = true;

@ -1,5 +1,5 @@
<template> <template>
<!-- 课程管理 --> <!-- 平台自建 -->
<div style="padding-top: 24px"> <div style="padding-top: 24px">
<div class="tool"> <div class="tool">
<ul class="filter" style="align-items: flex-start"> <ul class="filter" style="align-items: flex-start">
@ -29,8 +29,8 @@
</li> </li>
</ul> </ul>
<div> <div>
<el-button v-auth="'课程管理:新增'" type="primary" round @click="addCourse">新增</el-button> <el-button v-auth="'平台自建:新增'" type="primary" round @click="addCourse">新增</el-button>
<el-button v-auth="'课程管理:批量删除'" type="primary" round @click="delAllData">批量删除</el-button> <el-button v-auth="'平台自建:批量删除'" type="primary" round @click="delAllData">批量删除</el-button>
</div> </div>
</div> </div>
@ -61,19 +61,19 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="250"> <el-table-column label="操作" align="center" width="250">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button v-auth="'课程管理:编辑信息'" type="text" @click="editCourse(scope.row)">编辑信息</el-button> <el-button v-auth="'平台自建:编辑信息'" type="text" @click="editCourse(scope.row)">编辑信息</el-button>
<el-divider v-auth="'课程管理:编辑信息'" direction="vertical"></el-divider> <el-divider v-auth="'平台自建:编辑信息'" direction="vertical"></el-divider>
<el-button v-auth="'课程管理:内容设置'" type="text" @click="config(scope.row)">内容设置</el-button> <el-button v-auth="'平台自建:内容设置'" type="text" @click="config(scope.row)">内容设置</el-button>
<el-divider v-auth="'课程管理:内容设置'" direction="vertical"></el-divider> <el-divider v-auth="'平台自建:内容设置'" direction="vertical"></el-divider>
<el-button v-auth="'课程管理:预览'" type="text" @click="preview(scope.row)">预览</el-button> <el-button v-auth="'平台自建:预览'" type="text" @click="preview(scope.row)">预览</el-button>
<el-divider v-auth="'课程管理:预览'" direction="vertical"></el-divider> <el-divider v-auth="'平台自建:预览'" direction="vertical"></el-divider>
<el-button v-auth="'课程管理:删除'" type="text" @click="handleDelete(scope.row)">删除</el-button> <el-button v-auth="'平台自建:删除'" type="text" @click="handleDelete(scope.row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="可授权状态" align="center" width="120"> <el-table-column label="可授权状态" align="center" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
v-auth="'课程管理:启用'" v-auth="'平台自建:禁用'"
v-model="scope.row.ztOpen" v-model="scope.row.ztOpen"
:active-value="0" :active-value="0"
:inactive-value="1" :inactive-value="1"

@ -1,5 +1,5 @@
<template> <template>
<!-- 课程管理 --> <!-- 院校创建 -->
<div style="padding-top: 24px"> <div style="padding-top: 24px">
<div class="tool"> <div class="tool">
<ul class="filter" style="align-items: flex-start"> <ul class="filter" style="align-items: flex-start">
@ -28,8 +28,8 @@
</li> </li>
</ul> </ul>
<div> <div>
<!-- <el-button v-auth="'课程管理:新增'" type="primary" round @click="addCourse">新增</el-button> --> <!-- <el-button v-auth="'院校创建:新增'" type="primary" round @click="addCourse">新增</el-button> -->
<el-button v-auth="'课程管理:批量删除'" type="primary" round @click="delAllData">批量删除</el-button> <el-button v-auth="'院校创建:批量删除'" type="primary" round @click="delAllData">批量删除</el-button>
</div> </div>
</div> </div>
@ -60,19 +60,19 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="250"> <el-table-column label="操作" align="center" width="250">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button v-auth="'课程管理:编辑信息'" type="text" @click="editCourse(scope.row)">编辑信息</el-button> <el-button v-auth="'院校创建:编辑信息'" type="text" @click="editCourse(scope.row)">编辑信息</el-button>
<el-divider v-auth="'课程管理:编辑信息'" direction="vertical"></el-divider> <el-divider v-auth="'院校创建:编辑信息'" direction="vertical"></el-divider>
<el-button v-auth="'课程管理:内容设置'" type="text" @click="config(scope.row)">内容设置</el-button> <el-button v-auth="'院校创建:内容设置'" type="text" @click="config(scope.row)">内容设置</el-button>
<el-divider v-auth="'课程管理:内容设置'" direction="vertical"></el-divider> <el-divider v-auth="'院校创建:内容设置'" direction="vertical"></el-divider>
<el-button v-auth="'课程管理:预览'" type="text" @click="preview(scope.row)">预览</el-button> <el-button v-auth="'院校创建:预览'" type="text" @click="preview(scope.row)">预览</el-button>
<el-divider v-auth="'课程管理:预览'" direction="vertical"></el-divider> <el-divider v-auth="'院校创建:预览'" direction="vertical"></el-divider>
<el-button v-auth="'课程管理:删除'" type="text" @click="handleDelete(scope.row)">删除</el-button> <el-button v-auth="'院校创建:删除'" type="text" @click="handleDelete(scope.row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="可授权状态" align="center" width="120"> <el-table-column label="可授权状态" align="center" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
v-auth="'课程管理:启用'" v-auth="'院校创建:禁用'"
v-model="scope.row.ztOpen" v-model="scope.row.ztOpen"
:active-value="0" :active-value="0"
:inactive-value="1" :inactive-value="1"

Loading…
Cancel
Save