|
@@ -0,0 +1,205 @@
|
|
|
+<template>
|
|
|
+ <div class="business-auth-wrap">
|
|
|
+ <div class="header">
|
|
|
+ <div class="name">{{$route.query.name||''}}</div>
|
|
|
+ <div class="btn-wrap">
|
|
|
+ <el-button @click="handleBtnClik('cancel')">取消</el-button>
|
|
|
+ <el-button type="primary" @click="handleBtnClik('save')">保存</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="auth-wrap">
|
|
|
+ <el-tree
|
|
|
+ v-loading="treeLoading"
|
|
|
+ ref="checkboxTree"
|
|
|
+ :data="authList"
|
|
|
+ :props="{label:'Name',children:'Children'}"
|
|
|
+ :default-expand-all="false"
|
|
|
+ show-checkbox
|
|
|
+ node-key="MenuId"
|
|
|
+ :default-checked-keys="defaultCheckedKeys">
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {businessCustomInterence} from '@/api/api.js'
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ authList:[],
|
|
|
+ defaultCheckedKeys:[],
|
|
|
+ treeLoading:false
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getBusinessAuthList(){
|
|
|
+ const EtaBusinessId = this.$route.query.id
|
|
|
+ if(!EtaBusinessId) return
|
|
|
+ this.treeLoading = true
|
|
|
+ businessCustomInterence.getAuthList({
|
|
|
+ EtaBusinessId:Number(EtaBusinessId)
|
|
|
+ }).then(res=>{
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ this.treeLoading = false
|
|
|
+ if(!res.Data) return
|
|
|
+ const {List,ChoiceList=[],HalfChoiceList=[]} = res.Data
|
|
|
+ this.authList = List||[]
|
|
|
+ this.defaultCheckedKeys = ChoiceList.filter((item)=>!HalfChoiceList.some((halfItem)=>item===halfItem))
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async handleBtnClik(type){
|
|
|
+ if(type==='save'){
|
|
|
+ //获取树形列表选择的项 getCheckedKeys getHalfCheckedKeys
|
|
|
+ const keys = this.$refs.checkboxTree.getCheckedKeys()
|
|
|
+ const halfKeys = this.$refs.checkboxTree.getHalfCheckedKeys()
|
|
|
+ if(!keys.length&&!halfKeys.length){
|
|
|
+ this.$message.warning('请至少选择一个权限')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //合成一个数组并去重
|
|
|
+ const ChoiceList = Array.from(new Set([...keys,...halfKeys]))
|
|
|
+ console.log('aaa',ChoiceList)
|
|
|
+ console.log('half',halfKeys)
|
|
|
+ console.log('keys',keys)
|
|
|
+ const test = ChoiceList.filter((item)=>!halfKeys.some((halfItem)=>item===halfItem))
|
|
|
+ console.log('test',test)
|
|
|
+ //请求接口
|
|
|
+ const res = await businessCustomInterence.setAuthList({
|
|
|
+ EtaBusinessId:Number(this.$route.query.id),
|
|
|
+ MenuIds:ChoiceList,
|
|
|
+ HalfMenuIds:halfKeys
|
|
|
+ })
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ this.$message.success('权限设置成功')
|
|
|
+ }
|
|
|
+ this.$router.push('/businessETAList')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted(){
|
|
|
+ this.getBusinessAuthList()
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+.business-auth-wrap{
|
|
|
+ .el-tree {
|
|
|
+ border-top: 1px solid #E5E7ED;
|
|
|
+ border-left: 1px solid #E5E7ED;
|
|
|
+ border-right: 1px solid #E5E7ED;
|
|
|
+ width: 98%;
|
|
|
+ margin-bottom: 40px;
|
|
|
+ .el-tree-node__label{
|
|
|
+ margin:10px;
|
|
|
+ }
|
|
|
+ .el-tree-node__content{
|
|
|
+ min-width: 200px;
|
|
|
+ width: 200px;
|
|
|
+ white-space: normal;
|
|
|
+ box-sizing: border-box;
|
|
|
+ }
|
|
|
+ .el-tree-node{
|
|
|
+ .el-tree-node{
|
|
|
+ .el-tree-node__children{
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ .el-tree-node{
|
|
|
+ &:not(:first-child){
|
|
|
+ /* .el-tree-node__content{
|
|
|
+ border-right: 1px solid #E5E7ED;
|
|
|
+ } */
|
|
|
+ border-top: 1px solid #E5E7ED;
|
|
|
+ }
|
|
|
+ .el-tree-node__content{
|
|
|
+ border-right: 1px solid #E5E7ED;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .el-tree-node__content {
|
|
|
+ padding: 5px 10px !important;
|
|
|
+ height: auto;
|
|
|
+ .el-tree-node__expand-icon.el-icon-caret-right {
|
|
|
+ //display: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ > .el-tree-node {
|
|
|
+ padding: 0 !important;
|
|
|
+ display: flex;
|
|
|
+ border-bottom: 1px solid #E5E7ED;
|
|
|
+
|
|
|
+ > .el-tree-node__children {
|
|
|
+ width: 100%;
|
|
|
+ > .el-tree-node {
|
|
|
+ &:not(:first-child) {
|
|
|
+ border-top: 1px solid #E5E7ED;
|
|
|
+ }
|
|
|
+ >.el-tree-node__content{
|
|
|
+ border-left: 1px solid #E5E7ED;
|
|
|
+ border-right: 1px solid #E5E7ED;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .el-tree-node__children {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ .el-tree-node {
|
|
|
+ display: flex;
|
|
|
+ padding: 0px !important;
|
|
|
+ .el-tree-node__content {
|
|
|
+ border-bottom: none;
|
|
|
+ .custom-tree-node {
|
|
|
+ height: 24px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .tree-btn {
|
|
|
+ margin-left: 10px;
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ .el-button {
|
|
|
+ padding: 0px !important;
|
|
|
+ border-radius: 4px;
|
|
|
+ background: #363554;
|
|
|
+ color: #ffffff;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .el-tree-node__children {
|
|
|
+ .el-tree-node {
|
|
|
+ &:not(:first-child) {
|
|
|
+ .el-tree-node__content {
|
|
|
+ //border-left: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+</style>
|
|
|
+<style scoped lang="scss">
|
|
|
+.business-auth-wrap{
|
|
|
+ border: 1px solid #ECECEC;
|
|
|
+ padding: 20px 30px;
|
|
|
+ background: #fff;
|
|
|
+ border-radius: 4px;
|
|
|
+ box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
|
|
|
+ .header{
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ .name{
|
|
|
+ font-size: 18px;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .auth-wrap{
|
|
|
+ margin-top:20px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|