新增页面

1.0.0
黄崇栋 6 years ago
parent e3b16f3af2
commit 3e47cfe093

@ -13,7 +13,7 @@
<a
class="block mb16"
href="javascript:;"
@click="visible = false;$router.push({name: 'centerIndex'})"
@click="visible = false;$router.push({name: 'center'})"
>个人中心</a>
<a href="javascript:;" @click="logout">退</a>
</div>

@ -1,27 +0,0 @@
export default {
appList: {
url: '/app/list',
name: '查询应用集合',
method: 'POST'
},
addApp: {
url: '/app/save',
name: '添加应用',
method: 'POST'
},
removeApp: {
url: '/app/del/{id}',
name: '删除应用',
method: 'DELETE'
},
getApp: {
url: '/app/{id}',
name: '应用详情',
method: 'GET'
},
editApp: {
url: '/app/modify',
name: '修改应用',
method: 'PUT'
}
}

@ -1,15 +0,0 @@
<template>
<list v-if="$route.name === 'appIndex'"></list>
<router-view v-else></router-view>
</template>
<script>
import list from "./web/list";
export default {
name: "appIndex",
components: { list }
};
</script>
<style>
</style>

@ -1,19 +0,0 @@
export default [{
path: 'app',
name: 'appIndex',
meta: {
name: '应用管理',
icon: 'appstore',
unfold: false,
sort: 3
},
component: () => import('@/views/application/index'),
children: [{
path: 'detail',
name: 'appDetailIndex',
meta: {
name: '应用详情',
},
component: () => import('@/views/application/web/web/index'),
}]
}]

@ -1,213 +0,0 @@
<template>
<content-view>
<div class="roleList">
<reset-search ref="form" :form.sync="searchObj">
<table class="table-form">
<tr>
<td width="78">应用名称</td>
<td>
<a-input placeholder="请输入应用名称" v-model="searchObj.name"></a-input>
</td>
<td width="70">应用KEY</td>
<td>
<a-input placeholder="请输入应用KEY" v-model="searchObj.key"></a-input>
</td>
<td>
<a-button type="primary" class="mr8" @click="query"></a-button>
<a-button @click="reset"></a-button>
</td>
</tr>
</table>
</reset-search>
<p class="mt24 mb16">
<a-button type="primary" @click="add" :disabled="addAuth">
<a-icon type="plus"></a-icon>
<span>新增</span>
</a-button>
</p>
<!-- modal -->
<a-modal
v-model="visible"
title="新增应用"
@ok="modalOk"
@cancel="modalCancel"
cancelText="取消"
okText="确定"
>
<a-form :form="formModal" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
<a-form-item label="应用名">
<a-input
autocomplete="off"
placeholder="请输入应用名"
v-decorator="['name', { rules: [{ required: true, min:2, max: 10, message: '请输入2-10位应用名称' }] }]"
></a-input>
</a-form-item>
</a-form>
</a-modal>
<!-- table -->
<a-table :columns="columns" :dataSource="dataSource">
<template slot="action" slot-scope="text, record">
<a
:disabled="detailAuth"
href="javascript:;"
class="mr8"
@click="$router.push({name: 'appDetailIndex', query: {id: record.id}})"
>查看详情</a>
<a-popconfirm
title="确认是否删除该应用"
ok-text="确定"
cancel-text="取消"
@confirm="deleteConfirm(record)"
@cancel="deleteCancel(record)"
>
<a-icon slot="icon" type="close-circle" style="color: red" />
<a href="#" :disabled="removeAuth">删除</a>
</a-popconfirm>
</template>
</a-table>
</div>
</content-view>
</template>
<script>
export default {
name: "appList",
data() {
return {
searchObj: {
name: "",
key: ""
},
// add
visible: false,
formModal: this.$form.createForm(this),
// table
columns: [
{
title: "序号",
customRender: (text, record, index) => {
return index + 1;
}
},
{
title: "应用名",
dataIndex: "name"
},
{
title: "应用KEY",
dataIndex: "key"
},
{
title: "应用secret",
dataIndex: "secret"
},
{
title: "操作",
dataIndex: "action",
scopedSlots: {
customRender: "action"
}
}
],
dataSource: []
};
},
computed: {
addAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "addApp"
)
? false
: true;
},
detailAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "appDetailIndex"
)
? false
: true;
},
removeAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "removeApp"
)
? false
: true;
}
},
methods: {
query() {
this.getList();
},
reset() {
this.searchObj = this.$utils.cleanData(this.searchObj);
this.query();
},
//
getList() {
this.$api.appApi
.appList({
data: {
...this.searchObj
}
})
.then(res => {
this.dataSource = res.data;
});
},
//
add() {
this.visible = true;
},
modalOk() {
this.formModal.validateFields((err, values) => {
console.log(err, values);
if (!err) {
this.$api.appApi
.addApp({
data: values
})
.then(res => {
console.log(res);
this.$message.success("新增成功");
this.query();
this.modalCancel();
});
}
});
},
modalCancel() {
this.formModal.resetFields();
this.visible = false;
},
//
deleteConfirm(record) {
console.log(record);
this.$api.appApi
.removeApp({
path: {
id: record.id
}
})
.then(res => {
console.log(res);
this.$message.success("操作成功");
this.reset();
});
},
deleteCancel(record) {
console.log(record);
}
},
mounted() {
this.getList();
}
};
</script>
<style lang="scss"></style>

