wangting
2024-12-03 badf10af5578f3fe4151824670bb7a794efc63dd
Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/index.vue
@@ -19,24 +19,41 @@
    </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">
          @current-row-change="rowClickHandler">
          <template slot="menuLeft">
            <el-button icon="el-icon-plus" size="small" type="primary" @click="addHandler">添加</el-button>
            <el-button icon="el-icon-plus" size="small" type="primary" @click="editHandler">修改</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>
          <data-view key="dataView"></data-view>
        <div style="margin-top: 15px;">
          <data-view key="dataView" :btmNode="nodeRow" :selectRow="selectRow" :actionMap="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" :selectRow="selectRow" :actionMap="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
@@ -67,7 +84,7 @@
import {getBizTree} from "@/api/UI/uiDefine";
import basicOption from "@/util/basic-option";
import dataView from "./dataView";
import {getTypeActionByType} from "@/api/authority/ui/typeAction";
import {getData,saveGrand,delGrand} from "@/api/authority/ui/dataAuthor";
import func from "@/util/func";
import {getUsedEnumList} from "@/api/modeling/enumType/api";
export default {
@@ -75,6 +92,7 @@
  components:{dataView},
  data:function (){
    return{
      clientHeight:Math.max(document.body.clientHeight,700),
      treeOption: {
        height: 'auto',
        defaultExpandAll: true,
@@ -89,10 +107,11 @@
      nodeRow: {},
      treeData: [],
      tableLoading: false,
      selectList: [],
      selectRow: {},
      option: {
        ...basicOption,
        height:260,
        height:280,
        highlightCurrentRow:true,
        addBtn: false,
        editBtn: false,
        delBtn: false,
@@ -100,22 +119,32 @@
        columnBtn:false,
        gridBtn:false,
        tip: false,
        align: 'left',
        index:false,
        selection:false,
        menu:false,
        column: [
          {
            label: '规则名称',
            prop: 'plCode',
            overHidden: true
          },
          {
            label: '规则类型',
            prop: 'plName',
            overHidden: true
          }
        ]
        align:'center',
        column: [{
          label: '规则名称',
          prop: 0,
          overHidden: true
        },{
          label: '规则类型',
          prop: 1,
          overHidden: true
        }]
      },
      data: [],
      title: '',
      visible: false,
      form:{},
      actionMap:{},
      switchDic:[{
        label:'',
        value:false
      },{
        label:'',
        value:true
      }]
    }
  },
  created() {
@@ -140,12 +169,40 @@
      }
    },
    getTableList() {
      getTypeActionByType({
        'typeName': this.nodeRow.attributes.name,
      }).then(res => {
        this.data = res.data.data;
      getData(this.nodeRow.attributes.name).then(res => {
        /*if(typeof res.data == 'string'){
          res.data=eval('('+res.data +')')
        }*/
        if(res.data.obj.tableHeader){
          this.option.column=[ {
            label: '规则名称',
            prop: 0,
            overHidden: true
          },{
              label: '规则类型',
              prop: 1,
              overHidden: true
            }];
          res.data.obj.tableHeader.forEach((item,i)=>{
            if(i<=1) return;
            if(i=='rules') return;
            this.option.column.push({
              label: item,
              prop: i,
              overHidden: true,
              width:'auto',
              html:true,
              formatter:(val)=> {
                return '<label class="el-checkbox is-disabled ' + (val[i] == true ? 'is-checked' : '') + '"><span class="el-checkbox__input is-disabled ' + (val[i] == true ? 'is-checked' : '') + '"><span class="el-checkbox__inner"></span><input type="checkbox" aria-hidden="false" class="el-checkbox__original" value="' + val[i] + '"></span></label>'
              }
            })
          })
        }
        this.data = res.data.obj.rowList;
        this.$refs.crud.clearSelection();
        this.tableLoading = false;
        this.actionMap=res.data.obj.actionMap;
        this.selectRow={}
      })
    },
    handleRefresh() {
@@ -153,34 +210,16 @@
    },
    // 行点击
    rowClickHandler(row) {
      func.rowClickHandler(
        row,
        this.$refs.crud,
        this.lastIndex,
        (newIndex) => {
          this.lastIndex = newIndex;
        },
        () => {
          this.selectList = [row];
        }
      );
    },
    // 选择框
    selectChange(row) {
      this.selectList = row;
      this.selectRow=row
    },
    // 查看授权结果
    chekView() {
      if (this.selectList.length <= 0) {
        this.$message.warning('请至少选择一条数据');
        return;
      }
      if (this.selectList.length > 1) {
        this.$message.warning('只能选择一条数据进行查看');
      if (this.selectRow=={}) {
        this.$message.warning('请选择一条数据');
        return;
      }
      getUsedEnumList({enumName: this.selectList[0].id}).then(res => {
      getUsedEnumList({enumName: this.selectRow.id}).then(res => {
        if (res.data.code === 200) {
          this.checkViewVisible = true;
          this.checkViewData = res.data.data;
@@ -197,7 +236,6 @@
        this.checkViewData = this.checkViewDataSearch;
        return done();
      }
      ;
      this.checkViewData = this.checkViewData.filter(item => {
        return item.source && item.source.includes(source);
@@ -206,7 +244,62 @@
      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;