<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="Role Name" prop="roleName">
<el-input
v-model=""
placeholder="Please enter the role name"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="Role Permission String" prop="roleKey">
<el-input
v-model=""
placeholder="Please enter the role permission string"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="Show order" prop="roleSort">
<el-input
v-model=""
placeholder="Please enter the display order"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="Data range" prop="dataScope">
<el-input
v-model=""
placeholder="Please enter the data range"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="Whether menu tree selections are associated with display" prop="menuCheckStrictly">
<el-input
v-model=""
placeholder="Please enter the menu tree selections to be related to display"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="Whether department tree selections are related to display" prop="deptCheckStrictly">
<el-input
v-model=""
placeholder="Please enter the department tree selections to be related to the display"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">search</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">Reset</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:role:add']"
>New</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:role:edit']"
>Revise</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:role:remove']"
>delete</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:role:export']"
>Export</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="Role ID" align="center" prop="roleId" />
<el-table-column label="Role Name" align="center" prop="roleName" />
<el-table-column label="Role Permission String" align="center" prop="roleKey" />
<el-table-column label="Show order" align="center" prop="roleSort" />
<el-table-column label="Data range" align="center" prop="dataScope" />
<el-table-column label="Whether menu tree selections are associated with display" align="center" prop="menuCheckStrictly" />
<el-table-column label="Whether department tree selections are related to display" align="center" prop="deptCheckStrictly" />
<el-table-column label="Role Status" align="center" prop="status" />
<el-table-column label="Remark" align="center" prop="remark" />
<el-table-column label="operate" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate()"
v-hasPermi="['system:role:edit']"
>Revise</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete()"
v-hasPermi="['system:role:remove']"
>delete</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync=""
:limit.sync=""
@pagination="getList"
/>
<!--Add or modify role information dialog box-->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="Role Name" prop="roleName">
<el-input v-model="" placeholder="Please enter the role name" />
</el-form-item>
<el-form-item label="Role Permission String" prop="roleKey">
<el-input v-model="" placeholder="Please enter the role permission string" />
</el-form-item>
<el-form-item label="Show order" prop="roleSort">
<el-input v-model="" placeholder="Please enter the display order" />
</el-form-item>
<el-form-item label="Data range" prop="dataScope">
<el-input v-model="" placeholder="Please enter the data range" />
</el-form-item>
<el-form-item label="Whether menu tree selections are associated with display" prop="menuCheckStrictly">
<el-input v-model="" placeholder="Please enter the menu tree selections to be related to display" />
</el-form-item>
<el-form-item label="Whether department tree selections are related to display" prop="deptCheckStrictly">
<el-input v-model="" placeholder="Please enter the department tree selections to be related to the display" />
</el-form-item>
<el-form-item label="Delete flag" prop="delFlag">
<el-input v-model="" placeholder="Please enter the delete flag" />
</el-form-item>
<el-form-item label="Remark" prop="remark">
<el-input v-model="" type="textarea" placeholder="Please enter content" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">Sure</el-button>
<el-button @click="cancel">Cancel</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listRole, getRole, delRole, addRole, updateRole } from "@/api/system/role";
export default {
name: "Role",
data() {
return {
// Mask layer
loading: true,
// Select the array
ids: [],
// Not single disabled
single: true,
// Non-multiple disables
multiple: true,
// Show search criteria
showSearch: true,
// Total number of
total: 0,
// Role information table data
roleList: [],
// Pop-up layer title
title: "",
// Whether to display the pop-up layer
open: false,
// Query parameters
queryParams: {
pageNum: 1,
pageSize: 10,
roleName: null,
roleKey: null,
roleSort: null,
dataScope: null,
menuCheckStrictly: null,
deptCheckStrictly: null,
status: null,
},
// Form parameters
form: {},
// Form verification
rules: {
roleName: [
{ required: true, message: "The role name cannot be empty", trigger: "blur" }
],
roleKey: [
{ required: true, message: "Role permission string cannot be empty", trigger: "blur" }
],
roleSort: [
{ required: true, message: "The display order cannot be empty", trigger: "blur" }
],
status: [
{ required: true, message: "The character status cannot be empty", trigger: "change" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** Query role information list */
getList() {
this.loading = true;
listRole(this.queryParams).then(response => {
this.roleList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// Cancel button
cancel() {
this.open = false;
this.reset();
},
// Form reset
reset() {
this.form = {
roleId: null,
roleName: null,
roleKey: null,
roleSort: null,
dataScope: null,
menuCheckStrictly: null,
deptCheckStrictly: null,
status: null,
delFlag: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
};
this.resetForm("form");
},
/** Search button operation */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** Reset button operation */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// Multiple selection boxes to select data
handleSelectionChange(selection) {
this.ids = selection.map(item => item.roleId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** Added button operation */
handleAdd() {
this.reset();
this.open = true;
this.title = "Add role information";
},
/** Modify button operation */
handleUpdate(row) {
this.reset();
const roleId = row.roleId || this.ids
getRole(roleId).then(response => {
this.form = response.data;
this.open = true;
this.title = "Modify Role Information";
});
},
/** Submit button */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.roleId != null) {
updateRole(this.form).then(response => {
this.$modal.msgSuccess("Modification was successful");
this.open = false;
this.getList();
});
} else {
addRole(this.form).then(response => {
this.$modal.msgSuccess("Newly added");
this.open = false;
this.getList();
});
}
}
});
},
/** Delete button operation */
handleDelete(row) {
const roleIds = row.roleId || this.ids;
this.$modal.confirm('Whether to confirm that the deleted role information number is "' + roleIds + '" data item?').then(function() {
return delRole(roleIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("Delete successfully");
}).catch(() => {});
},
/** Export button operation */
handleExport() {
this.download('system/role/export', {
...this.queryParams
}, `role_${new Date().getTime()}.xlsx`)
}
}
};
</script>