店铺赋权
This commit is contained in:
parent
5b30555a04
commit
dd936a8e06
@ -24,8 +24,9 @@ export interface RoleVO extends BaseEntity {
|
||||
deptCheckStrictly: boolean;
|
||||
status: string;
|
||||
delFlag: string;
|
||||
tenantId: string;
|
||||
remark?: any;
|
||||
flag: boolean;
|
||||
has: boolean;
|
||||
menuIds?: Array<string | number>;
|
||||
deptIds?: Array<string | number>;
|
||||
admin: boolean;
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { DeptTreeVO, DeptVO } from './../dept/types';
|
||||
import { RoleVO } from '@/api/system/role/types';
|
||||
import request from '@/utils/request';
|
||||
import { UserForm, UserInfoVO, UserQuery, UserVO } from './types';
|
||||
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { UserForm, UserQuery, UserVO, UserInfoVO } from './types';
|
||||
import { RoleVO } from '@/api/system/role/types';
|
||||
import { parseStrEmpty } from '@/utils/ruoyi';
|
||||
import request from '@/utils/request';
|
||||
|
||||
/**
|
||||
* 查询用户列表
|
||||
@ -175,6 +176,28 @@ export const getAuthRole = (userId: string | number): AxiosPromise<{ user: UserV
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 查询授权租户
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
export const gettenantList = (userId: string | number, type: number, data: any): AxiosPromise<{ total: number; records: RoleVO[] }> => {
|
||||
return request({
|
||||
url: '/system/user/tenantList/' + userId + '/' + type,
|
||||
method: 'get',
|
||||
params: data
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 保存授权租户
|
||||
* @param data 用户ID
|
||||
*/
|
||||
export const updateTenant = (data: { userId: string; tenantIds: any }) => {
|
||||
return request({
|
||||
url: '/system/user/tenant',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存授权角色
|
||||
|
@ -20,13 +20,13 @@
|
||||
<el-option v-for="item in tenantList" :key="item.tenantId" :label="item.companyName" :value="item.tenantId"> </el-option>
|
||||
<template #prefix><svg-icon icon-class="company" class="el-input__icon input-icon" /></template>
|
||||
</el-select>
|
||||
<el-button :style="{ margin: '10px' }" @click="isStae = true">设置默认租户</el-button>
|
||||
<!-- <el-button :style="{ margin: '10px' }" @click="isStae = true">设置默认租户</el-button>
|
||||
<el-dialog title="设置默认租户" v-model="isStae" width="500px" append-to-body>
|
||||
<div v-for="item in tenantList" :key="item.tenantId" :style="{ display: 'flex', justifyItems: 'space-between', width: '100%' }">
|
||||
<div class="flex align-center width" v-if="item.companyName">{{ item.companyName }}</div>
|
||||
<el-button :style="{ margin: '10px' }" @click="issteFun(item.tenantId)" v-if="item.companyName">{{ '设置为默认租户' }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-dialog> -->
|
||||
<search-menu ref="searchMenuRef" />
|
||||
<el-tooltip content="搜索" effect="dark" placement="bottom">
|
||||
<div class="right-menu-item hover-effect" @click="openSearchMenu">
|
||||
|
@ -233,6 +233,7 @@ const dataScopeRef = ref<ElFormInstance>();
|
||||
const menuRef = ref<ElTreeInstance>();
|
||||
const deptRef = ref<ElTreeInstance>();
|
||||
|
||||
|
||||
const initForm: RoleForm = {
|
||||
roleId: undefined,
|
||||
roleSort: 1,
|
||||
@ -242,7 +243,7 @@ const initForm: RoleForm = {
|
||||
menuCheckStrictly: true,
|
||||
deptCheckStrictly: true,
|
||||
remark: '',
|
||||
dataScope: '1',
|
||||
dataScope: '5',
|
||||
menuIds: [],
|
||||
deptIds: []
|
||||
};
|
||||
|
@ -1,33 +1,15 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<div class="panel">
|
||||
3333
|
||||
<h4 class="panel-title">基本信息</h4>
|
||||
<el-form :model="form" :inline="true">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="2.5">
|
||||
<el-form-item label="用户昵称" prop="nickName">
|
||||
<el-input v-model="form.nickName" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="2.5">
|
||||
<el-form-item label="登录账号" prop="userName">
|
||||
<el-input v-model="form.userName" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<h4 class="panel-title">店铺信息</h4>
|
||||
<div>
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
row-key="tenantId"
|
||||
@row-click="clickRow"
|
||||
v-loading="loading"
|
||||
border
|
||||
:row-key="getRowKey"
|
||||
:data="roles.slice((pageNum - 1) * pageSize, pageNum * pageSize)"
|
||||
@row-click="clickRow"
|
||||
:data="roles"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column label="序号" width="55" type="index" align="center">
|
||||
@ -35,17 +17,10 @@
|
||||
<span>{{ (pageNum - 1) * pageSize + scope.$index + 1 }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column type="selection" :reserve-selection="true" :selectable="checkSelectable" width="55"></el-table-column>
|
||||
<el-table-column label="角色编号" align="center" prop="roleId" />
|
||||
<el-table-column label="角色名称" align="center" prop="roleName" />
|
||||
<el-table-column label="权限字符" align="center" prop="roleKey" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ proxy.parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column type="selection" :reserve-selection="true" width="55"></el-table-column>
|
||||
<el-table-column label="店铺名称" align="center" prop="tenantName" />
|
||||
</el-table>
|
||||
<pagination v-show="total > 0" v-model:page="pageNum" v-model:limit="pageSize" :total="total" />
|
||||
<pagination v-show="total > 0" v-model:page="params.current" v-model:limit="params.size" :total="total" />
|
||||
<div style="text-align: center; margin-left: -120px; margin-top: 30px">
|
||||
<el-button type="primary" @click="submitForm()">提交</el-button>
|
||||
<el-button @click="close()">返回</el-button>
|
||||
@ -58,10 +33,11 @@
|
||||
|
||||
<script setup name="AuthRole" lang="ts">
|
||||
import { RoleVO } from '@/api/system/role/types';
|
||||
import { getAuthRole, updateAuthRole } from '@/api/system/user';
|
||||
import { gettenantList, updateTenant } from '@/api/system/user';
|
||||
import { UserForm } from '@/api/system/user/types';
|
||||
import { RouteLocationNormalized } from 'vue-router';
|
||||
import { parseTime } from '@/utils/ruoyi';
|
||||
import { currentTaskAllUser } from '@/api/workflow/task';
|
||||
|
||||
const route = useRoute();
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
@ -83,23 +59,27 @@ const tableRef = ref<ElTableInstance>();
|
||||
/** 单击选中行数据 */
|
||||
const clickRow = (row: RoleVO) => {
|
||||
if (checkSelectable(row)) {
|
||||
row.flag = !row.flag;
|
||||
tableRef.value?.toggleRowSelection(row, row.flag);
|
||||
row.has = !row.has;
|
||||
tableRef.value?.toggleRowSelection(row, row.has);
|
||||
}
|
||||
};
|
||||
/** 多选框选中数据 */
|
||||
/** 检查角色状态 */
|
||||
const checkSelectable = (row: RoleVO): boolean => {
|
||||
return row.has;
|
||||
};
|
||||
// const handleSelectionChange = (selection: RoleVO[]) => {
|
||||
// selection.forEach((item: any) => {
|
||||
// roleIds.value.push(item.tenantId);
|
||||
// });
|
||||
// };
|
||||
const handleSelectionChange = (selection: RoleVO[]) => {
|
||||
roleIds.value = selection.map((item) => item.roleId);
|
||||
roleIds.value = selection.map((item) => item.tenantId);
|
||||
};
|
||||
/** 保存选中的数据编号 */
|
||||
const getRowKey = (row: RoleVO): string => {
|
||||
return String(row.roleId);
|
||||
return String(row.tenantId);
|
||||
};
|
||||
/** 检查角色状态 */
|
||||
const checkSelectable = (row: RoleVO): boolean => {
|
||||
return row.status === '0';
|
||||
};
|
||||
/** 关闭按钮 */
|
||||
const close = () => {
|
||||
const obj: RouteLocationNormalized = {
|
||||
fullPath: '',
|
||||
@ -116,24 +96,27 @@ const close = () => {
|
||||
};
|
||||
/** 提交按钮 */
|
||||
const submitForm = async () => {
|
||||
const userId = form.value.userId;
|
||||
const rIds = roleIds.value.join(',');
|
||||
await updateAuthRole({ userId: userId as string, roleIds: rIds });
|
||||
const userId = route.params && route.params.userId;
|
||||
await updateTenant({ userId: userId as string, tenantIds: roleIds.value });
|
||||
proxy?.$modal.msgSuccess('授权成功');
|
||||
close();
|
||||
};
|
||||
|
||||
const params = ref({
|
||||
size: 10,
|
||||
current: 1
|
||||
});
|
||||
const getList = async () => {
|
||||
const userId = route.params && route.params.userId;
|
||||
if (userId) {
|
||||
loading.value = true;
|
||||
const res = await getAuthRole(userId as string);
|
||||
Object.assign(form.value, res.data.user);
|
||||
Object.assign(roles.value, res.data.roles);
|
||||
total.value = roles.value.length;
|
||||
const res = await gettenantList(userId as string, 0, params.value);
|
||||
console.log(res.data);
|
||||
roles.value = res.data.records;
|
||||
total.value = res.data.total;
|
||||
// console.log(roles.value);
|
||||
await nextTick(() => {
|
||||
roles.value.forEach((row) => {
|
||||
if (row?.flag) {
|
||||
if (row?.has) {
|
||||
tableRef.value?.toggleRowSelection(row, true);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user