Просмотр исходного кода

任务执行日志改为分页查询

zyy 2 дней назад
Родитель
Сommit
7d28f75e0a
2 измененных файлов с 143 добавлено и 13 удалено
  1. 9 2
      src/api/company/companyVoiceRobotic.js
  2. 134 11
      src/views/company/companyVoiceRobotic/index.vue

+ 9 - 2
src/api/company/companyVoiceRobotic.js

@@ -142,11 +142,18 @@ export function getCIDGroupList(params) {
 }
 
 // 查询任务执行记录
-export function getExecRecords(roboticId) {
+// export function getExecRecords(roboticId) {
+//   return request({
+//     url: '/company/companyVoiceRobotic/execRecords',
+//     method: 'get',
+//     params: { roboticId }
+//   })
+// }
+export function getExecRecords(query) {
   return request({
     url: '/company/companyVoiceRobotic/execRecords',
     method: 'get',
-    params: { roboticId }
+    params: query
   })
 }
 export function wxListQw(params) {

+ 134 - 11
src/views/company/companyVoiceRobotic/index.vue

@@ -418,6 +418,39 @@
       append-to-body
       class="exec-logs-drawer">
       <div class="exec-logs-container" v-loading="execLogs.loading">
+        <el-card class="filter-card" shadow="never">
+          <el-form :inline="true" size="small" class="filter-form" style="margin-top: 20px;">
+            <el-form-item label="客户姓名">
+              <el-input
+                v-model="execLogs.customerName"
+                placeholder="请输入客户姓名"
+                clearable
+                @keyup.enter.native="handleSearch"
+                style="width: 180px">
+              </el-input>
+            </el-form-item>
+
+            <el-form-item label="手机号">
+              <el-input
+                v-model="execLogs.customerPhone"
+                placeholder="请输入手机号"
+                clearable
+                @keyup.enter.native="handleSearch"
+                style="width: 200px">
+              </el-input>
+            </el-form-item>
+
+            <el-form-item>
+              <el-button type="primary" icon="el-icon-search" @click="handleSearch">
+                查询
+              </el-button>
+              <el-button icon="el-icon-refresh" @click="handleReset">
+                重置
+              </el-button>
+            </el-form-item>
+          </el-form>
+        </el-card>
+
         <div v-if="execLogs.list.length === 0" class="empty-logs">
           <i class="el-icon-document"></i>
           <p>暂无执行记录</p>
@@ -431,7 +464,8 @@
                 <i class="el-icon-user" style="color: #1890ff;"></i>
                 <div class="stat-content">
                   <div class="stat-label">客户总数</div>
-                  <div class="stat-value">{{ execLogs.list.length }}</div>
+<!--                  <div class="stat-value">{{ execLogs.list.length }}</div>-->
+                  <div class="stat-value">{{ execLogs.total }}</div>
                 </div>
               </div>
               <div class="stat-item">
@@ -546,6 +580,19 @@
               </el-collapse-item>
             </el-collapse>
           </div>
+          <!-- 分页 -->
+          <div class="pagination-wrapper" style="margin-top: 20px;">
+            <el-pagination
+              background
+              layout="total, sizes, prev, pager, next, jumper"
+              :total="execLogs.total"
+              :page-size="execLogs.pageSize"
+              :current-page.sync="execLogs.pageNum"
+              :page-sizes="[5, 10, 20, 30, 50]"
+              @current-change="handlePageChange"
+              @size-change="handleSizeChange">
+            </el-pagination>
+          </div>
         </div>
       </div>
     </el-drawer>
@@ -705,7 +752,13 @@ export default {
           callDone: 0,
           addWxDone: 0,
           sendMsgDone: 0
-        }
+        },
+        pageNum: 1,
+        pageSize: 10,
+        total: 0,
+        currentTaskId: null,
+        customerName: '',
+        customerPhone: ''
       },
       // 表单校验
       rules: {
@@ -783,6 +836,24 @@ export default {
         }
       },
       immediate: false
