管道基础大数据平台系统开发-【前端】-新系統界面
Surpriseplus
2023-01-16 21ddc9ec1b1b76d2ce20e512328e65acaf1af2bf
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">
        <div style="min-width:200px">
          <el-tree
            ref="tree"
            :props="defaultProps"
@@ -17,52 +15,74 @@
            :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">
        <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
              :disabled="itemdetail.pid == null ? true : false"
              @click="setEditNode(1)"
              type="info"
              icon="el-icon-top"
              size="mini"
            >向上移动</el-button>
            <el-button
              :disabled="itemdetail.pid == null ? true : false"
              @click="setEditNode(2)"
              type="info"
              icon="el-icon-bottom"
              size="mini"
            >向下移动</el-button>
            <el-button
              :disabled="itemdetail.pid == null ? true : false"
              @click="setNewNode(1)"
              type="success"
              icon="el-icon-plus"
              size="mini"
            >新增同级</el-button>
            <el-button
              :disabled="itemdetail.pid == null ? true : false"
              @click="setNewNode(2)"
              type="success"
              icon="el-icon-plus"
              size="mini"
            >新增子级</el-button>
            <el-button
              @click="setDelNode()"
              :disabled="itemdetail.pid == null ? true : false"
              type="danger"
              icon="el-icon-delete"
              size="mini"
            >删除</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 +97,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 +115,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 +133,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 +151,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,9 +169,15 @@
              :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
                style="
                  background: #409eff;
@@ -147,92 +185,134 @@
                  color: white;
                "
                @click="updDep('itemdetail')"
                >{{ $t('common.submit') }}</el-button
              >
              >{{ $t('common.submit') }}</el-button>
              <el-button @click="reset('itemdetail')">{{
                $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">
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click="resetForm('ruleForm')">{{
          $t('common.cancel')
        }}</el-button>
@@ -240,8 +320,7 @@
          style="background: #409eff; border: 1px solid #409eff; color: white"
          @click="submitForm('ruleForm')"
          v-loading.fullscreen.lock="fullscreenLoading"
          >{{ $t('common.submit') }}</el-button
        >
        >{{ $t('common.submit') }}</el-button>
      </div>
    </el-dialog>
  </div>
@@ -322,6 +401,7 @@
      rules: {
        name: [{ required: true, validator: validName, trigger: 'blur' }],
      },
      newNode: null,
    };
  },
  methods: {
@@ -335,6 +415,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,
@@ -352,6 +438,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;
@@ -554,8 +740,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));
    },
@@ -622,12 +808,24 @@
<style lang="less" scoped>
//@import url(); 引入公共css类
.menuSettings_box {
  width: 100%;
  height: 100%;
  position: relative;
  height: 98%;
  width: 98%;
  padding: 1%;
  position: absolute;
  .cataLogContent {
    width: 100%;
    height: 92%;
    display: flex;
    justify-content: space-between;
  }
  .left_Tree {
    width: 15%;
    float: left;
    height: 91%;
    border: 1px solid white;
    border-radius: 5px;
    padding: 1%;
    overflow-y: auto;
    .el-icon-circle-plus {
      color: gray;
    }
@@ -636,19 +834,21 @@
    }
  }
  .right_menu {
    width: 84%;
    float: right;
    .form_box {
      width: 100%;
      height: 580px;
      overflow-y: auto;
    width: 80%;
    height: 91%;
    border: 1px solid white;
    border-radius: 5px;
    padding: 1%;
    overflow: auto;
      .el-input {
        width: 400px;
      }
      /deep/.el-form-item__label {
        color: white;
      }
    }
  }
  .el-card-define {
    height: 680px;