Răsfoiți Sursa

feat: 完成指标模板管理功能

weijianghai 2 ani în urmă
părinte
comite
8b532088cc

+ 34 - 0
src/main/java/com/nokia/hb/Controller/TemplateController.java

@@ -56,4 +56,38 @@ public class TemplateController {
       c = c.substring(0, c.length() - 1);
       return DbUtil.conditionRenderTable(c, searchType, indicators, ttype, sdate);
     }
+
+    /**
+     * 添加指标模板
+     *
+     * @param templateName 指标模板名称
+     * @param indicators 指标
+     */
+    @PostMapping("addTemplate")
+    @ResponseBody
+    public Object addTemplate(String templateName, String indicators, HttpSession session) {
+
+        return DbUtil.addTemplate(templateName, indicators,session);
+    }
+
+    /**
+     * 获取指标模板
+     */
+    @GetMapping("initTreeIndicatorTemplate")
+    @ResponseBody
+    public List<TreeNode> initTreeIndicatorTemplate(HttpSession session) {
+        return DbUtil.initTreeIndicatorTemplate(session);
+    }
+
+    /**
+     * 删除指标模板
+     *
+     * @param ids 模板id
+     */
+    @PostMapping("deleteTemplate")
+    @ResponseBody
+    public Object deleteTemplate(String ids) {
+
+        return DbUtil.deleteTemplate(ids);
+    }
 }

+ 18 - 5
src/main/java/com/nokia/hb/Pojo/TreeNode.java

