Commit 5af5aa7b by 蒋勇

d

parent 99cd7b56
import axios from '@/libs/api.request'
import config from '@/config'
export const refQuery = (url,q) => {
console.log(">>>>>>>>>>>.",url,q)
return axios.request({
......@@ -15,11 +15,30 @@ export const ossConfig = (url,q) => {
data:q
})
}
export const getApp = () => {
let appkey=config.fromappkey?config.fromappkey:config.appkey
return axios.request({
url: "/web/common/appCtl/getApp",
method: 'post',
data:{appkey:appkey}
})
}
export const saveAuths = (auths) => {
return axios.request({
url: "/web/auth/authCtl/saveAuths",
method: 'post',
data:{auths:auths}
})
}
export const findAuthsByRoles = (roleids) => {
return axios.request({
url: "/web/auth/authCtl/findAuthsByRoles",
method: 'post',
data:{roleids:roleids}
})
}
// export const uploadImg = formData => {
// return axios.request({
// url: 'image/upload',
// data: formData
// })
// }
......@@ -4,6 +4,7 @@ export default {
*/
title: '智慧中台 ',
appkey:'cbb91171-3c68-49f9-b27f-fa38daa376ee',
companykey:'41fabc4fc3a049f9823eee96cec7a94d',
/**
* @description token在Cookie中存储的天数,默认1天
*/
......
......@@ -29,8 +29,8 @@ class HttpRequest {
companykey=params.get("companykey")
regrole=params.get("regrole")
this.confapp.regrole=regrole
this.confapp.companykey=companykey
this.confapp.fromappkey=appkey;//为了区分当前切换应用上下文后,进入的应用非平台应用
this.confapp.fromcompanykey=companykey?companykey:this.confapp.companykey//来源公司key,如果URL里没有,那么就取平台应用公司
this.confapp.fromappkey=appkey?appkey:this.confapp.appkey;//来源应用,如果URL里没有,那么就取平台应用key
}catch(e){
console.log(e)
}
......@@ -38,8 +38,9 @@ class HttpRequest {
baseURL: this.baseUrl,
headers: {
Authorization:"Bearer "+getToken(),
XAPPKEY:appkey?appkey: this.confapp.appkey,
XCOMPANYKEY:companykey,
XAPPKEY:this.confapp.appkey,//当前应用
XFROMAPPKEY: this.confapp.fromappkey,//来源应用
XFROMCOMPANYKEY: this.confapp.fromcompanykey,//来源公司
XREGROLE:regrole,//专用于注册时,区分是否是非租户注册
XBIZPATH:this.confapp.bizpath
}
......
......@@ -140,9 +140,18 @@ export default [
name: 'role_info_page',
meta: {
icon: 'md-clipboard',
title: '角色信息'
title: '角色授权'
},
component: () => import('@/view/roleinfo/roleinfo_page.vue')
},
{
path: 'role_auth',
name: 'role_auth',
meta: {
icon: 'md-clipboard',
title: '授权操作'
},
component: () => import('@/view/roleinfo/roleauth_page.vue')
}
]
},
......
......@@ -6,7 +6,7 @@ export default {
{ title: '名称', key: 'name', sortable: true, insearch: true},//slot--自定义列 insearch--是否快速查询
{ title: '域名', key: 'domainName', sortable: true, insearch: true},//slot--自定义列 insearch--是否快速查询
{ title: '服务', key: 'backend', sortable: true, insearch: true},//slot--自定义列 insearch--是否快速查询
{ title: '创建时间', key: 'created_at' ,slot:'created_at' },
{ title: '创建时间', key: 'created_at' ,slot:'created_at' ,insearch: true},
{
title: '操作',
key: 'handle',
......
......@@ -49,7 +49,8 @@ export default {
// { "icon": "ios-cloud-download-outline", "title": "下载", "type": "text", "key": "export", "isOnGrid": true },
],
"edit": [
{ "icon": "ios-create-outline", "title": "修改", "type": "text", "key": "edit", "isInRow": true }
{ "icon": "ios-create-outline", "title": "修改", "type": "text", "key": "edit", "isInRow": true },
{ "icon": "ios-create-outline", "title": "授权", "type": "text", "key": "auth", "isInRow": true }
],
"delete": [
{ "icon": "ios-trash-outline", "title": "删除", "type": "text", "key": "delete", "isInRow": true },
......
<template>
<CheckboxGroup v-model="sels" @on-change="onchange">
<Checkbox v-for="item in datasource" :label="item.value" :key="item.value" :Border="isborder">{{item.label}}</Checkbox>
<Checkbox
v-for="item in datasource"
:label="item.value"
:key="item.value"
:Border="isborder"
>{{item.label}}</Checkbox>
</CheckboxGroup>
</template>
<script>
import { refQuery } from "@/api/meta";
export default {
name: "checkgroups",
name: "Checkgroups",
components: {},
model: {
prop: "value",
event: "change"
},
props:["value","dicName","refModel","labelField","valueField","refwhere","isborder"],
props: [
"value",
"dicName",
"refModel",
"labelField",
"valueField",
"refwhere",
"isborder",
"baseData"
],
data() {
return {
sels: this.value?this.value:[],
datasource: []
sels: this.value ? this.value : [],
datasource: this.baseData ? this.baseData : []
};
},
watch: {
......@@ -29,7 +43,7 @@ export default {
this.$emit("change", this.sels);
},
initDataSource(slike) {
if (this.dicName && this.dicName!="") {
if (this.dicName && this.dicName != "") {
let objdic = this.$store.getters.dict_info[this.dicName];
console.log(objdic);
Object.keys(objdic).forEach(k => {
......@@ -47,18 +61,18 @@ export default {
refQuery(url, query).then(r => {
if (r.data) {
this.datasource = r.data;
console.log(">>>>>>>>>>>>>>>>>>>>",r.data)
console.log(">>>>>>>>>>>>>>>>>>>>", r.data);
}
});
}
}
},
created() {
this.initDataSource()
if (!this.baseData) {
this.initDataSource();
}
},
mounted() {
}
mounted() {}
};
</script>
<style>
......
<template>
<div>
<Card>
<Tree :data="treedata" :render="renderContent" class="ptree"></Tree>
</Card>
</div>
</template>
<script>
import { getApp, saveAuths, findAuthsByRoles } from "@/api/meta";
import Checks from "@/view/components/tables/forms/childs/checkgroups.vue";
import config from "@/config";
export default {
name: "roleauth_page",
data() {
return {
roleid: -1, //
rolecode: "",
roleauths: null,
treedata: [],
buttonProps: {
type: "default",
size: "small"
}
};
},
components: {
Checks
},
computed: {
authdic() {
let dic = {};
this.roleauths.forEach(item => {
dic[item.bizcode] = item.authstrs.split(",");
});
return dic;
}
},
mounted() {
this.roleid = this.$route.query.roleid;
this.rolecode = this.$route.query.rolecode;
//获取当前应用的资源清单
this.initTree();
},
methods: {
initTree() {
getApp().then(res => {
let rtn = res.data;
if (rtn.status == 0) {
console.log(rtn.data.functionJSON);
let tmptreedata = JSON.parse(rtn.data.functionJSON);
this.treedata = tmptreedata; //
//按照当前角色,去获取当前应用的功能权限,对返回的数据进行处理
//赋予权限数据
findAuthsByRoles([this.roleid]).then(res=>{
let rtn=res.data
if(rtn.status==0){
this.roleauths=rtn.data
this.setAuthData(this.treedata);
}else{
console.log("fetch auths fails.....")
}
})
}
});
},
setAuthData(datas) {
datas.forEach(td => {
if (td.children) {
this.setAuthData(td.children);
} else {
if(td.sels){
console.log(this.authdic)
td.sels = this.authdic[td.name];
}
}
});
},
makeauths(datas, auths) {
datas.forEach(item => {
if (item.children) {
this.makeauths(item.children, auths);
} else {
if (item.sels) {
let oneauth = {
role_id: this.roleid,
rolecode: this.rolecode,
bizcode: item.name,
codepath: item.codepath,
authstrs: item.sels.join(",")
};
auths.push(oneauth);
}
}
});
},
saveAuths() {
let auths = [];
this.makeauths(this.treedata, auths);
saveAuths(auths).then(res => {
let rtn = res.data;
if (rtn.status == 0) {
this.roleauths = rtn.data;
this.$Message.success("当前操作成功完成")
} else {
this.$Message.success("当前操作未完成,请稍后重试或联系管理员")
}
});
},
refreshFunc() {},
renderContent(h, { root, node, data }) {
// console.log(node)
const parentKey = root.find(el => el === node).parent;
console.log(parentKey);
return h(
"span",
{
style: {
display: "inline-block",
width: "100%",
cursor: "pointer"
},
on: {
click: $event => {
$("span", ".ptree").removeClass("spansel");
$($event.target).addClass("spansel");
}
}
},
[
h("span", [
h("Icon", {
props: {
type: !data.auths ? "ios-folder-outline" : "ios-paper-outline"
},
style: {
marginRight: "8px"
}
}),
h("span", data.title)
]),
h(
"span",
{
style: {
display: "inline-block",
float: "right",
marginRight: "100px"
}
},
[
data.auths
? h(
"Checkbox",
{
on: {
"on-change": b => {
if (b) {
data.sels = data.auths;
} else {
data.sels = [];
}
}
},
style: {
display: "inline-block",
float: "left",
marginRight: "10px",
marginTop: "3px"
}
},
[h("span", ["all"])]
)
: data.name == "root"
? h("span", [
h(
"Button",
{
props: {
type: "text"
},
on: {
click: () => {
this.saveAuths();
}
}
},
["保存"]
),
h(
"Button",
{
props: {
type: "text"
},
on: {
click: () => {
this.refreshFunc();
}
}
},
["刷新"]
)
])
: "",
data.auths
? h(
"CheckboxGroup",
{
props: {
value: data.sels
},
on: {
"on-change": v => {
data.sels = v;
console.log(v);
}
}
},
[
data.auths.map(function(it) {
return h(
"Checkbox",
{
props: {
label: it
}
},
[h("span", [it])]
);
})
]
)
: ""
]
)
]
);
}
}
};
</script>
<style>
.ptree span:hover {
background-color: lightgray;
}
.spansel {
background-color: lightgray;
}
</style>
......@@ -6,6 +6,7 @@
metaName="role_info"
packageName="auth"
isMulti
@onexec="onexec"
></BizTable>
</div>
</template>
......@@ -20,6 +21,9 @@ export default {
BizTable
},
methods: {
onexec(k, row) {
this.$router.push({ name: "role_auth",query:{roleid:row.id,rolecode:row.code}})
},
// onnew() {
// this.$refs.bt.setFormCtlVisable("userName", true);
// },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment