管道基础大数据平台系统开发-【前端】-新系統界面
liupengpeng
2023-02-14 b671529a86644b7496279c469fa683f58be222e1
src/views/userManage/orgManage.vue
@@ -1,15 +1,13 @@
<template>
  <div class="menuSettings_box">
    <My-bread
      :list="[
    <My-bread :list="[
        `${$t('operatManage.operatManage')}`,
        `${$t('operatManage.organizationManage')}`,
      ]"
    ></My-bread>
      ]"></My-bread>
    <el-divider />
    <div class="left_Tree">
      <el-card class="el-card-define">
        <div class="card_tree">
    <div class="cataLogContent">
      <div class="left_Tree subpage_Div">
        <div style="min-width:200px">
          <el-tree
            ref="tree"
            :props="defaultProps"
@@ -17,52 +15,79 @@
            :data="depList"
            :expand-on-click-node="false"
            :default-expand-all="true"
            draggable
            @node-click="handleNodeClick"
            @node-drag-start="handleDragStart"
            @node-drag-end="handleDrop"
          >
            <span class="custom-tree-node" slot-scope="{ node, data }">
              <span>{{ node.label }}</span>
              <span class="btnBox">
                <el-button
                  v-if="menuStatus.insert"
                  type="text"
                  size="mini"
                  @click="() => append(node, data)"
                >
                  <i class="el-icon-circle-plus"></i>
                </el-button>
                <el-button
                  v-if="menuStatus.delete"
                  type="text"
                  size="mini"
                  @click="() => remove(node, data)"
                >
                  <i class="el-icon-delete-solid"></i>
                </el-button>
              </span>
            </span>
          </el-tree>
        </div>
      </el-card>
    </div>
    <div class="right_menu">
      <el-card class="el-card-define">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/' }">{{
      </div>
      <div class="right_menu subpage_Div">
        <div style="display:flex;justify-content:space-between">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/' }">{{
            $t('dataManage.dictionaryManageObj.particulars')
          }}</el-breadcrumb-item>
        </el-breadcrumb>
          </el-breadcrumb>
          <div>
            <el-button
              v-if="menuStatus.insert"
              :disabled="itemdetail.pid == null ? true : false"
              @click="setNewNode(1)"
              type="success"
              icon="el-icon-plus"
              size="small"
            >新增同级</el-button>
            <el-button
              v-if="menuStatus.insert"
              :disabled="itemdetail.pid == null ? true : false"
              @click="setNewNode(2)"
              type="success"
              icon="el-icon-plus"
              size="small"
            >新增子级</el-button>
            <el-button
              v-if="menuStatus.delete"
              @click="setDelNode()"
              :disabled="itemdetail.pid == null ? true : false"
              type="danger"
              icon="el-icon-delete"
              size="small"
            >删除</el-button>
            <el-button
              v-if="menuStatus.update"
              :disabled="itemdetail.pid == null ? true : false"
              @click="setEditNode(1)"
              type="info"
              icon="el-icon-top"
              size="small"
            >向上移动</el-button>
            <el-button
              v-if="menuStatus.update"
              :disabled="itemdetail.pid == null ? true : false"
              @click="setEditNode(2)"
              type="info"
              icon="el-icon-bottom"
              size="small"
            >向下移动</el-button>
          </div>
        </div>
        <el-divider />
        <div class="form_box">
          <el-form :model="itemdetail" ref="itemdetail" :rules="rules">
          <el-form
            :model="itemdetail"
            ref="itemdetail"
            :rules="rules"
          >
            <el-form-item
              :label="$t('userManage.orgManageObj.name')"
              :label-width="formLabelWidth"
            >
              <el-input v-model="itemdetail.name" autocomplete="off"></el-input>
              <el-input
                v-model="itemdetail.name"
                autocomplete="off"
              ></el-input>
            </el-form-item>
            <el-form-item
              :label="$t('userManage.orgManageObj.abbreviation')"
