callLogDetail.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  1. <template>
  2. <div class="app-container">
  3. <!-- 统计概览 -->
  4. <el-row :gutter="24" class="baseInfo">
  5. <el-col :xs="12" :sm="12" :lg="6" class="ivu-mb">
  6. <el-card shadow="hover" class="stat-card">
  7. <div slot="header" class="card-header">
  8. <span>记录总数</span>
  9. </div>
  10. <div class="content" v-loading="loading">
  11. <span class="card-number total">
  12. <count-to v-if="!loading" :start-val="0" :end-val="summary.totalCount || 0" :duration="2000" />
  13. </span>
  14. </div>
  15. </el-card>
  16. </el-col>
  17. <el-col :xs="12" :sm="12" :lg="6" class="ivu-mb">
  18. <el-card shadow="hover" class="stat-card">
  19. <div slot="header" class="card-header">
  20. <span>接通量</span>
  21. </div>
  22. <div class="content" v-loading="loading">
  23. <span class="card-number success">
  24. <count-to v-if="!loading" :start-val="0" :end-val="summary.connectedCount || 0" :duration="2000" />
  25. </span>
  26. </div>
  27. </el-card>
  28. </el-col>
  29. <el-col :xs="12" :sm="12" :lg="6" class="ivu-mb">
  30. <el-card shadow="hover" class="stat-card">
  31. <div slot="header" class="card-header">
  32. <span>计费分钟合计</span>
  33. </div>
  34. <div class="content" v-loading="loading">
  35. <span class="card-number billing">
  36. <count-to v-if="!loading" :start-val="0" :end-val="summary.totalBillingMinute || 0" :duration="2000" />
  37. </span>
  38. <span v-if="!loading" class="billing-unit">分钟</span>
  39. </div>
  40. </el-card>
  41. </el-col>
  42. <el-col :xs="12" :sm="12" :lg="6" class="ivu-mb">
  43. <el-card shadow="hover" class="stat-card">
  44. <div slot="header" class="card-header">
  45. <span>接通率</span>
  46. </div>
  47. <div class="content" v-loading="loading">
  48. <span class="card-number rate">
  49. <count-to v-if="!loading" :start-val="0" :end-val="summary.connectRate || 0" :duration="2000" />%
  50. </span>
  51. </div>
  52. </el-card>
  53. </el-col>
  54. </el-row>
  55. <!-- 筛选区域 -->
  56. <el-form
  57. ref="queryForm"
  58. :model="queryParams"
  59. :inline="true"
  60. size="small"
  61. label-width="100px"
  62. class="detail-query-form"
  63. >
  64. <el-form-item label="任务" prop="roboticId">
  65. <el-select
  66. v-model="queryParams.roboticId"
  67. filterable
  68. remote
  69. reserve-keyword
  70. clearable
  71. placeholder="请选择任务"
  72. style="width: 280px"
  73. :remote-method="searchRoboticTask"
  74. :loading="roboticLoading"
  75. @visible-change="handleRoboticDropdownVisible"
  76. @change="handleTaskChange"
  77. >
  78. <el-option
  79. v-for="item in roboticList"
  80. :key="item.id"
  81. :label="formatRoboticLabel(item)"
  82. :value="item.id"
  83. />
  84. </el-select>
  85. </el-form-item>
  86. <el-form-item label="手机号" prop="phone">
  87. <el-input
  88. v-model="queryParams.phone"
  89. placeholder="请输入手机号"
  90. clearable
  91. @keyup.enter.native="handleQuery"
  92. />
  93. </el-form-item>
  94. <el-form-item label="状态" prop="status">
  95. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
  96. <el-option label="执行中" :value="1" />
  97. <el-option label="成功" :value="2" />
  98. <el-option label="失败" :value="3" />
  99. </el-select>
  100. </el-form-item>
  101. <el-form-item label="是否接通" prop="isConnected">
  102. <el-select v-model="queryParams.isConnected" placeholder="请选择" clearable>
  103. <el-option label="是" :value="1" />
  104. <el-option label="否" :value="0" />
  105. </el-select>
  106. </el-form-item>
  107. <el-form-item label="客户类型" prop="intention">
  108. <el-select v-model="queryParams.intention" placeholder="请选择" clearable>
  109. <el-option
  110. v-for="dict in intentionOptions"
  111. :key="dict.dictValue"
  112. :label="dict.dictLabel"
  113. :value="dict.dictValue"
  114. />
  115. </el-select>
  116. </el-form-item>
  117. <el-form-item label="运行时间" prop="runDateRange">
  118. <el-date-picker
  119. v-model="runDateRange"
  120. type="daterange"
  121. value-format="yyyy-MM-dd"
  122. range-separator="至"
  123. start-placeholder="开始日期"
  124. end-placeholder="结束日期"
  125. style="width: 240px"
  126. />
  127. </el-form-item>
  128. <el-form-item label="通话时长(秒)">
  129. <div class="call-time-range">
  130. <el-input
  131. v-model="queryParams.minCallTime"
  132. placeholder="最小时长"
  133. clearable
  134. @keyup.enter.native="handleQuery"
  135. />
  136. <span class="range-separator">至</span>
  137. <el-input
  138. v-model="queryParams.maxCallTime"
  139. placeholder="最大时长"
  140. clearable
  141. @keyup.enter.native="handleQuery"
  142. />
  143. </div>
  144. </el-form-item>
  145. <el-form-item>
  146. <el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
  147. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  148. <el-button
  149. v-hasPermi="['company:callphoneDetail:list']"
  150. type="primary"
  151. icon="el-icon-refresh"
  152. :loading="syncLoading"
  153. @click="handleSyncAiCallData"
  154. >同步AI外呼数据</el-button>
  155. <el-button
  156. v-hasPermi="['company:callphonelog:exportPhone']"
  157. type="warning"
  158. icon="el-icon-download"
  159. :loading="exportLoading"
  160. @click="handleExport"
  161. >导出</el-button>
  162. </el-form-item>
  163. </el-form>
  164. <!-- 表格 -->
  165. <div v-hasPermi="['company:callphoneDetail:list']">
  166. <el-table
  167. border
  168. v-loading="loading"
  169. :data="list"
  170. height="520"
  171. >
  172. <el-table-column label="ID" align="center" prop="logId" width="80" fixed="left" />
  173. <el-table-column label="任务名称" align="center" prop="roboticName" min-width="150" show-overflow-tooltip />
  174. <el-table-column label="运行时间" align="center" prop="runTime" width="160">
  175. <template slot-scope="scope">
  176. <span>{{ formatDateTime(scope.row.runTime) }}</span>
  177. </template>
  178. </el-table-column>
  179. <el-table-column label="状态" align="center" prop="status" width="80">
  180. <template slot-scope="scope">
  181. <el-tag v-if="scope.row.status === 1" type="warning" size="mini">执行中</el-tag>
  182. <el-tag v-else-if="scope.row.status === 2" type="success" size="mini">成功</el-tag>
  183. <el-tag v-else-if="scope.row.status === 3" type="danger" size="mini">失败</el-tag>
  184. <span v-else>--</span>
  185. </template>
  186. </el-table-column>
  187. <el-table-column label="客户号码" align="center" prop="callerNum" width="155">
  188. <template slot-scope="scope">
  189. <span>{{ formatCallerNum(scope.row) }}</span>
  190. <el-button
  191. v-if="scope.row.callerNum || scope.row.customerId || scope.row.callerId"
  192. v-hasPermi="['crm:customer:queryPhone']"
  193. type="text"
  194. size="mini"
  195. icon="el-icon-view"
  196. @click="handleQueryPhone(scope.row)"
  197. >查看</el-button>
  198. </template>
  199. </el-table-column>
  200. <el-table-column label="客户类型" align="center" prop="intention" width="90">
  201. <template slot-scope="scope">
  202. <template v-for="dict in intentionOptions">
  203. <el-tag
  204. v-if="normalizeIntention(scope.row.intention) == dict.dictValue"
  205. :key="dict.dictValue"
  206. size="mini"
  207. >{{ dict.dictLabel }}</el-tag>
  208. </template>
  209. <span v-if="!matchIntentionDict(scope.row.intention)">--</span>
  210. </template>
  211. </el-table-column>
  212. <el-table-column label="通话时长(秒)" align="center" prop="callTime" width="105">
  213. <template slot-scope="scope">
  214. <span>{{ scope.row.callTime != null ? scope.row.callTime : '--' }}</span>
  215. </template>
  216. </el-table-column>
  217. <el-table-column label="计费分钟" align="center" prop="billingMinute" width="95">
  218. <template slot-scope="scope">
  219. <span v-if="scope.row.billingMinute != null">{{ scope.row.billingMinute }}分钟</span>
  220. <span v-else>--</span>
  221. </template>
  222. </el-table-column>
  223. <el-table-column label="销售名称" align="center" prop="companyUserName" width="100" show-overflow-tooltip />
  224. <el-table-column
  225. v-if="checkPermi(['crm:customer:showCallInfo'])"
  226. label="录音"
  227. align="center"
  228. prop="recordPath"
  229. min-width="260"
  230. >
  231. <template slot-scope="scope">
  232. <audio v-if="scope.row.recordPath" controls :src="handleRecordPath(scope.row.recordPath)" />
  233. <span v-else>--</span>
  234. </template>
  235. </el-table-column>
  236. <el-table-column label="操作" align="center" width="90" fixed="right">
  237. <template slot-scope="scope">
  238. <el-button
  239. v-if="scope.row.contentList && checkPermi(['crm:customer:showCallInfo'])"
  240. size="mini"
  241. type="text"
  242. @click="handleViewChat(scope.row)"
  243. >查看对话</el-button>
  244. <span v-else>--</span>
  245. </template>
  246. </el-table-column>
  247. </el-table>
  248. <pagination
  249. v-show="total > 0"
  250. :total="total"
  251. :page.sync="queryParams.pageNum"
  252. :limit.sync="queryParams.pageSize"
  253. @pagination="getList"
  254. />
  255. </div>
  256. <!-- 对话记录弹窗 -->
  257. <el-dialog
  258. title="通话详情"
  259. :visible.sync="chatDialogVisible"
  260. width="720px"
  261. append-to-body
  262. custom-class="chat-dialog"
  263. @close="handleChatClose"
  264. >
  265. <div v-if="chatList.length > 0" class="chat-summary">
  266. <div class="chat-summary-item">
  267. <span class="chat-summary-label">总条数:</span>
  268. <span class="chat-summary-value">{{ chatList.length }}</span>
  269. </div>
  270. <div class="chat-summary-item">
  271. <span class="chat-summary-label">机器人:</span>
  272. <span class="chat-summary-value blue">{{ chatStats.agentCount }}</span>
  273. </div>
  274. <div class="chat-summary-item">
  275. <span class="chat-summary-label">用户:</span>
  276. <span class="chat-summary-value green">{{ chatStats.userCount }}</span>
  277. </div>
  278. <div class="chat-summary-item">
  279. <span class="chat-summary-label">敏感词命中:</span>
  280. <span class="chat-summary-value red">{{ chatStats.sensitiveCount }}</span>
  281. </div>
  282. </div>
  283. <div v-if="chatList.length > 0" class="chat-container">
  284. <div
  285. v-for="(item, index) in chatList"
  286. :key="index"
  287. class="chat-item"
  288. :class="item.role === 'agent' ? 'chat-item-right' : 'chat-item-left'"
  289. >
  290. <div class="chat-avatar">
  291. <div
  292. class="chat-avatar-circle"
  293. :class="item.role === 'agent' ? 'avatar-agent' : 'avatar-user'"
  294. >
  295. <i :class="item.role === 'agent' ? 'el-icon-headset' : 'el-icon-user-solid'" />
  296. </div>
  297. </div>
  298. <div class="chat-content-wrap">
  299. <div class="chat-role-line">
  300. <span class="chat-role">{{ item.role === 'agent' ? '机器人' : '用户' }}</span>
  301. <span class="chat-index">#{{ index + 1 }}</span>
  302. </div>
  303. <div class="chat-bubble" v-html="item.content" />
  304. </div>
  305. </div>
  306. </div>
  307. <el-empty v-else description="暂无通话内容" />
  308. <div slot="footer" class="dialog-footer chat-dialog-footer">
  309. <span class="chat-footer-tip">标红内容为命中的敏感词</span>
  310. <el-button @click="chatDialogVisible = false">关 闭</el-button>
  311. </div>
  312. </el-dialog>
  313. </div>
  314. </template>
  315. <script>
  316. import { parseTime } from '@/utils/common'
  317. import { checkPermi } from '@/utils/permission'
  318. import {
  319. listCallphoneDetail,
  320. getCallphoneDetailSummary,
  321. exportDetailPhone,
  322. queryCallphoneLogPhone,
  323. syncAiCallData
  324. } from '@/api/company/callphone'
  325. import { listRoboticSelectOptions, getRobotic } from '@/api/company/companyVoiceRobotic'
  326. import { queryPhone } from '@/api/crm/customer'
  327. import CountTo from 'vue-count-to'
  328. export default {
  329. name: 'CallLogDetail',
  330. components: { CountTo },
  331. data() {
  332. return {
  333. loading: false,
  334. exportLoading: false,
  335. syncLoading: false,
  336. total: 0,
  337. list: [],
  338. roboticList: [],
  339. roboticLoading: false,
  340. roboticQueryParams: {
  341. pageNum: 1,
  342. pageSize: 20,
  343. name: null
  344. },
  345. runDateRange: [],
  346. intentionOptions: [],
  347. chatDialogVisible: false,
  348. chatList: [],
  349. taskInfo: {
  350. roboticId: null,
  351. roboticName: ''
  352. },
  353. summary: {
  354. totalCount: 0,
  355. connectedCount: 0,
  356. connectRate: 0,
  357. totalBillingMinute: 0
  358. },
  359. queryParams: {
  360. pageNum: 1,
  361. pageSize: 10,
  362. roboticId: null,
  363. phone: null,
  364. status: null,
  365. isConnected: null,
  366. intention: null,
  367. minCallTime: null,
  368. maxCallTime: null,
  369. beginRunTime: null,
  370. endRunTime: null
  371. }
  372. }
  373. },
  374. computed: {
  375. chatStats() {
  376. const stats = { agentCount: 0, userCount: 0, sensitiveCount: 0 }
  377. this.chatList.forEach(item => {
  378. if (item.role === 'agent') stats.agentCount++
  379. else stats.userCount++
  380. const matches = (item.content || '').match(/<span[^>]*class="sensitive-word"[^>]*>/g)
  381. if (matches) stats.sensitiveCount += matches.length
  382. })
  383. return stats
  384. }
  385. },
  386. created() {
  387. this.initFromRoute()
  388. this.loadIntentionDict()
  389. this.ensureSelectedRoboticInOptions().finally(() => {
  390. this.getList()
  391. })
  392. },
  393. methods: {
  394. checkPermi,
  395. formatRoboticLabel(item) {
  396. if (!item) return ''
  397. return item.name ? `${item.name}(${item.id})` : String(item.id)
  398. },
  399. normalizeIntention(intention) {
  400. if (intention === null || intention === undefined || intention === '') {
  401. return '0'
  402. }
  403. return String(intention)
  404. },
  405. matchIntentionDict(intention) {
  406. if (!Array.isArray(this.intentionOptions) || this.intentionOptions.length === 0) {
  407. return false
  408. }
  409. const value = this.normalizeIntention(intention)
  410. return this.intentionOptions.some(dict => String(dict.dictValue) === value)
  411. },
  412. initFromRoute() {
  413. const query = this.$route.query || {}
  414. this.taskInfo.roboticId = query.roboticId ? Number(query.roboticId) : null
  415. this.taskInfo.roboticName = query.roboticName || ''
  416. this.queryParams.roboticId = this.taskInfo.roboticId
  417. },
  418. ensureSelectedRoboticInOptions() {
  419. const roboticId = this.queryParams.roboticId
  420. if (!roboticId) {
  421. return Promise.resolve()
  422. }
  423. if (this.roboticList.some(item => item.id === roboticId)) {
  424. return Promise.resolve()
  425. }
  426. if (this.taskInfo.roboticName) {
  427. this.roboticList = [{ id: roboticId, name: this.taskInfo.roboticName }]
  428. return Promise.resolve()
  429. }
  430. return getRobotic(roboticId).then(res => {
  431. const data = res.data
  432. if (data && data.id) {
  433. this.roboticList = [{ id: data.id, name: data.name }]
  434. this.taskInfo.roboticName = data.name
  435. }
  436. }).catch(() => {})
  437. },
  438. loadRoboticOptions(reset = false) {
  439. if (reset) {
  440. this.roboticQueryParams.pageNum = 1
  441. }
  442. this.roboticLoading = true
  443. return listRoboticSelectOptions(this.roboticQueryParams).then(res => {
  444. const rows = res.rows || []
  445. if (reset || this.roboticQueryParams.pageNum === 1) {
  446. const selectedId = this.queryParams.roboticId
  447. const selected = selectedId
  448. ? this.roboticList.find(item => item.id === selectedId) || rows.find(item => item.id === selectedId)
  449. : null
  450. this.roboticList = selected && !rows.some(item => item.id === selected.id)
  451. ? [selected, ...rows]
  452. : rows
  453. } else {
  454. const existIds = new Set(this.roboticList.map(item => item.id))
  455. rows.forEach(item => {
  456. if (!existIds.has(item.id)) {
  457. this.roboticList.push(item)
  458. }
  459. })
  460. }
  461. }).catch(() => {
  462. if (reset || this.roboticQueryParams.pageNum === 1) {
  463. this.roboticList = []
  464. }
  465. }).finally(() => {
  466. this.roboticLoading = false
  467. })
  468. },
  469. searchRoboticTask(query) {
  470. this.roboticQueryParams.name = query || null
  471. this.loadRoboticOptions(true)
  472. },
  473. handleRoboticDropdownVisible(visible) {
  474. if (visible && this.roboticList.length === 0) {
  475. this.roboticQueryParams.name = null
  476. this.loadRoboticOptions(true)
  477. }
  478. },
  479. handleTaskChange(roboticId) {
  480. const task = this.roboticList.find(item => item.id === roboticId)
  481. this.taskInfo.roboticId = roboticId || null
  482. this.taskInfo.roboticName = task ? task.name : ''
  483. this.handleQuery()
  484. },
  485. loadIntentionDict() {
  486. this.getDicts('customer_intention_level').then(response => {
  487. if (response.data && response.data.length) {
  488. this.intentionOptions = response.data
  489. }
  490. }).catch(() => {})
  491. },
  492. desensitizePhone(phone) {
  493. if (!phone) return '--'
  494. if (String(phone).includes('****')) return phone
  495. if (phone.length < 7) return phone
  496. return phone.substring(0, 3) + '****' + phone.substring(phone.length - 4)
  497. },
  498. formatCallerNum(row) {
  499. if (row.callerNum) {
  500. return this.desensitizePhone(row.callerNum)
  501. }
  502. if (row.customerId || row.callerId) {
  503. return '******'
  504. }
  505. return '--'
  506. },
  507. formatDateTime(time) {
  508. if (!time) return '--'
  509. if (typeof time === 'string') return time.replace('T', ' ').substring(0, 16)
  510. return parseTime(time, '{y}-{m}-{d} {h}:{i}') || '--'
  511. },
  512. handleRecordPath(url) {
  513. if (!url) return ''
  514. if (url.startsWith('http')) {
  515. return process.env.VUE_APP_BASE_API + '/common/proxy/recording?url=' + encodeURIComponent(url)
  516. }
  517. const fullUrl = 'http://129.28.164.235:8899/recordings/files?filename=' + url
  518. return process.env.VUE_APP_BASE_API + '/common/proxy/recording?url=' + encodeURIComponent(fullUrl)
  519. },
  520. handleQueryPhone(row) {
  521. const customerId = row.customerId
  522. if (customerId) {
  523. queryPhone(customerId).then(response => {
  524. this.$alert(response.mobile, '手机号', { confirmButtonText: '确定' })
  525. })
  526. return
  527. }
  528. if (row.logId) {
  529. queryCallphoneLogPhone(row.logId).then(response => {
  530. this.$alert(response.mobile, '手机号', { confirmButtonText: '确定' })
  531. })
  532. return
  533. }
  534. this.$message.warning('无法查看手机号')
  535. },
  536. handleExport() {
  537. this.$confirm('是否确认导出当前筛选条件下的外呼记录(含解密手机号)?', '警告', {
  538. confirmButtonText: '确定',
  539. cancelButtonText: '取消',
  540. type: 'warning'
  541. }).then(() => {
  542. this.exportLoading = true
  543. return exportDetailPhone(this.getExportParams())
  544. }).then(response => {
  545. this.download(response.msg)
  546. }).finally(() => {
  547. this.exportLoading = false
  548. }).catch(() => {})
  549. },
  550. handleSyncAiCallData() {
  551. this.syncLoading = true
  552. syncAiCallData().then(res => {
  553. this.$message.success(res.msg || '正在同步中')
  554. }).finally(() => {
  555. this.syncLoading = false
  556. })
  557. },
  558. parseCallTime(val) {
  559. if (val === null || val === undefined || val === '') return null
  560. const num = Number(val)
  561. return isNaN(num) || num < 0 ? null : num
  562. },
  563. buildQueryParams() {
  564. const params = { ...this.queryParams }
  565. params.minCallTime = this.parseCallTime(params.minCallTime)
  566. params.maxCallTime = this.parseCallTime(params.maxCallTime)
  567. if (this.runDateRange && this.runDateRange.length === 2) {
  568. params.beginRunTime = this.runDateRange[0]
  569. params.endRunTime = this.runDateRange[1]
  570. } else {
  571. params.beginRunTime = null
  572. params.endRunTime = null
  573. }
  574. return params
  575. },
  576. getExportParams() {
  577. const params = this.buildQueryParams()
  578. delete params.pageNum
  579. delete params.pageSize
  580. return params
  581. },
  582. getSummary() {
  583. return getCallphoneDetailSummary(this.buildQueryParams()).then(res => {
  584. const data = res.data || {}
  585. this.summary = {
  586. totalCount: data.totalCount || 0,
  587. connectedCount: data.connectedCount || 0,
  588. connectRate: data.connectRate != null ? data.connectRate : 0,
  589. totalBillingMinute: data.totalBillingMinute || 0
  590. }
  591. }).catch(() => {
  592. this.summary = { totalCount: 0, connectedCount: 0, connectRate: 0, totalBillingMinute: 0 }
  593. })
  594. },
  595. getList() {
  596. this.loading = true
  597. const params = this.buildQueryParams()
  598. listCallphoneDetail(params).then(listRes => {
  599. this.list = listRes.rows || []
  600. this.total = listRes.total || 0
  601. if (this.list.length === 0 && this.total > 0 && this.queryParams.pageNum > 1) {
  602. this.queryParams.pageNum = 1
  603. this.getList()
  604. return
  605. }
  606. }).catch(() => {
  607. this.list = []
  608. this.total = 0
  609. }).finally(() => {
  610. this.loading = false
  611. })
  612. this.getSummary()
  613. },
  614. handleQuery() {
  615. this.queryParams.pageNum = 1
  616. this.getList()
  617. },
  618. resetQuery() {
  619. this.runDateRange = []
  620. this.resetForm('queryForm')
  621. this.queryParams.minCallTime = null
  622. this.queryParams.maxCallTime = null
  623. this.queryParams.beginRunTime = null
  624. this.queryParams.endRunTime = null
  625. const query = this.$route.query || {}
  626. this.queryParams.roboticId = query.roboticId ? Number(query.roboticId) : null
  627. this.taskInfo.roboticId = this.queryParams.roboticId
  628. this.taskInfo.roboticName = query.roboticName || ''
  629. this.ensureSelectedRoboticInOptions()
  630. this.handleQuery()
  631. },
  632. isSystemChatRole(role) {
  633. return String(role || '').toLowerCase() === 'system'
  634. },
  635. normalizeChatRole(role) {
  636. const r = String(role || '').toLowerCase()
  637. if (['agent', 'robot', 'ai', 'bot', 'assistant'].includes(r)) return 'agent'
  638. return 'user'
  639. },
  640. handleViewChat(row) {
  641. let list = []
  642. try {
  643. const raw = row.contentList
  644. list = typeof raw === 'string' ? JSON.parse(raw) : raw
  645. } catch (e) {
  646. list = []
  647. }
  648. this.chatList = (Array.isArray(list) ? list : [])
  649. .filter(item => item && !this.isSystemChatRole(item.role) && String(item.content || '').trim())
  650. .map(item => ({
  651. ...item,
  652. role: this.normalizeChatRole(item.role || item.speaker || item.from)
  653. }))
  654. this.chatDialogVisible = true
  655. },
  656. handleChatClose() {
  657. this.chatList = []
  658. }
  659. }
  660. }
  661. </script>
  662. <style lang="scss" scoped>
  663. .baseInfo {
  664. margin-bottom: 20px;
  665. }
  666. .stat-card {
  667. border-radius: 10px;
  668. transition: all 0.3s;
  669. }
  670. .stat-card:hover {
  671. transform: translateY(-3px);
  672. }
  673. .card-header {
  674. font-size: 14px;
  675. color: #666;
  676. }
  677. .content {
  678. height: 60px;
  679. display: flex;
  680. align-items: center;
  681. }
  682. .card-number {
  683. font-size: 28px;
  684. font-weight: bold;
  685. &.total { color: #409eff; }
  686. &.success { color: #67c23a; }
  687. &.rate { color: #e6a23c; }
  688. &.billing { color: #9b59b6; }
  689. }
  690. .billing-unit {
  691. margin-left: 4px;
  692. font-size: 14px;
  693. color: #909399;
  694. font-weight: normal;
  695. }
  696. .detail-query-form {
  697. margin-bottom: 16px;
  698. padding: 16px 16px 4px;
  699. background: #fff;
  700. border-radius: 4px;
  701. }
  702. .call-time-range {
  703. display: inline-flex;
  704. align-items: center;
  705. }
  706. .call-time-range .el-input {
  707. width: 100px;
  708. }
  709. .range-separator {
  710. margin: 0 6px;
  711. color: #909399;
  712. }
  713. </style>
  714. <style lang="scss">
  715. .chat-dialog {
  716. margin-top: 5vh !important;
  717. max-height: 90vh;
  718. display: flex;
  719. flex-direction: column;
  720. .el-dialog__body {
  721. padding: 0;
  722. background-color: #f5f7fa;
  723. max-height: calc(90vh - 120px);
  724. overflow-y: auto;
  725. }
  726. .chat-summary {
  727. display: flex;
  728. flex-wrap: wrap;
  729. gap: 20px;
  730. padding: 12px 20px;
  731. background: #fff;
  732. border-bottom: 1px solid #ebeef5;
  733. position: sticky;
  734. top: 0;
  735. z-index: 2;
  736. .chat-summary-label { color: #909399; font-size: 13px; }
  737. .chat-summary-value {
  738. font-weight: 600;
  739. &.blue { color: #409eff; }
  740. &.green { color: #67c23a; }
  741. &.red { color: #f56c6c; }
  742. }
  743. }
  744. .chat-container {
  745. padding: 16px 20px;
  746. }
  747. .chat-item {
  748. display: flex;
  749. margin-bottom: 14px;
  750. align-items: flex-start;
  751. }
  752. .chat-item-left {
  753. .chat-avatar { margin-right: 10px; }
  754. .chat-bubble {
  755. background: #fff;
  756. border: 1px solid #ebeef5;
  757. border-radius: 2px 8px 8px 8px;
  758. }
  759. .chat-role { color: #67c23a; }
  760. }
  761. .chat-item-right {
  762. flex-direction: row-reverse;
  763. .chat-avatar { margin-left: 10px; }
  764. .chat-content-wrap { align-items: flex-end; }
  765. .chat-role-line { flex-direction: row-reverse; }
  766. .chat-bubble {
  767. background: #ecf5ff;
  768. border: 1px solid #d9ecff;
  769. border-radius: 8px 2px 8px 8px;
  770. }
  771. .chat-role { color: #409eff; }
  772. }
  773. .chat-avatar-circle {
  774. width: 36px;
  775. height: 36px;
  776. border-radius: 50%;
  777. display: flex;
  778. align-items: center;
  779. justify-content: center;
  780. color: #fff;
  781. font-size: 18px;
  782. &.avatar-agent { background: #409eff; }
  783. &.avatar-user { background: #67c23a; }
  784. }
  785. .chat-content-wrap {
  786. display: flex;
  787. flex-direction: column;
  788. max-width: 70%;
  789. }
  790. .chat-role-line {
  791. display: flex;
  792. gap: 8px;
  793. margin-bottom: 4px;
  794. font-size: 12px;
  795. }
  796. .chat-index { color: #c0c4cc; }
  797. .chat-bubble {
  798. padding: 8px 12px;
  799. font-size: 14px;
  800. line-height: 1.6;
  801. word-break: break-word;
  802. .sensitive-word {
  803. color: #f56c6c !important;
  804. font-weight: 600;
  805. background: rgba(245, 108, 108, 0.12);
  806. padding: 0 3px;
  807. border-radius: 2px;
  808. }
  809. }
  810. .chat-dialog-footer {
  811. display: flex;
  812. justify-content: space-between;
  813. align-items: center;
  814. width: 100%;
  815. .chat-footer-tip {
  816. font-size: 12px;
  817. color: #909399;
  818. }
  819. }
  820. }
  821. </style>