| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | private CstmrTypeService cstmrTypeService; |
| | | @Autowired |
| | | private DicService dicService; |
| | | @Autowired |
| | | private DeptService deptService; |
| | | |
| | | @RequestMapping(value = "/cstmr/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | @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) |
| | | ); |
| | | } |
| | |
| | | |
| | | Cstmr selectCstmrByNewestUuid(@Param("hostId") Long hostId); |
| | | |
| | | 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); |
| | |
| | | |
| | | String getUuid(Long hostId); |
| | | |
| | | 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); |
| | |
| | | } |
| | | |
| | | @Override |
| | | 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)); |
| | | } |
| | |
| | | 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> |
| | |
| | | |
| | | // 树形图 |
| | | 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', |
| | |
| | | <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">客户代码</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">  |