@@ -77,7 +102,10 @@
              :label="$t('userManage.orgManageObj.unitCode')"
              :label-width="formLabelWidth"
            >
              <el-input v-model="itemdetail.code" autocomplete="off"></el-input>
              <el-input
                v-model="itemdetail.code"
                autocomplete="off"
              ></el-input>
            </el-form-item>
            <el-form-item
              :label="$t('userManage.orgManageObj.organizationCode')"
@@ -92,7 +120,10 @@
              :label="$t('userManage.orgManageObj.cmpanyAddress')"
              :label-width="formLabelWidth"
            >
              <el-input v-model="itemdetail.addr" autocomplete="off"></el-input>
              <el-input
                v-model="itemdetail.addr"
                autocomplete="off"
              ></el-input>
            </el-form-item>
            <el-form-item
              :label="$t('userManage.orgManageObj.continformation')"
@@ -107,7 +138,10 @@
              :label="$t('userManage.orgManageObj.fax')"
              :label-width="formLabelWidth"
            >
              <el-input v-model="itemdetail.fax" autocomplete="off"></el-input>
              <el-input
                v-model="itemdetail.fax"
                autocomplete="off"
              ></el-input>
            </el-form-item>
            <el-form-item
              :label="$t('userManage.orgManageObj.EMail')"
@@ -122,7 +156,10 @@
              :label="$t('userManage.orgManageObj.postalCode')"
              :label-width="formLabelWidth"
            >
              <el-input v-model="itemdetail.post" autocomplete="off"></el-input>
              <el-input
                v-model="itemdetail.post"
                autocomplete="off"
              ></el-input>
            </el-form-item>
            <el-form-item
              :label="$t('userManage.orgManageObj.WebsiteAddress')"
