用户
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="8" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/dictionaries
generated
Normal file
6
.idea/dictionaries
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="mima0000" />
|
||||
</component>
|
||||
</project>
|
||||
37
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
37
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,37 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="TOP_LEVEL_CLASS_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="INNER_CLASS_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="METHOD_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="FIELD_OPTIONS">
|
||||
<value>
|
||||
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||
<option name="REQUIRED_TAGS" value="" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="IGNORE_DEPRECATED" value="false" />
|
||||
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
|
||||
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
|
||||
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
||||
<option name="myAdditionalJavadocTags" value="date" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/nl-sso-server.iml" filepath="$PROJECT_DIR$/.idea/nl-sso-server.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/nl-sso-server.iml
generated
Normal file
9
.idea/nl-sso-server.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.modules.common.base;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -24,9 +25,11 @@ public class BaseDTO implements Serializable {
|
||||
private Long update_optid;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date update_time;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.nl.modules.system.domain;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -37,7 +39,7 @@ public class User extends BaseDTO implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private Long user_id;
|
||||
|
||||
@JsonFormat
|
||||
private String roles;
|
||||
|
||||
private String depts;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.system.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.nl.modules.system.domain.Menu;
|
||||
import org.nl.modules.system.domain.User;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-22
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class RoleVo implements Serializable {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long role_id;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "名称", hidden = true)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "级别,数值越小,级别越大")
|
||||
private Integer level = 3;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String order_seq;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String is_used;
|
||||
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import org.nl.modules.common.utils.RsaUtils;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.modules.system.domain.User;
|
||||
import org.nl.modules.system.service.UserRelateService;
|
||||
import org.nl.modules.system.service.UserService;
|
||||
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -54,7 +55,7 @@ public class UserController {
|
||||
|
||||
@ApiOperation("查询用户")
|
||||
@GetMapping
|
||||
@SaCheckPermission("user:list")
|
||||
// @SaCheckPermission("user:list")
|
||||
public ResponseEntity<Object> query(UserQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
@@ -62,7 +63,7 @@ public class UserController {
|
||||
@Log("新增用户")
|
||||
@ApiOperation("新增用户")
|
||||
@PostMapping
|
||||
@SaCheckPermission("user:add")
|
||||
// @SaCheckPermission("user:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody User resources){
|
||||
checkLevel(resources);
|
||||
// 默认密码 123456
|
||||
@@ -78,7 +79,7 @@ public class UserController {
|
||||
@Log("修改用户")
|
||||
@ApiOperation("修改用户")
|
||||
@PutMapping
|
||||
@SaCheckPermission("user:edit")
|
||||
// @SaCheckPermission("user:edit")
|
||||
public ResponseEntity<Object> update( @RequestBody User resources) throws Exception {
|
||||
checkLevel(resources);
|
||||
userService.update(resources);
|
||||
@@ -87,7 +88,7 @@ public class UserController {
|
||||
|
||||
@Log("修改用户:个人中心")
|
||||
@ApiOperation("修改用户:个人中心")
|
||||
@PutMapping(value = "center")
|
||||
// @PutMapping(value = "center")
|
||||
public ResponseEntity<Object> center(@RequestBody User resources){
|
||||
if(!resources.getUser_id().equals(StpUtil.getLoginIdAsLong())){
|
||||
throw new BadRequestException("不能修改他人资料");
|
||||
@@ -99,7 +100,7 @@ public class UserController {
|
||||
@Log("删除用户")
|
||||
@ApiOperation("删除用户")
|
||||
@DeleteMapping
|
||||
@SaCheckPermission("user:del")
|
||||
// @SaCheckPermission("user:del")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
/* Integer currentLevel = Collections.min(roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.system.service;
|
||||
|
||||
import org.nl.modules.system.domain.User;
|
||||
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-23
|
||||
*/
|
||||
public interface UserRelateService {
|
||||
|
||||
void inserDeptRelate(Long user,Set<Long> deptIds);
|
||||
void inserRoleRelate(Long user,Set<Long> RoleIds);
|
||||
void deleteDeptRelate(Set<Long> deptIds);
|
||||
void deleteRoleRelate(Set<Long> RoleIds);
|
||||
void updateDeptRelate(Long user,Set<Long> deptIds);
|
||||
void updateRoleRelate(Long user,Set<Long> RoleIds);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.nl.modules.system.service.impl;
|
||||
|
||||
import org.nl.modules.system.service.UserRelateService;
|
||||
import org.nl.modules.tools.MapOf;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/2 2:47 下午
|
||||
*/
|
||||
@Service
|
||||
public class UserRelateServiceImpl implements UserRelateService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void inserDeptRelate(Long user, Set<Long> deptIds) {
|
||||
if (user !=null && !CollectionUtils.isEmpty(deptIds)){
|
||||
for (Long deptId : deptIds) {
|
||||
WQLObject.getWQLObject("sys_user_dept").insert(MapOf.of("user_id",user,"dept_id",deptId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void inserRoleRelate(Long user, Set<Long> RoleIds) {
|
||||
if (user !=null && !CollectionUtils.isEmpty(RoleIds)){
|
||||
for (Long roleid : RoleIds) {
|
||||
WQLObject.getWQLObject("sys_users_roles").insert(MapOf.of("user_id",user,"role_id",roleid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDeptRelate(Set<Long> deptIds) {
|
||||
if (!CollectionUtils.isEmpty(deptIds)){
|
||||
String collect = deptIds.stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','"));
|
||||
String sql="dept_id in ('"+collect+"')";
|
||||
WQLObject.getWQLObject("sys_user_dept").delete(sql);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRoleRelate(Set<Long> RoleIds) {
|
||||
if (!CollectionUtils.isEmpty(RoleIds)){
|
||||
String collect = RoleIds.stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','"));
|
||||
String sql="dept_id in ('"+collect+"')";
|
||||
WQLObject.getWQLObject("sys_user_dept").delete(sql);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateDeptRelate(Long user, Set<Long> deptIds) {
|
||||
if (user !=null){
|
||||
this.deleteDeptRelate(deptIds);
|
||||
this.inserDeptRelate(user,deptIds);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateRoleRelate(Long user, Set<Long> RoleIds) {
|
||||
if (user !=null){
|
||||
this.deleteRoleRelate(RoleIds);
|
||||
this.inserRoleRelate(user,RoleIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,11 +34,13 @@ import org.nl.modules.common.utils.dto.CurrentUser;
|
||||
import org.nl.modules.security.service.OnlineUserService;
|
||||
import org.nl.modules.system.domain.User;
|
||||
import org.nl.modules.system.service.DeptService;
|
||||
import org.nl.modules.system.service.UserRelateService;
|
||||
import org.nl.modules.system.service.UserService;
|
||||
|
||||
import org.nl.modules.system.service.dto.UserQueryCriteria;
|
||||
import org.nl.modules.tools.MapOf;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -68,6 +70,8 @@ public class UserServiceImpl implements UserService {
|
||||
private final RedisUtils redisUtils;
|
||||
private final OnlineUserService onlineUserService;
|
||||
private final DeptService deptService;
|
||||
private final UserRelateService userRelateService;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -135,9 +139,25 @@ public class UserServiceImpl implements UserService {
|
||||
throw new EntityExistException(User.class, "username", resources.getUsername());
|
||||
}
|
||||
CurrentUser user = SecurityUtils.getCurrentUser();
|
||||
/* resources.setCreate_id(user.getId());
|
||||
resources.setCreate_name(user.getUsername());*/
|
||||
WQLObject.getWQLObject("sys_user").insert((JSONObject)JSON.toJSON(resources));
|
||||
resources.setCreate_time(new Date());
|
||||
resources.setCreate_id(user.getId());
|
||||
resources.setCreate_name(user.getUsername());
|
||||
ResultBean sys_user = WQLObject.getWQLObject("sys_user").insert(JSONObject.parseObject(JSON.toJSONString(resources)));
|
||||
//更新用户部门表,更新用户角色表
|
||||
String depts = resources.getDepts();
|
||||
String roles = resources.getRoles();
|
||||
JSONObject currentUser = WQLObject.getWQLObject("sys_user").query("username = '" + resources.getUsername() + "'").uniqueResult(0);
|
||||
|
||||
if (StringUtils.isNotEmpty(depts)){
|
||||
String[] split = depts.split(",");
|
||||
Set<Long> collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet());
|
||||
userRelateService.inserDeptRelate(currentUser.getLong("user_id"),collect);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(roles)){
|
||||
String[] split = roles.split(",");
|
||||
Set<Long> collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet());
|
||||
userRelateService.inserRoleRelate(currentUser.getLong("user_id"),collect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,10 +171,25 @@ public class UserServiceImpl implements UserService {
|
||||
onlineUserService.kickOutForUsername(resources.getUsername());
|
||||
}
|
||||
resources.setPassword(SaSecureUtil.md5BySalt(resources.getPassword(), "salt"));
|
||||
resources.setUpdate_time(new Date());
|
||||
resources.setUpdate_optid(user.getId());
|
||||
resources.setUpdate_optname(user.getUsername());
|
||||
WQLObject.getWQLObject("sys_user").update(JSONObject.parseObject(JSON.toJSONString(resources)),"user_id ='"+resources.getUser_id()+"'");
|
||||
// 清除缓存
|
||||
delCaches(user.getUser_id(), user.getUsername());
|
||||
//更新部门用户
|
||||
String depts = resources.getDepts();
|
||||
String roles = resources.getRoles();
|
||||
if (StringUtils.isNotEmpty(depts)){
|
||||
String[] split = depts.split(",");
|
||||
Set<Long> collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet());
|
||||
userRelateService.updateDeptRelate(resources.getUser_id(),collect);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(roles)){
|
||||
String[] split = roles.split(",");
|
||||
Set<Long> collect = Arrays.stream(split).map(a -> Long.valueOf(a)).collect(Collectors.toSet());
|
||||
userRelateService.updateRoleRelate(resources.getUser_id(),collect);
|
||||
}
|
||||
// 如果用户的角色改变
|
||||
if (!resources.getRoles().equals(user.getRoles())) {
|
||||
redisUtils.del(CacheKey.DATA_USER + resources.getUser_id());
|
||||
@@ -186,6 +221,9 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
String collectSql = ids.stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','"));
|
||||
WQLObject.getWQLObject("sys_user").delete("user_id in ('"+collectSql+"'");
|
||||
//删除用户部门,角色关系表
|
||||
userRelateService.deleteDeptRelate(ids);
|
||||
userRelateService.deleteRoleRelate(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -229,7 +229,6 @@ public class Syntax {
|
||||
|
||||
/**
|
||||
* 执行完整指令,包含嵌套
|
||||
* @param list
|
||||
*/
|
||||
private boolean exec(String endCmd){
|
||||
boolean isSuccess = false;
|
||||
|
||||
@@ -8,7 +8,7 @@ export function getDepts(params) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getDeptTreee(params) {
|
||||
export function getDeptTree(params) {
|
||||
return request({
|
||||
url: '/api/dept/allTree',
|
||||
method: 'get',
|
||||
@@ -57,4 +57,4 @@ export function edit(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, getDepts, getDeptSuperior, getDeptvo }
|
||||
export default { add, edit, del, getDepts, getDeptSuperior, getDeptvo, getDeptTree }
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<el-radio label="0">否</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="enabled">
|
||||
<el-form-item label="状态" prop="is_uesd">
|
||||
<el-switch
|
||||
v-model="form.is_used"
|
||||
active-color="#409EFF"
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
</div>
|
||||
<crudOperation show="" :permission="permission" />
|
||||
</div>
|
||||
<!--表单渲染-->
|
||||
<!--新增跟修改表单渲染-->
|
||||
<el-dialog
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@@ -77,12 +77,16 @@
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门" prop="dept.id" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
|
||||
<el-tree-select
|
||||
v-model="form.dept.id"
|
||||
:data="deptDatas"
|
||||
style="width: 200px"
|
||||
placeholder="选择部门"
|
||||
<el-form-item label="部门" prop="depts" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
|
||||
<treeselect
|
||||
v-model="form.depts"
|
||||
:load-options="loadDepts"
|
||||
:options="deptDatas"
|
||||
style="width: 370px;"
|
||||
:multiple="true"
|
||||
:flat="true"
|
||||
:normalizer="normalizer"
|
||||
placeholder="选择部门类目"
|
||||
/>
|
||||
</el-form-item>
|
||||
<br v-if="!crud.status.add">
|
||||
@@ -95,15 +99,14 @@
|
||||
<el-radio label="女">女</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="form.is_used" :disabled="form.id === user.id">
|
||||
<el-radio
|
||||
v-for="item in dict.user_status"
|
||||
:key="item.id"
|
||||
:label="item.value"
|
||||
>{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
<el-form-item label="状态" prop="is_uesd">
|
||||
<el-switch
|
||||
v-model="form.is_used"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-bottom: 0;" label="角色" prop="roles">
|
||||
<el-select
|
||||
@@ -116,12 +119,12 @@
|
||||
@remove-tag="deleteTag"
|
||||
@change="changeRole"
|
||||
>
|
||||
<!--:disabled="level !== 1 && item.level <= level"-->
|
||||
<el-option
|
||||
v-for="item in roles"
|
||||
:key="item.name"
|
||||
:disabled="level !== 1 && item.level <= level"
|
||||
:key="item.role_id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
:value="item.role_id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -150,7 +153,7 @@
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.is_used"
|
||||
:disabled="user.id === scope.row.id"
|
||||
:disabled="scope.row.id === 1"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
@@ -198,34 +201,33 @@
|
||||
|
||||
<script>
|
||||
import crudUser from '@/api/system/user'
|
||||
import { getDepts, getDeptSuperior, getDeptTreee } from '@/api/system/dept'
|
||||
import crudDept from '@/api/system/dept'
|
||||
import { getAll, getLevel } from '@/api/system/role'
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import DateRangePicker from '@/components/DateRangePicker'
|
||||
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { mapGetters } from 'vuex'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
|
||||
let userRoles = []
|
||||
const defaultForm = {
|
||||
id: null,
|
||||
dept_id: null,
|
||||
depts: [],
|
||||
username: null,
|
||||
person_name: null,
|
||||
gender: '男',
|
||||
email: null,
|
||||
enabled: 'true',
|
||||
roles: [],
|
||||
dept: { id: 2 },
|
||||
phone: null,
|
||||
password: null
|
||||
}
|
||||
export default {
|
||||
name: 'User',
|
||||
components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
|
||||
components: { Treeselect, crudOperation, rrOperation, udOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '用户', url: 'api/users', crudMethod: { ...crudUser }})
|
||||
},
|
||||
@@ -265,7 +267,7 @@ export default {
|
||||
])
|
||||
},
|
||||
beforeMount() {
|
||||
this.getDeptTree()
|
||||
this.deptTree()
|
||||
},
|
||||
created() {
|
||||
this.crud.msg.add = '新增成功'
|
||||
@@ -278,7 +280,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
changeRole(value) {
|
||||
userRoles = []
|
||||
userRoles = [],
|
||||
value.forEach(function(data, index) {
|
||||
const role = { id: data }
|
||||
userRoles.push(role)
|
||||
@@ -294,13 +296,13 @@ export default {
|
||||
// 新增与编辑前做的操作
|
||||
[CRUD.HOOK.afterToCU](crud, form) {
|
||||
this.getRoles()
|
||||
if (form.id == null) {
|
||||
this.getDepts()
|
||||
if (form.dept_id == null) {
|
||||
crudDept.getDepts()
|
||||
} else {
|
||||
this.getSupDepts(form.dept.id)
|
||||
this.getSupDepts(form.dept_id)
|
||||
}
|
||||
this.getRoleLevel()
|
||||
form.enabled = form.enabled.toString()
|
||||
form.is_used = form.enabled.toString()
|
||||
},
|
||||
// 新增前将多选的值设置为空
|
||||
[CRUD.HOOK.beforeToAdd]() {
|
||||
@@ -321,7 +323,7 @@ export default {
|
||||
},
|
||||
// 提交前做的操作
|
||||
[CRUD.HOOK.afterValidateCU](crud) {
|
||||
if (!crud.form.dept.id) {
|
||||
if (!crud.form.depts) {
|
||||
this.$message({
|
||||
message: '部门不能为空',
|
||||
type: 'warning'
|
||||
@@ -334,14 +336,18 @@ export default {
|
||||
})
|
||||
return false
|
||||
}
|
||||
crud.form.roles = userRoles
|
||||
const roles = []
|
||||
userRoles.forEach(function(data, index) {
|
||||
roles.push(data.id)
|
||||
})
|
||||
crud.form.roles = roles.toString()
|
||||
crud.form.depts = crud.form.depts.toString()
|
||||
return true
|
||||
},
|
||||
// 获取左侧部门数据
|
||||
getDeptDatas(node, resolve) {
|
||||
debugger
|
||||
setTimeout(() => {
|
||||
getDeptTreee({ name: node }).then(res => {
|
||||
crudDept.getDeptTree({ name: node }).then(res => {
|
||||
console.log('res', res)
|
||||
if (resolve) {
|
||||
resolve(res.content)
|
||||
@@ -352,16 +358,16 @@ export default {
|
||||
}, 100)
|
||||
},
|
||||
|
||||
getDeptTree() {
|
||||
deptTree() {
|
||||
setTimeout(() => {
|
||||
getDeptTreee().then(res => {
|
||||
crudDept.getDeptTree().then(res => {
|
||||
this.deptDatas = res.content
|
||||
})
|
||||
}, 100)
|
||||
},
|
||||
getDepts() {
|
||||
console.log('获取部门')
|
||||
getDepts({ is_used: 1 }).then(res => {
|
||||
crudDept.getDepts({ is_used: 1 }).then(res => {
|
||||
console.log('获取的部门信息', res)
|
||||
|
||||
this.depts = res.content.map(function(obj) {
|
||||
@@ -373,7 +379,7 @@ export default {
|
||||
})
|
||||
},
|
||||
getSupDepts(deptId) {
|
||||
getDeptSuperior(deptId).then(res => {
|
||||
crudDept.getDeptSuperior(deptId).then(res => {
|
||||
console.log('父部门', res)
|
||||
const date = res.content
|
||||
this.buildDepts(date)
|
||||
@@ -392,21 +398,25 @@ export default {
|
||||
},
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
debugger
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
getDepts({ is_used: 1, pid: parentNode.id }).then(res => {
|
||||
crudDept.getDeptvo({ is_used: '1', pid: parentNode.dept_id }).then(res => {
|
||||
parentNode.children = res.content.map(function(obj) {
|
||||
if (obj.hasChildren) {
|
||||
obj.children = null
|
||||
}
|
||||
return obj
|
||||
})
|
||||
setTimeout(() => {
|
||||
callback()
|
||||
}, 200)
|
||||
}, 100)
|
||||
})
|
||||
}
|
||||
},
|
||||
normalizer(node) {
|
||||
return {
|
||||
id: node.dept_id,
|
||||
label: node.name,
|
||||
children: node.children
|
||||
}
|
||||
},
|
||||
// 切换部门
|
||||
handleNodeClick(data) {
|
||||
this.query.deptId = data.dept_id
|
||||
|
||||
Reference in New Issue
Block a user