管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-02-22 853873ddb35e8eeb42b1b1b9fdb247ba5b1f19d1
src/views/AuthorizationManagement/menuRoleAuthorization.vue
@@ -1,20 +1,46 @@
<template>
  <div class="menuSettings_box">
    <div class="menuSettings_tree">
  <div class="menuSettings_box menuRoleAuthorization">
    <!-- <My-bread
      :list="[
        `${$t('operatManage.operatManage')}`,
        `${$t('operatManage.MenuRoleAuthorization')}`,
      ]"
    ></My-bread>
    <el-divider /> -->
    <div class="menuSettings_tree subpage_Div menuRoleAuthorization_left" style="padding-top:10px;width: 23%;overflow-y: auto;">
      <My-bread
        :list="[
          `${$t('operatManage.operatManage')}`,
          `${$t('operatManage.MenuRoleAuthorization')}`,
        ]"
      ></My-bread>
      <el-divider />
      <div class="menuTreeBox">
      <div>
        <div class="card_tree">
          <el-tree
            :data="depList"
            :props="defaultProps"
            :show-checkbox="false"
            :check-on-click-node="true"
            :check-strictly="true"
            node-key="id"
            @check="treeCheck"
            :default-expanded-keys="[1]"
            ref="treeForm"
          >
          </el-tree>
        </div>
      </div>
    </div>
    <!-- <div class="menuRoleAuthorization_resize" title="收缩侧边栏">⋮</div> -->
      <!-- <div class="left_tree subpage_Div">
        <el-tree
          :data="depList"
          :props="defaultProps"
          :show-checkbox="true"
          :show-checkbox="false"
          :check-on-click-node="true"
          :check-strictly="true"
          node-key="id"
@@ -23,13 +49,87 @@
          :default-expanded-keys="[1]"
        >
        </el-tree>
      </div>
    </div>
    <div class="menuSettings">
      <!-- <div class="title_box">
        <h4>详细信息</h4>
      </div> -->
      <div class="right_menu subpage_Div">
        <div
          style="
            font-size: 14px;
            color: #409eff;
            line-height: 1;
            cursor: text;
            margin-left: 10px;
            display: flex;
            align-items: center;
            flex-wrap: wrap;
          "
        >
          <span>
            {{
              $t("operatManage.UserRoleAuthorizationObj.PermissionTable")
            }}</span
          >
          <div class="btn" style="margin-left: auto">
            <el-button
              v-if="menuStatus.insert"
              type="success"
              icon="el-icon-circle-plus-outline"
              size="small"
              :disabled="roleid == null ? true : false"
              @click="adduser"
              >{{
                $t("operatManage.UserRoleAuthorizationObj.Added")
              }}</el-button
            >
            <el-button
              v-if="menuStatus.delete"
              type="danger"
              icon="el-icon-delete"
              size="small"
              @click="deletesUser"
              :disabled="roleid == null ? true : false"
              >{{
                $t("operatManage.UserRoleAuthorizationObj.delete")
              }}</el-button
            >
          </div>
        </div>
        <el-divider class="divider" />
        <el-table
          :data="tableData"
          style="width: 100%"
          height="calc(100% - 124px)"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column
            align="center"
            type="index"
            :label="$t('dataManage.styleObj.index')"
            width="55"
          />
          <el-table-column
            prop="authName"
            :label="$t('operatManage.UserRoleAuthorizationObj.name')"
          >
          </el-table-column>
        </el-table>
        <div class="pagination_box">
          <el-pagination
            @size-change="userhandleSizeChange"
            @current-change="userhandleCurrentChange"
            :current-page="userlistData.pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="userlistData.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="usercount"
          >
          </el-pagination>
        </div>
      </div>
    <!-- <div class="menuSettings">
      <div
        style="
          font-size: 14px;
@@ -56,6 +156,7 @@
            size="small"
            :disabled="roleid == null ? true : false"
            @click="adduser"
            style="background: #409eff"
            >{{ $t('operatManage.UserRoleAuthorizationObj.Added') }}</el-button
          >
          <el-button
@@ -71,42 +172,8 @@
      </div>
      <el-divider class="divider" />
      <el-table
        :data="tableData"
        stripe
        style="width: 100%"
        height="85%"
        @selection-change="handleSelectionChange"
        :header-cell-style="{
          background: 'transparent',
        }"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column
          align="center"
          type="index"
          :label="$t('dataManage.styleObj.index')"
        />
        <el-table-column
          prop="authName"
          :label="$t('operatManage.UserRoleAuthorizationObj.name')"
        >
        </el-table-column>
      </el-table>
      <div style="margin-top: 20px; text-align: center" class="pagination_box">
        <el-pagination
          @size-change="userhandleSizeChange"
          @current-change="userhandleCurrentChange"
          :current-page="userlistData.pageIndex"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="userlistData.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="usercount"
        >
        </el-pagination>
      </div>
    </div>
    </div> -->
    <el-dialog
      :title="$t('operatManage.UserRoleAuthorizationObj.Added')"
      :visible.sync="dialogTableVisible"