@ -1,192 +0,0 @@
<template>
<content-view>
<div class="roleDetail">
<div class="roleDetail-box">
<div class="roleDetail-box-title mb16">基础信息</div>
<div class="roleDetail-box-con flex flex-space-between flex-align-center">
<div class="roleDetail-box-con-item flex flex-start">
<div
class="roleDetail-box-con-item-block flex flex-start flex-align-center mr24"
>
<div class="roleDetail-box-con-item-block-label">应用名</div>
<div class="roleDetail-box-con-item-block-value">
<span v-if="!isEdit">{{detail.name ? detail.name : '-'}}</span>
<a-input v-else placeholder="请输入与角色名称" v-model="tempName"></a-input>
</div>
</div>
<div
class="roleDetail-box-con-item-block flex flex-start flex-align-center mr24"
>
<div class="roleDetail-box-con-item-block-label">应用KEY</div>
<div class="roleDetail-box-con-item-block-value flex">
<span>{{detail.key ? detail.key : '-'}}</span>
</div>
</div>
<div
class="roleDetail-box-con-item-block flex flex-start flex-align-center"
>
<div class="roleDetail-box-con-item-block-label">应用secret</div>
<div class="roleDetail-box-con-item-block-value flex">
<span>{{detail.secret ? detail.secret : '-'}}</span>
</div>
</div>
</div>
<div class="roleDetail-box-con-item flex flex-start flex-align-center">
<a-button
type="primary"
v-if="!isEdit"
@click="tempName = detail.name; isEdit = !isEdit"
:disabled="editAuth"
>编辑</a-button>
<template v-else>
<a-button class="mr8" type="primary" @click="saveEdit"></a-button>
<a-button @click="isEdit = false">取消</a-button>
</template>
</div>
</div>
</div>
<div class="roleDetail-box">
<div class="roleDetail-box-title flex flex-start flex-align-center mb8">
<span>应用权限列表</span>
</div>
<div class="roleDetail-box-con">
<a-tree
:replace-fields="replaceFields"
:auto-expand-parent="true"
:tree-data="treeData"
v-model="checkedKeys"
/>
</div>
</div>
</div>
</content-view>
</template>
<script>
import mixins from "@/plugins/mixins";
export default {
name: "appDetail",
mixins: [mixins],
data() {
return {
detail: {},
//
isEdit: false,
tempName: "",
//
treeData: [],
replaceFields: {
children: "children",
title: "description",
key: "rights"
},
checkedKeys: []
};
},
computed: {
editAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "editApp"
)
? false
: true;
}
},
methods: {
//
getDetail() {
this.$api.appApi
.getApp({
path: {
id: this.$route.query.id
}
})
.then(res => {
this.detail = res.data;
this.translateDataToTree(this.detail.permissions);
});
},
// tree
translateDataToTree(data) {
let parents = data.filter(value => value.parentId === 0);
let children = data.filter(value => value.parentId !== 0);
let translator = (parents, children) => {
parents.forEach(parent => {
children.forEach((current, index) => {
if (current.parentId === parent.id) {
//
let temp = JSON.parse(JSON.stringify(children));
//
temp.splice(index, 1);
// children
parent.children && parent.children.length
? parent.children.push(current)
: (parent.children = [current]);
//
translator([current], temp);
}
});
});
};
translator(parents, children);
this.treeData = parents;
},
//
saveEdit() {
if (this.tempName.length < 2 || this.tempName.length > 10) {
this.$message.info("2-10位角色名称");
return;
}
this.$api.appApi
.editApp({
data: {
id: this.$route.query.id,
name: this.tempName
}
})
.then(res => {
console.log(res);
this.$set(this.detail, "name", this.tempName);
this.isEdit = false;
this.$message.success("操作成功");
});
}
},
mounted() {
this.getDetail();
}
};
</script>
<style lang='scss'>
.roleDetail {
.circle {
width: 8px;
height: 8px;
border-radius: 50%;
background-color: rgba(0, 168, 84, 1);
margin-right: 4px;
}
.red {
background-color: rgba(240, 65, 52, 1);
}
&-box {
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
padding-bottom: 24px;
margin-bottom: 24px;
&-title {
font-size: 16px;
font-family: PingFangSC, PingFangSC-Medium;
font-weight: 500;
text-align: left;
color: rgba(0, 0, 0, 0.85);
}
}
&-box:last-child {
border-bottom: none;
margin-bottom: 0;
padding-bottom: 0;
}
}
</style>

@ -1,17 +0,0 @@
<template>
<detail v-if="$route.name === 'appDetailIndex'"></detail>
<router-view v-else></router-view>
</template>
<script>
import detail from "./detail";
export default {
name: "appDetailIndex",
components: {
detail
}
};
</script>
<style>
</style>

@ -0,0 +1,12 @@
<template>
<div class="center"></div>
</template>
<script>
export default {
name: "center"
};
</script>
<style>
</style>

@ -1,7 +0,0 @@
export default {
editPwd: {
url: '/account/users/password',
name: '修改用户密码',
method: 'PUT'
}
}

@ -1,15 +0,0 @@
<template>
<list v-if="$route.name === 'centerIndex'"></list>
<router-view v-else></router-view>
</template>
<script>
import list from "./web/list.vue";
export default {
name: "centerIndex",
components: { list }
};
</script>
<style>
</style>

@ -1,18 +0,0 @@
export default [{
path: 'center',
name: 'centerIndex',
meta: {
name: '个人中心',
unfold: false,
sort: 99
},
component: () => import('@/views/center/index'),
children: [{
path: 'edit',
name: 'centerPwd',
meta: {
name: '修改密码',
},
component: () => import('@/views/center/web/editPwd'),
}]
}]

@ -1,128 +0,0 @@
<template>
<content-view>
<div class="userPwd">
<div class="userPwd-pwd pb24">
<a-form :form="form" :label-col="{ span: 8 }" :wrapper-col="{ span: 7 }">
<a-form-item label="原始密码">
<a-input
autocomplete="off"
placeholder="请输入原始密码"
v-decorator="['oldPwd', { rules: [{ required: true, pattern: /(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{6,16}$/, message: '6-16个字符包含数字、字母或符号组成至少两种' }] }]"
></a-input>
</a-form-item>
<a-form-item label="新密码">
<a-input
autocomplete="off"
placeholder="请输入新密码"
v-decorator="['password', { rules: [{ required: true, pattern: /(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{6,16}$/, message: '6-16个字符包含数字、字母或符号组成至少两种' }] }]"
></a-input>
</a-form-item>
<a-form-item label="确认密码">
<a-input
autocomplete="off"
placeholder="请输入确认密码"
v-decorator="['againPwd', { rules: [{ required: true, validator: validatorPwd }] }]"
></a-input>
</a-form-item>
</a-form>
<a-row class="mt24">
<a-col span="22" align="center">
<a-button type="primary" class="mr8" @click="sure"></a-button>
<a-button @click="cancel"></a-button>
</a-col>
</a-row>
</div>
</div>
</content-view>
</template>
<script>
export default {
name: "centerPwd",
data() {
return {
detail: {},
form: this.$form.createForm(this)
};
},
methods: {
sure() {
if (
!this.form.getFieldValue("oldPwd") ||
!this.form.getFieldValue("password") ||
!this.form.getFieldValue("againPwd")
) {
this.$message.info("请输入密码");
return;
}
this.$api.centerApi
.editPwd({
data: {
oldPassword: this.form.getFieldValue("oldPwd"),
newPassword: this.form.getFieldValue("password")
}
})
.then(res => {
console.log(res);
this.$message.success("操作成功");
this.cancel();
});
},
cancel() {
sessionStorage.removeItem("userDetail");
this.$router.go(-1);
},
validatorPwd(rule, value, callback) {
if (this.form.getFieldValue("password") === value) {
callback();
} else {
callback("两次密码输入不一致");
}
}
},
created() {
this.detail = sessionStorage.getItem("userDetail")
? JSON.parse(sessionStorage.getItem("userDetail"))
: {};
}
};
</script>
<style lang='scss'>
.userPwd {
&-title {
font-size: 16px;
font-family: PingFangSC, PingFangSC-Medium;
font-weight: 500;
text-align: left;
color: rgba(0, 0, 0, 0.85);
}
&-current {
display: flex;
flex-direction: column;
padding-bottom: 27px;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
margin-bottom: 30px;
&-desc {
width: 70%;
display: flex;
align-items: center;
justify-content: space-between;
.status {
display: flex;
align-items: center;
&-circle {
width: 8px;
height: 8px;
border-radius: 50%;
background-color: rgba(0, 168, 84, 1);
margin-right: 4px;
}
&-red {
background-color: rgba(240, 65, 52, 1);
}
}
}
}
}
</style>

