This commit is contained in:
Vinjor 2025-12-02 18:13:19 +08:00
parent 7a8ac4cfe6
commit ba3175055e
9 changed files with 471 additions and 177 deletions

View File

@ -222,14 +222,19 @@ public class CusMainServiceImpl extends ServiceImpl<CusMainMapper,CusMain> impl
List<CusContacts> contacts = cusContactsService.list(new LambdaQueryWrapper<CusContacts>().eq(CusContacts::getCusId, id).orderByDesc(CusContacts::getIfDefault).orderByAsc(DlBaseEntity::getCreateTime));
cusMainVO.setContact(contacts);
//3.查公司表
CusCompany company = cusCompanyService.list(new LambdaQueryWrapper<CusCompany>().eq(CusCompany::getCusId, id).orderByDesc(DlBaseEntity::getCreateTime)).get(0);
List<CusCompany> companyList = cusCompanyService.list(new LambdaQueryWrapper<CusCompany>().eq(CusCompany::getCusId, id).orderByDesc(DlBaseEntity::getCreateTime));
CusCompany company = companyList.isEmpty() ? new CusCompany() : companyList.get(0);
cusMainVO.setCompanyInfo(company);
//4.查管理表
CusManager manager = cusManagerService.list(new LambdaQueryWrapper<CusManager>().eq(CusManager::getCusId, id).orderByDesc(DlBaseEntity::getCreateTime)).get(0);
List<CusManager> managerList = cusManagerService.list(new LambdaQueryWrapper<CusManager>().eq(CusManager::getCusId, id).orderByDesc(DlBaseEntity::getCreateTime));
CusManager manager = managerList.isEmpty() ? new CusManager() : managerList.get(0);
cusMainVO.setManagementInfo(manager);
//5.查银行表
List<CusBank> bankList = cusBankService.list(new LambdaQueryWrapper<CusBank>().eq(CusBank::getCusId, id).orderByDesc(DlBaseEntity::getCreateTime));
cusMainVO.setBankInfo(bankList);
cusMainVO.setBankInfo(bankList.isEmpty() ? new ArrayList<>() : bankList);
//6.查唛头表
List<CusMark> markList = cusMarkService.list(new LambdaQueryWrapper<CusMark>().eq(CusMark::getCusId, id).orderByDesc(DlBaseEntity::getCreateTime));
MarkVO markVO = new MarkVO();

View File

@ -250,8 +250,15 @@ public class SysUserController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/deptTree")
public AjaxResult deptTree(SysDept dept)
{
public AjaxResult deptTree(SysDept dept) {
return success(deptService.selectDeptTreeList(dept));
}
/**
* 获取部门树+客户列表客户左侧部门树
*/
@GetMapping("/deptAndUserTree")
public AjaxResult deptAndUserTree(SysDept dept) {
return success(deptService.selectDeptAndUserTreeList(dept));
}
}

View File

@ -6,7 +6,7 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://rm-bp1msd0a4kq4t7a66lo.mysql.rds.aliyuncs.com:3306/dl_crm_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://rm-bp1msd0a4kq4t7a66lo.mysql.rds.aliyuncs.com:3306/dl_crm_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: csd_rw
password: Csd2025#123
# 从库数据源

View File

