权限管理

This commit is contained in:
yl 2023-03-15 22:45:37 +08:00 committed by yovinchen
parent 13a9ff9ffd
commit e8e41560e1
3 changed files with 284 additions and 204 deletions

View File

@ -3,97 +3,130 @@
<!-- 工具条 -->
<div class="tools-div">
<el-button type="success" icon="el-icon-plus" size="mini" @click="add()"> </el-button>
<el-button
:disabled="$hasBP('bnt.sysMenu.add') === false"
icon="el-icon-plus"
size="mini"
type="success"
@click="add()"
>
</el-button>
</div>
<el-table
:data="sysMenuList"
style="width: 100%;margin-bottom: 20px;margin-top: 10px;"
row-key="id"
border
:default-expand-all="false"
:tree-props="{children: 'children'}">
:tree-props="{children: 'children'}"
border
row-key="id"
style="width: 100%;margin-bottom: 20px;margin-top: 10px;"
>
<el-table-column prop="name" label="菜单名称" width="160"/>
<el-table-column label="菜单名称" prop="name" width="160"/>
<el-table-column label="图标">
<template slot-scope="scope">
<i :class="scope.row.icon"></i>
<i :class="scope.row.icon"/>
</template>
</el-table-column>
<el-table-column prop="perms" label="权限标识" width="160"/>
<el-table-column prop="path" label="路由地址" width="120"/>
<el-table-column prop="component" label="组件路径" width="160"/>
<el-table-column prop="sortValue" label="排序" width="60"/>
<el-table-column label="权限标识" prop="perms" width="160"/>
<el-table-column label="路由地址" prop="path" width="120"/>
<el-table-column label="组件路径" prop="component" width="160"/>
<el-table-column label="排序" prop="sortValue" width="60"/>
<el-table-column label="状态" width="80">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status === 1" disabled="true">
</el-switch>
v-model="scope.row.status === 1"
disabled="true"
/>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="160"/>
<el-table-column label="操作" width="180" align="center" fixed="right">
<el-table-column label="创建时间" prop="createTime" width="160"/>
<el-table-column align="center" fixed="right" label="操作" width="180">
<template slot-scope="scope">
<el-button type="success" v-if="scope.row.type !== 2" icon="el-icon-plus" size="mini" @click="add(scope.row)" title="添加下级节点"/>
<el-button type="primary" icon="el-icon-edit" size="mini" @click="edit(scope.row)" title="修改"/>
<el-button type="danger" icon="el-icon-delete" size="mini" @click="removeDataById(scope.row.id)" title="删除" :disabled="scope.row.children.length > 0"/>
<el-button
v-if="scope.row.type !== 2"
icon="el-icon-plus"
size="mini"
title="添加下级节点"
type="success"
@click="add(scope.row)"
/>
<el-button
:disabled="$hasBP('bnt.sysMenu.update') === false"
icon="el-icon-edit"
size="mini"
title="修改"
type="primary"
@click="edit(scope.row)"
/>
<el-button
:disabled="(scope.row.children.length > 0) || !$hasBP('bnt.sysMenu.remove')"
icon="el-icon-delete"
size="mini"
title="删除"
type="danger"
@click="removeDataById(scope.row.id)"
/>
</template>
</el-table-column>
</el-table>
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="40%" >
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="40%">
<el-form ref="dataForm" :model="sysMenu" label-width="150px" size="small" style="padding-right: 40px;">
<el-form-item label="上级部门" v-if="sysMenu.id === ''">
<el-form-item v-if="sysMenu.id === ''" label="上级部门">
<el-input v-model="sysMenu.parentName" disabled="true"/>
</el-form-item>
<el-form-item label="菜单类型" prop="type">
<el-radio-group v-model="sysMenu.type" :disabled="typeDisabled">
<el-radio :label="0" :disabled="type0Disabled">目录</el-radio>
<el-radio :label="1" :disabled="type1Disabled">菜单</el-radio>
<el-radio :label="2" :disabled="type2Disabled">按钮</el-radio>
<el-radio :disabled="type0Disabled" :label="0">目录</el-radio>
<el-radio :disabled="type1Disabled" :label="1">菜单</el-radio>
<el-radio :disabled="type2Disabled" :label="2">按钮</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="菜单名称" prop="name">
<el-input v-model="sysMenu.name"/>
</el-form-item>
<el-form-item label="图标" prop="icon" v-if="sysMenu.type !== 2">
<el-form-item v-if="sysMenu.type !== 2" label="图标" prop="icon">
<el-select v-model="sysMenu.icon" clearable>
<el-option v-for="item in iconList" :key="item.class" :label="item.class" :value="item.class">
<span style="float: left;">
<i :class="item.class"></i> <!-- 如果动态显示图标这里添加判断 -->
</span>
<span style="float: left;">
<i :class="item.class"/> <!-- 如果动态显示图标这里添加判断 -->
</span>
<span style="padding-left: 6px;">{{ item.class }}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="排序">
<el-input-number v-model="sysMenu.sortValue" controls-position="right" :min="0" />
<el-input-number v-model="sysMenu.sortValue" :min="0" controls-position="right"/>
</el-form-item>
<el-form-item prop="path">
<span slot="label">
<el-tooltip content="访问的路由地址,如:`sysUser`" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
路由地址
</span>
<el-input v-model="sysMenu.path" placeholder="请输入路由地址" />
<span slot="label">
<el-tooltip content="访问的路由地址,如:`sysUser`" placement="top">
<i class="el-icon-question"/>
</el-tooltip>
路由地址
</span>
<el-input v-model="sysMenu.path" placeholder="请输入路由地址"/>
</el-form-item>
<el-form-item prop="component" v-if="sysMenu.type !== 0">
<span slot="label">
<el-tooltip content="访问的组件路径,如:`system/user/index`,默认在`views`目录下" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
组件路径
</span>
<el-input v-model="sysMenu.component" placeholder="请输入组件路径" />
<el-form-item v-if="sysMenu.type !== 0" prop="component">
<span slot="label">
<el-tooltip content="访问的组件路径,如:`system/user/index`,默认在`views`目录下" placement="top">
<i class="el-icon-question"/>
</el-tooltip>
组件路径
</span>
<el-input v-model="sysMenu.component" placeholder="请输入组件路径"/>
</el-form-item>
<el-form-item v-if="sysMenu.type === 2">
<el-input v-model="sysMenu.perms" placeholder="请输入权限标识" maxlength="100" />
<el-input v-model="sysMenu.perms" maxlength="100" placeholder="请输入权限标识"/>
<span slot="label">
<el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(hasAuthority('bnt.sysRole.list'))" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
权限字符
</span>
<el-tooltip
content="控制器中定义的权限字符,如:@PreAuthorize(hasAuthority('bnt.sysRole.list'))"
placement="top"
>
<i class="el-icon-question"/>
</el-tooltip>
权限字符
</span>
</el-form-item>
<el-form-item label="状态" prop="type">
<el-radio-group v-model="sysMenu.status">
@ -103,16 +136,16 @@
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false" size="small" icon="el-icon-refresh-right"> </el-button>
<el-button type="primary" icon="el-icon-check" @click="saveOrUpdate()" size="small"> </el-button>
<el-button icon="el-icon-refresh-right" size="small" @click="dialogVisible = false"> </el-button>
<el-button icon="el-icon-check" size="small" type="primary" @click="saveOrUpdate()"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import api from '@/api/system/sysMenu'
const defaultForm = {
id: '',
parentId: '',
@ -144,55 +177,55 @@ export default {
iconList: [
{
class: "el-icon-s-tools",
class: 'el-icon-s-tools'
},
{
class: "el-icon-s-custom",
class: 'el-icon-s-custom'
},
{
class: "el-icon-setting",
class: 'el-icon-setting'
},
{
class: "el-icon-user-solid",
class: 'el-icon-user-solid'
},
{
class: "el-icon-s-help",
class: 'el-icon-s-help'
},
{
class: "el-icon-phone",
class: 'el-icon-phone'
},
{
class: "el-icon-s-unfold",
class: 'el-icon-s-unfold'
},
{
class: "el-icon-s-operation",
class: 'el-icon-s-operation'
},
{
class: "el-icon-more-outline",
class: 'el-icon-more-outline'
},
{
class: "el-icon-s-check",
class: 'el-icon-s-check'
},
{
class: "el-icon-tickets",
class: 'el-icon-tickets'
},
{
class: "el-icon-s-goods",
class: 'el-icon-s-goods'
},
{
class: "el-icon-document-remove",
class: 'el-icon-document-remove'
},
{
class: "el-icon-warning",
class: 'el-icon-warning'
},
{
class: "el-icon-warning-outline",
class: 'el-icon-warning-outline'
},
{
class: "el-icon-question",
class: 'el-icon-question'
},
{
class: "el-icon-info",
class: 'el-icon-info'
}
]
}
@ -235,7 +268,7 @@ export default {
},
// -------------
add(row){
add(row) {
debugger
this.typeDisabled = false
this.dialogTitle = '添加下级节点'
@ -243,17 +276,17 @@ export default {
this.sysMenu = Object.assign({}, defaultForm)
this.sysMenu.id = ''
if(row) {
if (row) {
this.sysMenu.parentId = row.id
this.sysMenu.parentName = row.name
//this.sysMenu.component = 'ParentView'
if(row.type === 0) {
// this.sysMenu.component = 'ParentView'
if (row.type === 0) {
this.sysMenu.type = 1
this.typeDisabled = false
this.type0Disabled = false
this.type1Disabled = false
this.type2Disabled = true
} else if(row.type === 1) {
} else if (row.type === 1) {
this.sysMenu.type = 2
this.typeDisabled = true
}
@ -276,7 +309,7 @@ export default {
},
saveOrUpdate() {
if(this.sysMenu.type === 0 && this.sysMenu.parentId !== 0) {
if (this.sysMenu.type === 0 && this.sysMenu.parentId !== 0) {
this.sysMenu.component = 'ParentView'
}
this.$refs.dataForm.validate(valid => {

View File

@ -7,10 +7,10 @@
<el-col :span="24">
<el-form-item label="角色名称">
<el-input
style="width: 100%"
v-model="searchObj.roleName"
style="width: 100%"
placeholder="角色名称"
></el-input>
/>
</el-form-item>
</el-col>
</el-row>
@ -21,17 +21,24 @@
size="mini"
:loading="loading"
@click="fetchData()"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetData"
>重置</el-button
>
<el-button type="success" icon="el-icon-plus" size="mini" @click="add" :disabled="$hasBP('bnt.sysRole.add') === false"
> </el-button
>
<el-button class="btn-add" size="mini" @click="batchRemove()"
>批量删除</el-button
>
>搜索</el-button>
<el-button
icon="el-icon-refresh"
size="mini"
@click="resetData"
>重置</el-button>
<el-button
type="success"
icon="el-icon-plus"
size="mini"
:disabled="$hasBP('bnt.sysRole.add') === false"
@click="add"
> </el-button>
<el-button
class="btn-add"
size="mini"
@click="batchRemove()"
>批量删除</el-button>
</el-row>
</el-form>
</div>
@ -65,17 +72,26 @@
type="primary"
icon="el-icon-edit"
size="mini"
@click="edit(scope.row.id)"
:disabled="$hasBP('bnt.sysRole.update') === false"
title="修改"
@click="edit(scope.row.id)"
/>
<el-button
type="danger"
icon="el-icon-delete"
:disabled="$hasBP('bnt.sysRole.remove') === false"
size="mini"
@click="removeDataById(scope.row.id)"
title="删除"
@click="removeDataById(scope.row.id)"
/>
<el-button
type="warning"
:disabled="$hasBP('bnt.sysRole.assignAuth') === false"
icon="el-icon-baseball"
size="mini"
title="分配权限"
@click="showAssignAuth(scope.row)"
/>
<el-button type="warning" icon="el-icon-baseball" size="mini" @click="showAssignAuth(scope.row)" title="分配权限"/>
</template>
</el-table-column>
</el-table>
@ -106,24 +122,22 @@
</el-form>
<span slot="footer" class="dialog-footer">
<el-button
@click="dialogVisible = false"
size="small"
icon="el-icon-refresh-right"
> </el-button
>
@click="dialogVisible = false"
> </el-button>
<el-button
type="primary"
icon="el-icon-check"
@click="saveOrUpdate()"
size="small"
> </el-button
>
@click="saveOrUpdate()"
> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import api from "@/api/system/sysRole";
import api from '@/api/system/sysRole'
export default {
//
//
@ -133,126 +147,126 @@ export default {
list: [], //
total: 0, //
page: 1, //
limit: 3, //
limit: 10, //
searchObj: {}, //
sysRole: {}, //
sysRole: {}, //
multipleSelection: [], //
dialogVisible: false,
};
dialogVisible: false
}
},
//
created() {
this.fetchData();
this.fetchData()
},
//
methods: {
showAssignAuth(row) {
this.$router.push('/system/assignAuth?id='+row.id+'&roleName='+row.roleName);
this.$router.push('/system/assignAuth?id=' + row.id + '&roleName=' + row.roleName)
},
edit(id) {
this.dialogVisible = true;
this.fetchDataById(id);
this.dialogVisible = true
this.fetchDataById(id)
},
fetchDataById(id) {
api.getById(id).then((response) => {
this.sysRole = response.data;
});
this.sysRole = response.data
})
},
add() {
this.dialogVisible = true;
this.dialogVisible = true
},
saveOrUpdate() {
this.saveBtnDisabled = true; //
this.saveBtnDisabled = true //
if (!this.sysRole.id) {
this.saveData();
this.saveData()
} else {
this.updateData();
this.updateData()
}
},
//
saveData() {
api.save(this.sysRole).then((response) => {
this.$message.success(response.message || "操作成功");
this.dialogVisible = false;
this.fetchData(this.page);
});
this.$message.success(response.message || '操作成功')
this.dialogVisible = false
this.fetchData(this.page)
})
},
updateData() {
api.updateById(this.sysRole).then((response) => {
this.$message.success(response.message || "操作成功");
this.dialogVisible = false;
this.fetchData(this.page);
});
this.$message.success(response.message || '操作成功')
this.dialogVisible = false
this.fetchData(this.page)
})
},
fetchData(current = 1) {
this.page = current;
this.page = current
// api
api
.getPageList(this.page, this.limit, this.searchObj)
.then((response) => {
this.list = response.data.records;
this.total = response.data.total;
});
this.list = response.data.records
this.total = response.data.total
})
},
//
resetData() {
console.log("重置查询表单");
this.searchObj = {};
this.fetchData();
console.log('重置查询表单')
this.searchObj = {}
this.fetchData()
},
// id
removeDataById(id) {
// debugger
this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
// promise
// ajax
return api.removeById(id);
return api.removeById(id)
})
.then((response) => {
this.fetchData(this.page);
this.$message.success(response.message || "删除成功");
});
this.fetchData(this.page)
this.$message.success(response.message || '删除成功')
})
},
//
handleSelectionChange(selection) {
console.log(selection);
this.multipleSelection = selection;
console.log(selection)
this.multipleSelection = selection
},
//
batchRemove() {
if (this.multipleSelection.length === 0) {
this.$message.warning("请选择要删除的记录!");
return;
this.$message.warning('请选择要删除的记录!')
return
}
this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
// ajax
// selectionidid
var idList = [];
var idList = []
this.multipleSelection.forEach((item) => {
idList.push(item.id);
});
idList.push(item.id)
})
// api
return api.batchRemove(idList);
return api.batchRemove(idList)
})
.then((response) => {
this.fetchData();
this.$message.success(response.message);
});
},
},
};
this.fetchData()
this.$message.success(response.message)
})
}
}
}
</script>

