lxl
2022-10-27 9ce29c536ba2a636416c618761985e2b9a711ee6
src/views/userManage/roleManage.vue
@@ -27,7 +27,7 @@
        </el-form-item>
        <br />
        <el-form-item>
          <el-button @click="InsertFormdialog = true"
          <el-button @click="InsertFormdialog = true" v-if="menuStatus.insert"
            ><i class="el-icon-circle-plus-outline"></i> &nbsp;{{
              $t('userManage.RM.add')
            }}</el-button
@@ -47,10 +47,24 @@
            }}</el-button
          >
        </el-form-item>
        <el-form-item>
          <el-button @click="handleDelete()" v-if="menuStatus.delete"
            ><i class="el-icon-delete"></i>&nbsp;{{
              $t('common.delete')
            }}</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <div class="table_box">
      <el-table :data="tableData" stripe style="width: 100%" height="99%">
      <el-table
        :data="tableData"
        stripe
        style="width: 100%"
        @selection-change="handleSelectionChange"
        height="99%"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column
          align="center"
          type="index"
@@ -69,13 +83,24 @@
          prop="depName"
          :label="$t('userManage.RM.ownedSystem')"
        />
        <el-table-column
          align="center"
          prop="isAdmin"
          :label="$t('userManage.RM.isAdmin')"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.isAdmin == 1">是 </span>
            <span v-else-if="scope.row.isAdmin == 0">否</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="descr"
          :label="$t('userManage.RM.describe')"
        />
        <el-table-column
        <!-- <el-table-column
          align="center"
          prop="createUser"
          :label="$t('userManage.RM.creationuser')"
@@ -101,7 +126,7 @@
          align="center"
          prop="bak"
          :label="$t('userManage.RM.remarks')"
        />
        /> -->
        <el-table-column
          fixed="right"
          :label="$t('common.operate')"
@@ -109,16 +134,17 @@
        >
          <template slot-scope="scope">
            <el-button
              v-if="menuStatus.update"
              type="warning"
              @click="handleEdit(scope.$index, scope.row)"
              size="small"
              >{{ $t('common.update') }}</el-button
            >
            <el-button
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              @click="showDetail(scope.$index, scope.row)"
              type="primary"
              size="small"
              >{{ $t('common.delete') }}</el-button
              >{{ $t('common.see') }}</el-button
            >
          </template>
        </el-table-column>
@@ -136,6 +162,7 @@
        </el-pagination>
      </div>
    </div>
    <el-dialog
      :title="$t('userManage.RM.insertRole')"
      top="15vh"
@@ -172,6 +199,13 @@
          <el-input v-model="insertform.descr" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.RM.isAdmin')"
          :label-width="formLabelWidth"
        >
          <el-radio v-model="insertform.isAdmin" label="1">是</el-radio>
          <el-radio v-model="insertform.isAdmin" label="0">否</el-radio>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.RM.remarks')"
          :label-width="formLabelWidth"
        >
@@ -186,7 +220,7 @@
      </div>
    </el-dialog>
    <el-dialog
      :title="$t('userManage.RM.insertRole')"
      :title="$t('userManage.RM.updateRole')"
      top="15vh"
      width="80vh"
      style="overflow: hidden"
@@ -213,6 +247,13 @@
          <el-button style="margin-left: 20px" @click="showDepTree(3)">{{
            $t('common.choose')
          }}</el-button>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.RM.isAdmin')"
          :label-width="formLabelWidth"
        >
          <el-radio v-model="updateform.isAdmin" label="1">是</el-radio>
          <el-radio v-model="updateform.isAdmin" label="0">否</el-radio>
        </el-form-item>
        <el-form-item
          :label="$t('userManage.RM.describe')"
@@ -247,6 +288,67 @@
        >
      </div>
    </div>
    <div class="infoBox" v-show="showinfoBox">
      <el-card>
        <div slot="header" class="clearfix">
          <span>{{ $t('dataManage.styleObj.deInformation') }}</span>
          <div style="float: right; cursor: pointer" @click="closeDetial">
            <i class="el-icon-close"></i>
          </div>
        </div>
        <div class="contentBox">
          <p>
            <label> {{ $t('userManage.RM.roleName') }}:</label>
            <label class="boxlabel">{{ itemdetail.name }}</label>
          </p>
          <el-divider></el-divider>
          <p>
            <label> {{ $t('userManage.RM.ownedSystem') }}:</label>
            <label class="boxlabel">{{ itemdetail.depName }}</label>
          </p>
          <el-divider></el-divider>
          <p>
            <label> {{ $t('userManage.RM.isAdmin') }}:</label>
            <label class="boxlabel">{{ itemdetail.admin }}</label>
          </p>
          <el-divider></el-divider>
          <p>
            <label> {{ $t('userManage.RM.describe') }}:</label>
            <label class="boxlabel">{{ itemdetail.descr }}</label>
          </p>
          <el-divider></el-divider>
          <p>
            <label> {{ $t('userManage.RM.creationuser') }}:</label>
            <label class="boxlabel">{{ itemdetail.createUser }}</label>
          </p>
          <el-divider></el-divider>
          <p>
            <label> {{ $t('userManage.RM.creationtime') }}:</label>
            <label class="boxlabel">{{ itemdetail.createTime }}</label>
          </p>
          <el-divider></el-divider>
          <p>
            <label> {{ $t('userManage.RM.updateonuser') }}:</label>
            <label class="boxlabel">{{ itemdetail.UpdateUser }}</label>
          </p>
          <el-divider></el-divider>
          <p>
            <label> {{ $t('userManage.RM.updateontime') }}:</label>
            <label class="boxlabel">{{ itemdetail.updateTime }}</label>
          </p>
          <el-divider></el-divider>
          <p>
            <label> {{ $t('userManage.RM.remarks') }}:</label>
            <label class="boxlabel">{{ itemdetail.bak }}</label>
          </p>
          <el-divider></el-divider>
        </div>
      </el-card>
    </div>
  </div>
