<template>
|
<a-row :gutter="10">
|
<a-col :md="8" :sm="24">
|
<a-card :bordered="false" style="min-height: 800px" v-loading="loading">
|
<div style="background: #fff;padding-left:16px;height: 100%; margin-top: 5px">
|
<a-input-search @search="onSearch" style="width:100%;margin-top: 10px" placeholder="请输入文件名称" />
|
<!-- 树-->
|
<!-- <br></br>
|
<a>根目录</a> -->
|
<template v-if="docTree.length > 0">
|
|
<!--组织机构-->
|
<a-tree showLine :selectedKeys="selectedKeys" :checkStrictly="true" @select="onSelect"
|
:dropdownStyle="{ maxHeight: '200px', overflow: 'auto' }" :treeData="docTree"
|
:autoExpandParent="autoExpandParent" :expandedKeys="iExpandedKeys" @expand="onExpand" />
|
|
</template>
|
<div style="margin-top: 24px;" v-else-if="docTree.length == 0">
|
<h3><span>暂无文件信息</span></h3>
|
</div>
|
<!-- <div style="margin-top: 24px;" v-else><h3>普通员工暂无此权限</h3></div> -->
|
</div>
|
</a-card>
|
</a-col>
|
<a-col :md="16" :sm="24">
|
<a-card :bordered="false" title="权限配置" style="min-height: 800px" v-loading="rightLoading">
|
<a-table :columns="columns" :data-source="data" :pagination="false" :expanded-row-keys.sync="expandedRowKeys">
|
<span slot="visit" slot-scope="text, record">
|
<a-switch size="small" :checked="record.visit + '' == '1' ? true : false"
|
@change="visitChange($event, record)"></a-switch>
|
</span>
|
<span slot="download" slot-scope="text, record">
|
<a-switch size="small" :checked="record.download + '' == '1' ? true : false"
|
@change="downloadChange($event, record)"></a-switch>
|
</span>
|
<span slot="manage" slot-scope="text, record">
|
<a-switch size="small" :checked="record.manage + '' == '1' ? true : false"
|
@change="manageChange($event, record)"></a-switch>
|
</span>
|
</a-table>
|
|
</a-card>
|
</a-col>
|
</a-row>
|
</template>
|
<script>
|
import { getAction, postAction } from '@/api/manage';
|
import { JeecgListMixin } from '@/mixins/JeecgListMixin';
|
|
export default {
|
name: 'PathRoleUserList',
|
mixins: [JeecgListMixin],
|
|
data() {
|
return {
|
columns: [
|
{ title: '角色', dataIndex: 'roleName', key: 'roleName' },
|
{ title: '用户', dataIndex: 'userName', key: 'userName' },
|
{ title: '访问权限', dataIndex: 'visit', key: 'visit', scopedSlots: { customRender: 'visit' } },
|
{ title: '下载权限', dataIndex: 'download', key: 'download', scopedSlots: { customRender: 'download' } },
|
{ title: '管理权限', dataIndex: 'manage', key: 'manage', scopedSlots: { customRender: 'manage' } },
|
],
|
data: [],
|
|
expandedRowKeys: [],
|
currentDeptId: '',
|
iExpandedKeys: [0],
|
loading: false,
|
rightLoading: false,
|
autoExpandParent: true,
|
currFlowId: '',
|
currFlowName: '',
|
disable: true,
|
treeData: [],
|
visible: false,
|
docTree: [],
|
rightClickSelectedKey: '',
|
hiding: true,
|
model: {},
|
dropTrigger: '',
|
depart: {},
|
disableSubmit: false,
|
checkedKeys: [],
|
selectedKeys: [],
|
autoIncr: 1,
|
currSelected: {},
|
form: this.$form.createForm(this),
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
},
|
graphDatasource: {
|
nodes: [],
|
edges: []
|
},
|
userIdentity: "",
|
}
|
},
|
methods: {
|
callback(key) {
|
//console.log(key)
|
},
|
loadData() {
|
this.refresh();
|
},
|
clearSelectedDepartKeys() {
|
this.checkedKeys = [];
|
this.selectedKeys = [];
|
},
|
loadTree() {
|
this.loading = true
|
var that = this
|
that.treeData = []
|
that.docTree = []
|
|
|
getAction("/document/queryAsyncTreeList", null).then(res => {
|
if (res.success && res.result) {
|
console.log("获取树列表::", res);
|
|
var root = { isLeaf: false, key: 0, path: '/', pathId: '1', title: '根目录' }
|
root.children = res.result.treeList;
|
console.log("获取树列表::", [root]);
|
that.treeData = [root]
|
that.docTree = [root]
|
|
|
this.loadPathPrem(1)
|
|
this.loading = false
|
}
|
})
|
|
},
|
setThisExpandedKeys(node) {
|
//只展开一级目录
|
if (node.children && node.children.length > 0) {
|
this.iExpandedKeys.push(node.key)
|
//下方代码放开注释则默认展开所有节点
|
/**
|
for (let a = 0; a < node.children.length; a++) {
|
this.setThisExpandedKeys(node.children[a])
|
}
|
*/
|
}
|
},
|
refresh() {
|
this.loading = true
|
this.loadTree()
|
},
|
|
onExpand(expandedKeys, treeNode) {
|
// console.log('onExpand', expandedKeys)
|
// if not set autoExpandParent to false, if children expanded, parent can not collapse.
|
// or, you can remove all expanded children keys.
|
this.iExpandedKeys = expandedKeys
|
this.autoExpandParent = false
|
if (!treeNode.expanded) return
|
return new Promise(resolve => {
|
console.log("异步加载的treeNode:", treeNode);
|
if (treeNode.node.dataRef.children.length > 0) {
|
resolve()
|
return
|
}
|
this.loading = true
|
getAction("/document/queryAsyncTreeList", treeNode.node.dataRef).then(res => {
|
console.log("异步加载内容::", res)
|
treeNode.node.dataRef.children = res.result.treeList
|
this.treeData = [...this.treeData]
|
treeNode.expanded = false
|
resolve()
|
}).finally(() => {
|
this.loading = false
|
})
|
})
|
|
|
},
|
|
onSearch(value) {
|
let that = this
|
if (value) {
|
getAction("/document/queryAsyncTreeList", { fileName: value }).then((res) => {
|
if (res.success) {
|
that.docTree = res.result.treeList
|
|
} else {
|
that.$message.warning(res.message)
|
}
|
})
|
} else {
|
that.loadTree()
|
}
|
|
},
|
onCheck(checkedKeys, e) {
|
let record = e.node.dataRef;
|
console.log('onCheck', checkedKeys, e);
|
this.checkedKeys = [];
|
|
this.hiding = false;
|
},
|
onSelect(selectedKeys, e) {
|
console.log('onSelect', selectedKeys, e);
|
if (this.selectedKeys[0] !== selectedKeys[0]) {
|
this.selectedKeys = [selectedKeys[0]];
|
}
|
let record = e.node.dataRef;
|
this.loadPathPrem(record.pathId)
|
|
},
|
loadPathPrem(pathId) {
|
this.rightLoading = true
|
getAction("/pathPermission/queryAll", { 'pathId': pathId }).then(res => {
|
console.log("获取权限分配情况res:::", res);
|
this.data = res.result;
|
this.rightLoading = false
|
})
|
},
|
visitChange(event, record) {
|
console.log("访问权限更改EVENT:::", event, "RECORD:::", record);
|
record.visit = (event ? 1 : 0)
|
this.saveChange(record, 1)
|
},
|
downloadChange(event, record) {
|
console.log("下载权限更改EVENT:::", event, "RECORD:::", record);
|
record.download = (event ? 1 : 0)
|
this.saveChange(record, 2)
|
},
|
manageChange(event, record) {
|
console.log("管理权限更改EVENT:::", event, "RECORD:::", record);
|
record.manage = (event ? 1 : 0)
|
this.saveChange(record, 3)
|
},
|
|
saveChange(record, type) {
|
console.log("开始保存权限 Record:", record);
|
postAction("/pathPermission/save", record).then(res => {
|
console.log("保存文件权限RES::", res);
|
if (res.success) {
|
|
} else {
|
this.$message.error(res.msg)
|
if (type === 1) {
|
record.visit = !record.visit
|
} else if (type === 2) {
|
record.download = !record.download
|
} else if (type === 3) {
|
record.manage = !record.manage
|
}
|
}
|
this.loadPathPrem(record.pathId)
|
})
|
}
|
},
|
created() {
|
this.currFlowId = this.$route.params.id
|
this.currFlowName = this.$route.params.name
|
// this.loadTree()
|
},
|
}
|
</script>
|
<style scoped>
|
@import '~@assets/less/common.less'
|
</style>
|