RoleMg.vue 5.56 KB
Newer Older
yaqizhang's avatar
yaqizhang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
<template>
  <div class="pomentWrap">
    <el-row class="topBar">
          <el-col>
            <el-form :inline="true" :model="searchData">
              <el-form-item label>
                <el-input v-model="searchData.roleName" placeholder="请输入名称"></el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="searchFun()">
                  <i class="el-icon-search"></i> 搜索
                </el-button>
                <el-button type="primary" @click="resetFun()">
                  <i class="el-icon-refresh"></i> 重置
                </el-button>
              </el-form-item>
              <el-form-item class="fr">
                <el-button plain type="primary" @click="addFun()">
                  <i class="el-icon-plus"></i> 新增
                </el-button>
              </el-form-item>
            </el-form>
          </el-col>
        </el-row>
        <el-table
          :data="tableData.pageData"
          stripe
          border
          style="width:100%;"
          v-loading="loading"
        >
          <el-table-column width="50" type="index" label="序号"></el-table-column>
          <el-table-column prop="roleName" label="角色名称"></el-table-column>
          <el-table-column prop="roleCode" label="角色代码"></el-table-column>
          <el-table-column prop="roleStatus" label="角色状态">
            <template slot-scope="scope">
              <font :class="{'jinColor': scope.row.roleStatus == '1'}">{{scope.row.roleStatus == '1' ? '禁用' : '启用'}}</font>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="270" align="center">
            <template slot-scope="scope">
              <el-button type="success" @click="editFun(scope.row)" size="small" plain><i class="el-icon-edit"></i> 编辑</el-button>
              <el-button type="danger" @click="delFun(scope.row)" size="small" plain><i class="el-icon-delete"></i> 删除</el-button>
              <el-button type="warning" @click="quanFun(scope.row)" size="small" plain><i class="el-icon-setting"></i> 权限</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          background
          layout="total,sizes, prev, pager, next, jumper"
          :total="tableData.total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="PAGE.page"
          :page-size="PAGE.size"
        ></el-pagination>
        
    <RoleMgEdit
      v-if="dialogVisible"
      :dialogVisible="dialogVisible"
      :editForm="formData"
      :title="dialogTit"
      @dialogFun="closeDialog"
      @refreshTableData="getTableData"
      :key="zjKey"
    ></RoleMgEdit>
    <Quan
    v-if="qxdialogVisible"
    :qxdialogVisible="qxdialogVisible"
    :roleID="roleID"
    :roleName="roleName"
    @QXdialogFun="qxcloseDialog"
    @confirm="qxconfirm"
    ></Quan>
  </div>
</template>
<style lang="scss">

</style>
<script lang="ts">
import { Component, Vue, Provide } from "vue-property-decorator";
import RoleMgEdit from "./RoleMgEdit.vue";
import Quan from "@/components/quan.vue";
import METHOD from '@/utils/methods'
@Component({
  components: { RoleMgEdit, Quan }
})
export default class RoleMg extends Vue {
  @Provide() tableData: Object = { pageData: [], total: 0 };
  @Provide() PAGE: any = { page: 1, size: 10 };
  @Provide() searchData: any = { roleName: "" };
  @Provide() loading: boolean = false;
  //编辑组件
  @Provide() dialogVisible: Boolean = false;
  @Provide() dialogTit: String = "新增";
  @Provide() formData: Object = {};
  @Provide() zjKey: any = 0;
  @Provide() qxdialogVisible: Boolean = false;
  @Provide() roleID: String = '';
  @Provide() roleName: String = '';
  getTableData() {
    let that = this,
      param = Object.assign({}, that.PAGE, that.searchData);
    that.loading = true;
    (this as any).$axios
      .get(`/role/getRoleList?roleName=${param.roleName}&page=${param.page}&size=${param.size}`)
      .then((res: any) => {
        that.loading = false;
        if( res.code == 0 ) that.tableData = res.data;
      });
  }
  searchFun() {
    this.PAGE = { page: 1, size: 10 };
    this.getTableData();
  }
  resetFun() {
    this.PAGE = { page: 1, size: 10 };
    this.searchData.roleName = "";
    this.getTableData();
  }
  addFun() {
    this.zjKey++;
    this.dialogVisible = true;
  }
  editFun(row: any) {
    this.dialogTit = "编辑";
    this.formData = Object.assign({}, row);
    this.zjKey++;
    this.dialogVisible = true;
  }
  delFun(row: any) {
    let that = this as any;
    METHOD.deleteFun(that, `/role/delRoleInfoById/${row.id}`,function(){
      that.getTableData();
    } )
  }
  handleSizeChange(val: any) {
    this.PAGE.size = val;
    this.getTableData();
  }
  handleCurrentChange(val: any) {
    this.PAGE.page = val;
    this.getTableData();
  }
  closeDialog() {
    this.dialogVisible = false;
    this.formData = {};
  }
  quanFun(row: any){
    let that = this;
    that.qxdialogVisible = true;
    that.roleID = row.id;
    that.roleName = row.roleName;
  }
  cahngeQuan(param: any) {
    let that = this;
    (this as any).$axios
      .post(`role/addOrEditRoleResources`, param)
      .then((res: any) => {
        if( res.code == 0 ){
          (that as any).$message({
            type: "success",
            message: "操作成功!"
          })
          that.qxcloseDialog()
        }
      });
  }
  qxcloseDialog() {
    this.qxdialogVisible = false;
  }
  qxconfirm(cs:any){
    this.cahngeQuan(cs)
  }
  created() {
    this.getTableData();
  }
}
</script>