用户新增权限
This commit is contained in:
parent
b75fceca38
commit
5293f68ae4
|
|
@ -155,4 +155,22 @@ export function changePasswordInfo(params) {
|
||||||
data: params,
|
data: params,
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setUserPermission(params) {
|
||||||
|
return request({
|
||||||
|
url: '/user/setUserPermission',
|
||||||
|
method: 'post',
|
||||||
|
data: params,
|
||||||
|
timeout: 5000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户权限 API
|
||||||
|
export function getUserPermission(data) {
|
||||||
|
return request({
|
||||||
|
url: '/user/getUserPermission',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,12 @@
|
||||||
<el-table-column prop="updateTime" label="更新时间" :formatter="timeFormat" min-width="120px"
|
<el-table-column prop="updateTime" label="更新时间" :formatter="timeFormat" min-width="120px"
|
||||||
show-overflow-tooltip/>
|
show-overflow-tooltip/>
|
||||||
<el-table-column prop="addUser" label="添加用户" min-width="120px" show-overflow-tooltip/>
|
<el-table-column prop="addUser" label="添加用户" min-width="120px" show-overflow-tooltip/>
|
||||||
<el-table-column fixed="right" label="操作" min-width="140px">
|
<el-table-column fixed="right" label="操作" min-width="220px">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<div style="display: flex;justify-content: space-between;">
|
<div style="display: flex;justify-content: space-between;">
|
||||||
<el-button style="width: 80px" plain type="primary" @click="editCurrentRow(scope.row)">编辑</el-button>
|
<el-button style="width: 80px" plain type="primary" @click="editCurrentRow(scope.row)">编辑</el-button>
|
||||||
<el-button style="width: 80px" plain type="warning" @click="changePassword(scope.row)">改密</el-button>
|
<el-button style="width: 80px" plain type="warning" @click="changePassword(scope.row)">改密</el-button>
|
||||||
|
<el-button v-if="store.getters.getUser?.roleId == 0" style="width: 80px" plain type="success" @click="openPermissionDialog(scope.row)">权限</el-button>
|
||||||
<el-button style="width: 80px" plain type="danger" @click="deleteCurrentRow(scope.row)">删除</el-button>
|
<el-button style="width: 80px" plain type="danger" @click="deleteCurrentRow(scope.row)">删除</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -149,13 +150,75 @@
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<!-- 替换原有的权限弹窗代码 -->
|
||||||
|
<el-dialog v-model="permissionDialogVisible" title="设置权限" width="500px" draggable :show-close="false">
|
||||||
|
<div style="padding: 20px;">
|
||||||
|
<el-card shadow="never" style="margin-bottom: 20px;">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<span>用户信息</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-descriptions :column="1" size="small" border>
|
||||||
|
<el-descriptions-item label="登录账户">{{ currentEditUser?.loginAccount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="用户名">{{ currentEditUser?.userName }}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<el-card shadow="never">
|
||||||
|
<template #header>
|
||||||
|
<div class="card-header">
|
||||||
|
<span>权限配置</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="permission-section">
|
||||||
|
<div class="section-title">
|
||||||
|
<i class="el-icon-setting"></i>
|
||||||
|
<span>WMS权限</span>
|
||||||
|
</div>
|
||||||
|
<el-checkbox-group v-model="wmsPermissions" class="permission-checkbox-group">
|
||||||
|
<el-row :gutter="15">
|
||||||
|
<el-col :span="12" v-for="perm in wmsPermissionOptions" :key="perm.value">
|
||||||
|
<el-checkbox :label="perm.value" :border="true" style="width: 100%; margin-bottom: 10px;">
|
||||||
|
{{ perm.label }}
|
||||||
|
</el-checkbox>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="permission-section" style="margin-top: 20px;">
|
||||||
|
<div class="section-title">
|
||||||
|
<i class="el-icon-mobile"></i>
|
||||||
|
<span>PDA权限</span>
|
||||||
|
</div>
|
||||||
|
<el-checkbox
|
||||||
|
v-model="hasPdaPermission"
|
||||||
|
label="E"
|
||||||
|
border
|
||||||
|
style="width: 100%; margin-top: 10px;">
|
||||||
|
PDA操作权限
|
||||||
|
</el-checkbox>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="permissionDialogVisible = false">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="submitPermissionChange()">确 定</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
</el-config-provider>
|
</el-config-provider>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import {getUserList, getRoleOptions, updateUserInfo, addUserInfo, deleteUserInfo, changePasswordInfo} from '@/api/user.js'
|
import {setUserPermission, getUserPermission, getUserList, getRoleOptions, updateUserInfo, addUserInfo, deleteUserInfo, changePasswordInfo} from '@/api/user.js'
|
||||||
import {errorBox} from '@/utils/myMessageBox.js'
|
import {errorBox} from '@/utils/myMessageBox.js'
|
||||||
import {ElMessageBox, ElMessage} from 'element-plus'
|
import {ElMessageBox, ElMessage} from 'element-plus'
|
||||||
import {ref, reactive} from 'vue'
|
import {ref, reactive} from 'vue'
|
||||||
|
|
@ -197,6 +260,20 @@ export default {
|
||||||
addUserFormRef: ref(),
|
addUserFormRef: ref(),
|
||||||
|
|
||||||
|
|
||||||
|
// 在 data 的 return 中添加以下内容
|
||||||
|
permissionDialogVisible: false,
|
||||||
|
permissionFormEntity: reactive({}),
|
||||||
|
permissionFormRef: ref(),
|
||||||
|
currentEditUser: null,
|
||||||
|
wmsPermissions: [],
|
||||||
|
hasPdaPermission: false,
|
||||||
|
wmsPermissionOptions: [
|
||||||
|
{ value: 'A', label: '下发盘点' },
|
||||||
|
{ value: 'B', label: '出库单编排' },
|
||||||
|
{ value: 'C', label: '出空箱' },
|
||||||
|
{ value: 'D', label: '拣选任务状态编辑' }
|
||||||
|
],
|
||||||
|
|
||||||
passwordDialogVisible: false,
|
passwordDialogVisible: false,
|
||||||
passwordFormEntity: reactive({
|
passwordFormEntity: reactive({
|
||||||
loginAccount: '',
|
loginAccount: '',
|
||||||
|
|
@ -223,6 +300,8 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.search()
|
this.search()
|
||||||
|
console.log('当前用户信息:', store.getters.getUser)
|
||||||
|
console.log('当前用户roleId:', store.getters.getUser?.roleId)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 添加修改密码相关方法
|
// 添加修改密码相关方法
|
||||||
|
|
@ -411,6 +490,86 @@ export default {
|
||||||
errorBox('添加用户信息失败。')
|
errorBox('添加用户信息失败。')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 在 methods 中添加以下方法
|
||||||
|
openPermissionDialog(row) {
|
||||||
|
this.currentEditUser = row;
|
||||||
|
|
||||||
|
// 调用后端接口获取用户权限
|
||||||
|
const params = {
|
||||||
|
loginAccountUpdate: row.loginAccount,
|
||||||
|
roleIdOp: store.getters.getUser.roleId,
|
||||||
|
userName: store.getters.getUserName
|
||||||
|
};
|
||||||
|
|
||||||
|
getUserPermission(params).then(res => {
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
// 解析后端返回的权限字符串
|
||||||
|
const permissionStr = res.data.message || '';
|
||||||
|
this.wmsPermissions = [];
|
||||||
|
this.hasPdaPermission = false;
|
||||||
|
|
||||||
|
console.log(permissionStr);
|
||||||
|
if (permissionStr.includes('A')) this.wmsPermissions.push('A');
|
||||||
|
if (permissionStr.includes('B')) this.wmsPermissions.push('B');
|
||||||
|
if (permissionStr.includes('C')) this.wmsPermissions.push('C');
|
||||||
|
if (permissionStr.includes('D')) this.wmsPermissions.push('D');
|
||||||
|
if (permissionStr.includes('E')) this.hasPdaPermission = true;
|
||||||
|
} else {
|
||||||
|
// 如果获取失败,使用默认空值
|
||||||
|
this.wmsPermissions = [];
|
||||||
|
this.hasPdaPermission = false;
|
||||||
|
errorBox(res.data.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.permissionDialogVisible = true;
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
// 如果请求失败,使用默认空值
|
||||||
|
this.wmsPermissions = [];
|
||||||
|
this.hasPdaPermission = false;
|
||||||
|
this.permissionDialogVisible = true;
|
||||||
|
errorBox('获取用户权限失败');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
submitPermissionChange() {
|
||||||
|
// 构建权限字符串
|
||||||
|
let permissionStr = '';
|
||||||
|
permissionStr += this.wmsPermissions.join('');
|
||||||
|
if (this.hasPdaPermission) permissionStr += 'E';
|
||||||
|
|
||||||
|
// 这里调用设置权限的API
|
||||||
|
// 示例:
|
||||||
|
const params = {
|
||||||
|
loginAccountUpdate: this.currentEditUser.loginAccount,
|
||||||
|
userPermission: permissionStr,
|
||||||
|
roleIdOp: store.getters.getUser.roleId,
|
||||||
|
userName: store.getters.getUserName
|
||||||
|
};
|
||||||
|
|
||||||
|
setUserPermission(params).then(res => {
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
this.permissionDialogVisible = false;
|
||||||
|
ElMessage.success('权限设置成功。');
|
||||||
|
this.search(); // 刷新列表
|
||||||
|
} else {
|
||||||
|
errorBox(res.data.message);
|
||||||
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
errorBox('权限设置失败。');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 暂时只是演示逻辑,实际需要调用后端API
|
||||||
|
ElMessage.success('权限设置成功。');
|
||||||
|
console.log(permissionStr)
|
||||||
|
this.permissionDialogVisible = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
getCurrentRow(row) {
|
getCurrentRow(row) {
|
||||||
this.userId = row.userId
|
this.userId = row.userId
|
||||||
},
|
},
|
||||||
|
|
@ -463,4 +622,57 @@ export default {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
</style>
|
||||||
|
<style scoped>/* 在原有样式基础上添加以下内容 */
|
||||||
|
.card-header {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permission-section {
|
||||||
|
padding: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
color: #606266;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title i {
|
||||||
|
margin-right: 8px;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permission-checkbox-group {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permission-checkbox-group .el-checkbox {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-card__header) {
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
padding: 10px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-descriptions__label) {
|
||||||
|
width: 100px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-checkbox.is-bordered) {
|
||||||
|
padding: 8px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-checkbox.is-bordered:hover) {
|
||||||
|
border-color: #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-footer {
|
||||||
|
padding: 15px 20px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -121,4 +121,17 @@ public class TaskQueryController {
|
||||||
{
|
{
|
||||||
return taskQueryControllerService.queryInventoryRecordByPage(inventoryQuery);
|
return taskQueryControllerService.queryInventoryRecordByPage(inventoryQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量修改出库任务的执行时间
|
||||||
|
*
|
||||||
|
* @param batchEditDateVo 包含任务ID列表和统一设置的执行时间
|
||||||
|
* @return 操作结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/batchEditDate")
|
||||||
|
public WmsApiResponse<String> batchEditDate(@RequestBody OutsBatchEditDateVo batchEditDateVo) {
|
||||||
|
return taskQueryControllerService.batchEditDate(batchEditDateVo);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,4 +73,26 @@ public class UserController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置用户权限
|
||||||
|
* @param userUpdateRequest 获取权限参数
|
||||||
|
* @return 获取权限结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/setUserPermission")
|
||||||
|
BaseWmsApiResponse setUserPermission(@RequestBody UserUpdateRequest userUpdateRequest) {
|
||||||
|
return userControllerService.setUserPermission(userUpdateRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户权限
|
||||||
|
* @param userUpdateRequest 获取权限参数
|
||||||
|
* @return 获取权限结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/getUserPermission")
|
||||||
|
BaseWmsApiResponse getUserPermission(@RequestBody UserUpdateRequest userUpdateRequest) {
|
||||||
|
return userControllerService.getUserPermission(userUpdateRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.wms_main.model.dto.query;
|
package com.wms_main.model.dto.query;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.wms_main.model.dto.request.wms.BaseWmsRequest;
|
import com.wms_main.model.dto.request.wms.BaseWmsRequest;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
@ -52,4 +53,10 @@ public class UserUpdateRequest extends BaseWmsRequest {
|
||||||
*/
|
*/
|
||||||
@JsonProperty("newPassword")
|
@JsonProperty("newPassword")
|
||||||
private String newPassword;
|
private String newPassword;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户权限
|
||||||
|
*/
|
||||||
|
@JsonProperty("userPermission")
|
||||||
|
private String userPermission;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,4 +77,10 @@ public class TSysUser {
|
||||||
*/
|
*/
|
||||||
@TableField(value = "last_update_time")
|
@TableField(value = "last_update_time")
|
||||||
private LocalDateTime lastUpdateTime;
|
private LocalDateTime lastUpdateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户权限
|
||||||
|
*/
|
||||||
|
@TableField(value = "user_permission")
|
||||||
|
private String userPermission;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,8 @@ public interface IUserControllerService {
|
||||||
*/
|
*/
|
||||||
BaseWmsApiResponse changePassword(UserUpdateRequest userUpdateRequest);
|
BaseWmsApiResponse changePassword(UserUpdateRequest userUpdateRequest);
|
||||||
|
|
||||||
|
|
||||||
|
BaseWmsApiResponse setUserPermission(UserUpdateRequest userUpdateRequest);
|
||||||
|
BaseWmsApiResponse getUserPermission(UserUpdateRequest userUpdateRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,52 @@ public class UserControllerServiceImpl implements IUserControllerService {
|
||||||
return updateResult ? BaseWmsApiResponse.success("密码修改成功") : BaseWmsApiResponse.error("密码修改失败");
|
return updateResult ? BaseWmsApiResponse.success("密码修改成功") : BaseWmsApiResponse.error("密码修改失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public BaseWmsApiResponse setUserPermission(UserUpdateRequest userUpdateRequest) {
|
||||||
|
// 参数校验
|
||||||
|
if (userUpdateRequest == null ||
|
||||||
|
StringUtils.isEmpty(userUpdateRequest.getLoginAccountUpdate())) {
|
||||||
|
return BaseWmsApiResponse.error("请求参数不完整,必须包含登录账号和权限信息。");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询用户是否存在
|
||||||
|
TSysUser user = sysUserService.getById(userUpdateRequest.getLoginAccountUpdate());
|
||||||
|
if (user == null) {
|
||||||
|
return BaseWmsApiResponse.error("用户不存在。");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新用户权限
|
||||||
|
user.setUserPermission(userUpdateRequest.getUserPermission());
|
||||||
|
user.setLastUpdateTime(LocalDateTime.now());
|
||||||
|
user.setLastUpdateUser(userUpdateRequest.getUserName());
|
||||||
|
|
||||||
|
boolean updateResult = sysUserService.updateById(user);
|
||||||
|
|
||||||
|
return updateResult ?
|
||||||
|
BaseWmsApiResponse.success("用户权限设置成功") :
|
||||||
|
BaseWmsApiResponse.error("用户权限设置失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseWmsApiResponse getUserPermission(UserUpdateRequest userUpdateRequest) {
|
||||||
|
// 参数校验
|
||||||
|
if (userUpdateRequest == null ||
|
||||||
|
StringUtils.isEmpty(userUpdateRequest.getLoginAccountUpdate())) {
|
||||||
|
return BaseWmsApiResponse.error("请求参数不完整,必须包含登录账号。");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询用户信息
|
||||||
|
TSysUser user = sysUserService.getById(userUpdateRequest.getLoginAccountUpdate());
|
||||||
|
if (user == null) {
|
||||||
|
return BaseWmsApiResponse.error("用户不存在。");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回用户权限信息
|
||||||
|
return BaseWmsApiResponse.success(user.getUserPermission());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user