@@ -6,7 +6,7 @@ public class TreeNode {
 
     String title = "";
     String id = "";
-    boolean spread=false;
+    boolean spread = false;
     List<TreeNode> children = null;
 
     public TreeNode() {
@@ -18,6 +18,18 @@ public class TreeNode {
         this.children = children;
     }
 
+    public TreeNode(String title, String id, boolean spread, List<TreeNode> children) {
+        this.title = title;
+        this.id = id;
+        this.spread = spread;
+        this.children = children;
+    }
+
+    public TreeNode(String title, String id) {
+        this.title = title;
+        this.id = id;
+    }
+
     public String getTitle() {
         return title;
     }
@@ -52,10 +64,11 @@ public class TreeNode {
 
     @Override
     public String toString() {
-        return "{" +
-                "title:'" + title + '\'' +
-                ", id:'" + id + '\'' +
-                ", children:" + children +
+        return "TreeNode{" +
+                "title='" + title + '\'' +
+                ", id='" + id + '\'' +
+                ", spread=" + spread +
+                ", children=" + children +
                 '}';
     }
 }

+ 199 - 77
src/main/java/com/nokia/hb/utils/DbUtil.java

@@ -68,6 +68,7 @@ public class DbUtil {
       String startTime = timeArray[0];
       String endTime = timeArray[1];
       String sql = "select a.cellname,a.city,a.quxian,a.vendor,b.* from \n(select eci,cellname,city,quxian,vendor from pm_parse.per_cfg_cell where " + searchType + " in (" + condition + ")) a\ninner join \n(select " + indicators + " from pm_parse.pm_4g_" + ttype + " where sdate>='" + startTime + "' and sdate <= '" + endTime + "') b\n" + "on a.eci=b.eci";
+      // 全网
       if ("all".equals(searchType)) {
           sql = "select a.cellname,a.city,a.quxian,a.vendor,b.* from pm_parse.per_cfg_cell a\ninner join \n(select " + indicators + " from pm_parse.pm_4g_" + ttype + " where sdate>='" + startTime + "' and sdate <= '" + endTime + "') b\n" + "on a.eci=b.eci";
       }
@@ -115,13 +116,13 @@ public class DbUtil {
         log.debug("ttype: {}", ttype);
         log.debug("sdate: {}", sdate);
         // 获取城市数组
-        String[] cityArrays = StringUtils.delete(citys, "'").split(",");
+        String[] cityArray = StringUtils.delete(citys, "'").split(",");
         // 获取拥有的城市权限
         Map<String, String> areas = (Map<String, String>) session.getAttribute("areas");
         log.debug("{} areas: {}", areas.keySet().size(), areas.keySet());
-        log.debug("{} cityArrays: {}", cityArrays.length, Arrays.toString(cityArrays));
+        log.debug("{} cityArray: {}", cityArray.length, Arrays.toString(cityArray));
         // 地区权限校验
-        for (String t : cityArrays) {
+        for (String t : cityArray) {
             if (!areas.containsKey(t)) {
                 log.debug("没有权限的city: {}", t);
                 return new RetData(null, null, "没有" + t + "的权限");
@@ -215,7 +216,7 @@ public class DbUtil {
         List<TreeNode> res = new ArrayList<>();
         allTree.setSpread(true);
         res.add(allTree);
-        log.debug("res: {}", res);
+        log.debug("initTreeCitys: {}", res);
         return res;
     }
 
@@ -233,8 +234,8 @@ public class DbUtil {
             while (rs.next()) {
                 String indicator_type = rs.getString("indicator_type");
                 String indicator_cn = rs.getString("indicator_cn");
-                String indicator_en = rs.getString("indicator_en");
-                TreeNode t = new TreeNode(indicator_cn, indicator_en, null);
+                String indicator_id = rs.getString("indicator_id");
+                TreeNode t = new TreeNode(indicator_cn, indicator_id, null);
                 if (m.keySet().contains(indicator_type)) {
                     m.get(indicator_type).add(t);
                 } else {
@@ -254,6 +255,7 @@ public class DbUtil {
         List<TreeNode> res = new ArrayList<>();
         allTree.setSpread(true);
         res.add(allTree);
+        log.debug("initTreeIndicator: {}", res);
         return res;
     }
 
@@ -311,47 +313,47 @@ public class DbUtil {
 //        return res;
 //    }
 
-    public static HashMap<String, List<Object>> search(String from, String t1, String t2, String stype, String ttype, String provinces, String citys) {
-        HashMap<String, List<Object>> res = new HashMap<>();
-        PreparedStatement psmt = null;
-        String pn = "province_name";
-        String cn = "city_name";
-        if ("roaming".equals(from)) {
-            pn = "roaming_province_name";
-            cn = "roaming_city_name";
-        }
-//        String sql = "select sdate,sum(user_count) from sqmdb_5g.user_terminal_status_5g_abstract where sdate between '20210720' and '20210727' and stype='5G终端用户数' and size_type='7天' and province_name in ('河北') and city_name in ('石家庄','唐山') group by sdate;";
-        String sql = "select sdate as dt ,sum(user_count) as num from sqmdb_5g.user_terminal_status_5g_abstract where sdate between ? and ? and stype=? and size_type=? and " + pn + " in (" + provinces + ") and " + cn + " in (" + citys + ") group by sdate order by sdate;";
-        if ("".equals(citys)) {
-            sql = "select sdate as dt ,sum(user_count) as num from sqmdb_5g.user_terminal_status_5g_abstract where sdate between ? and ? and stype=? and size_type=? and " + pn + " in (" + provinces + ")  group by sdate order by sdate;";
-        }
-
-        List<Object> dtList = new ArrayList<>();
-        List<Object> numList = new ArrayList<>();
-        try {
-            psmt = conn.prepareStatement(sql);
-
-            psmt.setQueryTimeout(60 * 10);
-            psmt.setLong(1, Integer.valueOf(t1));
-            psmt.setLong(2, Integer.valueOf(t2));
-            psmt.setString(3, stype);
-            psmt.setString(4, ttype + "天");
-//            psmt.setString(5,provinces);
-//            psmt.setString(6,citys);
-            ResultSet rs = psmt.executeQuery();
-            while (rs.next()) {
-                String dt = rs.getString("dt");
-                Long num = rs.getLong("num");
-                dtList.add(dt);
-                numList.add(num);
-            }
-            res.put("dt", dtList);
-            res.put("num", numList);
-        } catch (SQLException e) {
-            e.printStackTrace();
-        }
-        return res;
-    }
+//    public static HashMap<String, List<Object>> search(String from, String t1, String t2, String stype, String ttype, String provinces, String citys) {
+//        HashMap<String, List<Object>> res = new HashMap<>();
+//        PreparedStatement psmt = null;
+//        String pn = "province_name";
+//        String cn = "city_name";
+//        if ("roaming".equals(from)) {
+//            pn = "roaming_province_name";
+//            cn = "roaming_city_name";
+//        }
+////        String sql = "select sdate,sum(user_count) from sqmdb_5g.user_terminal_status_5g_abstract where sdate between '20210720' and '20210727' and stype='5G终端用户数' and size_type='7天' and province_name in ('河北') and city_name in ('石家庄','唐山') group by sdate;";
+//        String sql = "select sdate as dt ,sum(user_count) as num from sqmdb_5g.user_terminal_status_5g_abstract where sdate between ? and ? and stype=? and size_type=? and " + pn + " in (" + provinces + ") and " + cn + " in (" + citys + ") group by sdate order by sdate;";
+//        if ("".equals(citys)) {
+//            sql = "select sdate as dt ,sum(user_count) as num from sqmdb_5g.user_terminal_status_5g_abstract where sdate between ? and ? and stype=? and size_type=? and " + pn + " in (" + provinces + ")  group by sdate order by sdate;";
+//        }
+//
+//        List<Object> dtList = new ArrayList<>();
+//        List<Object> numList = new ArrayList<>();
+//        try {
+//            psmt = conn.prepareStatement(sql);
+//
+//            psmt.setQueryTimeout(60 * 10);
+//            psmt.setLong(1, Integer.valueOf(t1));
+//            psmt.setLong(2, Integer.valueOf(t2));
+//            psmt.setString(3, stype);
+//            psmt.setString(4, ttype + "天");
+////            psmt.setString(5,provinces);
+////            psmt.setString(6,citys);
+//            ResultSet rs = psmt.executeQuery();
+//            while (rs.next()) {
+//                String dt = rs.getString("dt");
+//                Long num = rs.getLong("num");
+//                dtList.add(dt);
+//                numList.add(num);
+//            }
+//            res.put("dt", dtList);
+//            res.put("num", numList);
+//        } catch (SQLException e) {
+//            e.printStackTrace();
+//        }
+//        return res;
+//    }
 
 //    public static String typeExport(String from, String provinces, String citys, String ttype, String t1, String t2) {
 //        String res = "";
@@ -522,36 +524,36 @@ public class DbUtil {
 //        return res;
 //    }
 
-    public static String rsprocess(ResultSet rs) {
-        List<String> heads = new ArrayList<>();
-        String headStr = "";
-        StringBuffer sb = new StringBuffer();
-        try {
-            ResultSetMetaData rsmd = rs.getMetaData();
-            for (int i = 1; i <= rsmd.getColumnCount(); i++) {
-                String columnName = rsmd.getColumnName(i);
-                heads.add(columnName);
-                headStr += columnName + ",";
-
-            }
-
-            headStr = headStr.substring(0, headStr.length() - 1);
-            sb.append(headStr + "\n");
-            while (rs.next()) {
-                String line = "";
-                for (String head : heads) {
-                    line += rs.getString(head) + ",";
-
-                }
-                line = line.substring(0, line.length() - 1);
-                sb.append(line + "\n");
-            }
-
-        } catch (SQLException throwables) {
-            throwables.printStackTrace();
-        }
-        return sb.toString();
-    }
+//    public static String rsprocess(ResultSet rs) {
+//        List<String> heads = new ArrayList<>();
+//        String headStr = "";
+//        StringBuffer sb = new StringBuffer();
+//        try {
+//            ResultSetMetaData rsmd = rs.getMetaData();
+//            for (int i = 1; i <= rsmd.getColumnCount(); i++) {
+//                String columnName = rsmd.getColumnName(i);
+//                heads.add(columnName);
+//                headStr += columnName + ",";
+//
+//            }
+//
+//            headStr = headStr.substring(0, headStr.length() - 1);
+//            sb.append(headStr + "\n");
+//            while (rs.next()) {
+//                String line = "";
+//                for (String head : heads) {
+//                    line += rs.getString(head) + ",";
+//
+//                }
+//                line = line.substring(0, line.length() - 1);
+//                sb.append(line + "\n");
+//            }
+//
+//        } catch (SQLException throwables) {
+//            throwables.printStackTrace();
+//        }
+//        return sb.toString();
+//    }
 
     public static Object userLogin(String username, String password, HttpSession session) {
         // 计算密码md5
@@ -599,6 +601,126 @@ public class DbUtil {
         }
     }
 
+    public static Object addTemplate(String templateName, String indicators, HttpSession session) {
+        log.debug("templateName: {}", templateName);
+        log.debug("indicators: {}", indicators);
+        String username = (String) session.getAttribute("username");
+        long id = System.currentTimeMillis();
+        String sql = "insert into pm_parse.indicator_template (id, template_name, username) values (?, ?, ?)";
+        PreparedStatement psmt;
+        try {
+            conn.setAutoCommit(false);
+            psmt = conn.prepareStatement(sql);
+            psmt.setObject(1, id);
+            psmt.setObject(2, templateName);
+            psmt.setObject(3, username);
+            int rs = psmt.executeUpdate();
+            if (rs < 1) {
+                conn.rollback();
+                return "添加失败";
+            }
+
+            String[] indicatorArray = StringUtils.delete(indicators, "'").split(",");
+            sql = "insert into pm_parse.indicator_template_item (template_id, indicator_id) values (?, ?)";
+            psmt = conn.prepareStatement(sql);
+            for (String s : indicatorArray) {
+                psmt.setObject(1, id);
+                psmt.setObject(2, Integer.valueOf(s));
+                rs = psmt.executeUpdate();
+                if (rs < 1) {
+                    conn.rollback();
+                    return "添加失败";
+                }
+            }
+
+            conn.commit();
+        } catch (SQLException e) {
+            e.printStackTrace();
+            try {
+                conn.rollback();
+            } catch (SQLException ex) {
+                e.printStackTrace();
+                return "添加失败";
+            }
+            return "添加失败";
+        }
+
+        return null;
+    }
+
+    public static List<TreeNode> initTreeIndicatorTemplate(HttpSession session) {
+        // 查询用户指标模板
+        String username = (String) session.getAttribute("username");
+        String sql = "select id, template_name from pm_parse.indicator_template where username = ?";
+        PreparedStatement psmt = null;
+        TreeNode allTree = new TreeNode("指标模板选择", "指标模板选择", true, new ArrayList<>());
+        try {
+            psmt = conn.prepareStatement(sql);
+            psmt.setQueryTimeout(60 * 10);
+            psmt.setObject(1, username);
+            ResultSet rs = psmt.executeQuery();
+            while (rs.next()) {
+                String id = rs.getString("id");
+                String templateName = rs.getString("template_name");
+                TreeNode t = new TreeNode(templateName, id, new ArrayList<>());
+                allTree.getChildren().add(t);
+                // 查询模板下的指标
+                sql = "select x.indicator_cn, x.indicator_en from pm_parse.per_cfg_indicator x where x.indicator_id " +
+                        "in (select indicator_id from pm_parse.indicator_template_item where template_id = ?)";
+                psmt = conn.prepareStatement(sql);
+                psmt.setQueryTimeout(60 * 10);
+                psmt.setObject(1, Long.valueOf(id));
+                ResultSet r = psmt.executeQuery();
+                while (r.next()) {
+                    String indicatorCn = r.getString("indicator_cn");
+                    String indicatorEn = r.getString("indicator_en");
+                    t.getChildren().add(new TreeNode(indicatorCn, indicatorEn));
+                }
+            }
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        List<TreeNode> res = new ArrayList<>();
+        res.add(allTree);
+        log.debug("initTreeIndicatorTemplate: {}", res);
+        return res;
+    }
+
+    public static Object deleteTemplate(String ids) {
+        log.debug("ids: {}", ids);
+        String sql = "delete from pm_parse.indicator_template where id in (" + ids + ")";
+        PreparedStatement psmt;
+        try {
+            conn.setAutoCommit(false);
+            psmt = conn.prepareStatement(sql);
+            int rs = psmt.executeUpdate();
+            if (rs < 1) {
+                conn.rollback();
+                return "删除失败";
+            }
+
+            sql = "delete from pm_parse.indicator_template_item where template_id in (" + ids + ")";
+            psmt = conn.prepareStatement(sql);
+            rs = psmt.executeUpdate();
+            if (rs < 1) {
+                conn.rollback();
+                return "删除失败";
+            }
+
+            conn.commit();
+        } catch (SQLException e) {
+            e.printStackTrace();
+            try {
+                conn.rollback();
+            } catch (SQLException ex) {
+                e.printStackTrace();
+                return "删除失败";
+            }
+            return "删除失败";
+        }
+
+        return null;
+    }
 
 //    public static List<String> initCitys(String type, String province) {
 //        PreparedStatement psmt = null;

+ 133 - 46
src/main/resources/templates/template.html

@@ -28,7 +28,7 @@
         }
 
         .t1 {
-            width: 10%;
+            width: 15%;
         }
 
         .row {
@@ -41,7 +41,7 @@
 
         .view {
 
-            width: 80%;
+            width: 75%;
         }
 
         #timeType {
@@ -70,12 +70,22 @@
 <div class="all">
 
     <div class="c t1">
-
-        <button class="layui-btn layui-btn-sm" onclick="spread()">一键展开指标</button>
-
-        <div id="tree1" class=""></div>
-
-        <div id="tree2"></div>
+        <button type="button" class="layui-btn layui-btn-sm" onclick="addTemplate()">添加指标模板</button>
+        <button type="button" class="layui-btn layui-btn-sm" onclick="deleteTemplate()">删除指标模板</button>
+        <div id="allArea"></div>
+        <div id="indicatorTemplate"></div>
+        <div id="add-template" style="display: none;">
+            <form class="layui-form" action="">
+                <div class="layui-form-item" style="margin-top: 20px">
+                    <label class="layui-form-label">模板名称</label>
+                    <div class="layui-input-block" style="width: 400px">
+                        <input id="templateName" type="text" name="templateName" required lay-verify="required"
+                               placeholder="请输入模板名称" autocomplete="off" class="layui-input">
+                    </div>
+                </div>
+            </form>
+            <div id="allIndicator"></div>
+        </div>
     </div>
     <div class="c t2">
         <form class="layui-form" action="">
@@ -108,7 +118,7 @@
             <button class="layui-btn btn c1" style="margin-left: 20px;" onclick="conditionSearch()">条件查询</button>
         </div>
         <div class="row">
-            <table id="demo" lay-filter="test" style="width: 200pxs;"></table>
+            <table id="demo" lay-filter="test" style="width: 200px;"></table>
         </div>
     </div>
 </div>
@@ -168,13 +178,7 @@
 
             initTreeCity(tree)
             initTreeIndicator(tree)
-
-
-
-
-
-
-
+            initTreeIndicatorTemplate(tree)
         })
 
         var treeCity;
@@ -196,7 +200,7 @@
                     }
 
                     treeCity = tree.render({
-                        elem: '#tree1',
+                        elem: '#allArea',
                         showCheckbox: true,
                         accordion: true,
                         id: 'Id1',
@@ -213,46 +217,40 @@
         }
 
         var treeIn;
-        function initTreeIndicator(tree) {
-            console.log('initTreeIndicator')
+        // 渲染指标模板
+        function initTreeIndicatorTemplate(tree) {
+            console.log('initTreeIndicatorTemplate')
             $.ajax({
                 type: "GET",
-                url: './initTreeIndicator',
+                url: './initTreeIndicatorTemplate',
                 data: {
                     "spread": false
                 },
                 success: function (r) {
-
-                    // console.log(r)
                     let o = r instanceof Object
                     if (!o) {
                         r = JSON.parse(r)
                     }
 
                     treeIn = tree.render({
-                        elem: '#tree2',
+                        elem: '#indicatorTemplate',
                         showCheckbox: true,
                         accordion: true,
-                        id: 'Id2',
+                        id: 'Id3',
                         data: r
                     });
-
-
                     return false;
-
                 }
-
             });
-
         }
 
-        function spread() {
-            console.log('IndicatorSpread')
+        function initTreeIndicator(tree) {
+            console.log('initTreeIndicator')
             $.ajax({
                 type: "GET",
                 url: './initTreeIndicator',
                 data: {
-                    "spread": true
+                    "spread": false
                 },
                 success: function (r) {
 
@@ -263,7 +261,7 @@
                     }
 
                     treeIn = tree.render({
-                        elem: '#tree2',
+                        elem: '#allIndicator',
                         showCheckbox: true,
                         accordion: true,
                         id: 'Id2',
@@ -278,6 +276,7 @@
             });
 
         }
+
         function renderTable(table, citys, quxians, indicators, ttype, sdate) {
             console.log('renderTable')
 
@@ -296,7 +295,7 @@
                     dataA = r;
                     // 没有权限提示
                     if (r?.msg && r.msg.length > 0) {
-                        layer.msg(r.msg);
+                        alert(r.msg);
                         return;
                     }
 
@@ -397,7 +396,7 @@
                 alert('请选择地市')
                 return;
             }
-            if (tree.getChecked('Id2').length == 0) {
+            if (tree.getChecked('Id3').length == 0) {
                 alert('请选择指标')
                 return;
             }
@@ -406,33 +405,31 @@
             // layer.msg(JSON.stringify(data.field));
             console.log(JSON.stringify(tree.getChecked('Id1')))
             let checkData1 = tree.getChecked('Id1')[0].children;
-            let checkData2 = tree.getChecked('Id2')[0].children;
+            let checkData2 = tree.getChecked('Id3')[0].children;
             console.log(checkData1)
             console.log(checkData2)
 
-            const quxianA = [];
-            var citysA = new Array();
+            const quxianA = new Set();
+            var citysA = [];
             checkData1.forEach(eee => {
                 citysA.push("'" + eee.title + "'")
                 eee.children.forEach(ee => {
-                    quxianA.push("'" + ee.title + "'")
+                    quxianA.add("'" + ee.title + "'")
                 })
             });
 
-            const quxians = quxianA.join(',')
+            const quxians = Array.from(quxianA).join(',')
             citys = citysA.join(',')
             console.log(`citys: ${citys}`)
             console.log(`quxians: ${quxians}`)
-            var indicatorsA = new Array();
+            var indicatorsA = new Set();
             checkData2.forEach(eee => {
                 eee.children.forEach(ee => {
-
-                    indicatorsA.push(ee.id)
-
+                    indicatorsA.add(ee.id)
                 })
             });
-            indicators = indicatorsA.join(',')
-            // console.log(indicators)
+            const indicators = Array.from(indicatorsA).join(',')
+            console.log(`indicators: ${JSON.stringify(indicators)}`)
             let ttype = $('#timeType').val()
             let sdate = $('#time1').val()
             console.log(`sdate: ${sdate}`)
@@ -486,7 +483,97 @@
             return false;
         }
 
+        // 添加指标模板
+        function addTemplate() {
+            layer.open({
+                type: 1,
+                title:"添加指标模板",
+                content: $("#add-template"),
+                area: ['600px', '1000px'],
+                btn: ['确定'],
+                shadeClose: true,
+                yes: function(index, layero){
+                    const templateName = $('#templateName').val()
+                    if (!templateName || templateName.length <= 0) {
+                        alert('请输入模板名称!')
+                        return
+                    }
+
+                    const checkedData = tree?.getChecked('Id2')?.[0]?.children
+                    if (!checkedData || checkedData.length <= 0) {
+                        alert('请选择指标!')
+                        return
+                    }
 
+                    console.log(`templateName: ${templateName}`)
+                    console.log(`checkedData: ${JSON.stringify(checkedData)}`)
+                    const indicatorsA = []
+                    checkedData.forEach(eee => {
+                        eee.children.forEach(ee => {
+                            indicatorsA.push(ee.id)
+                        })
+                    });
+                    const indicators = indicatorsA.join(',')
+                    console.log(`indicators: ${indicators}`)
+                    $.ajax({
+                        type: "POST",
+                        url: './addTemplate',
+                        async: false,
+                        data: {
+                            "templateName": templateName,
+                            "indicators": indicators,
+                        },
+                        success: function (r) {
+                            console.log(`response: ${JSON.stringify(r)}`)
+
+                            if (r) {
+                                alert('添加失败!')
+                            } else {
+                                layer.msg('添加成功')
+                                layer.close(index)
+                            }
+                        }
+                    });
+                },
+            });
+        }
+
+        // 删除指标模板
+        function deleteTemplate() {
+            const checkedData = tree?.getChecked('Id3')?.[0]?.children
+            const idArray = []
+            checkedData.forEach(t => {
+                idArray.push(t.id)
+            });
+
+            if (!checkedData || checkedData.length <= 0) {
+                alert('请选择要删除的指标模板!')
+                return
+            }
+
+            layer.confirm('确认删除?', {icon: 3, title:'删除模板'}, function(index){
+                const ids = idArray.join(',')
+                console.log(`deleteTemplate: ${JSON.stringify(idArray)}`)
+                $.ajax({
+                    type: "POST",
+                    url: './deleteTemplate',
+                    async: false,
+                    data: {
+                        "ids": ids,
+                    },
+                    success: function (r) {
+                        console.log(`response: ${JSON.stringify(r)}`)
+
+                        if (r) {
+                            alert('删除失败!')
+                        } else {
+                            layer.msg('删除成功')
+                            layer.close(index)
+                        }
+                    }
+                });
+            });
+        }
     </script>
 </body>