@@ -137,112 +174,162 @@
              :label="$t('userManage.orgManageObj.remarks')"
              :label-width="formLabelWidth"
            >
              <el-input v-model="itemdetail.bak" autocomplete="off"></el-input>
              <el-input
                v-model="itemdetail.bak"
                autocomplete="off"
              ></el-input>
            </el-form-item>
            <div class="btnBox" v-if="menuStatus.update">
            <div
              class="btnBox"
              v-if="menuStatus.update"
            >
              <el-button
                class="el-button-sure"
                type="primary"
                size="small"
                @click="updDep('itemdetail')"
                >{{ $t('common.submit') }}</el-button
              >
              >{{ $t('common.submit') }}</el-button>
              <el-button
                class="el-button-sure"
                type="primary"
                size="small"
                @click="reset('itemdetail')"
                >{{ $t('common.cancel') }}</el-button
              >
              >{{
                $t('common.cancel')
              }}</el-button>
            </div>
          </el-form>
        </div>
      </el-card>
      </div>
    </div>
    <el-dialog
      width="30%"
      top="5vh"
      :title="$t('common.append')"
      :visible.sync="dialogFormVisible"
    >
      <el-form :model="ruleForm" ref="ruleForm" :rules="rules">
      <el-form
        :model="ruleForm"
        ref="ruleForm"
        :rules="rules"
      >
        <el-form-item
          prop="name"
          :label="$t('userManage.orgManageObj.name')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.name" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.name"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.orgManageObj.abbreviation')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.sname" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.sname"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.orgManageObj.unitCode')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.code" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.code"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.orgManageObj.organizationCode')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.uncode" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.uncode"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.orgManageObj.cmpanyAddress')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.addr" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.addr"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.orgManageObj.continformation')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.contact" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.contact"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.orgManageObj.fax')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.fax" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.fax"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.orgManageObj.EMail')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.email" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.email"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.orgManageObj.postalCode')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.post" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.post"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.orgManageObj.WebsiteAddress')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.website" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.website"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.orgManageObj.remarks')"
          :label-width="formLabelWidth"
        >
          <el-input v-model="ruleForm.bak" autocomplete="off"></el-input>
          <el-input
            v-model="ruleForm.bak"
            autocomplete="off"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button class="el-button-sure" @click="resetForm('ruleForm')">{{
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button
          size="small"
          @click="resetForm('ruleForm')"
        >{{
          $t('common.cancel')
        }}</el-button>
        <el-button
          class="el-button-remove"
          size="small"
          type="primary"
          @click="submitForm('ruleForm')"
          v-loading.fullscreen.lock="fullscreenLoading"
          >{{ $t('common.submit') }}</el-button
        >
        >{{ $t('common.submit') }}</el-button>
      </div>
    </el-dialog>
  </div>
@@ -257,6 +344,7 @@
  queryMaxId,
  insertDep,
  deleteDep,
  getPerms
} from '../../api/api';
export default {
  //import引入的组件需要注入到对象中才能使用
@@ -323,10 +411,11 @@
      rules: {
        name: [{ required: true, validator: validName, trigger: 'blur' }],
      },
      newNode: null,
    };
  },
  methods: {
    getDepTree() {
    getMenuTree() {
      //获取目录树最大ID,新建节点使用
      // queryMaxId().then((res) => {
      //   this.id = res.data;
@@ -336,6 +425,12 @@
          this.oriData = res.result;
          this.newData = res.result;
          this.depList = this.treeData(res.result);
          if (this.itemdetail.id != null) {
            this.$nextTick(() => {
              this.$refs.tree.setCurrentKey(this.itemdetail.id);
            });
          }
        } else {
          this.$notify.error({
            title: res.code,
@@ -353,6 +448,106 @@
        return father.pid == 0; // 返回一级菜单
      });
    },
    setEditNode(res) {
      let node = this.$refs.tree.getCurrentNode();
      let pchildNodes = this.$refs.tree.getNode(node.id).parent.childNodes;
      let currentId = {};
      for (let i = 0; i < pchildNodes.length; i++) {
        if (pchildNodes[i].data.id == node.id) {
          currentId = i;
        }
      }
      switch (res) {
        case 1://向上移动
          if (currentId != 0) {
            const tempChildrenNodex1 = pchildNodes[currentId - 1];
            const tempChildrenNodex2 = pchildNodes[currentId];
            tempChildrenNodex2.orderNum = pchildNodes[currentId - 1].data.orderNum;
            tempChildrenNodex1.orderNum = pchildNodes[currentId].data.orderNum
            var arr = [];
            this.oriData.filter(res => {
              if (res.id == tempChildrenNodex2.data.id) {
                res.orderNum = tempChildrenNodex2.orderNum;
                arr.push(res)
              } else if (res.id == tempChildrenNodex1.data.id) {
                res.orderNum = tempChildrenNodex1.orderNum;
                arr.push(res)
              }
            })
            this.newData = arr;
            this.sendChange();
          } else {
            this.$message({
              message: '处于顶端,不能继续上移',
              type: 'warning'
            });
          }
          break;
        case 2://向下移动
          if (currentId < (pchildNodes.length - 1)) {
            const tempChildrenNodex1 = pchildNodes[currentId + 1];
            const tempChildrenNodex2 = pchildNodes[currentId];
            tempChildrenNodex2.orderNum = pchildNodes[currentId + 1].data.orderNum;
            tempChildrenNodex1.orderNum = pchildNodes[currentId].data.orderNum;
            var arr = [];
            this.oriData.filter(res => {
              if (res.id == tempChildrenNodex2.data.id) {
                res.orderNum = tempChildrenNodex2.orderNum;
                arr.push(res)
              } else if (res.id == tempChildrenNodex1.data.id) {
                res.orderNum = tempChildrenNodex1.orderNum;
                arr.push(res)
              }
            })
            this.newData = arr;
            this.sendChange();
          } else {
            this.$message({
              message: '处于底端,不能继续下移',
              type: 'warning'
            });
          }
          break;
      }
    },
    setDelNode() {
      this.remove(this.newNode, this.itemdetail)
    },
    setNewNode(res) {
      var id, lever, orderNum;
      if (res == 1) {//新增同级
        id = this.itemdetail.pid;
        orderNum = this.getMaxOrderNum(this.newNode.parent.childNodes)
        lever = this.itemdetail.level;
      } else if (res == 2) {//新增子级
        id = this.itemdetail.id;
        orderNum = this.getMaxOrderNum(this.newNode.childNodes)
        lever = this.itemdetail.level + 1;
      }
      this.ruleForm.pid = id;
      this.ruleForm.level = lever;
      this.ruleForm.orderNum = orderNum
      this.dialogFormVisible = true;
    },
    getMaxOrderNum(res) {
      var val = -100;
      for (var i in res) {
        if (res[i].data.orderNum > val) {
          val = res[i].data.orderNum
        }
      }
      val = val + 1;
      return val;
    },
    append(node, data) {
      this.dialogFormVisible = true;
      this.ruleForm.pid = data.id;
@@ -382,11 +577,12 @@
                    message: '添加成功',
                    type: 'success',
                  });
                  this.getMenuTree();
                  this.itemdetail = {};
                  this.ruleForm = {};
                  this.dialogFormVisible = false;
                  this.$refs[formName].resetFields();
                  this.getMenuTree();
                }
              }, 500);
            })