+    },
+    'execLogs.currentTaskId': {
+      handler(newVal, oldVal) {
+        // 只有当任务ID真的变化时才重置搜索条件
+        if (newVal !== oldVal && oldVal !== undefined) {
+          // 清空搜索条件
+          this.execLogs.customerName = ''
+          this.execLogs.customerPhone = ''
+          this.execLogs.pageNum = 1
+
+          // 可选:重置分页
+          this.execLogs.pageSize = 10
+
+          // 重新获取执行记录
+          this.getExecLogs()
+        }
+      },
+      immediate: false
     }
   },
   methods: {
@@ -1079,19 +1150,23 @@ export default {
     // 打开执行日志
     async showExecLogs(row) {
       this.execLogs.show = true;
-      this.execLogs.loading = true;
-      this.execLogs.list = [];
+      // this.execLogs.loading = true;
+      // this.execLogs.list = [];
+      this.execLogs.pageNum = 1;
+      this.execLogs.pageSize = 10;
+      this.execLogs.currentTaskId = row.id;
 
       try {
-        const res = await getExecRecords(row.id);
-        this.execLogs.list = res.data || [];
+        // const res = await getExecRecords(row.id);
+        // this.execLogs.list = res.data || [];
+        this.getExecLogs();
 
         // 计算统计数据
-        this.execLogs.stats = {
-          callDone: this.execLogs.list.reduce((sum, r) => sum + (r.callPhoneDone || 0), 0),
-          addWxDone: this.execLogs.list.reduce((sum, r) => sum + (r.addWxDone || 0), 0),
-          sendMsgDone: this.execLogs.list.reduce((sum, r) => sum + (r.sendMsgDone || 0), 0)
-        };
+        // this.execLogs.stats = {
+        //   callDone: this.execLogs.list.reduce((sum, r) => sum + (r.callPhoneDone || 0), 0),
+        //   addWxDone: this.execLogs.list.reduce((sum, r) => sum + (r.addWxDone || 0), 0),
+        //   sendMsgDone: this.execLogs.list.reduce((sum, r) => sum + (r.sendMsgDone || 0), 0)
+        // };
       } catch (error) {
         console.error('获取执行日志失败:', error);
         this.$message.error('获取执行日志失败');
@@ -1185,6 +1260,54 @@ export default {
     getAvatarColor(index) {
       const colors = ['#1890ff', '#52c41a', '#faad14', '#722ed1', '#eb2f96'];
       return colors[index % colors.length];
+    },
+    async getExecLogs() {
+      this.execLogs.loading = true
+      try {
+        const res = await getExecRecords({
+          roboticId: this.execLogs.currentTaskId,
+          pageNum: this.execLogs.pageNum,
+          pageSize: this.execLogs.pageSize,
+          customerName: this.execLogs.customerName,
+          customerPhone: this.execLogs.customerPhone
+        })
+
+        this.execLogs.list = res.rows || []
+        this.execLogs.total = res.total || 0
+        this.execLogs.stats = res.stats || {
+          callDone: 0,
+          addWxDone: 0,
+          sendMsgDone: 0
+        }
+
+      } catch (e) {
+        this.$message.error("获取执行日志失败")
+      } finally {
+        this.execLogs.loading = false
+      }
+    },
+
+    handlePageChange(page) {
+      this.execLogs.pageNum = page
+      this.getExecLogs()
+    },
+
+    handleSizeChange(size) {
+      this.execLogs.pageSize = size
+      this.execLogs.pageNum = 1
+      this.getExecLogs()
+    },
+    handleSearch() {
+      // 查询时回到第一页
+      this.execLogs.pageNum = 1
+      this.getExecLogs()
+    },
+
+    handleReset() {
+      this.execLogs.customerName = ''
+      this.execLogs.customerPhone = ''
+      this.execLogs.pageNum = 1
+      this.getExecLogs()
     }
   }
 };