@ -1,242 +0,0 @@
<template>
<content-view>
<div class="userDetail">
<!-- 1 -->
<div class="userDetail-current">
<p class="userDetail-title">基本信息</p>
<div class="userDetail-current-desc">
<div class="userDetail-current-desc-left">
<div class="flex flex-start mr16">
<span style="display: inline-block;width: 46px;">姓名</span>
<a-input
style="width: 50%;"
v-if="isEdit"
placeholder="请输入姓名"
v-model="tempInfo.name"
></a-input>
<span v-else>{{detail.name}}</span>
</div>
<div class="flex flex-start">
<span style="display: inline-block;width: 60px;">手机号</span>
<a-input
style="width: 50%;"
v-if="isEdit"
placeholder="请输入手机号"
v-model="tempInfo.account"
></a-input>
<span v-else>{{detail.account}}</span>
</div>
</div>
<div class="userDetail-current-desc-right">
<template v-if="isEdit">
<a-button type="primary" class="mr8" @click="sureEdit"></a-button>
<a-button @click="cancelEdit"></a-button>
</template>
<template v-else>
<a-button type="primary" class="mr8" @click="showEdit"></a-button>
<a-button @click="go('centerPwd')"></a-button>
</template>
</div>
</div>
</div>
<!-- 2 -->
<div class="userDetail-list">
<div class="userDetail-list-top flex flex-start">
<span class="userDetail-title">所属角色列表</span>
</div>
<a-table
:columns="columns"
:dataSource="detail.roles"
:rowKey="record => record.id"
>
<template slot="action" slot-scope="text, record">
<a
href="javascript:;"
class="mr8"
@click="go('roleDetailIndex', record)"
>角色详情</a>
<a-popconfirm
class="mr8"
title="确认是否退出该角色"
ok-text="确定"
cancel-text="取消"
@confirm="quit(record)"
>
<a-icon slot="icon" type="close-circle" style="color: red" />
<a href="javascript:;">退出</a>
</a-popconfirm>
</template>
</a-table>
</div>
</div>
</content-view>
</template>
<script>
import { mapState, mapMutations } from "vuex";
export default {
name: "centerList",
data() {
return {
detail: {},
// isEdit
isEdit: false,
//
tempInfo: {},
columns: [
{
title: "序号",
customRender: (text, record, index) => {
return index + 1;
}
},
{
title: "角色",
dataIndex: "roleName"
},
{
title: "操作",
dataIndex: "action",
scopedSlots: {
customRender: "action"
}
}
],
visible: false,
formModal: this.$form.createForm(this)
};
},
computed: {
...mapState(["userInfo"])
},
methods: {
...mapMutations(["setState"]),
//
go(name, record = null) {
if (name === "centerPwd") {
sessionStorage.setItem(
"userDetail",
JSON.stringify(this.detail)
);
}
let obj = {
name: name,
query: record ? { id: record.roleId } : null
};
this.$router.push(obj);
},
//
quit(record) {
console.log(record);
this.$api.userApi
.quitRole({
path: {
id: record.id
}
})
.then(res => {
console.log(res);
this.detail.roles.map((item, index) => {
if (item.id === record.id) {
this.detail.roles.splice(index, 1);
this.$message.success("操作成功");
}
});
});
},
//
showEdit() {
this.tempInfo = JSON.parse(JSON.stringify(this.detail));
this.isEdit = !this.isEdit;
},
sureEdit() {
this.$api.userApi
.editUser({
data: {
id: this.$route.query.id,
account: this.tempInfo.account,
name: this.tempInfo.name
}
})
.then(res => {
this.detail.name = res.data.name;
this.detail.account = res.data.account;
//
this.setState({ userInfo: this.detail });
this.$message.success("操作成功");
this.cancelEdit();
});
},
cancelEdit() {
this.isEdit = false;
},
//
getDetail(id) {
this.$api.userApi.userDetail({ path: { id: id } }).then(res => {
this.detail = res.data;
});
}
},
mounted() {
this.getDetail(this.userInfo.id);
}
};
</script>
<style lang='scss'>
.userDetail {
&-title {
font-size: 16px;
font-family: PingFangSC, PingFangSC-Medium;
font-weight: 500;
text-align: left;
color: rgba(0, 0, 0, 0.85);
}
&-current {
display: flex;
flex-direction: column;
padding-bottom: 27px;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
margin-bottom: 30px;
&-desc {
display: flex;
align-items: center;
justify-content: space-between;
&-left {
display: flex;
align-items: center;
flex: 1;
> div {
width: 33%;
}
.status {
display: flex;
align-items: center;
&-circle {
width: 8px;
height: 8px;
border-radius: 50%;
background-color: rgba(0, 168, 84, 1);
margin-right: 4px;
}
&-red {
background-color: rgba(240, 65, 52, 1);
}
}
}
&-right {
width: 20%;
display: flex;
justify-content: flex-end;
}
}
}
&-list {
&-top {
margin-bottom: 8px;
}
}
}
</style>

@ -0,0 +1,12 @@
<template>
<div class="guide"></div>
</template>
<script>
export default {
name: "guide"
};
</script>
<style>
</style>

@ -0,0 +1,10 @@
<template></template>
<script>
export default {
name: "history"
};
</script>
<style>
</style>

@ -0,0 +1,10 @@
<template></template>
<script>
export default {
name: "realTime"
};
</script>
<style>
</style>

@ -1,67 +0,0 @@
export default {
roleAll: {
url: '/role/role/',
name: '角色列表不分页',
method: 'GET'
},
roleList: {
url: '/role/role/page',
name: '角色列表分页',
method: 'POST'
},
roleUserList: {
url: '/role/role/user',
name: '获取角色下所有用户列表',
method: 'POST'
},
roleAddUserList: {
url: '/role/role/user',
name: '获取角色下可新增用户列表',
method: 'GET'
},
addRole: {
url: '/role/role/save',
name: '新增角色',
method: 'POST'
},
editRole: {
url: '/role/role/upd',
name: '修改角色',
method: 'PUT'
},
enableRole: {
url: '/role/role/del/{id}',
name: '更改状态,删除',
method: 'DELETE'
},
getRole: {
url: '/role/role/{id}',
name: '查询角色',
method: 'GET'
},
roleDelUser: {
url: '/role/role/delUser',
name: '角色下删除用户',
method: 'POST'
},
roleAppList: {
url: '/role/role/application',
name: '查询角色下可新增的应用',
method: 'GET'
},
roleAddUser: {
url: '/role/role/addUser',
name: '角色下新增用户',
method: 'POST'
},
appAuthList: {
url: '/role/permission/application',
name: '获取应用下的权限列表',
method: 'GET'
},
editAuth: {
url: '/role/role/updRolePermission',
name: '角色下修改权限',
method: 'PUT'
}
}

@ -1,15 +0,0 @@
<template>
<list v-if="$route.name === 'roleIndex'"></list>
<router-view v-else></router-view>
</template>
<script>
import list from "./web/list";
export default {
name: "roleIndex",
components: { list }
};
</script>
<style>
</style>

@ -1,19 +0,0 @@
export default [{
path: 'role',
name: 'roleIndex',
meta: {
name: '角色管理',
icon: 'form',
unfold: false,
sort: 2
},
component: () => import('@/views/role/index'),
children: [{
path: 'detail',
name: 'roleDetailIndex',
meta: {
name: '角色详情',
},
component: () => import('@/views/role/web/web/index'),
}]
}]

