Jonlin 6 жил өмнө
parent
commit
1a8adcd5bc

+ 14 - 2
application/admin/controller/Robot.php

@@ -3,14 +3,13 @@ namespace app\admin\controller;
 
 use think\Loader;
 use think\Controller;
-
+use think\Db;
 /**
  * 智能问答类
  */
 class Robot extends Base
 {
 
-
     /**
      * 智能问答列表
      *
@@ -167,6 +166,19 @@ class Robot extends Base
         }
     }
 
+    // 删除全部智能问答
+    public function delAll()
+    {
+        if(request()->isAjax()){
+            try{
+                Db::execute("truncate table ws_robot");
+            }catch(\Exception $e){
+                return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+            return json(['code' => 1, 'data' => '', 'msg' => '删除全部智能问答成功']);
+        }
+    }
+
     // 生成按钮
     private function makeBtn($id)
     {

+ 15 - 1
application/admin/controller/Words.php

@@ -123,7 +123,7 @@ class Words extends Base
         return $this->fetch('editword');
     }
 
-    // 删除常用语
+    // 删除快捷回复
     public function delWord()
     {
         if(request()->isAjax()){
@@ -139,6 +139,20 @@ class Words extends Base
         }
     }
 
+    // 删除全部快捷回复
+    public function delAll()
+    {
+        if(request()->isAjax()){
+            try{
+                db('words')->where('user_id',0)->delete();
+            }catch(\Exception $e){
+                return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+
+            return json(['code' => 1, 'data' => '', 'msg' => '删除全部快捷回复成功']);
+        }
+    }
+
     // 生成按钮
     private function makeBtn($id)
     {

+ 27 - 4
application/admin/view/robot/index.html

@@ -20,11 +20,14 @@
         </div>
         <div class="ibox-content">
             <a href="/admin/robot/addword.html">
-                <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新 增</strong>
+                <button class="btn btn-primary" type="button" style="margin-top:10px"><strong>新增智能问答</strong>
                 </button>
             </a>
             <form action="/admin/robot/inserExcel" enctype="multipart/form-data" method="post" role="form" class="form-inline pull-right">
-                <div class="content clearfix m-b" style="margin-left: 30px;">
+                <div class="content clearfix m-b">
+                    <div class="form-group">
+                        <a href="javascript:allDel()" class="btn" style="margin-top:5px;" ><button type="button" class="btn btn-danger btn-sm"><i class="fa fa-trash-o"></i>全部删除</button></a>
+                    </div>
                     <div class="form-group">
                         <a href="/static/admin/file/robot.xlsx" class="btn btn-primary" style="margin-top:5px" >下载智能问答模板文件</a>
                     </div>
@@ -40,9 +43,9 @@
             <!--搜索框开始-->
             <form id='commentForm' role="form" method="post" class="form-inline pull-right">
                 <input style="display: none">
-                <div class="content clearfix m-b">
+                <div class="content clearfix m-b" style="margin-top:5px">
                     <div class="form-group">
-                        <label>问题关键字:</label>
+                        <label>问题:</label>
                         <input type="text" class="form-control" id="content" name="content">
                     </div>
                     <div class="form-group">
@@ -148,6 +151,26 @@
         })
 
     }
+
+    function allDel(){
+        layer.confirm('确认删除全部智能问答?', {icon: 3, title:'提示'}, function(index){
+            //do something
+            $.getJSON("{:url('robot/delAll')}", function(res){
+                if(1 == res.code){
+                    layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+                        initTable();
+                    });
+                }else if(111 == res.code){
+                    window.location.reload();
+                }else{
+                    layer.alert(res.msg, {title: '友情提示', icon: 2});
+                }
+            });
+
+            layer.close(index);
+        })
+
+    }
 </script>
 </body>
 </html>

+ 27 - 4
application/admin/view/words/index.html

@@ -31,11 +31,14 @@
         </div>
         <div class="ibox-content" style="border-top: 0;">
             <a href="/admin/words/addword.html">
-                <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新增常用语</strong>
+                <button class="btn btn-primary" type="button" style="margin-top:10px"><strong>新增常用语</strong>
                 </button>
             </a>
             <form action="/admin/words/inserExcel" enctype="multipart/form-data" method="post" role="form" class="form-inline pull-right">
-                <div class="content clearfix m-b" style="margin-left: 50px;">
+                <div class="content clearfix m-b">
+                    <div class="form-group">
+                        <a href="javascript:allDel()" class="btn" style="margin-top:5px;" ><button type="button" class="btn btn-danger btn-sm"><i class="fa fa-trash-o"></i>全部删除</button></a>
+                    </div>
                     <div class="form-group">
                         <a href="/static/admin/file/words.xlsx" class="btn btn-primary" style="margin-top:5px" >下载快捷回复模板文件</a>
                     </div>
@@ -51,9 +54,9 @@
             <!--搜索框开始-->
             <form id='commentForm' role="form" method="post" class="form-inline pull-right">
                 <input style="display: none">
-                <div class="content clearfix m-b">
+                <div class="content clearfix m-b"  style="margin-top:5px;">
                     <div class="form-group">
-                        <label>常用语内容:</label>
+                        <label>常用语:</label>
                         <input type="text" class="form-control" id="content" name="content">
                     </div>
                     <div class="form-group">
@@ -169,6 +172,26 @@
         })
 
     }
+
+    function allDel(){
+        layer.confirm('确认删除全部快捷回复?', {icon: 3, title:'提示'}, function(index){
+            //do something
+            $.getJSON("{:url('words/delAll')}", function(res){
+                if(1 == res.code){
+                    layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+                        initTable();
+                    });
+                }else if(111 == res.code){
+                    window.location.reload();
+                }else{
+                    layer.alert(res.msg, {title: '友情提示', icon: 2});
+                }
+            });
+
+            layer.close(index);
+        })
+
+    }
 </script>
 </body>
 </html>