From c5356be2f4f2444ebc2fe53de3d491445ab3d045 Mon Sep 17 00:00:00 2001 From: LSH Date: 星期一, 24 七月 2023 09:57:24 +0800 Subject: [PATCH] #甲方单位搜索 --- src/main/java/com/zy/crm/manager/service/CstmrService.java | 3 src/main/java/com/zy/crm/manager/controller/CstmrController.java | 22 +++++++ src/main/webapp/static/js/cstmr/cstmr.js | 3 src/main/webapp/views/cstmr/cstmr.html | 15 ++++ src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java | 7 ++ src/main/resources/mapper/CstmrMapper.xml | 93 +++++++++++++++++++++++++++++++ src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java | 3 7 files changed, 140 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/zy/crm/manager/controller/CstmrController.java b/src/main/java/com/zy/crm/manager/controller/CstmrController.java index 4b6ee9f..e5d62c5 100644 --- a/src/main/java/com/zy/crm/manager/controller/CstmrController.java +++ b/src/main/java/com/zy/crm/manager/controller/CstmrController.java @@ -7,6 +7,7 @@ import com.core.annotations.ManagerAuth; import com.core.common.BaseRes; import com.core.common.Cools; +import com.core.common.DateUtils; import com.core.common.R; import com.core.domain.KeyValueVo; import com.core.exception.CoolException; @@ -18,9 +19,11 @@ import com.zy.crm.manager.service.CstmrFollService; import com.zy.crm.manager.service.CstmrService; import com.zy.crm.manager.service.CstmrTypeService; +import com.zy.crm.system.entity.Dept; import com.zy.crm.system.entity.Dic; import com.zy.crm.system.entity.Role; import com.zy.crm.system.entity.User; +import com.zy.crm.system.service.DeptService; import com.zy.crm.system.service.DicService; import com.zy.crm.system.service.UserService; import lombok.extern.slf4j.Slf4j; @@ -51,6 +54,8 @@ private CstmrTypeService cstmrTypeService; @Autowired private DicService dicService; + @Autowired + private DeptService deptService; @RequestMapping(value = "/cstmr/{id}/auth") @ManagerAuth @@ -62,13 +67,28 @@ @ManagerAuth public R page(@RequestParam(defaultValue = "1") Integer curr, @RequestParam(defaultValue = "10") Integer limit, + @RequestParam(required = false) String conditionName, @RequestParam(required = false) String condition, @RequestParam(required = false, value = "dept_id") Long deptId, @RequestParam(required = false, value = "user_id") Long userId){ - return R.ok(cstmrService.getPage(new Page<>(curr, limit) + if (!Cools.isEmpty(conditionName)){ + switch (conditionName){ + case "director": + try { + condition=userService.selectOne(new EntityWrapper<User>().eq("username", condition)).getId().toString(); + }catch (Exception e){ + conditionName = null; + } + break; + default: + + } + } + return R.ok(cstmrService.getPage2(new Page<>(curr, limit) , getHostId() , deptId == null ? null : String.valueOf(deptId) , userId == null ? getUserId() : userId + , conditionName , condition) ); } diff --git a/src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java b/src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java index c4d06c6..c760dbb 100644 --- a/src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java +++ b/src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java @@ -17,7 +17,8 @@ Cstmr selectCstmrByNewestUuid(@Param("hostId") Long hostId); - List<Cstmr> listByPage(Page<Cstmr> page, @Param("hostId")Long hostId, @Param("deptId") String deptId, @Param("userId") Long userId ,@Param("condition") String condition); + List<Cstmr> listByPage2(Page<Cstmr> page, @Param("hostId")Long hostId, @Param("deptId") String deptId, @Param("userId") Long userId,@Param("conditionName") String conditionName ,@Param("condition") String condition); + List<Cstmr> listByPage(Page<Cstmr> page, @Param("hostId")Long hostId, @Param("deptId") String deptId, @Param("userId") Long userId,@Param("condition") String condition); int updateDeptIdByUserId(@Param("userId")Long userId, @Param("deptId")Long deptId); diff --git a/src/main/java/com/zy/crm/manager/service/CstmrService.java b/src/main/java/com/zy/crm/manager/service/CstmrService.java index af5e51d..d8add45 100644 --- a/src/main/java/com/zy/crm/manager/service/CstmrService.java +++ b/src/main/java/com/zy/crm/manager/service/CstmrService.java @@ -10,7 +10,8 @@ String getUuid(Long hostId); - Page<Cstmr> getPage(Page<Cstmr> page, Long hostId, String deptId, Long userId, String condition); + Page<Cstmr> getPage2(Page<Cstmr> page, Long hostId, String deptId, Long userId, String conditionName, String condition); + Page<Cstmr> getPage(Page<Cstmr> page, Long hostId, String deptId, Long userId, String condition); int updateDeptIdByUserId(Long userId, Long deptId); diff --git a/src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java b/src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java index 5f3ee66..31f1692 100644 --- a/src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java +++ b/src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java @@ -40,7 +40,12 @@ } @Override - public Page<Cstmr> getPage(Page<Cstmr> page, Long hostId, String deptId, Long userId, String condition) { + public Page<Cstmr> getPage2(Page<Cstmr> page, Long hostId, String deptId, Long userId, String conditionName, String condition) { + return page.setRecords(baseMapper.listByPage2(page, hostId, deptId, userId,conditionName, condition)); + } + + @Override + public Page<Cstmr> getPage(Page<Cstmr> page, Long hostId, String deptId, Long userId, String condition) { return page.setRecords(baseMapper.listByPage(page, hostId, deptId, userId, condition)); } diff --git a/src/main/resources/mapper/CstmrMapper.xml b/src/main/resources/mapper/CstmrMapper.xml index a886742..71bfca7 100644 --- a/src/main/resources/mapper/CstmrMapper.xml +++ b/src/main/resources/mapper/CstmrMapper.xml @@ -109,6 +109,99 @@ ORDER BY mc.create_time DESC </select> + <select id="listByPage2" resultMap="BaseResultMap"> + SELECT + mc.* + FROM man_cstmr mc + LEFT JOIN sys_dept sd ON mc.dept_id = sd.id + WHERE 1=1 + <choose> + <when test="deptId != null and deptId != ''"> + AND (CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId}) + or + ( + user_id = #{userId} + or + mc.id in + ( + select + cstmr_id + from man_cstmr_foll + where 1=1 + and user_id = #{userId} + ) + ) + </when> + <otherwise> + and + ( + user_id = #{userId} + or + mc.id in + ( + select + cstmr_id + from man_cstmr_foll + where 1=1 + and user_id = #{userId} + ) + ) + </otherwise> + </choose> + <if test="hostId != null"> + and mc.host_id = #{hostId} + </if> + <choose> + <when test="conditionName != null and conditionName != ''"> + <if test="condition != null and condition != ''"> + <if test="conditionName == 'uuid'"> + and mc.uuid like concat('%',#{condition},'%') + </if> + <if test="conditionName == 'name'"> + and mc.name like concat('%',#{condition},'%') + </if> + <if test="conditionName == 'simple'"> + and mc.simple like concat('%',#{condition},'%') + </if> + <if test="conditionName == 'rela'"> + and mc.rela like concat('%',#{condition},'%') + </if> + <if test="conditionName == 'tel'"> + and mc.tel like concat('%',#{condition},'%') + </if> + <if test="conditionName == 'contacts'"> + and mc.contacts like concat('%',#{condition},'%') + </if> + <if test="conditionName == 'remarks'"> + and mc.remarks like concat('%',#{condition},'%') + </if> + <if test="conditionName == 'director'"> + and mc.director = #{condition} + </if> + <if test="conditionName == 'addr'"> + and mc.addr like concat('%',#{condition},'%') + </if> + </if> + </when> + <otherwise> + <if test="condition != null and condition != ''"> + and ( + mc.uuid like concat('%',#{condition},'%') + or mc.name like concat('%',#{condition},'%') + or mc.simple like concat('%',#{condition},'%') + or mc.rela like concat('%',#{condition},'%') + or mc.tel like concat('%',#{condition},'%') + or mc.contacts like concat('%',#{condition},'%') + or mc.remarks like concat('%',#{condition},'%') + or mc.director like concat('%',#{condition},'%') + or mc.addr like concat('%',#{condition},'%') + ) + </if> + </otherwise> + </choose> + ORDER BY mc.create_time DESC + </select> + <update id="updateDeptIdByUserId"> update man_cstmr set dept_id = #{deptId} where user_id = #{userId} </update> diff --git a/src/main/webapp/static/js/cstmr/cstmr.js b/src/main/webapp/static/js/cstmr/cstmr.js index 6a19a12..76a54ba 100644 --- a/src/main/webapp/static/js/cstmr/cstmr.js +++ b/src/main/webapp/static/js/cstmr/cstmr.js @@ -81,12 +81,13 @@ // 鏍戝舰鍥� var organizationTree; - window.loadTree = function(condition){ + window.loadTree = function(conditionName,condition){ var loadIndex = layer.load(2); $.ajax({ url: baseUrl+"/dept/user/tree/auth", headers: {'token': localStorage.getItem('token')}, data: { + 'conditionName': conditionName, 'condition': condition }, method: 'POST', diff --git a/src/main/webapp/views/cstmr/cstmr.html b/src/main/webapp/views/cstmr/cstmr.html index 528876d..fa602f9 100644 --- a/src/main/webapp/views/cstmr/cstmr.html +++ b/src/main/webapp/views/cstmr/cstmr.html @@ -66,7 +66,20 @@ <div class="layui-form-item"> <div class="layui-inline"> <div class="layui-input-inline"> - <input class="layui-input" type="text" name="condition" placeholder="璇疯緭鍏�" autocomplete="off" style="border-color: #e1e1e1"> +<!-- <input class="layui-input" type="text" name="conditionName" placeholder="鎼滅储瀛楁" autocomplete="off" style="border-color: #e1e1e1">--> + <span id="conditionNameSpan">鎼滅储瀛楁锛�</span> + <select id="conditionNameSelect" name="conditionName" lay-verify="required"> + <option value = "" name="conditionName" disabled selected hidden > 璇烽�夋嫨... </option> + <option value="name" name="conditionName">瀹㈡埛鍚嶇О</option> + <option value="uuid" name="conditionName">瀹㈡埛浠g爜</option> + <option value="addr" name="conditionName">璇︾粏鍦板潃</option> + <option value="tel" name="conditionName">鐢佃瘽</option> + <option value="remarks" name="conditionName">澶囨敞</option> + <option value="rela" name="conditionName">瀹㈡埛鍏崇郴</option> + <option value="director" name="conditionName">璐熻矗浜�</option> + <option value="contacts" name="conditionName">瀹㈡埛鑱旂郴浜�</option> + </select> + <input class="layui-input" type="text" name="condition" placeholder="鍊�" autocomplete="off" style="border-color: #e1e1e1"> </div> </div> <div class="layui-inline">  -- Gitblit v1.9.1