index.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978
  1. <template>
  2. <div class="el-container-md">
  3. <!-- 数据统计指标展示区域 -->
  4. <el-card class="statistics-card" shadow="never">
  5. <el-row :gutter="20">
  6. <el-col :span="4">
  7. <div class="statistics-item">
  8. <div class="statistics-title">累计观看人数</div>
  9. <div class="statistics-value">{{ statisticsData.totalViewers || 0 }}</div>
  10. </div>
  11. </el-col>
  12. <el-col :span="4">
  13. <div class="statistics-item">
  14. <div class="statistics-title">
  15. 累计完课人数
  16. <el-popover placement="top" width="200" trigger="click">
  17. <div>
  18. <el-input-number v-model="completeWatchTime" :min="0" :precision="0" placeholder="看课时长(分钟)" style="width: 100%;"></el-input-number>
  19. <el-button type="primary" size="mini" style="width: 100%; margin-top: 10px;" @click="updateCompleteWatchTime('total')">确定</el-button>
  20. </div>
  21. <el-button slot="reference" size="mini" type="text" icon="el-icon-setting" style="margin-left: 5px;">设置</el-button>
  22. </el-popover>
  23. </div>
  24. <div class="statistics-value">{{ statisticsData.totalCompletedCourses || 0 }}</div>
  25. </div>
  26. </el-col>
  27. <el-col :span="4">
  28. <div class="statistics-item">
  29. <div class="statistics-title">直播观看人数</div>
  30. <div class="statistics-value">{{ statisticsData.liveViewers || 0 }}</div>
  31. </div>
  32. </el-col>
  33. <el-col :span="4">
  34. <div class="statistics-item">
  35. <div class="statistics-title">
  36. 直播完课人数
  37. <el-popover placement="top" width="200" trigger="click">
  38. <div>
  39. <el-input-number v-model="liveCompleteWatchTime" :min="0" :precision="0" placeholder="看课时长(分钟)" style="width: 100%;"></el-input-number>
  40. <el-button type="primary" size="mini" style="width: 100%; margin-top: 10px;" @click="updateCompleteWatchTime('live')">确定</el-button>
  41. </div>
  42. <el-button slot="reference" size="mini" type="text" icon="el-icon-setting" style="margin-left: 5px;">设置</el-button>
  43. </el-popover>
  44. </div>
  45. <div class="statistics-value">{{ statisticsData.liveCompletedCourses || 0 }}</div>
  46. </div>
  47. </el-col>
  48. <el-col :span="4">
  49. <div class="statistics-item">
  50. <div class="statistics-title">回放观看人数</div>
  51. <div class="statistics-value">{{ statisticsData.playbackViewers || 0 }}</div>
  52. </div>
  53. </el-col>
  54. <el-col :span="4">
  55. <div class="statistics-item">
  56. <div class="statistics-title">
  57. 回放完课人数
  58. <el-popover placement="top" width="200" trigger="click">
  59. <div>
  60. <el-input-number v-model="replayCompleteWatchTime" :min="0" :precision="0" placeholder="看课时长(分钟)" style="width: 100%;"></el-input-number>
  61. <el-button type="primary" size="mini" style="width: 100%; margin-top: 10px;" @click="updateCompleteWatchTime('replay')">确定</el-button>
  62. </div>
  63. <el-button slot="reference" size="mini" type="text" icon="el-icon-setting" style="margin-left: 5px;">设置</el-button>
  64. </el-popover>
  65. </div>
  66. <div class="statistics-value">{{ statisticsData.playbackCompletedCourses || 0 }}</div>
  67. </div>
  68. </el-col>
  69. </el-row>
  70. <el-row :gutter="20" style="margin-top: 20px;">
  71. <el-col :span="4">
  72. <div class="statistics-item">
  73. <div class="statistics-title">直播峰值</div>
  74. <div class="statistics-value">{{ statisticsData.livePeak || 0 }}</div>
  75. </div>
  76. </el-col>
  77. <el-col :span="4">
  78. <div class="statistics-item">
  79. <div class="statistics-title">直播平均时长</div>
  80. <div class="statistics-value">{{ formatDuration(statisticsData.liveAvgDuration) }}</div>
  81. </div>
  82. </el-col>
  83. <el-col :span="4">
  84. <div class="statistics-item">
  85. <div class="statistics-title">回放平均时长</div>
  86. <div class="statistics-value">{{ formatDuration(statisticsData.playbackAvgDuration) }}</div>
  87. </div>
  88. </el-col>
  89. <el-col :span="4">
  90. <div class="statistics-item">
  91. <div class="statistics-title">GMV</div>
  92. <div class="statistics-value">¥{{ statisticsData.gmv || 0 }}</div>
  93. </div>
  94. </el-col>
  95. <el-col :span="4">
  96. <div class="statistics-item">
  97. <div class="statistics-title">付费人数</div>
  98. <div class="statistics-value">{{ statisticsData.paidUsers || 0 }}</div>
  99. </div>
  100. </el-col>
  101. <el-col :span="4">
  102. <div class="statistics-item">
  103. <div class="statistics-title">付费单数</div>
  104. <div class="statistics-value">{{ statisticsData.paidOrders || 0 }}</div>
  105. </div>
  106. </el-col>
  107. </el-row>
  108. <el-row :gutter="20" style="margin-top: 20px;">
  109. <el-col :span="4">
  110. <div class="statistics-item">
  111. <div class="statistics-title">销量统计</div>
  112. <div class="statistics-value">{{ statisticsData.salesCount || 0 }}</div>
  113. </div>
  114. </el-col>
  115. </el-row>
  116. </el-card>
  117. <!-- 筛选条件区域 -->
  118. <el-form :model="queryParams" class="live-data-css" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  119. <el-form-item label="直播名称" prop="liveName">
  120. <el-input
  121. v-model="queryParams.liveName"
  122. placeholder="请输入直播名称"
  123. clearable
  124. size="small"
  125. @keyup.enter.native="handleQuery"
  126. />
  127. </el-form-item>
  128. <el-form-item label="观看类型" prop="watchType">
  129. <el-select v-model="queryParams.watchType" placeholder="请选择观看类型" clearable size="small">
  130. <el-option label="直播" value="live"></el-option>
  131. <el-option label="回放" value="replay"></el-option>
  132. </el-select>
  133. </el-form-item>
  134. <el-form-item label="完课状态" prop="completeStatus">
  135. <el-select v-model="queryParams.completeStatus" placeholder="请选择完课状态" clearable size="small">
  136. <el-option label="已完课" value="1"></el-option>
  137. <el-option label="未完课" value="0"></el-option>
  138. </el-select>
  139. </el-form-item>
  140. <el-form-item label="付费状态" prop="payStatus">
  141. <el-select v-model="queryParams.payStatus" placeholder="请选择付费状态" clearable size="small">
  142. <el-option label="已付费" value="1"></el-option>
  143. <el-option label="未付费" value="0"></el-option>
  144. </el-select>
  145. </el-form-item>
  146. <el-form-item label="观看时长" prop="watchDuration">
  147. <el-input-number
  148. v-model="queryParams.watchDuration"
  149. :min="0"
  150. :precision="0"
  151. placeholder="观看时长(分钟)"
  152. size="small"
  153. ></el-input-number>
  154. </el-form-item>
  155. <el-form-item label="时间范围" prop="dateRange">
  156. <el-date-picker
  157. v-model="dateRange"
  158. type="datetimerange"
  159. range-separator="至"
  160. start-placeholder="开始日期"
  161. end-placeholder="结束日期"
  162. size="small"
  163. value-format="yyyy-MM-dd HH:mm:ss"
  164. ></el-date-picker>
  165. </el-form-item>
  166. <el-form-item>
  167. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  168. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  169. </el-form-item>
  170. </el-form>
  171. <!-- 操作工具栏 -->
  172. <div class="selection-toolbar">
  173. <el-checkbox :indeterminate="isIndeterminate" v-model="allChecked" @change="toggleSelectAll">
  174. {{ multipleSelection.length > 0 ? `已选 ${multipleSelection.length} 条` : '选中本页' }}
  175. </el-checkbox>
  176. <!-- <el-button plain size="mini" @click="handleAutoTag">自动打标签</el-button>-->
  177. <!-- <el-button plain size="mini" @click="handleAutoRemark">自动备注</el-button>-->
  178. <el-button plain type="primary" size="mini" icon="el-icon-download" :loading="exportLoading" @click="handleExport">导出</el-button>
  179. </div>
  180. <!-- 数据表格 -->
  181. <el-table
  182. ref="dataTable"
  183. :data="dataList"
  184. style="width: 100%"
  185. v-loading="loading"
  186. @selection-change="handleSelectionChange"
  187. >
  188. <el-table-column type="selection" width="55"></el-table-column>
  189. <el-table-column type="index" label="序号" width="55" align="center"></el-table-column>
  190. <el-table-column prop="liveName" label="直播间名称" min-width="160" show-overflow-tooltip></el-table-column>
  191. <el-table-column prop="liveType" label="直播类型" width="100" align="center">
  192. <template slot-scope="scope">
  193. <el-tag type="danger" v-if="scope.row.liveType == 1">直播</el-tag>
  194. <el-tag type="success" v-else-if="scope.row.liveType == 2">录播</el-tag>
  195. <el-tag v-else-if="scope.row.liveType == 3">直播回放</el-tag>
  196. <span v-else>-</span>
  197. </template>
  198. </el-table-column>
  199. <el-table-column prop="status" label="状态" width="100" align="center">
  200. <template slot-scope="scope">
  201. <el-tag type="info" v-if="scope.row.status == 1">未开始</el-tag>
  202. <el-tag type="warning" v-else-if="scope.row.status == 2">进行中</el-tag>
  203. <el-tag type="success" v-else-if="scope.row.status == 3">已结束</el-tag>
  204. <span v-else>-</span>
  205. </template>
  206. </el-table-column>
  207. <el-table-column prop="startTime" label="开始时间" width="180" align="center"></el-table-column>
  208. <el-table-column prop="finishTime" label="结束时间" width="180" align="center"></el-table-column>
  209. <el-table-column prop="totalViewers" label="累计观看" width="110" align="center"></el-table-column>
  210. <el-table-column prop="liveViewers" label="直播观看" width="110" align="center"></el-table-column>
  211. <el-table-column prop="playbackViewers" label="回放观看" width="110" align="center"></el-table-column>
  212. <el-table-column prop="liveAvgDuration" label="直播平均时长" width="140" align="center">
  213. <template slot-scope="scope">{{ formatDuration(scope.row.liveAvgDuration) }}</template>
  214. </el-table-column>
  215. <el-table-column prop="playbackAvgDuration" label="回放平均时长" width="140" align="center">
  216. <template slot-scope="scope">{{ formatDuration(scope.row.playbackAvgDuration) }}</template>
  217. </el-table-column>
  218. <el-table-column prop="totalCompletedCourses" label="累计完课" width="110" align="center"></el-table-column>
  219. <el-table-column prop="liveCompletedCourses" label="直播完课" width="110" align="center"></el-table-column>
  220. <el-table-column prop="playbackCompletedCourses" label="回放完课" width="110" align="center"></el-table-column>
  221. <el-table-column prop="gmv" label="GMV" width="120" align="center">
  222. <template slot-scope="scope">¥{{ scope.row.gmv || 0 }}</template>
  223. </el-table-column>
  224. <el-table-column prop="paidUsers" label="付费人数" width="100" align="center"></el-table-column>
  225. <el-table-column prop="paidOrders" label="付费单数" width="100" align="center"></el-table-column>
  226. <el-table-column prop="salesCount" label="销量统计" width="100" align="center"></el-table-column>
  227. <el-table-column label="操作" width="120" fixed="right">
  228. <template slot-scope="scope">
  229. <el-button type="text" size="small" @click="handleViewDetail(scope.row)">查看详情</el-button>
  230. </template>
  231. </el-table-column>
  232. </el-table>
  233. <!-- 分页组件 -->
  234. <pagination
  235. v-show="total > 0"
  236. :total="total"
  237. :page.sync="queryParams.pageNum"
  238. :limit.sync="queryParams.pageSize"
  239. @pagination="getList"
  240. style="margin-top: 20px;"
  241. />
  242. <!-- 自动打标签弹窗 -->
  243. <el-dialog
  244. title="自动打标签"
  245. :visible.sync="tagDialogVisible"
  246. width="600px"
  247. :close-on-click-modal="false"
  248. >
  249. <el-form :model="tagForm" label-width="120px">
  250. <el-form-item label="打标签规则">
  251. <el-checkbox-group v-model="tagForm.rules">
  252. <el-checkbox label="liveComplete">直播完课</el-checkbox>
  253. <el-checkbox label="replayComplete">回放完课</el-checkbox>
  254. <el-checkbox label="pay">付费行为</el-checkbox>
  255. </el-checkbox-group>
  256. </el-form-item>
  257. <el-form-item label="标签名称">
  258. <el-input v-model="tagForm.tagName" placeholder="请输入标签名称"></el-input>
  259. </el-form-item>
  260. <el-form-item label="备注格式">
  261. <el-radio-group v-model="tagForm.remarkFormat">
  262. <el-radio label="time">时间—行为(如:2024-01-01—直播完课)</el-radio>
  263. <el-radio label="simple">仅行为(如:直播完课)</el-radio>
  264. </el-radio-group>
  265. </el-form-item>
  266. </el-form>
  267. <div slot="footer" class="dialog-footer">
  268. <el-button @click="tagDialogVisible = false">取 消</el-button>
  269. <el-button type="primary" @click="confirmAutoTag">确 定</el-button>
  270. </div>
  271. </el-dialog>
  272. <!-- 自动备注弹窗 -->
  273. <el-dialog
  274. title="自动备注"
  275. :visible.sync="remarkDialogVisible"
  276. width="600px"
  277. :close-on-click-modal="false"
  278. >
  279. <el-form :model="remarkForm" label-width="120px">
  280. <el-form-item label="备注规则">
  281. <el-checkbox-group v-model="remarkForm.rules">
  282. <el-checkbox label="liveComplete">直播完课</el-checkbox>
  283. <el-checkbox label="replayComplete">回放完课</el-checkbox>
  284. <el-checkbox label="pay">付费行为</el-checkbox>
  285. </el-checkbox-group>
  286. </el-form-item>
  287. <el-form-item label="备注格式">
  288. <el-radio-group v-model="remarkForm.remarkFormat">
  289. <el-radio label="time">时间—行为(如:2024-01-01—直播完课)</el-radio>
  290. <el-radio label="simple">仅行为(如:直播完课)</el-radio>
  291. </el-radio-group>
  292. </el-form-item>
  293. <el-form-item label="备注位置">
  294. <el-radio-group v-model="remarkForm.position">
  295. <el-radio :label="1">添加在最前面</el-radio>
  296. <el-radio :label="2">添加在最后面</el-radio>
  297. <el-radio :label="3">替换所有备注</el-radio>
  298. </el-radio-group>
  299. </el-form-item>
  300. </el-form>
  301. <div slot="footer" class="dialog-footer">
  302. <el-button @click="remarkDialogVisible = false">取 消</el-button>
  303. <el-button type="primary" @click="confirmAutoRemark">确 定</el-button>
  304. </div>
  305. </el-dialog>
  306. <!-- 详情侧边栏 -->
  307. <el-drawer
  308. title="直播间详情"
  309. :visible.sync="detailDrawerVisible"
  310. direction="rtl"
  311. size="60%"
  312. :before-close="closeDetailDrawer"
  313. >
  314. <div v-if="!showUserDetail" class="detail-content">
  315. <el-card shadow="never" style="margin-bottom: 20px;">
  316. <div slot="header">
  317. <span>总体数据</span>
  318. <el-button style="float: right; padding: 3px 0" type="text" @click="handleViewUserDetail">查看用户详情</el-button>
  319. </div>
  320. <el-row :gutter="20">
  321. <el-col :span="12">
  322. <div class="detail-item">
  323. <span class="detail-label">视频时长:</span>
  324. <span class="detail-value">{{ formatDuration(detailData.videoDuration || 0) }}</span>
  325. </div>
  326. </el-col>
  327. <el-col :span="12">
  328. <div class="detail-item">
  329. <span class="detail-label">累计观看人数:</span>
  330. <span class="detail-value">{{ detailData.totalViewers || 0 }}</span>
  331. </div>
  332. </el-col>
  333. <el-col :span="12">
  334. <div class="detail-item">
  335. <span class="detail-label">累计完课人数:</span>
  336. <span class="detail-value">{{ detailData.totalCompletedCourses || 0 }}</span>
  337. </div>
  338. </el-col>
  339. <el-col :span="12">
  340. <div class="detail-item">
  341. <span class="detail-label">到课完课率:</span>
  342. <span class="detail-value">{{ formatPercent(detailData.totalCompletionRate) }}</span>
  343. </div>
  344. </el-col>
  345. </el-row>
  346. </el-card>
  347. <el-card shadow="never" style="margin-bottom: 20px;">
  348. <div slot="header">直播数据</div>
  349. <el-row :gutter="20">
  350. <el-col :span="12">
  351. <div class="detail-item">
  352. <span class="detail-label">直播观看人数:</span>
  353. <span class="detail-value">{{ detailData.liveViewers || 0 }}</span>
  354. </div>
  355. </el-col>
  356. <el-col :span="12">
  357. <div class="detail-item">
  358. <span class="detail-label">>20分钟人数(直播):</span>
  359. <span class="detail-value">{{ detailData.liveOver20Minutes || 0 }}</span>
  360. </div>
  361. </el-col>
  362. <el-col :span="12">
  363. <div class="detail-item">
  364. <span class="detail-label">>30分钟人数(直播):</span>
  365. <span class="detail-value">{{ detailData.liveOver30Minutes || 0 }}</span>
  366. </div>
  367. </el-col>
  368. <el-col :span="12">
  369. <div class="detail-item">
  370. <span class="detail-label">到课完课率直播(>20分钟):</span>
  371. <span class="detail-value">{{ formatPercent(detailData.liveCompletionRate20) }}</span>
  372. </div>
  373. </el-col>
  374. <el-col :span="12">
  375. <div class="detail-item">
  376. <span class="detail-label">到课完课率直播(>30分钟):</span>
  377. <span class="detail-value">{{ formatPercent(detailData.liveCompletionRate30) }}</span>
  378. </div>
  379. </el-col>
  380. </el-row>
  381. </el-card>
  382. <el-card shadow="never" style="margin-bottom: 20px;">
  383. <div slot="header">回放数据</div>
  384. <el-row :gutter="20">
  385. <el-col :span="12">
  386. <div class="detail-item">
  387. <span class="detail-label">回放观看人数:</span>
  388. <span class="detail-value">{{ detailData.playbackViewers || 0 }}</span>
  389. </div>
  390. </el-col>
  391. <el-col :span="12">
  392. <div class="detail-item">
  393. <span class="detail-label">>20分钟人数(回放):</span>
  394. <span class="detail-value">{{ detailData.playbackOver20Minutes || 0 }}</span>
  395. </div>
  396. </el-col>
  397. <el-col :span="12">
  398. <div class="detail-item">
  399. <span class="detail-label">>30分钟人数(回放):</span>
  400. <span class="detail-value">{{ detailData.playbackOver30Minutes || 0 }}</span>
  401. </div>
  402. </el-col>
  403. <el-col :span="12">
  404. <div class="detail-item">
  405. <span class="detail-label">到课完课率回放(>20分钟):</span>
  406. <span class="detail-value">{{ formatPercent(detailData.playbackCompletionRate20) }}</span>
  407. </div>
  408. </el-col>
  409. <el-col :span="12">
  410. <div class="detail-item">
  411. <span class="detail-label">到课完课率回放(>30分钟):</span>
  412. <span class="detail-value">{{ formatPercent(detailData.playbackCompletionRate30) }}</span>
  413. </div>
  414. </el-col>
  415. </el-row>
  416. </el-card>
  417. <el-card shadow="never" style="margin-bottom: 20px;">
  418. <div slot="header">时长统计</div>
  419. <el-row :gutter="20">
  420. <el-col :span="12">
  421. <div class="detail-item">
  422. <span class="detail-label">直播峰值:</span>
  423. <span class="detail-value">{{ detailData.livePeak || 0 }}</span>
  424. </div>
  425. </el-col>
  426. <el-col :span="12">
  427. <div class="detail-item">
  428. <span class="detail-label">直播平均时长:</span>
  429. <span class="detail-value">{{ formatDuration(detailData.liveAvgDuration || 0) }}</span>
  430. </div>
  431. </el-col>
  432. <el-col :span="12">
  433. <div class="detail-item">
  434. <span class="detail-label">回放平均时长:</span>
  435. <span class="detail-value">{{ formatDuration(detailData.playbackAvgDuration || 0) }}</span>
  436. </div>
  437. </el-col>
  438. <el-col :span="12">
  439. <div class="detail-item">
  440. <span class="detail-label">回放完播率:</span>
  441. <span class="detail-value">{{ formatPercent(detailData.playbackFinishRate) }}</span>
  442. </div>
  443. </el-col>
  444. </el-row>
  445. </el-card>
  446. <el-card shadow="never" style="margin-bottom: 20px;">
  447. <div slot="header">订单数据</div>
  448. <el-row :gutter="20">
  449. <el-col :span="12">
  450. <div class="detail-item">
  451. <span class="detail-label">GMV:</span>
  452. <span class="detail-value">{{ formatMoney(detailData.gmv) }}</span>
  453. </div>
  454. </el-col>
  455. <el-col :span="12">
  456. <div class="detail-item">
  457. <span class="detail-label">付费人数:</span>
  458. <span class="detail-value">{{ detailData.paidUsers || 0 }}</span>
  459. </div>
  460. </el-col>
  461. <el-col :span="12">
  462. <div class="detail-item">
  463. <span class="detail-label">付费单数:</span>
  464. <span class="detail-value">{{ detailData.paidOrders || 0 }}</span>
  465. </div>
  466. </el-col>
  467. <el-col :span="12">
  468. <div class="detail-item">
  469. <span class="detail-label">峰值转化率:</span>
  470. <span class="detail-value">{{ formatPercent(detailData.peakConversionRate) }}</span>
  471. </div>
  472. </el-col>
  473. <el-col :span="12">
  474. <div class="detail-item">
  475. <span class="detail-label">总到课转化率:</span>
  476. <span class="detail-value">{{ formatPercent(detailData.totalViewerConversionRate) }}</span>
  477. </div>
  478. </el-col>
  479. <el-col :span="12">
  480. <div class="detail-item">
  481. <span class="detail-label">30min完课转化率:</span>
  482. <span class="detail-value">{{ formatPercent(detailData.completion30MinConversionRate) }}</span>
  483. </div>
  484. </el-col>
  485. <el-col :span="12">
  486. <div class="detail-item">
  487. <span class="detail-label">峰值R值:</span>
  488. <span class="detail-value">{{ formatMoney(detailData.peakRValue) }}</span>
  489. </div>
  490. </el-col>
  491. <el-col :span="12">
  492. <div class="detail-item">
  493. <span class="detail-label">完课R值:</span>
  494. <span class="detail-value">{{ formatMoney(detailData.completionRValue) }}</span>
  495. </div>
  496. </el-col>
  497. </el-row>
  498. </el-card>
  499. <el-card shadow="never" v-if="detailData.productSalesList && detailData.productSalesList.length > 0">
  500. <div slot="header">单品销量统计</div>
  501. <el-table :data="detailData.productSalesList" border>
  502. <el-table-column prop="productName" label="商品名称" min-width="200"></el-table-column>
  503. <el-table-column prop="salesCount" label="销量" width="100" align="center"></el-table-column>
  504. <el-table-column prop="salesAmount" label="销售额" width="150" align="center">
  505. <template slot-scope="scope">
  506. {{ formatMoney(scope.row.salesAmount) }}
  507. </template>
  508. </el-table-column>
  509. </el-table>
  510. </el-card>
  511. </div>
  512. <!-- 用户详情列表 -->
  513. <div v-else class="user-detail-content">
  514. <el-button type="text" icon="el-icon-arrow-left" @click="showUserDetail = false" style="margin-bottom: 20px;">返回</el-button>
  515. <el-table
  516. :data="userDetailList"
  517. v-loading="userDetailLoading"
  518. border
  519. style="width: 100%"
  520. >
  521. <el-table-column type="index" label="序号" width="60" align="center"></el-table-column>
  522. <el-table-column prop="userName" label="用户名称" min-width="120"></el-table-column>
  523. <el-table-column prop="liveWatchDuration" label="直播观看时长" width="140" align="center">
  524. <template slot-scope="scope">
  525. {{ formatDuration(scope.row.liveWatchDuration || 0) }}
  526. </template>
  527. </el-table-column>
  528. <el-table-column prop="playbackWatchDuration" label="回放观看时长" width="140" align="center">
  529. <template slot-scope="scope">
  530. {{ formatDuration(scope.row.playbackWatchDuration || 0) }}
  531. </template>
  532. </el-table-column>
  533. <el-table-column prop="orderCount" label="订单数" width="100" align="center"></el-table-column>
  534. <el-table-column prop="orderAmount" label="订单金额" width="120" align="center">
  535. <template slot-scope="scope">
  536. {{ formatMoney(scope.row.orderAmount) }}
  537. </template>
  538. </el-table-column>
  539. <el-table-column prop="companyName" label="分公司" min-width="150"></el-table-column>
  540. <el-table-column prop="salesName" label="销售" min-width="120"></el-table-column>
  541. </el-table>
  542. </div>
  543. </el-drawer>
  544. </div>
  545. </template>
  546. <script>
  547. import { listLiveData, exportLiveData, autoTagAndRemark, dashboardData, getLiveDataDetailBySql, getLiveUserDetailListBySql } from "@/api/live/liveData";
  548. import { batchUpdateExternalContactNotes } from "@/api/qw/externalContact";
  549. import { addTag } from "@/api/qw/externalContact";
  550. export default {
  551. name: "LiveData",
  552. data() {
  553. return {
  554. liveId: '',
  555. loading: true,
  556. exportLoading: false,
  557. showSearch: true,
  558. dataList: [],
  559. total: 0,
  560. multipleSelection: [],
  561. allChecked: false,
  562. isIndeterminate: false,
  563. dateRange: [],
  564. // 统计数据
  565. statisticsData: {
  566. gmv: 0,
  567. liveAvgDuration: 0,
  568. liveCompletedCourses: 0,
  569. livePeak: 0,
  570. liveViewers: 0,
  571. paidOrders: 0,
  572. paidUsers: 0,
  573. playbackAvgDuration: 0,
  574. playbackCompletedCourses: 0,
  575. playbackViewers: 0,
  576. salesCount: 0,
  577. totalCompletedCourses: 0,
  578. totalViewers: 1
  579. },
  580. // 完课时长设置
  581. completeWatchTime: 0,
  582. liveCompleteWatchTime: 0,
  583. replayCompleteWatchTime: 0,
  584. // 查询参数
  585. queryParams: {
  586. pageNum: 1,
  587. pageSize: 10,
  588. liveId: null,
  589. liveName: null,
  590. watchType: null,
  591. completeStatus: null,
  592. payStatus: null,
  593. watchDuration: null,
  594. startTime: null,
  595. endTime: null
  596. },
  597. // 打标签弹窗
  598. tagDialogVisible: false,
  599. tagForm: {
  600. rules: [],
  601. tagName: '',
  602. remarkFormat: 'time'
  603. },
  604. // 备注弹窗
  605. remarkDialogVisible: false,
  606. remarkForm: {
  607. rules: [],
  608. remarkFormat: 'time',
  609. position: 1
  610. },
  611. // 详情侧边栏
  612. detailDrawerVisible: false,
  613. currentLiveId: null,
  614. detailData: {},
  615. userDetailList: [],
  616. userDetailLoading: false,
  617. showUserDetail: false
  618. };
  619. },
  620. created() {
  621. this.liveId = this.$route.query.liveId;
  622. this.queryParams.liveId = this.liveId;
  623. this.getList();
  624. },
  625. methods: {
  626. /** 获取统计数据 */
  627. getStatistics() {
  628. if (!this.liveId) return;
  629. dashboardData(this.liveId).then(response => {
  630. if (response.code === 200) {
  631. this.statisticsData = response.data || {};
  632. }
  633. });
  634. },
  635. /** 获取列表数据 */
  636. getList() {
  637. this.loading = true;
  638. // 处理时间范围
  639. if (this.dateRange && this.dateRange.length === 2) {
  640. this.queryParams.startTime = this.dateRange[0];
  641. this.queryParams.endTime = this.dateRange[1];
  642. } else {
  643. this.queryParams.startTime = null;
  644. this.queryParams.endTime = null;
  645. }
  646. listLiveData(this.queryParams).then(response => {
  647. if (response.code === 200) {
  648. this.statisticsData = response.data || {};
  649. this.dataList = response.list || [];
  650. this.total = response.total || 0;
  651. }
  652. this.loading = false;
  653. }).catch(() => {
  654. this.loading = false;
  655. });
  656. },
  657. /** 搜索按钮操作 */
  658. handleQuery() {
  659. this.queryParams.pageNum = 1;
  660. this.getList();
  661. },
  662. /** 重置按钮操作 */
  663. resetQuery() {
  664. this.dateRange = [];
  665. this.$refs.queryForm.resetFields();
  666. this.handleQuery();
  667. },
  668. /** 全选或取消全选 */
  669. toggleSelectAll(val) {
  670. if (val) {
  671. this.toggleSelection(this.dataList);
  672. } else {
  673. this.toggleSelection();
  674. }
  675. },
  676. toggleSelection(rows) {
  677. if (rows) {
  678. rows.forEach(row => {
  679. this.$refs.dataTable.toggleRowSelection(row);
  680. });
  681. } else {
  682. this.$refs.dataTable.clearSelection();
  683. }
  684. },
  685. /** 多选框选中数据 */
  686. handleSelectionChange(val) {
  687. this.multipleSelection = val;
  688. this.allChecked = val.length === this.dataList.length;
  689. this.isIndeterminate = val.length > 0 && val.length < this.dataList.length;
  690. },
  691. /** 导出按钮操作 */
  692. handleExport() {
  693. if (this.dateRange && this.dateRange.length === 2) {
  694. this.queryParams.startTime = this.dateRange[0];
  695. this.queryParams.endTime = this.dateRange[1];
  696. } else {
  697. this.queryParams.startTime = null;
  698. this.queryParams.endTime = null;
  699. }
  700. this.$confirm('是否确认导出所有直播数据?', "警告", {
  701. confirmButtonText: "确定",
  702. cancelButtonText: "取消",
  703. type: "warning"
  704. }).then(() => {
  705. this.exportLoading = true;
  706. return exportLiveData(this.queryParams);
  707. }).then(response => {
  708. if (response.code === 200) {
  709. this.download(response.msg);
  710. }
  711. this.exportLoading = false;
  712. }).catch(() => {
  713. this.exportLoading = false;
  714. });
  715. },
  716. /** 自动打标签 */
  717. // handleAutoTag() {
  718. // if (this.multipleSelection.length === 0) {
  719. // this.$message.warning('请选择要打标签的数据');
  720. // return;
  721. // }
  722. // this.tagDialogVisible = true;
  723. // },
  724. /** 确认自动打标签 */
  725. confirmAutoTag() {
  726. if (this.tagForm.rules.length === 0) {
  727. this.$message.warning('请选择打标签规则');
  728. return;
  729. }
  730. const userIds = this.multipleSelection.map(item => item.userId).filter(id => id);
  731. if (userIds.length === 0) {
  732. this.$message.warning('所选数据中没有有效的用户ID');
  733. return;
  734. }
  735. const data = {
  736. userIds: userIds,
  737. rules: this.tagForm.rules,
  738. tagName: this.tagForm.tagName,
  739. remarkFormat: this.tagForm.remarkFormat,
  740. liveId: this.liveId
  741. };
  742. autoTagAndRemark(data).then(response => {
  743. if (response.code === 200) {
  744. this.$message.success('打标签成功');
  745. this.tagDialogVisible = false;
  746. this.tagForm = {
  747. rules: [],
  748. tagName: '',
  749. remarkFormat: 'time'
  750. };
  751. this.getList();
  752. }
  753. });
  754. },
  755. /** 自动备注 */
  756. // handleAutoRemark() {
  757. // if (this.multipleSelection.length === 0) {
  758. // this.$message.warning('请选择要备注的数据');
  759. // return;
  760. // }
  761. // this.remarkDialogVisible = true;
  762. // },
  763. /** 确认自动备注 */
  764. confirmAutoRemark() {
  765. if (this.remarkForm.rules.length === 0) {
  766. this.$message.warning('请选择备注规则');
  767. return;
  768. }
  769. const userIds = this.multipleSelection.map(item => item.userId).filter(id => id);
  770. if (userIds.length === 0) {
  771. this.$message.warning('所选数据中没有有效的用户ID');
  772. return;
  773. }
  774. // 生成备注内容
  775. let notes = '';
  776. const now = new Date();
  777. const dateStr = now.getFullYear() + '-' +
  778. String(now.getMonth() + 1).padStart(2, '0') + '-' +
  779. String(now.getDate()).padStart(2, '0');
  780. this.remarkForm.rules.forEach((rule, index) => {
  781. let ruleText = '';
  782. if (rule === 'liveComplete') {
  783. ruleText = '直播完课';
  784. } else if (rule === 'replayComplete') {
  785. ruleText = '回放完课';
  786. } else if (rule === 'pay') {
  787. ruleText = '付费行为';
  788. }
  789. if (this.remarkForm.remarkFormat === 'time') {
  790. notes += (index > 0 ? ';' : '') + dateStr + '—' + ruleText;
  791. } else {
  792. notes += (index > 0 ? ';' : '') + ruleText;
  793. }
  794. });
  795. const data = {
  796. userIds: userIds,
  797. notes: notes,
  798. type: this.remarkForm.position,
  799. nameType: 3, // 不添加客户名称
  800. filter: false
  801. };
  802. batchUpdateExternalContactNotes(data).then(response => {
  803. if (response.code === 200) {
  804. this.$message.success('备注成功');
  805. this.remarkDialogVisible = false;
  806. this.remarkForm = {
  807. rules: [],
  808. remarkFormat: 'time',
  809. position: 1
  810. };
  811. this.getList();
  812. }
  813. });
  814. },
  815. /** 查看详情 */
  816. handleViewDetail(row) {
  817. this.currentLiveId = row.liveId;
  818. this.detailDrawerVisible = true;
  819. this.loadDetailData();
  820. },
  821. /** 格式化时长 */
  822. formatDuration(seconds) {
  823. if (!seconds) return '00:00:00';
  824. const hours = Math.floor(seconds / 3600);
  825. const minutes = Math.floor((seconds % 3600) / 60);
  826. const secs = seconds % 60;
  827. return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(secs).padStart(2, '0')}`;
  828. },
  829. /** 更新完课时长设置 */
  830. updateCompleteWatchTime(type) {
  831. // 这里可以调用API保存设置
  832. let watchTime = 0;
  833. if (type === 'total') {
  834. watchTime = this.completeWatchTime;
  835. } else if (type === 'live') {
  836. watchTime = this.liveCompleteWatchTime;
  837. } else if (type === 'replay') {
  838. watchTime = this.replayCompleteWatchTime;
  839. }
  840. // 更新查询参数并重新获取数据
  841. this.queryParams.completeWatchTime = watchTime;
  842. // this.getStatistics();
  843. this.getList();
  844. this.$message.success('设置成功');
  845. },
  846. /** 加载详情数据 */
  847. loadDetailData() {
  848. if (!this.currentLiveId) return;
  849. // 使用SQL方式获取详情数据
  850. getLiveDataDetailBySql(this.currentLiveId).then(response => {
  851. if (response.code === 200) {
  852. this.detailData = response.data || {};
  853. }
  854. });
  855. },
  856. /** 查看用户详情 */
  857. handleViewUserDetail() {
  858. if (!this.currentLiveId) return;
  859. this.showUserDetail = true;
  860. this.userDetailLoading = true;
  861. getLiveUserDetailListBySql(this.currentLiveId).then(response => {
  862. if (response.code === 200) {
  863. this.userDetailList = response.data || [];
  864. }
  865. this.userDetailLoading = false;
  866. }).catch(() => {
  867. this.userDetailLoading = false;
  868. });
  869. },
  870. /** 关闭详情侧边栏 */
  871. closeDetailDrawer() {
  872. this.detailDrawerVisible = false;
  873. this.showUserDetail = false;
  874. this.detailData = {};
  875. this.userDetailList = [];
  876. this.currentLiveId = null;
  877. },
  878. /** 格式化百分比 */
  879. formatPercent(value) {
  880. if (value == null || value === undefined) return '0%';
  881. return (typeof value === 'number' ? value : parseFloat(value)).toFixed(2) + '%';
  882. },
  883. /** 格式化金额 */
  884. formatMoney(value) {
  885. if (value == null || value === undefined) return '¥0.00';
  886. return '¥' + (typeof value === 'number' ? value : parseFloat(value)).toFixed(2);
  887. }
  888. }
  889. };
  890. </script>
  891. <style scoped>
  892. .statistics-card {
  893. margin-bottom: 20px;
  894. }
  895. .statistics-item {
  896. text-align: center;
  897. padding: 15px;
  898. background: #f5f7fa;
  899. border-radius: 4px;
  900. }
  901. .statistics-title {
  902. font-size: 14px;
  903. color: #606266;
  904. margin-bottom: 10px;
  905. display: flex;
  906. align-items: center;
  907. justify-content: center;
  908. }
  909. .statistics-value {
  910. font-size: 24px;
  911. font-weight: bold;
  912. color: #303133;
  913. }
  914. .selection-toolbar {
  915. display: flex;
  916. align-items: center;
  917. margin-bottom: 10px;
  918. padding-left: 10px;
  919. }
  920. .selection-toolbar .el-checkbox {
  921. margin-right: 10px;
  922. }
  923. .live-data-css {
  924. padding-left: 10px;
  925. padding-top: 30px;
  926. }
  927. .detail-content {
  928. padding: 20px;
  929. }
  930. .detail-item {
  931. margin-bottom: 15px;
  932. line-height: 32px;
  933. }
  934. .detail-label {
  935. color: #606266;
  936. font-size: 14px;
  937. }
  938. .detail-value {
  939. color: #303133;
  940. font-size: 14px;
  941. font-weight: bold;
  942. }
  943. .user-detail-content {
  944. padding: 20px;
  945. }
  946. </style>