@ -1,271 +0,0 @@
<template>
<content-view>
<div class="roleList">
<reset-search ref="form" :form.sync="searchObj">
<table class="table-form">
<tr>
<td width="78">角色名称</td>
<td>
<a-input placeholder="请输入角色名称" v-model="searchObj.roleName"></a-input>
</td>
<td width="47">状态</td>
<td>
<a-select placeholder="请选择状态" v-model="searchObj.state">
<a-select-option :value="0">启用</a-select-option>
<a-select-option :value="1">停用</a-select-option>
</a-select>
</td>
<td>
<a-button type="primary" class="mr8" @click="query"></a-button>
<a-button @click="reset"></a-button>
</td>
</tr>
</table>
</reset-search>
<p class="mt24 mb16">
<a-button type="primary" @click="add" :disabled="addAuth">
<a-icon type="plus"></a-icon>
<span>新增</span>
</a-button>
</p>
<!-- modal -->
<a-modal
v-model="visible"
title="新增角色"
@ok="modalOk"
@cancel="modalCancel"
cancelText="取消"
okText="确定"
>
<a-form :form="formModal" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
<a-form-item label="角色名称">
<a-input
autocomplete="off"
placeholder="请输入角色名称"
v-decorator="['roleName', { rules: [{ required: true, min:2, max: 10, message: '请输入2-10位角色名称' }] }]"
></a-input>
</a-form-item>
</a-form>
</a-modal>
<!-- table -->
<a-table
:rowKey="record => record.id"
:columns="columns"
:dataSource="dataSource"
:pagination="pagination"
@change="paginationChange"
>
<div class="state flex flex-start" slot="state" slot-scope="text, record">
<div
class="state-circle mr8"
:style="{
'width': '8px',
'height': '8px',
'border-radius': '50%',
'background-color': record.state === 0 ? 'rgba(0,168,84,1)' : 'rgba(240,65,52,1)'
}"
></div>
<span>{{record.state === 0 ? '启用' : '停用'}}</span>
</div>
<template slot="action" slot-scope="text, record">
<a
:disabled="detailAuth"
href="javascript:;"
class="mr8"
@click="$router.push({name: 'roleDetailIndex', query: {id: record.id}})"
>角色详情</a>
<a
:disabled="enableAuth"
href="javascript:;"
class="mr8"
@click="enable(record)"
>{{record.state === 0 ? '停用' : '启用'}}</a>
<a-popconfirm
title="确认是否删除该角色"
ok-text="确定"
cancel-text="取消"
@confirm="deleteConfirm(record)"
@cancel="deleteCancel(record)"
>
<a-icon slot="icon" type="close-circle" style="color: red" />
<a href="#" :disabled="removeAuth">删除</a>
</a-popconfirm>
</template>
</a-table>
</div>
</content-view>
</template>
<script>
import mixins from "@/plugins/mixins";
export default {
name: "roleList",
mixins: [mixins],
data() {
return {
searchObj: {
roleName: "",
state: undefined
},
// add
visible: false,
formModal: this.$form.createForm(this),
// table
columns: [
{
title: "序号",
customRender: (text, record, index) => {
return (
(this.pagination.current - 1) *
this.pagination.pageSize +
(index + 1)
);
}
},
{
title: "角色名称",
dataIndex: "roleName"
},
{
title: "状态",
dataIndex: "state",
scopedSlots: {
customRender: "state"
}
},
{
title: "操作",
dataIndex: "action",
scopedSlots: {
customRender: "action"
}
}
],
dataSource: []
};
},
computed: {
//
addAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "addRole"
)
? false
: true;
},
detailAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "roleDetailIndex"
)
? false
: true;
},
enableAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "enableRole"
)
? false
: true;
},
removeAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "removeRole"
)
? false
: true;
}
},
methods: {
//
getList() {
this.$api.roleApi
.roleList({
data: {
pageNum: this.pagination.current,
pageSize: this.pagination.pageSize,
roleName: this.searchObj.roleName,
state: this.searchObj.state
}
})
.then(res => {
this.dataSource = res.data.list;
this.pagination.total = res.data.total;
});
},
//
add() {
this.visible = true;
},
modalOk() {
this.formModal.validateFields((err, values) => {
console.log(err, values);
if (!err) {
this.$api.roleApi
.addRole({
data: values
})
.then(res => {
console.log(res);
this.$message.success("新增成功");
this.modalCancel();
this.query();
});
}
});
},
modalCancel() {
this.formModal.resetFields();
this.visible = false;
},
//
deleteConfirm(record) {
console.log(record);
this.$api.roleApi
.enableRole({
path: {
id: record.id
},
params: {
state: 2
}
})
.then(res => {
console.log(res);
this.$message.success("操作成功");
this.reset();
});
},
deleteCancel(record) {
console.log(record);
},
//
enable(record) {
console.log(record);
this.$api.roleApi
.enableRole({
path: {
id: record.id
},
params: {
state: record.state === 0 ? 1 : 0
}
})
.then(res => {
console.log(res);
this.query();
this.$message.success("操作成功");
});
}
},
mounted() {
this.getList();
}
};
</script>
<style lang="scss"></style>

