callLogDetail.vue 26 KB

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