@ -63,6 +63,12 @@
<if test="entity.cusCode!=null and entity.cusCode!=''">
AND cm.cus_code = #{entity.cusCode}
</if>
<if test="entity.userId!=null and entity.userId!=''">
AND cm.user_id = #{entity.userId}
</if>
<if test="entity.deptId!=null and entity.deptId!=''">
AND cm.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = #{entity.deptId} or find_in_set( #{entity.deptId}, ancestors ) )
</if>
<if test="entity.fullName!=null and entity.fullName!=''">
AND cm.full_name LIKE CONCAT('%',#{entity.fullName},'%')
</if>

View File

@ -0,0 +1,112 @@
package com.ruoyi.common.core.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.StringUtils;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
* Treeselect树结构实体类---点亮扩展
*
* @author ruoyi
*/
public class DlTreeSelect implements Serializable
{
private static final long serialVersionUID = 1L;
/** 节点ID */
private Long id;
/** 节点名称 */
private String label;
/** 节点类型user用户|dept部门 */
private String type;
/** 节点禁用 */
private boolean disabled = false;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<DlTreeSelect> children;
public DlTreeSelect()
{
}
public DlTreeSelect(SysDept dept) {
this.id = dept.getDeptId();
this.type="dept";
this.label = dept.getDeptName();
this.disabled = StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus());
this.children = dept.getChildren().stream().map(DlTreeSelect::new).collect(Collectors.toList());
}
public DlTreeSelect(SysUser user) {
this.id = user.getUserId();
this.type="user";
this.label = user.getNickName();
}
public DlTreeSelect(SysMenu menu)
{
this.id = menu.getMenuId();
this.label = menu.getMenuName();
this.children = menu.getChildren().stream().map(DlTreeSelect::new).collect(Collectors.toList());
}
public Long getId()
{
return id;
}
public void setId(Long id)
{
this.id = id;
}
public String getLabel()
{
return label;
}
public void setLabel(String label)
{
this.label = label;
}
public boolean isDisabled()
{
return disabled;
}
public void setDisabled(boolean disabled)
{
this.disabled = disabled;
}
public List<DlTreeSelect> getChildren()
{
return children;
}
public void setChildren(List<DlTreeSelect> children)
{
this.children = children;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -1,6 +1,9 @@
package com.ruoyi.system.service;
import java.util.List;
import java.util.Map;
import com.ruoyi.common.core.domain.DlTreeSelect;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysDept;
@ -27,6 +30,14 @@ public interface ISysDeptService
*/
public List<TreeSelect> selectDeptTreeList(SysDept dept);
/**
* 获取部门树+客户列表客户左侧部门树
*
* @param dept 部门信息
* @return 部门树信息集合
*/
public Map<String,Object> selectDeptAndUserTreeList(SysDept dept);
/**
* 构建前端所需要树结构
*

View File

@ -1,9 +1,11 @@
package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import com.ruoyi.common.core.domain.DlTreeSelect;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.annotation.DataScope;
@ -27,13 +29,14 @@ import com.ruoyi.system.service.ISysDeptService;
* @author ruoyi
*/
@Service
public class SysDeptServiceImpl implements ISysDeptService
{
public class SysDeptServiceImpl implements ISysDeptService {
@Autowired
private SysDeptMapper deptMapper;
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private SysUserMapper userMapper;
/**
* 查询部门管理数据
@ -55,12 +58,60 @@ public class SysDeptServiceImpl implements ISysDeptService
* @return 部门树信息集合
*/
@Override
public List<TreeSelect> selectDeptTreeList(SysDept dept)
{
public List<TreeSelect> selectDeptTreeList(SysDept dept) {
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
return buildDeptTreeSelect(depts);
}
/**
* 获取部门树+客户列表客户左侧部门树
*
* @param dept 部门信息
* @return 部门树信息集合
*/
@Override
public Map<String,Object> selectDeptAndUserTreeList(SysDept dept) {
Map<String,Object> rtnMap = new HashMap<>();
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
//所有部门的Id
rtnMap.put("deptId",depts.stream().map(SysDept::getDeptId).collect(Collectors.toList()));
List<DlTreeSelect> deptTreeSelects = buildDeptAndUserTreeSelect(depts);
//部门树处理完以后逐级查询用户
List<SysUser> userList = userMapper.selectAllUserList();
Map<Long, List<SysUser>> userMap = userList.stream().collect(Collectors.groupingBy(SysUser::getDeptId));
//树处理-添加每个部门的用户
dealDeptUser(deptTreeSelects,userMap);
rtnMap.put("deptTree",deptTreeSelects);
return rtnMap;
}
/**
* 组装每个部门的子级用户
* @author vinjor-M
* @date 16:47 2025/12/2
* @param deptTreeSelects TODO
* @param userMap TODO
**/
private void dealDeptUser(List<DlTreeSelect> deptTreeSelects,Map<Long, List<SysUser>> userMap){
for (DlTreeSelect deptTree : deptTreeSelects){
if("dept".equals(deptTree.getType())){
//只处理部门
List<DlTreeSelect> children = new ArrayList<>();
if(null!=deptTree.getChildren() && !deptTree.getChildren().isEmpty()){
children = deptTree.getChildren();
}
if(userMap.containsKey(deptTree.getId())){
//存在当前部门的用户添加到子级中
for(SysUser sysUser:userMap.get(deptTree.getId())){
children.add(new DlTreeSelect(sysUser));
}
}
//处理所有子级
this.dealDeptUser(children,userMap);
}
}
}
/**
* 构建前端所需要树结构
*
@ -68,8 +119,7 @@ public class SysDeptServiceImpl implements ISysDeptService
* @return 树结构列表
*/
@Override
public List<SysDept> buildDeptTree(List<SysDept> depts)
{
public List<SysDept> buildDeptTree(List<SysDept> depts) {
List<SysDept> returnList = new ArrayList<SysDept>();
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
for (SysDept dept : depts)
@ -95,12 +145,23 @@ public class SysDeptServiceImpl implements ISysDeptService
* @return 下拉树结构列表
*/
@Override
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts)
{
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
List<SysDept> deptTrees = buildDeptTree(depts);
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
}
/**
* 构建前端所需要下拉树结构--点亮扩展
* @author vinjor-M
* @date 16:33 2025/12/2
* @param depts
* @return java.util.List<com.ruoyi.common.core.domain.DlTreeSelect>
**/
private List<DlTreeSelect> buildDeptAndUserTreeSelect(List<SysDept> depts) {
List<SysDept> deptTrees = buildDeptTree(depts);
return deptTrees.stream().map(DlTreeSelect::new).collect(Collectors.toList());
}
/**
* 根据角色ID查询部门树信息
*

View File

@ -134,3 +134,10 @@ export function deptTreeSelect() {
method: 'get'
})
}
// 查询部门下拉树结构--带用户
export function deptAndUserTree() {
return request({
url: '/system/user/deptAndUserTree',
method: 'get'
})
}

View File

@ -88,7 +88,16 @@
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-row :gutter="10">
<el-col v-if="showTree" :span="4">
<div class="head-container">
<el-input v-model="deptName" placeholder="请输入部门名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px" />
</div>
<div class="head-container">
<el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current @node-click="handleNodeClick" />
</div>
</el-col>
<el-col :span="showTree?20:24">
<el-table v-loading="loading" :data="mainList">
<el-table-column fixed label="客户编码" align="center" prop="cusCode" width="150">
<template slot-scope="scope">
@ -256,6 +265,8 @@
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<pagination
v-show="total>0"
@ -297,6 +308,7 @@
</template>
<script>
import { deptAndUserTree } from "@/api/system/user";
import { listMain, getMain, delMain, addMain, updateMain ,setIfStar,moveToSeas} from '@/api/cus/main'
import { updateUser} from '@/api/cus/main'
import DrawForm from './drawForm'
@ -305,13 +317,21 @@ import FollowForm from '../follow/followForm'
import LabelForm from './labelForm'
import SelectAllUser from '../../system/user/selectAllUser'
import CheckCus from './checkCus'
import { mapGetters } from 'vuex'
export default {
name: 'Main',
computed: {
// 使 getter computed
...mapGetters([
'roles'
])
},
components: { CheckCus, SelectAllUser, LabelForm, DrawForm, FollowForm },
dicts: ['cus_main_product', 'cus_label', 'cus_type', 'sys_user_sex', 'cus_from', 'cus_level', 'cus_busi_type', 'cus_follow_step'],
data() {
return {
showTree:false,
//
loading: true,
//
@ -326,6 +346,8 @@ export default {
queryParams: {
pageNum: 1,
pageSize: 10,
deptId:null,
userId:null,
cusLabels: null,
cusCode: null,
fullName: null,
@ -343,6 +365,18 @@ export default {
fullName: '',
cusCode: ''
},
//
deptName: undefined,
//
deptOptions: undefined,
//
enabledDeptOptions: undefined,
defaultProps: {
children: "children",
label: "label"
},
//Id
allDeptIdList:[],
//
upload: {
//
@ -360,15 +394,63 @@ export default {
}
}
},
watch: {
//
deptName(val) {
this.$refs.tree.filter(val);
}
},
activated() {
//
this.getList()
},
created() {
this.getDeptTree();
//user
if(this.roles.indexOf('user') == -1){
this.showTree=true
}
this.getList()
},
methods: {
/** 查询部门下拉树结构 */
getDeptTree() {
deptAndUserTree().then(response => {
this.deptOptions = response.data.deptTree;
this.enabledDeptOptions = this.filterDisabledDept(JSON.parse(JSON.stringify(response.data.deptTree)));
this.allDeptIdList = response.data.deptId
});
},
//
filterDisabledDept(deptList) {
return deptList.filter(dept => {
if (dept.disabled) {
return false;
}
if (dept.children && dept.children.length) {
dept.children = this.filterDisabledDept(dept.children);
}
return true;
});
},
//
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
//
handleNodeClick(data) {
if(this.allDeptIdList.indexOf(data.id)==-1){
//
this.queryParams.userId = data.id;
this.queryParams.deptId = null;
}else{
//
this.queryParams.userId = null;
this.queryParams.deptId = data.id;
}
this.handleQuery();
},
/**
* 下载导入模板
*/
@ -650,5 +732,8 @@ export default {
z-index: 10;
background-color: #fff;
}
::v-deep .el-table__empty-block{
width: 100% !important;
}
</style>