@ -1,543 +0,0 @@
<template>
<content-view>
<div class="roleDetail">
<!-- 1 -->
<div class="roleDetail-box">
<div class="roleDetail-box-title mb16">基础信息</div>
<div class="roleDetail-box-con flex flex-space-between flex-align-center">
<div class="roleDetail-box-con-item flex flex-start">
<div
class="roleDetail-box-con-item-block flex flex-start flex-align-center mr24"
>
<div class="roleDetail-box-con-item-block-label">角色名称</div>
<div class="roleDetail-box-con-item-block-value">
<span v-if="!isEdit">{{detail.roleName ? detail.roleName : '-'}}</span>
<a-input v-else placeholder="请输入与角色名称" v-model="tempName"></a-input>
</div>
</div>
<div
class="roleDetail-box-con-item-block flex flex-start flex-align-center"
>
<div class="roleDetail-box-con-item-block-label">状态</div>
<div class="roleDetail-box-con-item-block-value flex">
<div :class="{'circle' : true, 'red': detail.state !== 0}"></div>
<span>{{detail.state === 0 ? '启用': '停用'}}</span>
</div>
</div>
</div>
<div class="roleDetail-box-con-item">
<a-button
type="primary"
v-if="!isEdit"
@click="tempName = detail.roleName; isEdit = !isEdit"
:disabled="editAuth"
>编辑</a-button>
<template v-else>
<a-button class="mr8" type="primary" @click="saveEdit"></a-button>
<a-button @click="isEdit = false">取消</a-button>
</template>
</div>
</div>
</div>
<!-- 2 -->
<div class="roleDetail-box">
<div class="roleDetail-box-title flex flex-space-between flex-align-center mb8">
<span>下属权限列表</span>
<div>
<a-button
type="primary"
@click="type = 0; visible = true"
:disabled="addAppAuth"
class="mr8"
>
<a-icon type="plus"></a-icon>
</a-button>
<a-button @click="handleEditAuth">{{isDisabled ? '' : ''}}</a-button>
</div>
</div>
<div class="roleDetail-box-con flex flex-start">
<div
class="roleDetail-box-con-item"
v-for="(item, index) in detail.appPermissions"
:key="index"
>
<span class="text-center">{{item.applicationName}}</span>
<a-tree
checkable
:auto-expand-parent="true"
:tree-data="item.treeData"
:replace-fields="replaceFields"
v-model="item.checkedKeys"
@check="onCheck"
:disabled="isDisabled"
/>
</div>
</div>
</div>
<!-- 2 -->
<div class="roleDetail-box">
<div class="roleDetail-box-title flex flex-space-between flex-align-center mb8">
<span>下属用户列表</span>
<a-button
type="primary"
@click="type = 1; visible = true"
:disabled="bindUserAuth"
>
<a-icon type="plus"></a-icon>
</a-button>
</div>
<div class="roleDetail-box-con">
<a-table
:rowKey="record => record.id"
:columns="columns"
:dataSource="dataSource"
:pagination="pagination"
@change="paginationChange"
>
<div
class="flex flex-start flex-align-center"
slot="state"
slot-scope="text, record"
>
<div :class="{'circle' : true, 'red': record.state !== 0}"></div>
<span>{{record.state === 0 ? '启用': '停用'}}</span>
</div>
<template slot="action" slot-scope="text, record">
<a
:disabled="userDetailAuth"
href="javascript:;"
class="mr8"
@click="$router.push({name: 'userDetailIndex', query: {id: record.id}})"
>用户详情</a>
<a-popconfirm
title="确认是否删除该用户"
ok-text="确定"
cancel-text="取消"
@confirm="deleteConfirm(record)"
>
<a-icon slot="icon" type="close-circle" style="color: red" />
<a href="#" :disabled="unbindUserAuth">删除</a>
</a-popconfirm>
</template>
</a-table>
</div>
</div>
<!-- 4 -->
<a-modal
v-model="visible"
:title="title"
okText="确定"
cancelText="取消"
@ok="handleOk"
@cancel="handleCancel"
>
<a-row type="flex" align="middle">
<a-col span="7" align="right">{{type === 0 ? '应用' : '选择用户'}}</a-col>
<a-col span="12">
<a-select
style="width: 100%;"
v-if="type === 0"
placeholder="请选择应用"
v-model="modalObj.appId"
@change="getAppAuth"
>
<a-select-option
v-for="(item, index) in appList"
:key="index"
:value="item.id"
>{{item.name}}</a-select-option>
</a-select>
<a-select
v-else
style="width: 100%;"
mode="multiple"
placeholder="请选择用户"
v-model="modalObj.userIds"
>
<a-select-option
v-for="(item, index) in addUserList"
:key="index"
:value="item.id"
>{{item.name}}</a-select-option>
</a-select>
</a-col>
</a-row>
</a-modal>
</div>
</content-view>
</template>
<script>
import mixins from "@/plugins/mixins";
export default {
name: "roleDetail",
mixins: [mixins],
data() {
return {
detail: {},
//
isEdit: false,
tempName: "",
//
appList: [],
//
addUserList: [],
//
replaceFields: {
children: "children",
title: "description",
key: "id"
},
//
isDisabled: true,
//
columns: [
{
title: "序号",
customRender: (text, record, index) => {
return (
(this.pagination.current - 1) *
this.pagination.pageSize +
(index + 1)
);
}
},
{
title: "姓名",
dataIndex: "name"
},
{
title: "手机号",
dataIndex: "account"
},
{
title: "状态",
dataIndex: "state",
scopedSlots: {
customRender: "state"
}
},
{
title: "操作",
dataIndex: "action",
scopedSlots: {
customRender: "action"
}
}
],
dataSource: [],
// modal
visible: false,
type: 0, // 0 1
modalObj: {
appId: undefined,
permissionIds: "",
userIds: []
}
};
},
computed: {
title() {
if (this.type === 0) {
return "新增角色下所属应用权限";
} else {
return "新增角色下所属用户";
}
},
//
editAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "editRole"
)
? false
: true;
},
addAppAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "addAppAuth"
)
? false
: true;
},
bindUserAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "bindUser"
)
? false
: true;
},
userDetailAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "userDetailIndex"
)
? false
: true;
},
unbindUserAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "unbindUser"
)
? false
: true;
}
},
methods: {
//
getDetail() {
this.$api.roleApi
.getRole({
path: {
id: this.$route.query.id
}
})
.then(res => {
this.detail = res.data;
this.detail.appPermissions.map(item => {
const obj = this.translateDataToTree(item.permissions);
item.treeData = obj.parents;
item.checkedKeys = obj.checked;
this.$forceUpdate();
});
console.log("detail", this.detail);
});
},
// tree
translateDataToTree(list) {
const data = JSON.parse(JSON.stringify(list));
let checked = [];
data.map(item => item.isPoint === 1 && checked.push(item.id));
let parents = data.filter(value => value.parentId === 0);
let children = data.filter(value => value.parentId !== 0);
let translator = (parents, children) => {
parents.forEach(parent => {
children.forEach((current, index) => {
if (current.parentId === parent.id) {
//
let temp = JSON.parse(JSON.stringify(children));
//
temp.splice(index, 1);
// children
parent.children && parent.children.length
? parent.children.push(current)
: (parent.children = [current]);
//
translator([current], temp);
}
});
});
};
translator(parents, children);
return {
parents: parents,
checked: checked
};
},
// tree
onCheck(checkedKeys, e) {
console.log("onCheck", checkedKeys, "e", e);
this.$forceUpdate();
},
//
getApp() {
this.$api.roleApi
.roleAppList({ params: { id: this.$route.query.id } })
.then(res => {
this.appList = res.data;
});
},
//
getAppAuth(id) {
this.$api.roleApi
.appAuthList({ params: { applicationId: id } })
.then(res => {
let arr = [];
res.data.map(item => {
arr.push(item.id);
});
this.modalObj.permissionIds = arr.join(",");
});
},
//
getUser() {
this.$api.roleApi
.roleAddUserList({ params: { roleId: this.$route.query.id } })
.then(res => {
this.addUserList = res.data;
});
},
//
saveEdit() {
if (this.tempName.length < 2 || this.tempName.length > 10) {
this.$message.info("2-10位角色名称");
return;
}
this.$api.roleApi
.editRole({
data: {
id: this.$route.query.id,
roleName: this.tempName
}
})
.then(res => {
console.log(res);
this.$set(this.detail, "roleName", res.data.roleName);
this.isEdit = false;
this.$message.success("操作成功");
});
},
//
handleEditAuth() {
let temp = [];
if (this.isDisabled) {
//
this.isDisabled = false;
temp = JSON.parse(JSON.stringify(this.detail.appPermissions));
} else {
//
console.log(this.detail.appPermissions);
let ids = [];
this.detail.appPermissions.map(item => {
ids = ids.concat(item.checkedKeys);
});
this.$api.roleApi
.editAuth({
data: {
id: this.$route.query.id,
permissionIds: ids.join(",")
}
})
.then(res => {
console.log(res);
this.getDetail();
this.isDisabled = true;
this.$message.success("操作成功");
})
.catch(err => {
console.log(err);
this.detail.appPermissions = temp;
this.$forceUpdate();
this.isDisabled = true;
});
}
},
//
getList() {
this.$api.roleApi
.roleUserList({
data: {
pageNum: this.pagination.current,
pageSize: this.pagination.pageSize,
roleId: this.$route.query.id
}
})
.then(res => {
this.dataSource = res.data.list;
});
},
//
deleteConfirm(record) {
console.log(record);
this.$api.roleApi
.roleDelUser({
data: {
roleId: this.$route.query.id,
userId: record.id
}
})
.then(res => {
console.log(res);
this.$message.success("操作成功");
this.pagination.current = 1;
this.pagination.pageSize = 10;
this.getList();
this.getUser();
});
},
// modal
handleOk() {
if (this.type === 0) {
if (!this.modalObj.appId) {
this.$message.info("请选择应用");
return;
}
this.$api.roleApi
.editRole({
data: {
id: this.$route.query.id,
permissionIds: this.modalObj.permissionIds
}
})
.then(res => {
console.log(res);
this.getDetail();
this.$message.success("操作成功");
this.handleCancel();
});
} else {
if (!this.modalObj.userIds.length) {
this.$message.info("请选择用户");
return;
}
this.$api.roleApi
.roleAddUser({
data: {
roleId: this.$route.query.id,
userIds: this.modalObj.userIds
}
})
.then(res => {
console.log(res);
this.getList(); //
this.getUser(); //
this.$message.success("操作成功");
this.handleCancel();
});
}
},
handleCancel() {
this.visible = false;
this.modalObj = this.$utils.cleanData(this.modalObj);
}
},
mounted() {
this.getDetail();
this.getList();
this.getApp();
this.getUser();
}
};
</script>
<style lang='scss'>
.roleDetail {
.circle {
width: 8px;
height: 8px;
border-radius: 50%;
background-color: rgba(0, 168, 84, 1);
margin-right: 4px;
}
.red {
background-color: rgba(240, 65, 52, 1);
}
&-box {
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
padding-bottom: 24px;
margin-bottom: 24px;
&-title {
font-size: 16px;
font-family: PingFangSC, PingFangSC-Medium;
font-weight: 500;
text-align: left;
color: rgba(0, 0, 0, 0.85);
}
}
&-box:last-child {
border-bottom: none;
margin-bottom: 0;
padding-bottom: 0;
}
}
</style>