View File

@ -6,58 +6,68 @@
<el-row>
<el-col :span="8">
<el-form-item label="关 键 字">
<el-input style="width: 95%" v-model="searchObj.keyword" placeholder="用户名/姓名/手机号码"></el-input>
<el-input v-model="searchObj.keyword" placeholder="用户名/姓名/手机号码" style="width: 95%"/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="操作时间">
<el-date-picker
v-model="createTimes"
type="datetimerange"
end-placeholder="结束时间"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
value-format="yyyy-MM-dd HH:mm:ss"
style="margin-right: 10px;width: 100%;"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm:ss"
/>
</el-form-item>
</el-col>
</el-row>
<el-row style="display:flex">
<el-button type="primary" icon="el-icon-search" size="mini" :loading="loading" @click="fetchData()">搜索</el-button>
<el-button :loading="loading" icon="el-icon-search" size="mini" type="primary" @click="fetchData()">搜索
</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetData">重置</el-button>
<el-button type="success" icon="el-icon-plus" size="mini" @click="add"> </el-button>
<el-button
:disabled="$hasBP('bnt.sysUser.add') === false"
icon="el-icon-plus"
size="mini"
type="success"
@click="add"
>
</el-button>
</el-row>
</el-form>
</div>
<!-- 工具条 -->
<!-- <div class="tools-div">-->
<!-- <el-button type="success" icon="el-icon-plus" size="mini" @click="add"> </el-button>-->
<!-- </div>-->
<!-- <div class="tools-div">-->
<!-- <el-button type="success" icon="el-icon-plus" size="mini" @click="add"> </el-button>-->
<!-- </div>-->
<!-- 列表 -->
<el-table
v-loading="listLoading"
:data="list"
stripe
border
style="width: 100%;margin-top: 10px;">
stripe
style="width: 100%;margin-top: 10px;"
>
<el-table-column
align="center"
label="序号"
width="70"
align="center">
>
<template slot-scope="scope">
{{ (page - 1) * limit + scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column prop="username" label="用户名" width="100"/>
<el-table-column prop="name" label="姓名" width="70"/>
<el-table-column prop="phone" label="手机" width="120"/>
<el-table-column prop="postName" label="岗位" width="100"/>
<el-table-column prop="deptName" label="部门" width="100"/>
<el-table-column label="用户名" prop="username" width="100"/>
<el-table-column label="姓名" prop="name" width="70"/>
<el-table-column label="手机" prop="phone" width="120"/>
<el-table-column label="岗位" prop="postName" width="100"/>
<el-table-column label="部门" prop="deptName" width="100"/>
<el-table-column label="所属角色" width="130">
<template slot-scope="scope">
<span v-for="item in scope.row.roleList" :key="item.id" style="margin-right: 10px;">{{ item.roleName }}</span>
@ -67,17 +77,38 @@
<template slot-scope="scope">
<el-switch
v-model="scope.row.status === 1"
@change="switchStatus(scope.row)">
</el-switch>
@change="switchStatus(scope.row)"
/>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="160"/>
<el-table-column label="创建时间" prop="createTime" width="160"/>
<el-table-column label="操作" width="180" align="center" fixed="right">
<el-table-column align="center" fixed="right" label="操作" width="180">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" size="mini" @click="edit(scope.row.id)" title="修改"/>
<el-button type="danger" icon="el-icon-delete" size="mini" @click="removeDataById(scope.row.id)" title="删除" />
<el-button type="warning" icon="el-icon-baseball" size="mini" @click="showAssignRole(scope.row)" title="分配角色"/>
<el-button
:disabled="$hasBP('bnt.sysUser.update') === false"
icon="el-icon-edit"
size="mini"
title="修改"
type="primary"
@click="edit(scope.row.id)"
/>
<el-button
:disabled="$hasBP('bnt.sysUser.remove') === false"
icon="el-icon-delete"
size="mini"
title="删除"
type="danger"
@click="removeDataById(scope.row.id)"
/>
<el-button
:disabled="$hasBP('bnt.sysUser.assignRole') === false"
icon="el-icon-baseball"
size="mini"
title="分配角色"
type="warning"
@click="showAssignRole(scope.row)"
/>
</template>
</el-table-column>
</el-table>
@ -85,17 +116,17 @@
<!-- 分页组件 -->
<el-pagination
:current-page="page"
:total="total"
:page-size="limit"
:page-sizes="[5, 10, 20, 30, 40, 50, 100]"
style="padding: 30px 0; text-align: center;"
:total="total"
layout="sizes, prev, pager, next, jumper, ->, total, slot"
style="padding: 30px 0; text-align: center;"
@current-change="fetchData"
@size-change="changeSize"
/>
<el-dialog title="添加/修改" :visible.sync="dialogVisible" width="40%" >
<el-form ref="dataForm" :model="sysUser" label-width="100px" size="small" style="padding-right: 40px;">
<el-dialog :visible.sync="dialogVisible" title="添加/修改" width="40%">
<el-form ref="dataForm" :model="sysUser" label-width="100px" size="small" style="padding-right: 40px;">
<el-form-item label="用户名" prop="username">
<el-input v-model="sysUser.username"/>
</el-form-item>
@ -110,28 +141,29 @@
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false" size="small" icon="el-icon-refresh-right"> </el-button>
<el-button type="primary" icon="el-icon-check" @click="saveOrUpdate()" size="small"> </el-button>
<el-button icon="el-icon-refresh-right" size="small" @click="dialogVisible = false"> </el-button>
<el-button icon="el-icon-check" size="small" type="primary" @click="saveOrUpdate()"> </el-button>
</span>
</el-dialog>
<el-dialog title="分配角色" :visible.sync="dialogRoleVisible">
<el-dialog :visible.sync="dialogRoleVisible" title="分配角色">
<el-form label-width="80px">
<el-form-item label="用户名">
<el-input disabled :value="sysUser.username"></el-input>
<el-input :value="sysUser.username" disabled/>
</el-form-item>
<el-form-item label="角色列表">
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
<div style="margin: 15px 0;"></div>
<el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">全选
</el-checkbox>
<div style="margin: 15px 0;"/>
<el-checkbox-group v-model="userRoleIds" @change="handleCheckedChange">
<el-checkbox v-for="role in allRoles" :key="role.id" :label="role.id">{{role.roleName}}</el-checkbox>
<el-checkbox v-for="role in allRoles" :key="role.id" :label="role.id">{{ role.roleName }}</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<div slot="footer">
<el-button type="primary" @click="assignRole" size="small">保存</el-button>
<el-button @click="dialogRoleVisible = false" size="small">取消</el-button>
<el-button size="small" type="primary" @click="assignRole">保存</el-button>
<el-button size="small" @click="dialogRoleVisible = false">取消</el-button>
</div>
</el-dialog>
</div>
@ -140,6 +172,7 @@
<script>
import api from '@/api/system/sysUser'
import roleApi from '@/api/system/sysRole'
const defaultForm = {
id: '',
username: '',
@ -178,7 +211,7 @@ export default {
this.fetchData()
roleApi.findAll().then(response => {
this.roleList = response.data;
this.roleList = response.data
})
},
@ -201,14 +234,14 @@ export default {
this.page = page
console.log('翻页。。。' + this.page)
if(this.createTimes && this.createTimes.length ==2) {
if (this.createTimes && this.createTimes.length == 2) {
this.searchObj.createTimeBegin = this.createTimes[0]
this.searchObj.createTimeEnd = this.createTimes[1]
}
api.getPageList(this.page, this.limit, this.searchObj).then(
response => {
//this.list = response.data.list
// this.list = response.data.list
this.list = response.data.records
this.total = response.data.total
@ -245,7 +278,7 @@ export default {
},
// -------------
add(){
add() {
this.dialogVisible = true
this.sysUser = Object.assign({}, defaultForm)
},
@ -292,26 +325,26 @@ export default {
})
},
showAssignRole (row) {
showAssignRole(row) {
this.sysUser = row
this.dialogRoleVisible = true
this.getRoles()
},
getRoles () {
getRoles() {
roleApi.getRoles(this.sysUser.id).then(response => {
const {allRolesList, assginRoleList} = response.data
this.allRoles = allRolesList
this.userRoleIds = assginRoleList.map(item => item.id)
this.checkAll = allRolesList.length===assginRoleList.length
this.isIndeterminate = assginRoleList.length>0 && assginRoleList.length<allRolesList.length
this.checkAll = allRolesList.length === assginRoleList.length
this.isIndeterminate = assginRoleList.length > 0 && assginRoleList.length < allRolesList.length
})
},
/*
全选勾选状态发生改变的监听
*/
handleCheckAllChange (value) {// value true/false
handleCheckAllChange(value) { // value true/false
// , userRoleIdsid,
this.userRoleIds = value ? this.allRoles.map(item => item.id) : []
// , false
@ -321,14 +354,14 @@ export default {
/*
角色列表选中项发生改变的监听
*/
handleCheckedChange (value) {
handleCheckedChange(value) {
const {userRoleIds, allRoles} = this
this.checkAll = userRoleIds.length === allRoles.length && allRoles.length>0
this.isIndeterminate = userRoleIds.length>0 && userRoleIds.length<allRoles.length
this.checkAll = userRoleIds.length === allRoles.length && allRoles.length > 0
this.isIndeterminate = userRoleIds.length > 0 && userRoleIds.length < allRoles.length
},
assignRole () {
let assginRoleVo = {
assignRole() {
const assginRoleVo = {
userId: this.sysUser.id,
roleIdList: this.userRoleIds
}