yzx 3 일 전
부모
커밋
b3c4755e50

+ 2 - 11
ruoyi-admin/src/main/java/com/ruoyi/aicall/controller/CcCallPhoneController.java

@@ -71,7 +71,6 @@ public class CcCallPhoneController extends BaseController
         logger.info("通话记录查询执行sql耗时:{}ms", (System.currentTimeMillis() - t0));
         TableDataInfo tableDataInfo = getDataTable(list);
         List<CcCallPhone> records = (List<CcCallPhone>) tableDataInfo.getRows();
-        Map<Long, String> batchNameMap = new HashMap<>();
         for (CcCallPhone data: records) {
             if (data.getWavfile().startsWith("/")) {
                 data.setWavfile(data.getWavfile().substring(1));
@@ -79,17 +78,9 @@ public class CcCallPhoneController extends BaseController
             data.setWavfile("/recordings/files?filename=" + data.getWavfile());
             data.setTelephone(CommonUtils.maskPhoneNumber(data.getTelephone()));
             data.setCallerNumber(CommonUtils.maskPhoneNumber(data.getCallerNumber()));
-            String batchName = batchNameMap.getOrDefault(data.getBatchId(), "");
-            if (StringUtils.isBlank(batchName)) {
-                CcCallTask ccCallTask = ccCallTaskService.selectCcCallTaskByBatchId(data.getBatchId());
-                if (null != ccCallTask) {
-                    batchName = ccCallTask.getBatchName();
-                } else {
-                    batchName = "-";
-                }
-                batchNameMap.put(data.getBatchId(), batchName);
+            if (StringUtils.isBlank(data.getBatchName())) {
+                data.setBatchName("-");
             }
-            data.setBatchName(batchName);
             // 挂机原因处理
             if (StringUtils.isNotEmpty(data.getHangupCause())) {
                 if (data.getHangupCause().startsWith("{") && data.getHangupCause().endsWith("}")) {

+ 2 - 2
ruoyi-admin/src/main/java/com/ruoyi/aicall/controller/CcCallTaskController.java

@@ -554,9 +554,9 @@ public class CcCallTaskController extends BaseController
 
     @GetMapping("/all")
     @ResponseBody
-    public AjaxResult all()
+    public AjaxResult all(CcCallTask ccCallTask)
     {
-        List<CcCallTask> list = ccCallTaskService.selectCcCallTaskList(new CcCallTask());
+        List<CcCallTask> list = ccCallTaskService.selectCcCallTaskList(ccCallTask);
         return AjaxResult.success(list);
     }
 

+ 2 - 1
ruoyi-admin/src/main/resources/mapper/aicall/CcCallPhoneMapper.xml

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="CcCallPhone" id="CcCallPhoneResult">
         <result property="id"    column="id"    />
         <result property="batchId"    column="batch_id"    />
+        <result property="batchName"    column="batchName"    />
         <result property="telephone"    column="telephone"    />
         <result property="custName"    column="cust_name"    />
         <result property="createtime"    column="createtime"    />
@@ -347,4 +348,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectCcCallPhoneDialogueByUuid" resultType="java.lang.String">
         select dialogue from cc_call_phone where uuid = #{uuid} limit 1
     </select>
-</mapper>
+</mapper>

+ 44 - 65
ruoyi-admin/src/main/resources/templates/aicall/callPhone/callPhone.html

@@ -2,7 +2,7 @@
 <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
 <head>
     <th:block th:include="include :: header('AI外呼记录查询')" />
-
+    <th:block th:include="include :: select2-css" />
     <th:block th:include="include :: video-js-css" />
     <th:block th:include="include :: video-js" />
     <style>
@@ -223,8 +223,9 @@
                     <ul>
                         <li>
                             <label th:text="#{callPhone.query.callTask}">外呼任务</label>
-                            <input type="text" id="batchNameInput" name="batchName" autocomplete="off" style="width:160px"/>
-                            <input type="hidden" id="batchIdHidden" name="batchId"/>
+                            <select name="batchId" id="batchIdSelect" class="form-control" style="width: 180px;">
+                                <option value="" th:text="#{options.all}"></option>
+                            </select>
                         </li>
                         <!-- 客户意向下拉框 -->
                         <li>
@@ -332,74 +333,52 @@
     </div>
 </div>
 <th:block th:include="include :: footer" />
+<th:block th:include="include :: select2-js" />
 <script th:inline="javascript">
     var linstenFlag = [[${@permission.hasPermi('cc:inboundcdr:listen')}]];
     var downloadFlag = [[${@permission.hasPermi('cc:inboundcdr:download')}]];
     var prefix = ctx + "aicall/callPhone";
 
-    // 外呼任务自动补全
-    var $batchNameInput = $("#batchNameInput");
-    var $batchIdHidden = $("#batchIdHidden");
-    var taskList = [];
-    var $taskDropdown = $('<ul class="task-autocomplete-dropdown"></ul>').css({
-        position: 'absolute', background: '#fff', border: '1px solid #ddd',
-        'list-style': 'none', margin: 0, padding: 0, 'z-index': 9999,
-        'max-height': '200px', 'overflow-y': 'auto', width: $batchNameInput.outerWidth() || 160
-    }).hide().appendTo('body');
-
-    // 加载全部任务列表(任务表数据量小,一次加载即可)
-    $.get(ctx + "aicall/callTask/all", function(result) {
-        if (result.code === 200 && result.data) {
-            taskList = result.data;
-        }
-    });
-
-    $batchNameInput.on('input', function() {
-        var val = $(this).val().trim().toLowerCase();
-        $batchIdHidden.val('');
-        if (!val) {
-            $taskDropdown.hide();
-            return;
-        }
-        var filtered = taskList.filter(function(item) {
-            return item.batchName && item.batchName.toLowerCase().indexOf(val) >= 0;
-        }).slice(0, 20);
-        if (filtered.length === 0) {
-            $taskDropdown.hide();
-            return;
-        }
-        var offset = $batchNameInput.offset();
-        $taskDropdown.css({
-            left: offset.left,
-            top: offset.top + $batchNameInput.outerHeight(),
-            width: $batchNameInput.outerWidth()
-        }).empty();
-        $.each(filtered, function(i, item) {
-            $('<li>').text(item.batchName).css({
-                padding: '4px 8px', cursor: 'pointer', 'font-size': '13px'
-            }).hover(
-                function() { $(this).css('background-color', '#f5f5f5'); },
-                function() { $(this).css('background-color', '#fff'); }
-            ).on('click', function() {
-                $batchNameInput.val(item.batchName);
-                $batchIdHidden.val(item.batchId);
-                $taskDropdown.hide();
-            }).appendTo($taskDropdown);
+    $(function() {
+        // 外呼任务下拉列表:输入字符模糊查询任务表,选中后按任务ID查询外呼记录
+        var $batchIdSelect = $("#batchIdSelect");
+        $batchIdSelect.select2({
+            theme: "bootstrap",
+            width: "180px",
+            dropdownParent: $(".search-collapse"),
+            placeholder: "请输入任务名称",
+            allowClear: true,
+            ajax: {
+                url: ctx + "aicall/callTask/all",
+                dataType: "json",
+                delay: 250,
+                data: function(params) {
+                    return {
+                        batchName: params.term || ""
+                    };
+                },
+                processResults: function(result) {
+                    var success = result && (result.code === 0 || result.code === 200);
+                    var data = (success && result.data) ? result.data : [];
+                    return {
+                        results: $.map(data, function(item) {
+                            return {
+                                id: String(item.batchId),
+                                text: item.batchName
+                            };
+                        })
+                    };
+                },
+                cache: true
+            },
+            minimumInputLength: 1,
+            language: {
+                inputTooShort: function() { return "请输入任务名称"; },
+                searching: function() { return "搜索中..."; },
+                noResults: function() { return "未找到任务"; }
+            }
         });
-        $taskDropdown.show();
-    }).on('blur', function() {
-        setTimeout(function() { $taskDropdown.hide(); }, 200);
-    });
 
-    // 搜索前:如果没有选中具体任务,清空batchId,不走LIKE
-    var _originalQuery = $.fn.bootstrapTable.defaults.queryParams;
-    $(document).on("pre.bs.table", "#bootstrap-table", function() {
-        if (!$batchIdHidden.val()) {
-            $batchNameInput.val('');
-        }
-    });
-
-    $(function() {
         var options = {
             url: prefix + "/list",
             createUrl: prefix + "/add",
@@ -960,4 +939,4 @@
     })();
 </script>
 </body>
-</html>
+</html>