dangsn
2024-12-03 f31d6505363fa191fb715976826369484c26cf16
Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/index.vue
@@ -1,33 +1,17 @@
<template>
  <el-container>
    <el-aside>
      <basic-container>
        <div ref="TreeBox" style="height: calc(100vh - 144px);!important;">
          <div class="headerCon">
            <el-button icon="el-icon-plus" plain size="small" type="primary" @click="addClickHandler">创建
            </el-button>
            <el-button icon="el-icon-edit" plain size="small" type="primary" @click="editClickHandler">修改
            </el-button>
            <el-button icon="el-icon-delete" plain size="small" type="danger" @click="delClickHandler">删除
            </el-button>
            <el-button icon="el-icon-download" plain size="small" type="primary" @click="exportClickHandler">导出
            </el-button>
            <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="uploadClickHandler">导入
            </el-button>
            <el-button class="smallBtn" plain size="small" type="primary"
                       @click="checkViewClickHandler">查看使用范围
            </el-button>
          </div>
        <div ref="TreeBox" style="height: calc(100vh - 154px);!important;">
          <!-- 左侧树         -->
          <div style="height:  calc(100vh - 280px);">
          <div style="height:  calc(100vh - 190px);">
            <avue-tree :data="treeData" :option="treeOption" @node-click="nodeClick">
          <span slot-scope="{ node, data }" class="el-tree-node__label">
           <span style="font-size: 15px">
              <i class="el-icon-s-promotion"></i>
                {{ (node || {}).label }}
            </span>
          </span>
              <span slot-scope="{ node, data }" class="el-tree-node__label">
               <span style="font-size: 15px">
                  <i class="el-icon-s-promotion"></i>
                    {{ (node || {}).label }}
                </span>
              </span>
            </avue-tree>
          </div>
        </div>
@@ -35,7 +19,61 @@
    </el-aside>
    <el-main>
      <basic-container>
      <basic-container cardBodyStyle="padding-bottom:0;">
        <avue-crud
          ref="crud"
          :data="data"
          :option="option"
          :table-loading="tableLoading"
          @refresh-change="handleRefresh"
          @selection-change="selectChange"
          @row-click="rowClickHandler">
          <template slot="menuLeft">
            <el-button icon="el-icon-plus" size="small" type="primary" @click="addHandler">添加</el-button>
            <el-button icon="el-icon-delete" plain size="small" type="danger" @click="delHandler">删除</el-button>
            <el-button icon="el-icon-view" plain size="small" type="primary" @click="chekView">查看授权结果</el-button>
          </template>
        </avue-crud>
        <div style="margin-top: 15px;">
          <data-view key="dataView" :btmNode="nodeRow" :data="viewData" :actionDic="actionMap" :readOnly="true" :height="clientHeight-260-220"></data-view>
        </div>
        <!-- 新增 && 编辑 -->
        <el-dialog
          v-dialogDrag
          :title="title === 'add' ? '创建' : '修改'"
          :visible.sync="visible"
          append-to-body="true"
          class="avue-dialog"
          width="70%"
          @close="addDialogClose">
            <div>
              <data-view ref="editView" key="editView" :btmNode="nodeRow" :data="viewData" :actionDic="actionMap" :readOnly="false" :height="clientHeight-340"></data-view>
            </div>
            <span slot="footer" class="dialog-footer">
               <el-button size="small" type="primary" @click="addDialogSavaHandler">确 定</el-button>
               <el-button size="small" @click="addDialogClose">取 消</el-button>
            </span>
        </el-dialog>
        <!-- 查看授权结果    -->
        <el-dialog
          v-dialogDrag
          v-loading="checkViewLoading"
          :visible.sync="checkViewVisible"
          append-to-body="true"
          class="avue-dialog"
          title="查看使用范围"
          width="60%"
        >
          <avue-crud
            ref="checkViewCrud"
            :data="checkViewData"
            :option="checkViewOption"
            @search-change="checkHandleSearch"
            @search-reset="checkHandleReset"
          >
          </avue-crud>
        </el-dialog>
      </basic-container>
    </el-main>