@ -1,17 +0,0 @@
<template>
<detail v-if="$route.name === 'roleDetailIndex'"></detail>
<router-view v-else></router-view>
</template>
<script>
import detail from "./detail";
export default {
name: "roleDetailIndex",
components: {
detail
}
};
</script>
<style>
</style>

@ -1,47 +0,0 @@
export default {
login: {
url: '/account/login',
name: '登录',
method: 'POST'
},
userList: {
url: '/account/users/list',
name: '用户列表',
method: 'POST'
},
addUser: {
url: '/account/users/save',
name: '新增用户',
method: 'POST'
},
addUserRole: {
url: '/account/users/addRole',
name: '用户新增角色',
method: 'POST'
},
editUser: {
url: '/account/users/upd',
name: '编辑用户',
method: 'PUT'
},
userDetail: {
url: '/account/users/{id}',
name: '用户详情',
method: 'GET'
},
enableUser: {
url: '/account/users/del/{id}',
name: '启用禁用,删除',
method: 'DELETE'
},
quitRole: {
url: '/account/users/delRole/{id}',
name: '用户退出角色',
method: 'DELETE'
},
updUserPwd: {
url: '/account/users/updPassword',
name: '修改用户密码',
method: 'PUT'
}
}

@ -1,16 +0,0 @@
<template>
<list v-if="$route.name === 'userIndex'"></list>
<router-view v-else></router-view>
</template>
<script>
import list from "./web/list";
export default {
name: "userIndex",
components: {
list
}
};
</script>
<style></style>

@ -1,27 +0,0 @@
export default [{
path: 'user',
name: 'userIndex',
meta: {
name: '用户管理',
icon: 'lock',
unfold: false,
sort: 1
},
component: () => import('@/views/user/index'),
children: [{
path: 'detail',
name: 'userDetailIndex',
meta: {
name: '用户详情',
},
component: () => import('@/views/user/web/web/index'),
children: [{
path: 'edit',
name: 'editUserPwd',
meta: {
name: '修改密码',
},
component: () => import('@/views/user/web/web/editPwd'),
}]
}]
}]

