中扬CRM客户关系管理系统
#
LSH
2023-10-16 8bdf67ac86644d1ba285646ca26b413c58dc7330
#
7个文件已修改
2个文件已添加
1041 ■■■■■ 已修改文件
src/main/java/com/zy/crm/manager/controller/CstmrController.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/entity/Cstmr.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/service/CstmrService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/CstmrMapper.xml 266 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/cstmr/cstmr2.js 526 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/cstmr/cstmr.html 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/cstmr/cstmr2.html 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/manager/controller/CstmrController.java
@@ -123,6 +123,50 @@
        );
    }
    @RequestMapping(value = "/cstmr2/page/auth")
    @ManagerAuth
    public R page2(@RequestParam(defaultValue = "1") Integer curr,
                  @RequestParam(defaultValue = "10") Integer limit,
                  @RequestParam(required = false) String followerName,
                  @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){
        List<Integer> ids = new ArrayList<>();
        if (!Cools.isEmpty(followerName)){
            User username = userService.selectOne(new EntityWrapper<User>().eq("username", followerName));
            if (!Cools.isEmpty(username)){
                List<CstmrFoll> cstmrIds = cstmrFollService.selectCstmrIdUserId(username.getId().intValue());
                for (CstmrFoll id : cstmrIds){
                    ids.add(id.getCstmrId().intValue());
                }
            }else {
                return R.error("未查询到跟进人信息!");
            }
        }
        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.getPage33(new Page<>(curr, limit)
                , getHostId()
                , deptId == null ? null : String.valueOf(deptId)
                , userId == null ? getUserId() : userId
                , Cools.isEmpty(followerName) ? null : ids
                , conditionName
                , condition)
        );
    }
    @RequestMapping(value = "/cstmr/add/auth")
    @ManagerAuth(memo = "添加甲方单位")
    public R add(Cstmr cstmr) {
@@ -146,9 +190,21 @@
        cstmr.setCreateTime(new Date());
        cstmr.setUpdateBy(getUserId());
        cstmr.setUpdateTime(new Date());
        cstmr.setDirector(getUserId());
//        cstmr.setDirector(getUserId());
        cstmr.setStatus(1);
        cstmrService.insert(cstmr);
        return R.ok();
    }
    @RequestMapping(value = "/cstmr2/add/auth")
    @ManagerAuth(memo = "接取甲方单位")
    public R add2(Cstmr cstmr) {
        Cstmr cstmr1 = cstmrService.selectByName(getHostId(),cstmr.getName());
        if (Cools.isEmpty(cstmr1) || cstmr1.getDirector()!=null){
            return R.error("你无法接取此甲方单位!");
        }
        cstmr1.setDirector(getUserId());
        cstmrService.updateById(cstmr1);
        return R.ok();
    }