@@ -133,7 +200,7 @@
          @size-change="addhandleSizeChange"
          @current-change="addhandleCurrentChange"
          :current-page="addlistData.pageIndex"
          :page-sizes="[10, 20, 30, 40]"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="addlistData.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="addcount"
@@ -141,11 +208,11 @@
        </el-pagination>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogTableVisible = false">{{
          $t('dataManage.dictionaryManageObj.cancel')
        <el-button size="small" @click="dialogTableVisible = false">{{
          $t("dataManage.dictionaryManageObj.cancel")
        }}</el-button>
        <el-button type="primary" @click="addConfirm">{{
          $t('dataManage.dictionaryManageObj.confirm')
        <el-button size="small" type="primary" @click="addConfirm">{{
          $t("dataManage.dictionaryManageObj.confirm")
        }}</el-button>
      </div>
    </el-dialog>
@@ -153,14 +220,14 @@
</template>
<script>
import MyBread from '../../components/MyBread.vue';
import MyBread from "../../components/MyBread.vue";
import {
  selectMenuRecursive,
  selectMenuRecursives,
  select_menuAuth_ByPageAndCount,
  menuAuthDeletes,
  select_AuthMenu_ByPageAndCount,
  menuAuthinserts,
} from '../../api/api';
} from "../../api/api";
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {
@@ -189,18 +256,18 @@
      usercount: 0,
      tableData: [],
      //   当前选择的行的id
      templateSelection: '',
      templateSelection: "",
      //   当前选择的行的数据
      checkList: [],
      defaultProps: {
        children: 'children',
        label: 'cnName',
        children: "children",
        label: "cnName",
      },
      oriData: [], //原始树数据
      depList: [], //el树数据
      backUpData: {},
      formLabelWidth: '170px',
      formLabelWidth: "170px",
      listData: {
        pageIndex: 1,
        pageSize: 10,
@@ -213,6 +280,50 @@
    };
  },
  methods: {
    //左右拖動
    dragControllerDiv() {
      var resize = document.getElementsByClassName(
        "menuRoleAuthorization_resize"
      );
      var left = document.getElementsByClassName("menuRoleAuthorization_left");
      var mid = document.getElementsByClassName("menuRoleAuthorization_mid");
      var box = document.getElementsByClassName("menuRoleAuthorization");
      for (let i = 0; i < resize.length; i++) {
        // 鼠标按下事件
        resize[i].onmousedown = function (e) {
          //颜色改变提醒
          resize[i].style.background = "#818181";
          var startX = e.clientX;
          resize[i].left = resize[i].offsetLeft;
          // 鼠标拖动事件
          document.onmousemove = function (e) {
            var endX = e.clientX;
            var moveLen = resize[i].left + (endX - startX); // (endx-startx)=移动的距离。resize[i].left+移动的距离=左边区域最后的宽度
            var maxT = box[i].clientWidth - resize[i].offsetWidth; // 容器宽度 - 左边区域的宽度 = 右边区域的宽度
            if (moveLen < 205) moveLen = 205; // 左边区域的最小宽度为32px
            if (moveLen > maxT - 300) moveLen = maxT - 300; //右边区域最小宽度为150px
            resize[i].style.left = moveLen; // 设置左侧区域的宽度
            for (let j = 0; j < left.length; j++) {
              left[j].style.width = moveLen + "px";
              mid[j].style.width = box[i].clientWidth - moveLen - 10 + "px";
            }
          };
          // 鼠标松开事件
          document.onmouseup = function (evt) {
            //颜色恢复
            resize[i].style.background = "#d6d6d6";
            document.onmousemove = null;
            document.onmouseup = null;
            resize[i].releaseCapture && resize[i].releaseCapture(); //当你不在需要继续获得鼠标消息就要应该调用ReleaseCapture()释放掉
          };
          resize[i].setCapture && resize[i].setCapture(); //该函数在属于当前线程的指定窗口里设置鼠标捕获
          return false;
        };
      }
    },
    /**
     * sws
     */
@@ -220,9 +331,9 @@
    // 部门请求
    async getMenuTree() {
      //获取目录树最大ID,新建节点使用
      const data = await selectMenuRecursive({ name: '管道基础大数据平台' });
      const data = await selectMenuRecursives({ name: menuStartName });
      if (data.code !== 200) {
        return this.$message.error('请求单位报错');
        return this.$message.error("请求单位报错");
      }
      this.depList = this.treeData(data.result);
@@ -232,7 +343,7 @@
      return cloneData.filter((father) => {
        // 循环所有项
        let branchArr = cloneData.filter((child) => father.id == child.pid); // 对比ID,分别上下级菜单,并返回数据
        branchArr.length > 0 ? (father.children = branchArr) : ''; // 给父级添加一个children属性,并赋值
        branchArr.length > 0 ? (father.children = branchArr) : ""; // 给父级添加一个children属性,并赋值
        return father.pid == 0; // 返回一级菜单
      });
    },
@@ -259,10 +370,10 @@
    },
    addConfirm() {
      this.$confirm('确定是否新增', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      this.$confirm("确定是否新增", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          let arr = [];
@@ -272,11 +383,11 @@
          const data = await menuAuthinserts(arr);
          if (data.code !== 200) {
            return this.$message.error('新增失败');
            return this.$message.error("新增失败");
          }
          this.$message({
            type: 'success',
            message: '新增成功!',
            type: "success",
            message: "新增成功!",
          });
          this.dialogTableVisible = false;
          this.getRole();
@@ -293,22 +404,49 @@
      this.usermultipleSelection.forEach((e) => {
        arr.push(e.id);
      });
      const data = await menuAuthDeletes({ ids: arr.toString() });
      if (data.code !== 200) {
        return this.$message.error('删除失败');
      }
      this.$message({
        message: '删除成功',
        type: 'success',
      });
      this.getRole();
      this.$confirm("此操作将永久删除该权限, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          const data = await menuAuthDeletes({ ids: arr.toString() });
          if (data.code == 200) {
            this.InsertFormdialog = false;
            this.$message({
              message: "删除成功!",
              type: "success",
            });
            this.getRole();
          } else {
            this.$message({
              message: "删除失败!",
              type: "warning",
            });
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
      // const data = await menuAuthDeletes({ ids: arr.toString() });
      // if (data.code !== 200) {
      //   return this.$message.error('删除失败');
      // }
      // this.$message({
      //   message: '删除成功',
      //   type: 'success',
      // });
      // this.getRole();
    },
    async getadduserList() {
      this.addlistData.menuid = this.roleid;
      const data = await select_AuthMenu_ByPageAndCount(this.addlistData);
      if (data.code !== 200) {
        return this.$message.error('新增用户列表请求错误');
        return this.$message.error("新增用户列表请求错误");
      }
      this.gridData = data.result;
      this.addcount = data.count;
@@ -347,20 +485,20 @@
    async getRole() {
      const data = await select_menuAuth_ByPageAndCount(this.listData);
      if (data.code !== 200) {
        return this.$message.error('用户角色请求错误');
        return this.$message.error("用户角色请求错误");
      }
      this.tableData = data.result;
      this.usercount = data.count;
    },
    showPermsMenu(res) {
      switch (res.tag) {
        case '/delete':
        case "/delete":
          this.menuStatus.delete = true;
          break;
        case '/insert':
        case "/insert":
          this.menuStatus.insert = true;
          break;
        case '/update':
        case "/update":
          this.menuStatus.update = true;
          break;
      }
@@ -376,99 +514,58 @@
    }
    this.getMenuTree();
  },
  mounted() {
    // this.dragControllerDiv();
  },
};
</script>
<style lang="less" scoped>
//@import url(); 引入公共css类
.menuSettings_box {
  //   background: rgb(240, 242, 245);
  height: 96%;
  width: 98%;
  padding: 1%;
  border-radius: 10px;
  height: 100%;
  padding: 10px;
  box-sizing: border-box;
  position: relative;
  display: flex;
  .menuSettings_tree {
    position: relative;
    width: 30%;
    height: 100%;
    background: rgb(240, 242, 245);
    padding: 20px;
    border-radius: 10px;
    box-sizing: border-box;
    overflow: auto;
    .saveBtn {
      position: absolute;
      left: 250px;
      top: 23px;
    }
    .menuTreeBox {
      height: 90%;
      overflow: auto;
      .el-tree {
        background: transparent;
        font-size: 15px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #000000;
        // /deep/ .el-tree-node__label {
        //   font-size: 18px;
        // }
        /deep/ .el-tree-node {
          padding-top: 10px;
          // padding-bottom: 10px;
        }
        /deep/ .el-tree-node:focus > .el-tree-node__content {
          background-color: #b9b9b9;
        }
        /deep/ .el-tree-node__content:hover {
          background-color: rgb(153, 153, 153);
        }
        .btnBox {
          margin-left: 5px;
          .el-button + .el-button {
            margin-left: 5px;
          }
        }
      }
    }
  }
  .menuSettings {
    width: 70%;
    border-radius: 10px;
    background: rgb(240, 242, 245);
    margin-left: 10px;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    .title_box {
      background: #fff;
  justify-content: space-between;
    .left_tree {
      width: 23%;
      height: 92%;
      padding: 10px;
      margin-bottom: 24px;
      display: flex;
      border-radius: 5px;
      float: left;
      overflow-y: auto;
      border-radius: 10px;
      border: 1px solid rgb(202, 201, 204);
      box-sizing: border-box;
    }
  }
  .table_box {
    padding: 10px;
    background: #fff;
    border-radius: 5px;
    border: 1px solid rgb(202, 201, 204);
    overflow: auto;
    height: 85%;
  }
    .right_menu {
      border-radius: 10px;
      width: 75%;
      // height: 92%;
      padding: 10px;
      // padding-top:0;
      border-radius: 10px;
      float: right;
    }
  .divider {
    margin-top: 8px;
  }
}
.subpage_Div {
  border-radius: 10px;
}
.el-table,
.el-table /deep/ .el-table__expanded-cell {
  background-color: transparent;
  background-color: transparent !important;
}
.el-table /deep/ th,
.el-table /deep/ tr {
  background-color: transparent;
  background-color: transparent !important;
}
</style>