</template>
@@ -258,7 +360,7 @@
  select_Role_ByPageAndCount,
  selectdepTab,
  insertRole,
  deleteRole,
  deleteRoles,
  selectDep,
  updateRole,
} from '../../api/api';
@@ -270,6 +372,7 @@
  },
  data() {
    return {
      showinfoBox: false,
      showCata: false,
      formLabelWidth: '120px',
      InsertFormdialog: false,
@@ -284,19 +387,49 @@
      updateform: {},
      count: 0,
      selData: [],
      itemdetail: {},
      multipleSelection: [],
      listData: {
        name: null,
        depName: null,
        pageIndex: 1,
        pageSize: 10,
      },
      menuStatus: {
        delete: false,
        insert: false,
        update: false,
      },
    };
  },
  methods: {
    closeDetial() {
      this.showinfoBox = false;
      this.itemdetail = {};
    },
    showDetail(index, row) {
      this.showinfoBox = true;
      this.itemdetail = row;
      this.itemdetail.createTime = this.formomentTime(
        this.itemdetail.createTime
      );
      this.itemdetail.updateTime = this.formomentTime(
        this.itemdetail.updateTime
      );
      this.itemdetail.admin =
        parseInt(this.itemdetail.isAdmin) === 0 ? '否' : '是';
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    formatTime(row, column) {
      let date = row[column.property]; // 我这里的crtime=1657528899所以这里*1000
      let date = row[column.property];
      return this.formomentTime(date);
    },
    formomentTime(date) {
      if (date === undefined || date === null) {
        return '';
        return;
      }
      return moment(parseInt(date)).format('YYYY-MM-DD HH:mm:ss');
    },
@@ -339,10 +472,10 @@
      this.listData.name = this.roleForm.username;
      this.listData.depName = this.roleForm.value;
      const data = await select_Role_ByPageAndCount(this.listData);
      console.log(data.result);
      if (data.code != 200) {
        this.$message.error('列表调用失败');
      }
      console.log(data);
      this.tableData = data.result;
      this.count = data.count;
    },
@@ -401,6 +534,7 @@
        });
        return;
      }
      console.log(this.updateform);
      const data = await updateRole(this.updateform);
      if (data.code == 200) {
        this.UpdateFormdialog = false;
@@ -417,8 +551,13 @@
        });
      }
    },
    async handleDelete(index, row) {
      const data = await deleteRole({ id: row.id.toString() });
    async handleDelete() {
      var std = [];
      for (var i in this.multipleSelection) {
        std.push(this.multipleSelection[i].id);
      }
      const data = await deleteRoles({ ids: std.toString() });
      if (data.code == 200) {
        this.InsertFormdialog = false;
        this.$message({
@@ -438,18 +577,17 @@
      this.getRoleTabelData();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.listData.pageIndex = val;
      this.getRoleTabelData();
    },
    async handleEdit(index, row) {
      this.updateform = row;
      this.updateform.isAdmin = row.isAdmin.toString();
      const data = await selectDep({ id: row.depid });
      this.updateform.depValue = data.result.name;
      this.UpdateFormdialog = true;
    },
    onSubmit() {
      console.log(this.roleForm);
      this.getRoleTabelData();
    },
    resetForm(formName) {
@@ -457,8 +595,28 @@
      this.roleForm = {};
      this.getRoleTabelData();
    },
    showPermsMenu(res) {
      switch (res.tag) {
        case '/delete':
          this.menuStatus.delete = true;
          break;
        case '/insert':
          this.menuStatus.insert = true;
          break;
        case '/update':
          this.menuStatus.update = true;
          break;
      }
    },
  },
  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]);
      }
    }
    this.getRoleTabelData();
    this.getSelectDepTab();
  },
@@ -520,5 +678,58 @@
  .text-center {
    text-align: center;
  }
  .infoBox {
    width: 500px;
    border: 1px solid #eee;
    position: absolute;
    z-index: 100;
    top: 25%;
    right: 12%;
    background-color: #fff;
    .el-card {
      background-color: transparent;
      span {
        font-size: 16px;
        font-weight: 600;
      }
    }
    .contentBox {
      margin: 0 aotu 10px;
      height: 485px;
      overflow: auto;
      p {
        // background-color: #bfa;
        // margin-bottom: 10px;
        font-size: 14px;
      }
      .boxlabel {
        margin-left: 10px;
      }
    }
    /* 整体样式 */
    .contentBox::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }
    /* 滚动条 */
    .contentBox::-webkit-scrollbar-thumb {
      background-color: #b3d8ff;
      border-radius: 6px;
    }
    /* 滚动条鼠标经过样式 */
    .contentBox::-webkit-scrollbar-thumb:hover {
      background-color: #b3d8ff;
      border-radius: 6px;
    }
    /* 滚动条轨道 */
    .contentBox::-webkit-scrollbar-track-piece {
      -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
      border-radius: 10px;
      background: #ededed;
    }
  }
}
</style>