update 优化用户信息及用户查询,实现用户授权角色

This commit is contained in:
2021-04-25 22:14:21 +08:00
parent ce92b15fe8
commit f6258537c2
10 changed files with 160 additions and 9 deletions

View File

@@ -71,7 +71,7 @@ namespace Ewide.Core.Service
/// <summary>
/// 搜索状态(字典 0正常 1停用 2删除
/// </summary>
public CommonStatus SearchStatus { get; set; } = CommonStatus.ENABLE;
public CommonStatus? SearchStatus { get; set; }
}
public class AddUserInput : UserInput

View File

@@ -103,6 +103,13 @@
width: 61.8%;
min-width: 220px;
}
.yo-form--fluid {
.ant-form-item-control-wrapper {
flex: 0 0 100%;
width: 100%;
}
}
.ant-form-explain {
font-size: @font-size-base - 1px;

View File

@@ -142,9 +142,6 @@
height: 18px;
>a {
color: darken(@primary-color, 20%);
}
}
}

View File

@@ -1,3 +1,4 @@
@import '~@/assets/style/app.less';
@primary-color: #007bff;
@font-size-base: 13px;
@border-radius-base: 0;

View File

@@ -160,6 +160,7 @@ api.$queue = function (queue) {
export {
axios,
urls,
api,
STATUS
}

View File

@@ -71,7 +71,7 @@
</Auth>
<Auth auth="sysUser:grantData">
<a-menu-item>
<a @click="onOpen('org-form', record)">授权数据</a>
<a @click="onOpen('org-form', record)">授权额外数据</a>
</a-menu-item>
</Auth>
</a-menu>
@@ -80,7 +80,13 @@
<a-list-item-meta>
<div slot="title">{{ record.nickName || record.name }}</div>
<div slot="description">{{ record.account }}</div>
<a-avatar :size="48" :src="record.avatar" icon="user" shape="square" slot="avatar" />
<a-avatar
:size="48"
:src="`${previewUrl}?id=${record.avatar}`"
icon="user"
shape="square"
slot="avatar"
/>
</a-list-item-meta>
<div class="yo-list-content--h">
<div class="yo-list-content--h--item">
@@ -109,14 +115,20 @@
</container>
<add-form @ok="onReloadData" ref="add-form" />
<edit-form @ok="onReloadData" ref="edit-form" />
<role-form @ok="onReloadData" ref="role-form" />
<org-form @ok="onReloadData" ref="org-form" />
</yo-tree-layout>
</template>
<script>
import { PERVIEW_URL } from '@/util/global';
import YoTreeLayout from '@/components/yoTreeLayout';
import YoList from '@/components/yoList';
import AddForm from './addForm';
import EditForm from './editForm';
import RoleForm from './roleForm';
import OrgForm from './orgForm';
export default {
components: {
@@ -124,6 +136,8 @@ export default {
YoList,
AddForm,
EditForm,
RoleForm,
OrgForm,
},
data() {
@@ -139,6 +153,8 @@ export default {
values: [],
},
],
previewUrl: PERVIEW_URL,
};
},
@@ -231,7 +247,11 @@ export default {
* 从列表页调用窗口的打开方法
*/
onOpen(formName, record) {
try {
this.$refs[formName].onOpen(record, this.query['sysEmpParam.orgId']);
} catch {
console.warn('component open method not found');
}
},
onSetUserStatus(record, checked) {

View File

@@ -0,0 +1,3 @@
<template>
<div></div>
</template>

View File

@@ -0,0 +1,111 @@
<template>
<a-modal
:confirmLoading="confirmLoading"
:visible="visible"
@cancel="onCancel"
@ok="onOk"
class="yo-modal-form"
title="授权角色"
>
<a-form-model class="yo-form" ref="form">
<a-spin :spinning="loading">
<a-icon slot="indicator" spin type="loading" />
<div class="yo-form-group">
<a-form-model-item class="yo-form--fluid">
<a-select mode="multiple" placeholder="请选择角色" v-model="roles">
<a-select-option
:key="role.id"
:value="role.id"
v-for="role in roleList"
>{{ role.name }}</a-select-option>
</a-select>
</a-form-model-item>
</div>
</a-spin>
</a-form-model>
</a-modal>
</template>
<script>
export default {
data() {
return {
visible: false,
confirmLoading: false,
loading: false,
id: '',
roles: [],
roleList: [],
};
},
methods: {
/**
* 必要的方法
* 从外部调用打开本窗口
*/
async onOpen(record) {
this.visible = true;
this.id = record.id;
this.$nextTick(() => {
this.onInit();
});
},
/**
* 必要的方法
* 点击保存时的操作
*/
onOk() {
this.confirmLoading = true;
this.$api
/** !!此处必须修改调用的接口方法 */
.sysUserGrantRole({
id: this.id,
grantRoleIdList: this.roles,
})
.then(({ success }) => {
if (success) {
this.$message.success('授权成功');
this.onCancel();
this.$emit('ok');
}
})
.finally(() => {
this.confirmLoading = false;
});
},
/**
* 必要的方法
* 关闭窗口时的操作
*/
onCancel() {
this.visible = false;
setTimeout(() => {
this.roles = [];
}, 300);
},
async onInit() {
this.loading = true;
this.roleList = await this.onLoadRoleList();
this.roles = await this.onLoadRole();
this.loading = false;
},
onLoadRoleList() {
return this.$api.getRolePage().then(({ data }) => {
return data.rows;
});
},
onLoadRole() {
return this.$api.sysUserOwnRole({ id: this.id }).then(({ data }) => {
return data;
});
},
},
};
</script>

View File

@@ -1 +1,10 @@
/**
* 空GUID
*/
export const EMPTY_ID = '00000000-0000-0000-0000-000000000000'
/**
* 文件预览地址
*/
import { urls } from '@/common/api'
export const PERVIEW_URL = process.env.VUE_APP_BASE_URL + urls.sysFileInfoPreview[0]

View File

@@ -2,6 +2,8 @@ let userOpenTimer, userCloseTimer
let initDropdownHeight
import { PERVIEW_URL } from '@/util/global';
import { doLogout } from '@/common/login'
export default {
@@ -51,7 +53,7 @@ export default {
<div class="user-container-inner">
<div class="user--base">
<a-avatar
src={this.$root.global.info && this.$root.global.info.avatar}
src={this.$root.global.info && (`${PERVIEW_URL}?id=${this.$root.global.info.avatar}`)}
class="user--avatar"
icon="user"
/>