@ -1,353 +0,0 @@
<template>
<content-view>
<div class="userList">
<reset-search ref="form" :form.sync="searchObj">
<table class="table-form">
<tr>
<td width="47">姓名</td>
<td>
<a-input placeholder="请输入姓名" v-model="searchObj.name"></a-input>
</td>
<td width="60">手机号</td>
<td>
<a-input placeholder="请输入手机号" v-model="searchObj.account"></a-input>
</td>
<td width="47">角色</td>
<td>
<a-select mode="multiple" placeholder="请选择角色" v-model="searchObj.role">
<a-select-option
v-for="(item, index) in roleList"
:key="index"
:value="item.id"
>{{item.roleName}}</a-select-option>
</a-select>
</td>
</tr>
<tr>
<td width="47">状态</td>
<td>
<a-select placeholder="请选择状态" v-model="searchObj.state">
<a-select-option :value="0">启用</a-select-option>
<a-select-option :value="1">停用</a-select-option>
</a-select>
</td>
<td colspan="2">
<a-button type="primary" class="mr8" @click="query"></a-button>
<a-button @click="reset"></a-button>
</td>
</tr>
</table>
</reset-search>
<p class="mt24 mb16">
<a-button type="primary" @click="add" :disabled="addAuth">
<a-icon type="plus"></a-icon>
<span>新增</span>
</a-button>
</p>
<!-- modal -->
<a-modal
v-model="visible"
title="新增用户"
@ok="modalOk"
@cancel="modalCancel"
cancelText="取消"
okText="确定"
>
<a-form :form="formModal" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
<a-form-item label="姓名">
<a-input
autocomplete="off"
placeholder="请输入姓名"
v-decorator="['name', { rules: [{ required: true, min:2, max: 10, message: '请输入姓名' }] }]"
></a-input>
</a-form-item>
<a-form-item label="手机号">
<a-input
autocomplete="off"
placeholder="请输入手机号"
v-decorator="['account', { rules: [{ required: true, pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号' }] }]"
></a-input>
</a-form-item>
<a-form-item label="所属角色">
<a-select
style="width: 100%;"
mode="multiple"
placeholder="请选择角色"
v-decorator="['roleIds', { rules: [{ required: true, message: '请选择角色' }] }]"
>
<a-select-option
v-for="(item, index) in roleList"
:key="index"
:value="item.id"
>{{item.roleName}}</a-select-option>
</a-select>
</a-form-item>
</a-form>
</a-modal>
<!-- table -->
<a-table
:rowKey="record => record.id"
:columns="columns"
:dataSource="dataSource"
:pagination="pagination"
@change="paginationChange"
>
<div
class="state flex flex-start flex-align-center"
slot="state"
slot-scope="text, record"
>
<div
class="state-circle mr8"
:style="{
'width': '8px',
'height': '8px',
'border-radius': '50%',
'background-color': record.state === 0 ? 'rgba(0,168,84,1)' : 'rgba(240,65,52,1)'
}"
></div>
<span>{{record.state === 0 ? '启用' : '停用'}}</span>
</div>
<a-tooltip slot="roleName" slot-scope="text, record">
<template
slot="title"
v-if="record.roleName && record.roleName.length > 15"
>{{record.roleName}}</template>
{{record.roleName ? (record.roleName.length > 15 ? record.roleName.subString(0, 15) + '...' : record.roleName) : '-'}}
</a-tooltip>
<template slot="action" slot-scope="text, record">
<a
:disabled="detailAuth"
href="javascript:;"
class="mr8"
@click="$router.push({name: 'userDetailIndex', query: {id: record.id}})"
>用户详情</a>
<a
:disabled="enableAuth"
href="javascript:;"
class="mr8"
@click="enable(record)"
>{{record.state === 0 ? '停用' : '启用'}}</a>
<a-popconfirm
class="mr8"
title="确认是否删除该用户"
ok-text="确定"
cancel-text="取消"
@confirm="deleteConfirm(record)"
@cancel="deleteCancel(record)"
>
<a-icon slot="icon" type="close-circle" style="color: red" />
<a href="#" :disabled="removeAuth">删除</a>
</a-popconfirm>
</template>
</a-table>
</div>
</content-view>
</template>
<script>
import mixins from "@/plugins/mixins";
export default {
name: "userList",
mixins: [mixins],
data() {
return {
searchObj: {
name: "",
account: "",
role: [],
state: undefined
},
roleList: [],
// add
visible: false,
formModal: this.$form.createForm(this),
// table
columns: [
{
title: "序号",
customRender: (text, record, index) => {
return (
(this.pagination.current - 1) *
this.pagination.pageSize +
(index + 1)
);
}
},
{
title: "姓名",
dataIndex: "name"
},
{
title: "手机号",
dataIndex: "account"
},
{
title: "所属角色",
dataIndex: "roleName",
scopedSlots: {
customRender: "roleName"
}
},
{
title: "状态",
dataIndex: "state",
scopedSlots: {
customRender: "state"
}
},
{
title: "操作",
dataIndex: "action",
scopedSlots: {
customRender: "action"
}
}
],
dataSource: []
};
},
computed: {
//
addAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "addUser"
)
? false
: true;
},
detailAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "userDetailIndex"
)
? false
: true;
},
enableAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "enableUser"
)
? false
: true;
},
removeAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "removeUser"
)
? false
: true;
}
},
methods: {
//
getList() {
this.$api.userApi
.userList({
data: {
pageNum: this.pagination.current,
pageSize: this.pagination.pageSize,
roleId: this.searchObj.role,
name: this.searchObj.name,
account: this.searchObj.account
}
})
.then(res => {
res.data.list.map(item => {
item.roleName = "";
if (item.roles && item.roles.length) {
item.roles.map((v, i) => {
item.roleName += v.roleName;
if (i !== item.roles.length - 1)
item.roleName += ",";
});
}
});
this.dataSource = res.data.list;
this.pagination.total = res.data.total;
});
},
//
getRoleList() {
this.$api.roleApi.roleAll().then(res => {
this.roleList = res.data;
});
},
//
add() {
this.visible = true;
},
modalOk() {
this.formModal.validateFields((err, values) => {
console.log(err, values);
if (!err) {
this.$api.userApi
.addUser({
data: values
})
.then(res => {
console.log(res);
this.$message.success("新增成功");
this.modalCancel();
this.reset();
});
}
});
},
modalCancel() {
this.formModal.resetFields();
this.visible = false;
},
//
deleteConfirm(record) {
console.log(record);
this.$api.userApi
.enableUser({
path: {
id: record.id
},
params: {
state: 2
}
})
.then(res => {
console.log(res);
this.$message.success("操作成功");
this.reset();
});
},
deleteCancel(record) {
console.log(record);
},
//
enable(record) {
console.log(record);
this.$api.userApi
.enableUser({
path: {
id: record.id
},
params: {
state: record.state === 0 ? 1 : 0
}
})
.then(res => {
console.log(res);
this.query();
this.$message.success("操作成功");
});
}
},
mounted() {
this.getList();
this.getRoleList();
}
};
</script>
<style lang="scss"></style>

