From 8bdf67ac86644d1ba285646ca26b413c58dc7330 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期一, 16 十月 2023 14:46:31 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/crm/manager/service/CstmrService.java          |    2 
 src/main/webapp/static/js/cstmr/cstmr2.js                           |  526 +++++++++++++++++++++++++++++
 src/main/java/com/zy/crm/manager/controller/CstmrController.java    |   73 ++++
 src/main/webapp/views/cstmr/cstmr.html                              |    2 
 src/main/java/com/zy/crm/manager/entity/Cstmr.java                  |    1 
 src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java |   14 
 src/main/resources/mapper/CstmrMapper.xml                           |  266 ++++++++++++++
 src/main/webapp/views/cstmr/cstmr2.html                             |  154 ++++++++
 src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java            |    3 
 9 files changed, 1,039 insertions(+), 2 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 ca07e48..fc4669f 100644
--- a/src/main/java/com/zy/crm/manager/controller/CstmrController.java
+++ b/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 {
diff --git a/src/main/java/com/zy/crm/manager/entity/Cstmr.java b/src/main/java/com/zy/crm/manager/entity/Cstmr.java
index deb79cb..1964642 100644
--- a/src/main/java/com/zy/crm/manager/entity/Cstmr.java
+++ b/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)){
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 50d18c7..74c052d 100644
--- a/src/main/java/com/zy/crm/manager/mapper/CstmrMapper.java
+++ b/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);
 
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 02b967c..aad8426 100644
--- a/src/main/java/com/zy/crm/manager/service/CstmrService.java
+++ b/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);
 
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 c4725b8..c206eea 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
@@ -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);
     }
diff --git a/src/main/resources/mapper/CstmrMapper.xml b/src/main/resources/mapper/CstmrMapper.xml
index 9e7a239..5d6d2ef 100644
--- a/src/main/resources/mapper/CstmrMapper.xml
+++ b/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>
diff --git a/src/main/webapp/static/js/cstmr/cstmr2.js b/src/main/webapp/static/js/cstmr/cstmr2.js
new file mode 100644
index 0000000..24a169b
--- /dev/null
+++ b/src/main/webapp/static/js/cstmr/cstmr2.js
@@ -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: '瀹㈡埛浠e彿', 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});
+}
diff --git a/src/main/webapp/views/cstmr/cstmr.html b/src/main/webapp/views/cstmr/cstmr.html
index d6d49f8..71ddf41 100644
--- a/src/main/webapp/views/cstmr/cstmr.html
+++ b/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="璇疯緭鍏ヨ礋璐d汉" style="display: none" lay-verify="required">
+                        <input class="layui-input" name="director" placeholder="璇疯緭鍏ヨ礋璐d汉" style="display: none">
                         <input id="director$" name="director$" class="layui-input cool-auto-complete-div" onclick="autoShow(this.id)" type="text" placeholder="璇疯緭鍏ヨ礋璐d汉" 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'))">
diff --git a/src/main/webapp/views/cstmr/cstmr2.html b/src/main/webapp/views/cstmr/cstmr2.html
new file mode 100644
index 0000000..6bf23ea
--- /dev/null
+++ b/src/main/webapp/views/cstmr/cstmr2.html
@@ -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" >瀹㈡埛浠g爜</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>
+

--
Gitblit v1.9.1