@@ -554,8 +750,8 @@
          alert('修改失败,请重试!');
        });
    },
    handleNodeClick(data) {
      // console.log(data);
    handleNodeClick(data, node) {
      this.newNode = node
      this.backUpData = JSON.stringify(data);
      this.itemdetail = JSON.parse(JSON.stringify(data));
    },
@@ -604,217 +800,72 @@
          break;
      }
    },
    getPerms() {
      var val = this.$store.state.currentPerms;
      var permsEntity = this.$store.state.permsEntity;
      if (permsEntity.length == 0) {
        getPerms().then((res) => {
          if (res.code == 200) {
            permsEntity = res.result;
          }
        });
      }
      for (var i = 0; i < permsEntity.length; i++) {
        if (permsEntity[i].perms == val) {
          console.log(permsEntity[i])
          this.showPermsMenu(permsEntity[i]);
        }
      }
    },
  },
  mounted() {
    this.getDepTree();
    this.getMenuTree();
    this.getPerms();
  },
  created() {
    var val = this.$store.state.currentPerms;
    var permsEntity = this.$store.state.permsEntity;
    for (var i = 0; i < permsEntity.length; i++) {
      if (permsEntity[i].perms == val) {
        this.showPermsMenu(permsEntity[i]);
      }
    }
    // var val = this.$store.state.currentPerms;
    // var permsEntity = this.$store.state.permsEntity;
    // for (var i = 0; i < permsEntity.length; i++) {
    //   if (permsEntity[i].perms == val) {
    //     this.showPermsMenu(permsEntity[i]);
    //   }
    // }
  },
};
</script>
<style lang="less" scoped>
//@import url(); 引入公共css类
.menuSettings_box {
  width: 100%;
  height: 100%;
  position: relative;
  height: 98%;
  width: 98%;
  padding: 1%;
  .cataLogContent {
    width: 100%;
    height: 92%;
    display: flex;
    justify-content: space-between;
  }
  .left_Tree {
    width: 15%;
    float: left;
    .el-icon-circle-plus {
      color: gray;
    }
    .el-icon-delete-solid {
      color: gray;
    }
    height: 91%;
    border-radius: 5px;
    padding: 1%;
    overflow-y: auto;
  }
  .right_menu {
    width: 84%;
    float: right;
    .form_box {
      width: 100%;
      height: 580px;
      overflow-y: auto;
      .el-input {
        width: 400px;
      }
      /deep/.el-form-item__label {
        color: white;
      }
    width: 80%;
    height: 91%;
    border-radius: 5px;
    padding: 1%;
    overflow: auto;
    .el-input {
      width: 400px;
    }
  }
  .el-card-define {
    height: 680px;
    background: #303030;
    border: 1px solid gray;
    padding: 1px;
  }
  .card_tree {
    display: block;
    height: 650px;
    overflow-y: auto;
    // 更改指标树图标颜色
    /deep/ .el-tree .el-icon-caret-right:before {
      color: white; /** 这里是要修改图标的颜色 **/
    }
    /deep/ .el-tree {
      color: white; /** 这里是要修改图标的颜色 **/
      background: transparent;
    }
    /deep/.el-tree-node__content {
      &:hover {
        background-color: rgba(255, 255, 255, 0.3) !important;
      }
    }
    /deep/.el-tree-node.is-current > .el-tree-node__content {
      background-color: rgba(255, 255, 255, 0.3) !important;
      color: #409eff;
    }
  }
  // .menuSettings_tree {
  //   position: relative;
  //   width: 344px;
  //   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;
  //   }
  //   .depTreeBox {
  //     height: 88%;
  //     width: 100%;
  //     overflow: auto;
  //     .el-tree {
  //       background: transparent;
  //       font-size: 15px;
  //       font-family: Microsoft YaHei;
  //       font-weight: 400;
  //       color: #000000;
  //       /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: 0 10px 0 5px;
  //         .el-button + .el-button {
  //           margin-left: 5px;
  //         }
  //       }
  //     }
  //   }
  // }
  // .itemSettings {
  //   width: calc(100% - 344px);
  //   border-radius: 10px;
  //   background: rgb(240, 242, 245);
  //   margin-left: 10px;
  //   height: 100%;
  //   padding: 10px;
  //   box-sizing: border-box;
  //   .title_box {
  //     background: #fff;
  //     padding: 10px;
  //     margin-bottom: 24px;
  //     display: flex;
  //     border-radius: 10px;
  //     border: 1px solid rgb(202, 201, 204);
  //     box-sizing: border-box;
  //   }
  //   .form_box {
  //     border: 1px solid rgb(202, 201, 204);
  //     border-radius: 10px;
  //     background: #fff;
  //     padding-top: 30px;
  //     box-sizing: border-box;
  //     width: 100%;
  //     .el-input,
  //     /deep/ .el-textarea {
  //       width: 400px;
  //     }
  //     .btnBox {
  //       margin: 0 270px 20px;
  //       width: 200px;
  //       display: flex;
  //       justify-content: space-between;
  //     }
  //   }
  // }
  /deep/ .el-dialog__body {
    padding: 0 30px 0 0;
  }
  /*里面的代码可以根据自己需求去进行更改*/
  /* 设置滚动条的样式 */
  ::-webkit-scrollbar {
    width: 4px;
  }
  /* 滚动槽 */
  ::-webkit-scrollbar-track {
    -webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.3);
    border-radius: 10px;
  }
  /* 滚动条滑块 */
  ::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #8b8b8b;
    -webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.5);
  }
  ::-webkit-scrollbar-thumb:window-inactive {
    background: #8b8b8b;
    height: 289px;
  }
  /deep/ .el-input__inner {
    background-color: transparent !important;
    border: 1px solid;
    color: white;
  }
  /deep/ .el-dialog {
    background: #303030;
  }
  /deep/.el-range-editor.is-active,
  .el-range-editor.is-active:hover,
  .el-select .el-input.is-focus .el-input__inner {
    border: 1px solid;
  }
  /deep/.el-dialog__title {
    color: white;
  }
  /deep/.el-form-item__label {
    color: white;
  }
  .el-button-sure {
    width: 116px;
    height: 40px;
    background: linear-gradient(180deg, #002992, #080472);
    border: 1px solid #000000;
    box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.21);
    border-radius: 3px;
  }
  .el-button-remove {
    width: 116px;
    height: 40px;
    background: linear-gradient(180deg, #002992, #080472);
    border: 1px solid #000000;
    box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.21);
    opacity: 0.5;
    border-radius: 3px;
  }
}
</style>