@ -1,371 +0,0 @@
<template>
<content-view>
<div class="userDetail">
<!-- 1 -->
<div class="userDetail-current">
<p class="userDetail-title">基本信息</p>
<div class="userDetail-current-desc">
<div class="userDetail-current-desc-left">
<div class="flex flex-start">
<span style="display: inline-block;width: 46px;">姓名</span>
<a-input
style="width: 50%;"
v-if="isEdit"
placeholder="请输入姓名"
v-model="tempInfo.name"
></a-input>
<span v-else>{{detail.name}}</span>
</div>
<div class="flex flex-start">
<span style="display: inline-block;width: 60px;">手机号</span>
<a-input
style="width: 50%;"
v-if="isEdit"
placeholder="请输入手机号"
v-model="tempInfo.account"
></a-input>
<span v-else>{{detail.account}}</span>
</div>
<div class="status flex">
<span style="display: inline-block;width: 48px;">状态</span>
<div :class="{'status-circle': true, 'status-red': detail.state !== 0}"></div>
<span>{{detail.state === 0 ? '启用' : '停用'}}</span>
</div>
</div>
<div class="userDetail-current-desc-right">
<template v-if="isEdit">
<a-button type="primary" class="mr8" @click="sureEdit"></a-button>
<a-button @click="cancelEdit"></a-button>
</template>
<template v-else>
<a-button
type="primary"
class="mr8"
@click="showEdit"
:disabled="editAuth"
>编辑</a-button>
<a-button @click="go('editUserPwd')" :disabled="pwdAuth">修改密码</a-button>
</template>
</div>
</div>
</div>
<!-- 2 -->
<div class="userDetail-list">
<div class="userDetail-list-top flex flex-space-between flex-align-center">
<span class="userDetail-title">所属角色列表</span>
<a-button type="primary" @click="showModal" :disabled="bindRoleAuth">
<a-icon type="plus"></a-icon>
<span>新增</span>
</a-button>
</div>
<a-table
:columns="columns"
:dataSource="detail.roles"
:rowKey="record => record.id"
>
<template slot="action" slot-scope="text, record">
<a
href="javascript:;"
class="mr8"
@click="go('roleDetailIndex', record)"
:disabled="roleDetailAuth"
>角色详情</a>
<a-popconfirm
class="mr8"
title="确认是否退出该角色"
ok-text="确定"
cancel-text="取消"
@confirm="quit(record)"
@cancel="deleteCancel(record)"
>
<a-icon slot="icon" type="close-circle" style="color: red" />
<a href="javascript:;" :disabled="unbindRoleAuth">退出</a>
</a-popconfirm>
</template>
</a-table>
</div>
<!-- 3 -->
<a-modal
title="新增用户所属角色"
v-model="visible"
@ok="modalOk"
@cancel="modalCancel"
cancelText="取消"
okText="确定"
>
<a-form :form="formModal" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
<a-form-item label="所属角色">
<a-select
style="width: 100%;"
mode="multiple"
placeholder="请选择角色"
v-decorator="['roleIds', { rules: [{ required: true, message: '请选择角色' }] }]"
>
<a-select-option
v-for="(item, index) in roleList"
:key="index"
:value="item.id"
>{{item.roleName}}</a-select-option>
</a-select>
</a-form-item>
</a-form>
</a-modal>
</div>
</content-view>
</template>
<script>
export default {
name: "userDetail",
data() {
return {
detail: {},
// isEdit
isEdit: false,
//
tempInfo: {},
//
roleList: [],
columns: [
{
title: "序号",
customRender: (text, record, index) => {
return index + 1;
}
},
{
title: "角色",
dataIndex: "roleName"
},
{
title: "操作",
dataIndex: "action",
scopedSlots: {
customRender: "action"
}
}
],
visible: false,
formModal: this.$form.createForm(this)
};
},
computed: {
editAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "editUser"
)
? false
: true;
},
pwdAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "editUserPwd"
) &&
(
JSON.parse(sessionStorage.getItem("userInfo")).roleIds || []
).some(item => item === 1) //
? false
: true;
},
bindRoleAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "bindRole"
)
? false
: true;
},
unbindRoleAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "unbindRole"
)
? false
: true;
},
roleDetailAuth() {
return this.$store.state.userInfo.permissionList.some(
item => item.rights === "roleDetailIndex"
)
? false
: true;
}
},
methods: {
//
getDetail() {
this.$api.userApi
.userDetail({
path: {
id: this.$route.query.id
}
})
.then(res => {
this.detail = res.data;
});
},
//
getRoleList() {
this.$api.roleApi.roleAll().then(res => {
this.roleList = res.data;
});
},
//
go(name, record) {
if (name === "editUserPwd") {
sessionStorage.setItem(
"userDetail",
JSON.stringify(this.detail)
);
if (
this.detail.id ===
JSON.parse(sessionStorage.getItem("userInfo")).id
) {
this.$router.push({ name: "centerPwd" });
return;
}
}
let obj = {
name: name,
query: record ? { id: record.roleId } : null
};
this.$router.push(obj);
},
//
quit(record) {
console.log(record);
this.$api.userApi
.quitRole({
path: {
id: record.id
}
})
.then(res => {
console.log(res);
this.detail.roles.map((item, index) => {
if (item.id === record.id) {
this.detail.roles.splice(index, 1);
this.$message.success("操作成功");
}
});
});
},
//
showEdit() {
this.tempInfo = JSON.parse(JSON.stringify(this.detail));
this.isEdit = !this.isEdit;
},
sureEdit() {
this.$api.userApi
.editUser({
data: {
id: this.$route.query.id,
account: this.tempInfo.account,
name: this.tempInfo.name
}
})
.then(res => {
this.detail.name = res.data.name;
this.detail.account = res.data.account;
//
if (this.detail.id === this.userInfo.id) {
this.setState({ userInfo: this.detail });
}
this.$message.success("操作成功");
this.cancelEdit();
});
},
cancelEdit() {
this.isEdit = false;
},
//
showModal() {
this.visible = true;
},
modalOk() {
this.formModal.validateFields((err, values) => {
console.log(err, values);
if (!err) {
this.$api.userApi
.addUserRole({
data: {
userId: this.$route.query.id,
...values
}
})
.then(res => {
console.log(res);
this.getDetail();
this.$message.success("操作成功");
this.modalCancel();
});
}
});
},
modalCancel() {
this.formModal.resetFields();
this.visible = false;
}
},
mounted() {
this.getDetail();
this.getRoleList();
}
};
</script>
<style lang='scss'>
.userDetail {
&-title {
font-size: 16px;
font-family: PingFangSC, PingFangSC-Medium;
font-weight: 500;
text-align: left;
color: rgba(0, 0, 0, 0.85);
}
&-current {
display: flex;
flex-direction: column;
padding-bottom: 27px;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
margin-bottom: 30px;
&-desc {
display: flex;
align-items: center;
justify-content: space-between;
&-left {
display: flex;
align-items: center;
flex: 1;
> div {
width: 33%;
}
.status {
display: flex;
align-items: center;
&-circle {
width: 8px;
height: 8px;
border-radius: 50%;
background-color: rgba(0, 168, 84, 1);
margin-right: 4px;
}
&-red {
background-color: rgba(240, 65, 52, 1);
}
}
}
&-right {
width: 20%;
display: flex;
justify-content: flex-end;
}
}
}
&-list {
&-top {
margin-bottom: 8px;
}
}
}
</style>

@ -1,131 +0,0 @@
<template>
<content-view>
<div class="userPwd">
<div class="userPwd-current">
<p class="userPwd-title">用户信息</p>
<div class="userPwd-current-desc">
<span>姓名{{detail.name}}</span>
<span>手机号{{detail.account}}</span>
<div class="status">
<span>状态</span>
<div :class="{'status-circle': true, 'status-red': detail.state !== 0}"></div>
<span>{{detail.state === 0 ? '启用' : '停用'}}</span>
</div>
</div>
</div>
<div class="userPwd-pwd pb24">
<a-form :form="form" :label-col="{ span: 8 }" :wrapper-col="{ span: 7 }">
<a-form-item label="新密码">
<a-input
autocomplete="off"
placeholder="请输入新密码"
v-decorator="['password', { rules: [{ required: true, pattern: /(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{6,16}$/, message: '6-16个字符包含数字、字母或符号组成至少两种' }] }]"
></a-input>
</a-form-item>
<a-form-item label="确认密码">
<a-input
autocomplete="off"
placeholder="请输入确认密码"
v-decorator="['againPwd', { rules: [{ required: true, validator: validatorPwd }] }]"
></a-input>
</a-form-item>
</a-form>
<a-row class="mt24">
<a-col span="22" align="center">
<a-button type="primary" class="mr8" @click="sure"></a-button>
<a-button @click="cancel"></a-button>
</a-col>
</a-row>
</div>
</div>
</content-view>
</template>
<script>
export default {
name: "editUserPwd",
data() {
return {
detail: {},
form: this.$form.createForm(this)
};
},
methods: {
sure() {
if (
!this.form.getFieldValue("password") ||
!this.form.getFieldValue("againPwd")
) {
this.$message.info("请输入密码");
return;
}
this.$api.userApi
.updUserPwd({
data: {
userId: this.detail.id,
password: this.form.getFieldValue("password")
}
})
.then(res => {
console.log(res);
this.cancel();
});
},
cancel() {
sessionStorage.removeItem("userDetail");
this.$router.go(-1);
},
validatorPwd(rule, value, callback) {
if (this.form.getFieldValue("password") === value) {
callback();
} else {
callback("两次密码输入不一致");
}
}
},
created() {
this.detail = sessionStorage.getItem("userDetail")
? JSON.parse(sessionStorage.getItem("userDetail"))
: {};
}
};
</script>
<style lang='scss'>
.userPwd {
&-title {
font-size: 16px;
font-family: PingFangSC, PingFangSC-Medium;
font-weight: 500;
text-align: left;
color: rgba(0, 0, 0, 0.85);
}
&-current {
display: flex;
flex-direction: column;
padding-bottom: 27px;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
margin-bottom: 30px;
&-desc {
width: 70%;
display: flex;
align-items: center;
justify-content: space-between;
.status {
display: flex;
align-items: center;
&-circle {
width: 8px;
height: 8px;
border-radius: 50%;
background-color: rgba(0, 168, 84, 1);
margin-right: 4px;
}
&-red {
background-color: rgba(240, 65, 52, 1);
}
}
}
}
}
</style>

@ -1,16 +0,0 @@
<template>
<detail v-if="$route.name === 'userDetailIndex'"></detail>
<router-view v-else></router-view>
</template>
<script>
import detail from "./detail";
export default {
name: "userDetailIndex",
components: {
detail
}
};
</script>
<style></style>
Loading…
Cancel
Save