@@ -429,6 +485,21 @@
        return R.ok().add(vos);
    }
    @RequestMapping("/cstmr2/all/get/kv")
    @ManagerAuth
    public R getDataKV2(@RequestParam(required = false) String condition) {
        User user = getUser(); assert user != null;
        Role role = getRole(); assert role != null;
        Page<Cstmr> page = cstmrService.getPageCstmr2(new Page<>(1, 30)
                , getHostId()
                , role.judgeLeader() ? String.valueOf(user.getDeptId()) : null
                , user.getId()
                , condition);
        List<KeyValueVo> vos = new ArrayList<>();
        page.getRecords().forEach(item -> vos.add(new KeyValueVo(item.getName(), item.getId())));
        return R.ok().add(vos);
    }
    @RequestMapping("/cstmr/file/import")
    @Transactional
    public R fileImport() throws IOException {
src/main/java/com/zy/crm/manager/entity/Cstmr.java
@@ -347,6 +347,7 @@
    }
    public String getDirector$(){
        if (Cools.isEmpty(this.director)) return null;
        UserService service = SpringUtils.getBean(UserService.class);
        User user = service.selectById(this.director);
        if (!Cools.isEmpty(user)){
src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java
@@ -19,8 +19,11 @@
    List<Cstmr> listByPage2(Page<Cstmr> page, @Param("hostId")Long hostId, @Param("deptId") Long deptId, @Param("userId") Long userId,@Param("roleId") Long roleId, @Param("conditionName") String conditionName ,@Param("condition") String condition);
    List<Cstmr> listByPage1(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> listByPage11(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> listByPage3(Page<Cstmr> page, @Param("hostId")Long hostId, @Param("deptId") String deptId, @Param("userId") Long userId,@Param("cstmrIds") List<Integer> cstmrIds, @Param("conditionName") String conditionName ,@Param("condition") String condition);
    List<Cstmr> listByPage33(Page<Cstmr> page, @Param("hostId")Long hostId, @Param("deptId") String deptId, @Param("userId") Long userId,@Param("cstmrIds") List<Integer> cstmrIds, @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);
    List<Cstmr> listByPageCstmr2(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);
src/main/java/com/zy/crm/manager/service/CstmrService.java
@@ -15,7 +15,9 @@
    Page<Cstmr> getPage2(Page<Cstmr> page, Long hostId, Long deptId, Long userId,Long roleId, String conditionName, String condition);
    Page<Cstmr> getPage1(Page<Cstmr> page, Long hostId, String deptId, Long userId, String conditionName, String condition);
    Page<Cstmr> getPage3(Page<Cstmr> page, Long hostId, String deptId, Long userId, List<Integer> cstmrIds, String conditionName, String condition);
    Page<Cstmr> getPage33(Page<Cstmr> page, Long hostId, String deptId, Long userId, List<Integer> cstmrIds, String conditionName, String condition);
    Page<Cstmr> getPage(Page<Cstmr> page, Long hostId, String deptId, Long userId,  String condition);
    Page<Cstmr> getPageCstmr2(Page<Cstmr> page, Long hostId, String deptId, Long userId,  String condition);
    int updateDeptIdByUserId(Long userId, Long deptId);
src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java
@@ -61,11 +61,25 @@
    }
    @Override
    public Page<Cstmr> getPage33(Page<Cstmr> page, Long hostId, String deptId, Long userId, List<Integer> cstmrIds, String conditionName, String condition) {
        if (cstmrIds==null){
            return page.setRecords(baseMapper.listByPage11(page, hostId, deptId, userId,conditionName, condition));
        }else {
            return page.setRecords(baseMapper.listByPage33(page, hostId, deptId, userId,cstmrIds,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));
    }
    @Override
    public Page<Cstmr> getPageCstmr2(Page<Cstmr> page, Long hostId, String deptId, Long userId,  String condition) {
        return page.setRecords(baseMapper.listByPageCstmr2(page, hostId, deptId, userId, condition));
    }
    @Override
    public int updateDeptIdByUserId(Long userId, Long deptId) {
        return this.baseMapper.updateDeptIdByUserId(userId, deptId);
    }
src/main/resources/mapper/CstmrMapper.xml
@@ -82,6 +82,7 @@
        FROM man_cstmr mc
        LEFT JOIN sys_dept sd ON mc.dept_id = sd.id
        WHERE 1=1
        and director is not null
        <choose>
            <when test="deptId != null and deptId != ''">
                AND ((CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})
@@ -140,6 +141,105 @@
        FROM man_cstmr mc
        LEFT JOIN sys_dept sd ON mc.dept_id = sd.id
        WHERE 1=1
        and director is null
        <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
                director = #{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>
    <select id="listByPage11" resultMap="BaseResultMap">
        SELECT
        mc.*
        FROM man_cstmr mc
        LEFT JOIN sys_dept sd ON mc.dept_id = sd.id
        WHERE 1=1
        and director is not null
        <choose>
            <when test="deptId != null and deptId != ''">
                AND (
@@ -306,6 +406,7 @@
        FROM man_cstmr mc
        LEFT JOIN sys_dept sd ON mc.dept_id = sd.id
        WHERE 1=1
        and director is null
        <choose>
            <when test="deptId != null and deptId != ''">
                AND (
@@ -405,4 +506,169 @@
        ORDER BY mc.create_time DESC
    </select>
    <select id="listByPage3" resultMap="BaseResultMap">
        SELECT
        mc.*
        FROM man_cstmr mc
        LEFT JOIN sys_dept sd ON mc.dept_id = sd.id
        WHERE 1=1
        and director is not null
        <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
                director = #{userId}
                or
                mc.id in
                (
                select
                cstmr_id
                from man_cstmr_foll
                where 1=1
                and user_id = #{userId}
                )
                )
            </otherwise>
        </choose>
        <if test="cstmrIds != null">
            and mc.id in
            <foreach collection="cstmrIds" item="cstmrId" index="index" open="(" close=")" separator=",">
                #{cstmrId}
            </foreach>
        </if>
        <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>
    <select id="listByPageCstmr2" resultMap="BaseResultMap">
        SELECT
        mc.*
        FROM man_cstmr mc
        LEFT JOIN sys_dept sd ON mc.dept_id = sd.id
        WHERE 1=1
        and director is null
        <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>
        <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>
        ORDER BY mc.create_time DESC
    </select>
</mapper>
src/main/webapp/static/js/cstmr/cstmr2.js
New file
@@ -0,0 +1,526 @@
var pageCurr;
var pageCount = 0;
var treeCond;
var admin;
layui.config({
    base: baseUrl + "/static/layui/lay/modules/"
}).extend({
    cascader: 'cascader/cascader',
}).use(['table','laydate', 'form', 'admin', 'xmSelect', 'element', 'cascader', 'tree', 'dropdown'], function(){
    var table = layui.table;
    var $ = layui.jquery;
    var layer = layui.layer;
    var layDate = layui.laydate;
    var form = layui.form;
    admin = layui.admin;
    var xmSelect = layui.xmSelect;
    var cascader = layui.cascader;
    var tree = layui.tree;
    var dropdown = layui.dropdown;
    $('#organization').html(localStorage.getItem('nickname') + ' <i class="layui-icon">&#xe61a;</i>');
    // 部门人员 筛选
    dropdown.render({
        elem: '#organization'
        ,content: ['<div id="organizationTree" style="height: calc(100vh - 525px);border: none"></div>'].join('')
        ,style: 'width: 370px; height: 350px; padding: 0 15px; box-shadow: 1px 1px 30px rgb(0 0 0 / 12%);'
        ,ready: function(){
            loadTree();
        }
    });
    // 数据同步
    dropdown.render({
        elem: '#data-btn'
        ,align: 'right'
        ,style: 'border-radius: 5px;'
        ,className: 'site-dropdown-demo'
        ,data: [
            {
                title: '模板下载'
                ,templet: '<i class="layui-icon layui-icon-template-1"></i>{{d.title}}'
                ,id: 1
            },
            {
                title: '导入 Excel'
                ,templet: '<i class="layui-icon layui-icon-upload"></i>{{d.title}}'
                ,id: 2
            },
            {type: '-'}, //分割线
            {
                title: '导出 Excel'
                ,templet: '<i class="layui-icon layui-icon-export"></i>{{d.title}}'
                ,id: 3
            }
        ]
        ,click: async function(item){
            switch (item.id) {
                case 1:
                    // 模板下载
                    layer.load(1, {shade: [0.1,'#fff']});
                    location.href = baseUrl + "/mould/甲方单位导入模板.xls";
                    layer.closeAll('loading');
                    break
                case 2:
                    // 导入 Excel
                    $("#importExcel").trigger("click");
                    // let arrFileHandle = await window.showOpenFilePicker()
                    // let file = await arrFileHandle[0].getFile();
                    // upload(file);
                    break
                case 3:
                    // 导出 Excel
                    layer.msg("来不及做,等等", {icon: 6});
                    break
                default:
                    break
            }
        }
    });
    // 树形图
    var organizationTree;
    window.loadTree = function(followerName,conditionName,condition){
        var loadIndex = layer.load(2);
        $.ajax({
            url: baseUrl+"/dept/user/tree/auth",
            headers: {'token': localStorage.getItem('token')},
            data: {
                'followerName' : followerName,
                'conditionName' : conditionName,
                'condition' : condition
            },
            method: 'POST',
            success: function (res) {
                layer.close(loadIndex);
                if (res.code === 200){
                    organizationTree = tree.render({
                        elem: '#organizationTree',
                        id: 'organizationTree',
                        onlyIconControl: true,
                        data: res.data,
                        click: function (obj) {
                            treeCond = {
                                key: obj.data.key,
                                val: obj.data.id
                            }
                            $('#organization').html(obj.data.title + ' <i class="layui-icon">&#xe61a;</i>');
                            $('#organizationTree').find('.ew-tree-click').removeClass('ew-tree-click');
                            $(obj.elem).children('.layui-tree-entry').addClass('ew-tree-click');
                            clearFormVal($('#search-box'));
                            tableIns.reload({
                                where: {[obj.data.key]: obj.data.id},
                                page: {curr: 1}
                            });
                        }
                    });
                    treeData = res.data;
                } else if (res.code === 403){
                    top.location.href = baseUrl+"/";
                } else {
                    layer.msg(res.msg)
                }
            }
        })
    }
    // 数据渲染
    tableIns = table.render({
        elem: '#cstmr',
        headers: {token: localStorage.getItem('token')},
        url: baseUrl+'/cstmr2/page/auth',
        page: true,
        limit: 15,
        limits: [15, 30, 50, 100, 200, 500],
        // cellMinWidth: 100,
        height: 'full-148',
        // size: 'sm',
        skin: 'line',
        cols: [[
            // {type: 'checkbox'}
            // ,{field: 'id', align: 'center',title: 'ID'}
            // ,{field: 'hostId$', align: 'center',title: '所属商户'},
            {field: 'name', align: 'left',title: '客户名称', style: 'color: #1890ff;cursor:pointer', event: 'more', width: 350}
            ,{field: 'simple', align: 'left',title: '客户简称', hide: true}
            ,{field: 'uuid', align: 'left',title: '客户代号', hide: false}
            ,{field: 'addr', align: 'left',title: '详细地址', hide: false, templet:function(d){return emptyShow(d.addr)}}
            ,{field: 'tel', align: 'left',title: '电话', hide: false, templet:function(d){return emptyShow(d.tel)}}
            ,{field: 'remarks', align: 'left',title: '备注', hide: false, templet:function(d){return emptyShow(d.remarks)}}
            ,{field: 'cstmrType$', align: 'left',title: '客户类别', hide: false}
            ,{field: 'industry', align: 'left',title: '客户行业', hide: false}
            ,{field: 'productCategory', align: 'left',title: '产品类别', hide: false}
            ,{field: 'userId$', align: 'left',title: '添加人员', hide: true}
            ,{field: 'createTime$', align: 'left',title: '添加时间', hide: false}
            ,{field: 'deptId$', align: 'left',title: '所属部门', hide: true}
            ,{field: 'rela', align: 'left',title: '客户关系', hide: true}
            ,{field: 'contacts', align: 'left',title: '客户联系人', hide: true}
            ,{field: 'director$', align: 'left',title: '负责人', hide: false}
            ,{field: 'province', align: 'left',title: '省', hide: true}
            ,{field: 'city', align: 'left',title: '市', hide: true}
            ,{field: 'district', align: 'left',title: '县', hide: true}
            ,{field: 'town', align: 'left',title: '镇', hide: true}
            ,{field: 'type$', align: 'left',title: '区分', hide: true}
            ,{field: 'files', align: 'left',title: '附件', hide: true}
            ,{field: 'status$', align: 'left',title: '状态', hide: true}
            // ,{field: 'createBy$', align: 'center',title: '添加人员', hide: true}
            ,{field: 'updateBy$', align: 'left',title: '修改人员', hide: true}
            ,{field: 'updateTime$', align: 'left',title: '修改时间', hide: true}
            ,{field: 'memo', align: 'left',title: '注释', hide: true}
            ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120}
        ]],
        request: {
            pageName: 'curr',
            pageSize: 'limit'
        },
        parseData: function (res) {
            return {
                'code': res.code,
                'msg': res.msg,
                'count': res.data.total,
                'data': res.data.records
            }
        },
        response: {
            statusCode: 200
        },
        done: function(res, curr, count) {
            if (res.code === 403) {
                top.location.href = baseUrl+"/";
            }
            pageCurr=curr;
            pageCount = count;
            limit();
        }
    });
    // 添加
    $("#cstmrAddBtn").click(function () {
        form.verify({
            account: function(value, item){
                var min = item.getAttribute('lay-min');
                if(value.length < min){
                    return '客户名称不能小于'+min+'个字符的长度';
                }
            }
        });
        showEditModel();
    });
    // 删除
    form.on('submit(cstmrDel)', function (data) {
        let checkStatus = layui.table.checkStatus('cstmr').data;
        if (checkStatus.length === 0) {
            layer.msg('请选择要删除的数据', {icon: 2});
            return;
        }
        del(checkStatus.map(function (d) {
            return d.id;
        }));
    });
    // 监听排序事件
    table.on('sort(cstmr)', function (obj) {
        var searchData = {};
        $.each($('#search-box [name]').serializeArray(), function() {
            searchData[this.name] = this.value;
        });
        searchData['orderByField'] = obj.field;
        searchData['orderByType'] = obj.type;
        tableIns.reload({
            where: searchData,
            page: {curr: 1}
        });
    });
    // 监听行工具事件
    table.on('tool(cstmr)', function(obj){
        var data = obj.data;
        switch (obj.event) {
            case 'more':
                top.cstmrByMore = data.id;
                admin.popupRight({
                    type: 1,
                    window: "top",
                    area: "1250px",
                    url: "cstmr_more.html",
                    end: function () {
                        // $(".layui-laypage-btn")[0].click();
                    }
                })
                break;
            case 'edit':
                showEditModel(data);
                break;
            case "del":
                del([data.id]);
                break;
        }
    });
    /* 弹窗 - 新增、修改 */
    function showEditModel(mData) {
        admin.open({
            type: 1,
            area: '1500px',
            title: (mData ? '修改' : '添加') + '甲方单位',
            content: $('#editDialog').html(),
            success: function (layero, dIndex) {
                let loadNameXml = loadNameXmlSel()
                let method = mData?'update':'add';
                if (mData) {
                    $('#cascaderVal').val(mData.pcd);
                    if (mData.name) { loadNameXml.setValue([{name: mData.name, value: mData.name}]); }
                }
                if (method === 'update'){
                    var directorNone = document.getElementById("directorNone");
                    directorNone.style.display = "block";
                }
                form.verify({
                    name: function(value, item){
                        var min = item.getAttribute('lay-min');
                        if(value.length < min){
                            return '客户名称不能小于'+min+'个字符的长度';
                        }
                    }
                });
                if (mData) {
                    $('#cascaderVal').val(mData.pcd);
                }
                layDateRender(mData);
                cascaderRender();
                form.val('detail', mData);
                form.on('submit(editSubmit)', function (data) {
                    data.field.name = loadNameXml.getValue()[0] ? loadNameXml.getValue()[0].name : null;
                    //将公司数据全部返回
                    companyData = loadNameXml.getValue()[0] ? loadNameXml.getValue()[0].value : null;//将公司数据全部返回
                    if (companyData != null) {
                        data.field.creditCode = companyData.creditCode
                        data.field.issueTime = companyData.issueTime
                        data.field.companyType = companyData.companyType
                        data.field.companyPerson = companyData.companyPerson
                        data.field.companyStatus = companyData.companyStatus
                        data.field.regMoney = companyData.regMoney
                    }
                    if (!data.field.name) {
                        layer.msg("客户名称不能为空", {icon: 2});
                        return false;
                    }
                    var loadIndex = layer.load(2);
                    $.ajax({
                        url: baseUrl+"/cstmr2/"+(mData?'update':'add')+"/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: data.field,
                        method: 'POST',
                        success: function (res) {
                            layer.close(loadIndex);
                            if (res.code === 200){
                                layer.close(dIndex);
                                layer.msg(res.msg, {icon: 1});
                                tableReload()
                            } else if (res.code === 403){
                                top.location.href = baseUrl+"/";
                            }else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }
                    })
                    return false;
                });
                $(layero).children('.layui-layer-content').css('overflow', 'visible');
                layui.form.render('select');
            }
        });
    }
    /* 删除 */
    function del(ids) {
        layer.confirm('确定要删除选中数据吗?', {
            skin: 'layui-layer-admin',
            shade: .1
        }, function (i) {
            layer.close(i);
            var loadIndex = layer.load(2);
            $.ajax({
                url: baseUrl+"/cstmr/delete/auth",
                headers: {'token': localStorage.getItem('token')},
                data: {ids: ids},
                method: 'POST',
                success: function (res) {
                    layer.close(loadIndex);
                    if (res.code === 200){
                        layer.msg(res.msg, {icon: 1});
                        tableReload();
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }
            })
        });
    }
    // 搜索
    form.on('submit(search)', function (data) {
        pageCurr = 1;
        pageCount = 0;
        tableReload();
    });
    // 时间选择器
    function layDateRender(data) {
        setTimeout(function () {
            layDate.render({
                elem: '.layui-laydate-range'
                ,type: 'datetime'
                ,range: true
            });
            layDate.render({
                elem: '#createTime\\$',
                type: 'datetime',
                value: data!==undefined?data['createTime\\$']:null
            });
            layDate.render({
                elem: '#updateTime\\$',
                type: 'datetime',
                value: data!==undefined?data['updateTime\\$']:null
            });
        }, 300);
    }
    layDateRender();
    // 省市区选择
    function cascaderRender() {
        cascader.render({
            elem: '#cascaderVal',
            data: citysData,
            itemHeight: '250px',
            filterable: true,
            onChange: function (values, data) {
                // console.log(values);console.log(data);
            }
        });
    }
    window.loadNameXmlSel = function () {
        return xmSelect.render({
            el: '#nameXmlSel',
            autoRow: true,
            filterable: true,
            remoteSearch: true,
            clickClose: true,
            radio: true,
            remoteMethod: function (val, cb, show) {
                $.ajax({
                    url: baseUrl + "/cstmr2/all/get/kv",
                    headers: {'token': localStorage.getItem('token')},
                    data: {
                        condition: val
                    },
                    method: 'POST',
                    success: function (res) {
                        if (res.code === 200) {
                            cb(res.data)
                        } else {
                            cb([]);
                            layer.msg(res.msg, {icon: 2});
                        }
                    }
                });
            },
            // on: function (data) {
            //     console.log(data)
            //     let arr = data.arr
            //     let change = data.change;
            //     if (arr.length > 0 && change.length>0) {
            //         let name = arr[0].name;
            //         $.ajax({
            //             url: baseUrl + "/cstmr/name/check/auth",
            //             headers: {'token': localStorage.getItem('token')},
            //             data: {
            //                 name: name
            //             },
            //             method: 'POST',
            //             success: function (res) {
            //                 if (res.code === 200) {
            //                 } else {
            //                     layer.msg(res.msg, {icon: 2});
            //                 }
            //             }
            //         });
            //     }
            // }
        });
    }
});
// 关闭动作
$(document).on('click','#data-detail-close', function () {
    parent.layer.closeAll();
});
function tableReload() {
    if (pageCount === 0) {
        let searchData = {};
        $.each($('#search-box [name]').serializeArray(), function() {
            searchData[this.name] = this.value;
        });
        if (treeCond) {
            searchData[treeCond.key] = treeCond.val;
        }
        tableIns.reload({
            where: searchData,
            page: {curr: pageCurr}
        });
    } else {
        $(".layui-laypage-btn")[0].click();
    }
}
function upload(obj){
    if(!obj.files) {
        return;
    }
    var file = obj.files[0];
    admin.confirm('确认同步 [' + file.name +'] 文件吗?', function (index) {
        layer.load(1, {shade: [0.1,'#fff']});
        var url = baseUrl + "/cstmr/excel/import/auth";
        var form = new FormData();
        form.append("file", file);
        let xhr = new XMLHttpRequest();
        xhr.open("post", url, true);
        xhr.setRequestHeader('token', localStorage.getItem('token'));
        xhr.onload = uploadComplete;
        xhr.onerror =  uploadFailed;
        xhr.onloadend = function () {
            layer.closeAll('loading');
        };
        // xhr.upload.onprogress = progressFunction;
        xhr.upload.onloadstart = function(){
            ot = new Date().getTime();
            oloaded = 0;
        };
        xhr.send(form);
    }, function(index){
    });
}
function uploadComplete(evt) {
    let res = JSON.parse(evt.target.responseText);
    if(res.code === 200) {
        layer.msg(res.msg, {icon: 1});
        tableReload();
    } else {
        alert(res.msg);
        // layer.msg(res.msg, {icon: 2});
    }
}
function uploadFailed(evt) {
    let res = JSON.parse(evt.target.responseText);
    alert(res.msg);
    // layer.msg(res.msg, {icon: 2});
}
src/main/webapp/views/cstmr/cstmr.html
@@ -203,7 +203,7 @@
                <div class="layui-form-item"  style="display: none;" id="directorNone">
                    <label class="layui-form-label layui-form-required">负责人: </label>
                    <div class="layui-input-block cool-auto-complete">
                        <input class="layui-input" name="director" placeholder="请输入负责人" style="display: none" lay-verify="required">
                        <input class="layui-input" name="director" placeholder="请输入负责人" style="display: none">
                        <input id="director$" name="director$" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" type="text" placeholder="请输入负责人" onfocus=this.blur()>
                        <div class="cool-auto-complete-window">
                            <input class="cool-auto-complete-window-input" data-key="userQueryBydirector" onkeyup="autoLoad(this.getAttribute('data-key'))">
src/main/webapp/views/cstmr/cstmr2.html
New file
@@ -0,0 +1,154 @@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/admin.css?v=318" media="all">
    <link rel="stylesheet" href="../../static/css/cool.css" media="all">
    <link rel="stylesheet" href="../../static/css/tree.css" media="all">
    <style>
        .nav-box {
            position: absolute;
            top: 1px;
            left: 5px;
        }
        .nav-box-item {
            display: inline-block;
            vertical-align: middle;
            margin-right: 5px;
        }
        .layui-dropdown.layui-border-box.layui-panel.layui-anim.layui-anim-downbit,.layui-dropdown.layui-border-box.layui-panel.layui-anim.layui-anim-downbit * {
            box-sizing:inherit;
        }
        .layui-menu li {
            width: inherit;
        }
        .layui-tree-icon {
            height: 16px;
            line-height: 15px;
            width: 15px;
            text-align: center;
            border: 1px solid #c0c4cc;
        }
        .site-dropdown-demo,
        .site-dropdown-demo .layui-menu{background: #32363F;border-color: #484e58;}
        .site-dropdown-demo .layui-menu li{color: #a1a8b8;}
        .site-dropdown-demo .layui-menu li:hover{background-color: #32363F;}
        .layui-menu-body-title>.layui-icon {
            position: relative;
            margin-right: 5px;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card" style="margin-bottom: 5px">
        <div class="layui-card-body">
            <div id="search-box" class="layui-form toolbar" style="display: flex;justify-content: flex-end;position: relative">
                <div class="nav-box">
                    <div class="nav-box-item">
                        <i class="layui-icon" style="color: #1890ff;font-weight: bold">&#xe613;</i>
                    </div>
                    <div class="nav-box-item">
                        <button id="organization" style="border: none;padding-right: 35px;" class="layui-btn layui-btn-primary icon-btn">
                            未知
                        </button>
                    </div>
                </div>
                <div class="layui-form-item">
<!--                    <div class="layui-inline">-->
<!--                        <label class="layui-form-label">跟进人:</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <input class="layui-input" type="text" name="followerName" placeholder="跟进人" autocomplete="off" style="border-color: #e1e1e1">-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="layui-inline">
                        <label class="layui-form-label">指定字段:</label>
                        <div class="layui-input-block">
                            <select id="conditionNameSelect" name="conditionName"  lay-search>
                                <option value = "" > 请选择... </option>
                                <option value="name" >客户名称</option>
                                <option value="uuid" >客户代码</option>
                                <option value="addr" >详细地址</option>
                                <option value="tel" >电话</option>
                                <option value="remarks" >备注</option>
                                <option value="simple" >客户简称</option>
                                <option value="director" >负责人</option>
                                <option value="contacts" >客户联系人</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <input class="layui-input" type="text" name="condition" placeholder="值" autocomplete="off" style="border-color: #e1e1e1">
                    </div>
                    <div class="layui-inline">&emsp;
                        <button class="layui-btn icon-btn layui-btn-sm" lay-filter="search" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                        <button id="cstmrAddBtn" class="layui-btn icon-btn btn-add layui-btn-sm"><i class="layui-icon">&#xe654;</i>接取
                        </button>
<!--                        <button class="layui-btn layui-btn-danger icon-btn layui-btn-sm" lay-filter="cstmrDel" lay-submit>-->
<!--                            <i class="layui-icon">&#xe640;</i>删除-->
<!--                        </button>-->
                        <button id="data-btn" class="layui-btn layui-btn-primary layui-border-black icon-btn layui-btn-sm">&nbsp;数据同步
                        </button>
                    </div>
                </div>
            </div>
            <table class="layui-hide" id="cstmr" lay-filter="cstmr"></table>
            <input style="display:none" id="importExcel" type="file" onchange="upload(this)" >
        </div>
    </div>
    <div class="layui-card" style="margin-bottom: 0">
        <div class="layui-card-body">
            甲方资料:数据关联订单,
            <span class="text-danger">请勿随意删除。</span>
        </div>
    </div>
</div>
<script type="text/html" id="operate">
    <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">修改</a>
<!--    <a class="layui-btn layui-btn-danger layui-btn-xs btn-edit" lay-event="del">删除</a>-->
</script>
<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/layui/lay/modules/cascader/citys-data.js" charset="utf-8"></script>
<script type="text/javascript" src="../../static/js/cstmr/cstmr2.js" charset="utf-8"></script>
</body>
<!-- 表单弹窗 -->
<script type="text/html" id="editDialog">
    <div id="detail" lay-filter="detail" class="layui-form admin-form model-form">
        <input name="id" type="hidden">
        <div class="layui-row">
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">甲方单位: </label>
                    <div class="layui-input-block">
                        <div id="nameXmlSel" name="nameXmlSel">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <hr class="layui-bg-gray">
        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="editSubmit" lay-submit="">保存</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </div>
</script>
</html>