exerciseDurationDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <el-page-header @back="onCancel" content="观看时长详情"></el-page-header>
  5. </h2>
  6. <div class="m-core">
  7. <!-- 搜索标题 -->
  8. <saveform
  9. :inline="true"
  10. ref="searchForm"
  11. class="searchForm"
  12. :model.sync="searchForm"
  13. >
  14. <el-form-item prop="organId">
  15. <el-select
  16. class="multiple"
  17. v-model.trim="searchForm.organId"
  18. filterable
  19. clearable
  20. placeholder="请选择分部"
  21. >
  22. <el-option
  23. v-for="(item, index) in selects.branchs"
  24. :key="index"
  25. :label="item.name"
  26. :value="item.id"
  27. ></el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item prop="dates">
  31. <el-date-picker
  32. :clearable="false"
  33. v-model="searchForm.dates"
  34. value-format="yyyy-MM-dd"
  35. :picker-options="{
  36. firstDayOfWeek: 1,
  37. disabledDate(time) {
  38. return time.getTime() >= nowIndex;
  39. }
  40. }"
  41. type="daterange"
  42. style="width: 405px"
  43. range-separator="至"
  44. start-placeholder="开始日期"
  45. end-placeholder="结束日期"
  46. >
  47. </el-date-picker>
  48. </el-form-item>
  49. <el-form-item>
  50. <el-button @click="search" type="danger">搜索</el-button>
  51. <el-button @click="onReSet" type="primary">重置</el-button>
  52. </el-form-item>
  53. </saveform>
  54. <!-- 分组添加柱状图 -->
  55. <el-button
  56. type="primary"
  57. @click="exportQuestion"
  58. style="margin: 0 0 16px"
  59. v-permission="'studentCoursewarePlayRecord/exportStatDetailPage'"
  60. >导出</el-button
  61. >
  62. <div class="tableWrap">
  63. <el-table
  64. :data="tableList"
  65. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  66. @sort-change="onSortChange"
  67. >
  68. <!-- <el-table-column width="120px" align="center" prop="id" label="排名">
  69. <template slot-scope="scope">
  70. <div>
  71. {{ scope.$index + 1 }}
  72. </div>
  73. </template>
  74. </el-table-column> -->
  75. <el-table-column
  76. align="center"
  77. prop="teacherName"
  78. label="声部老师"
  79. ></el-table-column>
  80. <el-table-column
  81. align="center"
  82. prop="memberNum"
  83. sortable="custom"
  84. label="会员人数"
  85. width="100px"
  86. >
  87. <template slot-scope="scope">
  88. <div>{{ scope.row.memberNum }}人</div>
  89. </template>
  90. </el-table-column>
  91. <el-table-column
  92. align="center"
  93. prop="noPlayNum"
  94. sortable="custom"
  95. label="无练习人数"
  96. width="120px"
  97. >
  98. <template slot-scope="scope">
  99. <div>{{ scope.row.noPlayNum }}人</div>
  100. </template></el-table-column
  101. >
  102. <el-table-column
  103. align="center"
  104. prop="playTimeLess10"
  105. sortable="custom"
  106. label="0-10分钟"
  107. width="120px"
  108. >
  109. <template slot-scope="scope">
  110. <div>{{ scope.row.playTimeLess10 }}人</div>
  111. </template>
  112. </el-table-column>
  113. <el-table-column
  114. align="center"
  115. prop="playTimeLess60"
  116. sortable="custom"
  117. label="10-60分钟"
  118. width="120px"
  119. >
  120. <template slot-scope="scope">
  121. <div>{{ scope.row.playTimeLess60 }}人</div>
  122. </template></el-table-column
  123. >
  124. <el-table-column
  125. align="center"
  126. prop="playTimeLess120"
  127. sortable="custom"
  128. label="60-120分钟"
  129. width="120px"
  130. >
  131. <template slot-scope="scope">
  132. <div>{{ scope.row.playTimeLess120 }}人</div>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. align="center"
  137. prop="playTimeLess240"
  138. sortable="custom"
  139. label="120-240分钟"
  140. width="130px"
  141. >
  142. <template slot-scope="scope">
  143. <div>{{ scope.row.playTimeLess240 }}人</div>
  144. </template>
  145. </el-table-column>
  146. <el-table-column
  147. align="center"
  148. prop="playTimeRather240"
  149. sortable="custom"
  150. label=">240分钟"
  151. width="120px"
  152. >
  153. <template slot-scope="scope">
  154. <div>{{ scope.row.playTimeRather240 }}人</div>
  155. </template>
  156. </el-table-column>
  157. <el-table-column
  158. align="center"
  159. prop="avgPlayTime"
  160. sortable="custom"
  161. label="平均时长"
  162. width="100px"
  163. >
  164. <template slot-scope="scope">
  165. <div>{{ scope.row.avgPlayTime }}分钟</div>
  166. </template>
  167. </el-table-column>
  168. </el-table>
  169. <pagination
  170. sync
  171. :total.sync="pageInfo.total"
  172. :page.sync="pageInfo.page"
  173. :limit.sync="pageInfo.limit"
  174. :page-sizes="pageInfo.page_size"
  175. @pagination="getList"
  176. />
  177. </div>
  178. </div>
  179. </div>
  180. </template>
  181. <script>
  182. import { Export } from "@/utils/downLoadFile";
  183. import pagination from "@/components/Pagination/index";
  184. import saveform from "@/components/save-form";
  185. import dayjs from "dayjs";
  186. import histogram from "v-charts/lib/histogram.common";
  187. import { getNowDateAndMonday, getNowDateAndSunday } from "@/utils/utils";
  188. import { api_studentCoursewarePlayRecordDetail } from "../api";
  189. import { getTimeFormat } from "@/utils";
  190. let nowTime = new Date();
  191. nowTime =
  192. nowTime.getFullYear() +
  193. "-" +
  194. (nowTime.getMonth() + 1) +
  195. "-" +
  196. nowTime.getDate();
  197. // export const getTimes = (times, keys = []) => {
  198. // if (times && times.length) {
  199. // return {
  200. // [keys[0] || "start"]: dayjs(times[0]).format("YYYY-MM-DD"),
  201. // [keys[1] || "start"]: dayjs(times[1]).format("YYYY-MM-DD")
  202. // };
  203. // }
  204. // return {};
  205. // };
  206. export default {
  207. components: { saveform, "ve-histogram": histogram, pagination },
  208. name: "helpCategory",
  209. data() {
  210. return {
  211. nowIndex: dayjs(dayjs().format("YYYY-MM-DD")).valueOf(),
  212. searchForm: {
  213. dates: [
  214. dayjs()
  215. .subtract(1, "day")
  216. .format("YYYY-MM-DD"),
  217. dayjs()
  218. .subtract(1, "day")
  219. .format("YYYY-MM-DD")
  220. ],
  221. organId: "",
  222. sort: null,
  223. asc: null
  224. },
  225. tableList: [],
  226. activeName: "first",
  227. // specialList: [],
  228. pageInfo: {
  229. // 分页规则
  230. limit: 10, // 限制显示条数
  231. page: 1, // 当前页
  232. total: 0, // 总条数
  233. page_size: [10, 20, 40, 50] // 选择限制显示条数
  234. }
  235. };
  236. },
  237. async mounted() {
  238. const query = this.$route.query;
  239. this.searchForm.organId = query.organId ? Number(query.organId) : "";
  240. this.searchForm.dates = query.dates
  241. ? JSON.parse(query.dates)
  242. : [
  243. dayjs()
  244. .subtract(1, "day")
  245. .format("YYYY-MM-DD"),
  246. dayjs()
  247. .subtract(1, "day")
  248. .format("YYYY-MM-DD")
  249. ];
  250. await this.$store.dispatch("setBranchs");
  251. // const arr = [36, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 54, 56];
  252. // this.specialList = this.selects.branchs.filter(item => {
  253. // return arr.indexOf(item.id) == -1;
  254. // });
  255. // this.searchForm.dates.push(getNowDateAndMonday(nowTime));
  256. // this.searchForm.dates.push(getNowDateAndSunday(nowTime));
  257. this.getList();
  258. },
  259. methods: {
  260. onSortChange(val) {
  261. const template = {
  262. memberNum: 1,
  263. noPlayNum: 2,
  264. playTimeLess10: 3,
  265. playTimeLess60: 4,
  266. playTimeLess120: 5,
  267. playTimeLess240: 6,
  268. playTimeRather240: 7,
  269. avgPlayTime: 8
  270. };
  271. this.searchForm.sort = template[val.prop];
  272. if (val.order === "ascending") {
  273. this.searchForm.asc = true;
  274. } else if (val.order === "descending") {
  275. this.searchForm.asc = false;
  276. } else {
  277. this.searchForm.asc = null;
  278. this.searchForm.sort = null;
  279. }
  280. this.getList();
  281. },
  282. exportQuestion() {
  283. const { dates, organId, asc, sort } = this.searchForm;
  284. Export(
  285. this,
  286. {
  287. url: "/api-web/studentCoursewarePlayRecord/exportStatDetailPage",
  288. fileName: "云练习练习时长.xls",
  289. method: "post",
  290. params: {
  291. exportEnum: "VIDEO_PLAY_DETAIL_STAT",
  292. queryInfo: {
  293. ...getTimeFormat(dates, ["startTime", "endTime"]),
  294. organizationId: organId,
  295. asc,
  296. sort
  297. }
  298. }
  299. },
  300. "您确定导出云练习练习时长?"
  301. );
  302. },
  303. search() {
  304. this.$refs.searchForm.validate(valid => {
  305. this.pageInfo = {
  306. ...this.pageInfo,
  307. page: 1
  308. };
  309. this.getList();
  310. });
  311. },
  312. onCancel() {
  313. this.$store.dispatch("delVisitedViews", this.$route);
  314. this.$router.push({
  315. path: "/coursewareDate"
  316. });
  317. },
  318. onReSet() {
  319. this.pageInfo = {
  320. ...this.pageInfo,
  321. page: 1
  322. };
  323. this.$refs.searchForm.resetFields();
  324. this.getList();
  325. },
  326. getDefaultTime() {
  327. const dayjs = this.$helpers.dayjs;
  328. let nowDate = dayjs(new Date()).format("YYYY-MM-DD");
  329. let lastWeek = dayjs(nowDate)
  330. .subtract(1, "week")
  331. .format("YYYY-MM-DD");
  332. this.searchForm.dates = [
  333. getNowDateAndMonday(lastWeek),
  334. getNowDateAndSunday(nowDate)
  335. ];
  336. },
  337. changeWeek(val) {
  338. if (val) {
  339. // this.searchForm.dates = [
  340. // getNowDateAndMonday(val[0]),
  341. // getNowDateAndSunday(val[1])
  342. // ];
  343. } else {
  344. this.getDefaultTime();
  345. }
  346. },
  347. async getList() {
  348. // api_studentCoursewarePlayRecordDetail
  349. try {
  350. const { dates, organId, sort, asc } = this.searchForm;
  351. let params = {
  352. sort,
  353. asc,
  354. ...getTimeFormat(dates, ["startTime", "endTime"]),
  355. organId
  356. };
  357. const res = await api_studentCoursewarePlayRecordDetail({
  358. page: this.pageInfo.page,
  359. rows: this.pageInfo.limit,
  360. ...params
  361. });
  362. this.tableList = [];
  363. this.tableList = res.data.rows || [];
  364. this.pageInfo.total = res.data.total;
  365. } catch {}
  366. }
  367. }
  368. };
  369. </script>
  370. <style lang="scss" scoped>
  371. ::v-deep .el-date-editor.el-input {
  372. width: 100% !important;
  373. }
  374. ::v-deep .el-select {
  375. width: 100% !important;
  376. }
  377. ::v-deep .el-table .cell {
  378. display: -webkit-box;
  379. overflow: hidden;
  380. max-height: 45px;
  381. text-overflow: ellipsis;
  382. -webkit-line-clamp: 3;
  383. -webkit-box-orient: vertical;
  384. }
  385. ::v-deep .el-dialog__body {
  386. padding: 10px 20px;
  387. }
  388. .newBand {
  389. display: inline-block;
  390. }
  391. ::v-deep .el-tabs__active-bar {
  392. background-color: transparent !important;
  393. }
  394. ::v-deep.el-tabs__nav-wrap {
  395. &:after {
  396. background-color: transparent !important;
  397. }
  398. }
  399. /*去掉切换时el-tab-pane底部的蓝色下划线*/
  400. ::v-deep .el-tabs__nav-wrap::after {
  401. background-color: transparent !important;
  402. }
  403. /*去掉tabs底部的下划线*/
  404. </style>