123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <template>
- <div class="role-manage">
- <div class="part-box part-box-filter part-box-flex">
- <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
- <el-form-item label="角色名称:">
- <el-input
- style="width: 200px;"
- v-model.trim="filter.roleName"
- placeholder="请输入内容"
- clearable
- ></el-input>
- </el-form-item>
- <el-form-item label="启用/禁用:" label-width="90px">
- <el-select
- v-model="filter.enable"
- style="width: 100px;"
- placeholder="请选择"
- clearable
- >
- <el-option
- v-for="(val, key) in ABLE_TYPE"
- :key="key"
- :value="key"
- :label="val"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="icon icon-search" @click="toPage(1)"
- >查询</el-button
- >
- </el-form-item>
- </el-form>
- <div class="part-box-action">
- <el-button type="warning" icon="icon icon-plus" @click="toAdd"
- >添加角色</el-button
- >
- </div>
- </div>
- <div class="part-box">
- <el-table ref="TableList" :data="roles" border stripe>
- <el-table-column
- type="index"
- label="序号"
- width="70"
- align="center"
- :index="indexMethod"
- ></el-table-column>
- <el-table-column prop="roleName" label="角色名称"></el-table-column>
- <el-table-column prop="enable" label="启用/禁用">
- <template slot-scope="scope">
- {{ scope.row.enable | enableFilter }}
- </template>
- </el-table-column>
- <el-table-column prop="createTime" label="创建时间"></el-table-column>
- <el-table-column
- class-name="action-column"
- label="操作"
- align="center"
- width="120px"
- >
- <template slot-scope="scope">
- <el-button
- class="btn-table-icon"
- type="text"
- icon="icon icon-edit"
- @click="toEdit(scope.row)"
- title="编辑"
- ></el-button>
- <el-button
- class="btn-table-icon"
- type="text"
- icon="icon icon-delete"
- @click="toDelete(scope.row)"
- title="删除"
- ></el-button>
- <el-button
- class="btn-table-icon"
- type="text"
- :icon="
- scope.row.enable
- ? 'icon icon-circle-stop'
- : 'icon icon-circle-caret-right'
- "
- @click="toEnable(scope.row)"
- :title="scope.row.enable ? '禁用' : '启用'"
- ></el-button>
- </template>
- </el-table-column>
- </el-table>
- <div class="part-page">
- <el-pagination
- background
- layout="total,prev, pager, next"
- :current-page="current"
- :total="total"
- :page-size="size"
- @current-change="toPage"
- >
- </el-pagination>
- </div>
- </div>
- <!-- ModifyRole -->
- <modify-role
- ref="ModifyRole"
- :instance="curRole"
- :menus="menus"
- @modified="getList"
- ></modify-role>
- </div>
- </template>
- <script>
- import { ABLE_TYPE, TEMPLATE_TYPE } from "@/constants/enumerate";
- import { menuList, roleListPage, ableRole, deleteRole } from "../api";
- import ModifyRole from "../components/ModifyRole";
- export default {
- name: "role-manage",
- components: {
- ModifyRole
- },
- props: {
- templateType: {
- type: String,
- default: "GENERIC",
- validator(val) {
- return Object.keys(TEMPLATE_TYPE).indexOf(val) !== -1;
- }
- }
- },
- data() {
- return {
- filter: {
- enable: null,
- roleName: ""
- },
- current: 1,
- size: this.GLOBAL.pageSize,
- total: 0,
- roles: [],
- curRole: {},
- ABLE_TYPE,
- // menus: [],
- menus: []
- };
- },
- created() {
- this.getList();
- this.getMenus();
- },
- methods: {
- async getMenus() {
- this.menus = await menuList();
- },
- async getList() {
- const datas = {
- ...this.filter,
- pageNumber: this.current,
- pageSize: this.size
- };
- const data = await roleListPage(datas);
- this.roles = data.records;
- this.total = data.total;
- },
- toPage(page) {
- this.current = page;
- this.getList();
- },
- toAdd() {
- this.curRole = {};
- this.$refs.ModifyRole.open();
- },
- toEdit(row) {
- this.curRole = row;
- this.$refs.ModifyRole.open();
- },
- toDelete(row) {
- this.$confirm("确定要删除当前角色吗?", "提示", {
- cancelButtonClass: "el-button--danger is-plain",
- confirmButtonClass: "el-button--primary",
- type: "warning"
- }).then(async () => {
- await deleteRole(row.id);
- this.$message.success("删除成功!");
- this.deletePageLastItem();
- });
- },
- async toEnable(row) {
- const enable = Number(!row.enable);
- await ableRole({
- id: row.id,
- enable
- });
- row.enable = enable;
- }
- }
- };
- </script>
|