@@ -43,8 +81,222 @@
</template>
<script>
import {getBizTree} from "@/api/UI/uiDefine";
import basicOption from "@/util/basic-option";
import dataView from "./dataView";
import {getData,saveGrand,delGrand} from "@/api/authority/ui/dataAuthor";
import func from "@/util/func";
import {getUsedEnumList} from "@/api/modeling/enumType/api";
export default {
  name: "index"
  name: "index",
  components:{dataView},
  data:function (){
    return{
      clientHeight:Math.max(document.body.clientHeight,700),
      treeOption: {
        height: 'auto',
        defaultExpandAll: true,
        menu: false,
        addBtn: false,
        props: {
          label: 'text',
          value: 'oid',
          children: 'children'
        }
      },
      nodeRow: {},
      treeData: [],
      tableLoading: false,
      selectList: [],
      option: {
        ...basicOption,
        height:280,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        filterBtn:false,
        columnBtn:false,
        gridBtn:false,
        tip: false,
        align: 'left',
        menu:false,
        column: [
          {
            label: '规则名称',
            prop: 'plCode',
            overHidden: true
          },
          {
            label: '规则类型',
            prop: 'plName',
            overHidden: true
          }
        ]
      },
      data: [],
      viewData:{},
      title: '',
      visible: false,
      form:{},
      actionMap:{}
    }
  },
  created() {
    this.getTreeList();
  },
  methods: {
    //树表查询
    getTreeList() {
      const loading = this.$loading({});
      getBizTree().then(res => {
        this.treeData = [res.data.obj];
        loading.close();
      }).catch(error => {
        loading.close();
      })
    },
    // 树点击
    nodeClick(row) {
      if (row.oid) {
        this.nodeRow = row;
        this.getTableList();
      }
    },
    getTableList() {
      getData({
        'typeName': this.nodeRow.attributes.name,
      }).then(res => {
        this.data = res.data.obj.rowList;
        this.$refs.crud.clearSelection();
        this.tableLoading = false;
        this.actionMap=res.data.obj.actionMap
      })
    },
    handleRefresh() {
      this.getTableList();
    },
    // 行点击
    rowClickHandler(row) {
      func.rowClickHandler(
        row,
        this.$refs.crud,
        this.lastIndex,
        (newIndex) => {
          this.lastIndex = newIndex;
        },
        () => {
          this.selectList = [row];
        }
      );
      this.getViewData(row)
    },
    // 选择框
    selectChange(row) {
      this.selectList = row;
    },
    //获取下方数据
    getViewData(row){
      this.viewData={
        oid:row.plOId
      };
    },
    // 查看授权结果
    chekView() {
      if (this.selectList.length <= 0) {
        this.$message.warning('请至少选择一条数据');
        return;
      }
      if (this.selectList.length > 1) {
        this.$message.warning('只能选择一条数据进行查看');
        return;
      }
      getUsedEnumList({enumName: this.selectList[0].id}).then(res => {
        if (res.data.code === 200) {
          this.checkViewVisible = true;
          this.checkViewData = res.data.data;
          this.checkViewDataSearch = res.data.data;
        }
      })
    },
    // 查看授权结果查询
    checkHandleSearch(params, done) {
      const {source} = params;
      if (!params.source) {
        this.checkViewData = this.checkViewDataSearch;
        return done();
      }
      this.checkViewData = this.checkViewData.filter(item => {
        return item.source && item.source.includes(source);
      });
      done();
    },
    //创建
    addHandler(){
      if (func.isEmptyObject(this.nodeRow)) {
        this.$message.error('请选择要添加的节点');
        return;
      }
      this.title = 'add';
      this.visible = true;
    },
    //修改
    editHandler(){
      if (func.isEmptyObject(this.nodeRow)) {
        this.$message.error('请至少选择一条数据');
        return;
      }
      this.title = 'edit';
      this.visible = true;
    },
    // 新增编辑保存
    addDialogSavaHandler() {
      saveGrand(this.viewData).then(res => {
        if (res.data.code === 200) {
          this.$message.success(res.data.obj);
          this.getTableList();
          this.addDialogClose();
        }
      })
    },
    // 新增编辑对话框取消
    addDialogClose() {
      this.visible = false;
    },
    //删除
    delHandler(){
      if (func.isEmptyObject(this.nodeRow)) {
        this.$message.error('请选择数据');
        return;
      }
      this.$confirm('您确定要删除所选择的数据吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delGrand({name:this.templateForm}).then(res => {
          if (res.data.code === 200) {
            this.$message.success(res.data.obj);
            this.getTableList();
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    // 查看使用范围重置
    checkHandleReset() {
      this.checkViewData = this.checkViewDataSearch;
    },
  }
}
</script>
@@ -53,40 +305,6 @@
  .el-scrollbar__wrap {
    overflow: auto !important;
  }
  .headerCon{
    .el-button{
      width: 82px;
    }
  }
}
.headerCon {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 5px;
  .el-button + .el-button {
    margin-left: 5px;
  }
  .el-button {
    margin-top: 5px;
  }
}
.headerCon > .el-button:nth-child(4) {
  margin-left: 0;
}
.headerCon > .el-button:nth-child(7) {
  margin-left: 0;
}
.smallBtn {
  width: 82px;
  text-align: center;
  padding-left: 4.5px;
}
</style>