exerciseDurationDetail.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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="dates">
  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. <!-- @change="changeWeek" -->
  32. <el-date-picker
  33. :clearable="false"
  34. v-model="searchForm.dates"
  35. value-format="yyyy-MM-dd"
  36. :picker-options="{
  37. firstDayOfWeek: 1,
  38. disabledDate(time) {
  39. return time.getTime() >= nowIndex;
  40. }
  41. }"
  42. type="daterange"
  43. style="width: 405px"
  44. range-separator="至"
  45. start-placeholder="开始日期"
  46. end-placeholder="结束日期"
  47. >
  48. </el-date-picker>
  49. </el-form-item>
  50. <el-form-item>
  51. <el-button @click="search" type="danger">搜索</el-button>
  52. <el-button @click="onReSet" type="primary">重置</el-button>
  53. </el-form-item>
  54. </saveform>
  55. <!-- 分组添加柱状图 -->
  56. <el-button
  57. type="primary"
  58. @click="exportQuestion"
  59. style="margin: 0 0 16px"
  60. v-permission="'export/managerDownload/numDetail'"
  61. >导出</el-button
  62. >
  63. <div class="tableWrap">
  64. <el-table
  65. :data="tableList"
  66. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  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 align="center" prop="normalNum" label="会员人数">
  81. <template slot-scope="scope">
  82. <div>{{ scope.row.normalNum }}人</div>
  83. </template>
  84. </el-table-column>
  85. <el-table-column
  86. align="center"
  87. prop="trainStudentNum"
  88. label="练习人数"
  89. >
  90. <template slot-scope="scope">
  91. <div>{{ scope.row.trainStudentNum }}人</div>
  92. </template></el-table-column
  93. >
  94. <el-table-column align="center" prop="trainRate" label="练习率">
  95. <template slot-scope="scope">
  96. <div>{{ scope.row.trainRate }}%</div>
  97. </template>
  98. </el-table-column>
  99. <el-table-column align="center" prop="id" label="≤60分钟">
  100. <template slot-scope="scope">
  101. <div>{{ scope.row.train1 }}人</div>
  102. </template></el-table-column
  103. >
  104. <el-table-column align="center" prop="id" label="60~120分钟">
  105. <template slot-scope="scope">
  106. <div>{{ scope.row.train2 }}人</div>
  107. </template>
  108. </el-table-column>
  109. <el-table-column align="center" prop="id" label="120~240分钟">
  110. <template slot-scope="scope">
  111. <div>{{ scope.row.train3 }}人</div>
  112. </template>
  113. </el-table-column>
  114. <el-table-column align="center" prop="id" label=">240分钟">
  115. <template slot-scope="scope">
  116. <div>{{ scope.row.train4 }}人</div>
  117. </template>
  118. </el-table-column>
  119. <el-table-column align="center" prop="id" label="平均练习时长">
  120. <template slot-scope="scope">
  121. <div>{{ scope.row.avgTrainTime }}分钟</div>
  122. </template>
  123. </el-table-column>
  124. <el-table-column align="center" prop="id" label="练习达标占比">
  125. <template slot-scope="scope">
  126. <div>{{ scope.row.trainStandRate }}%</div>
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. </div>
  131. </div>
  132. </div>
  133. </template>
  134. <script>
  135. import { Export } from "@/utils/downLoadFile";
  136. import saveform from "@/components/save-form";
  137. import dayjs from "dayjs";
  138. import histogram from "v-charts/lib/histogram.common";
  139. import { getNowDateAndMonday, getNowDateAndSunday } from "@/utils/utils";
  140. import { cloudTeacherSumDetail } from "../api";
  141. let nowTime = new Date();
  142. nowTime =
  143. nowTime.getFullYear() +
  144. "-" +
  145. (nowTime.getMonth() + 1) +
  146. "-" +
  147. nowTime.getDate();
  148. export const getTimes = (times, keys = []) => {
  149. if (times && times.length) {
  150. return {
  151. [keys[0] || "start"]: dayjs(times[0]).format("YYYY-MM-DD"),
  152. [keys[1] || "start"]: dayjs(times[1]).format("YYYY-MM-DD")
  153. };
  154. }
  155. return {};
  156. };
  157. export default {
  158. components: { saveform, "ve-histogram": histogram },
  159. name: "helpCategory",
  160. data() {
  161. return {
  162. nowIndex: dayjs(dayjs().format("YYYY-MM-DD")).valueOf(),
  163. searchForm: {
  164. dates: [
  165. dayjs()
  166. .subtract(1, "day")
  167. .format("YYYY-MM-DD"),
  168. dayjs()
  169. .subtract(1, "day")
  170. .format("YYYY-MM-DD")
  171. ],
  172. organId: ""
  173. },
  174. tableList: [],
  175. activeName: "first",
  176. specialList: []
  177. };
  178. },
  179. async mounted() {
  180. const query = this.$route.query;
  181. this.searchForm.organId = query.organId ? Number(query.organId) : "";
  182. await this.$store.dispatch("setBranchs");
  183. const arr = [36, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 54, 56];
  184. this.specialList = this.selects.branchs.filter(item => {
  185. return arr.indexOf(item.id) == -1;
  186. });
  187. // this.searchForm.dates.push(getNowDateAndMonday(nowTime));
  188. // this.searchForm.dates.push(getNowDateAndSunday(nowTime));
  189. this.getList();
  190. },
  191. methods: {
  192. exportQuestion() {
  193. const { dates, organId } = this.searchForm;
  194. Export(
  195. this,
  196. {
  197. url: "/api-web/export/managerDownload",
  198. fileName: "云教练练习时长.xls",
  199. method: "post",
  200. params: {
  201. exportEnum: "EXPORT_CLOUD_TEACHER_SUM_DETAIL",
  202. ...getTimes(dates, ["startDate", "endDate"]),
  203. organId
  204. }
  205. },
  206. "您确定导出云教练练习时长?"
  207. );
  208. },
  209. search() {
  210. this.$refs.searchForm.validate(valid => {
  211. this.pageInfo = {
  212. ...this.pageInfo,
  213. page: 1
  214. };
  215. this.getList();
  216. });
  217. },
  218. onCancel() {
  219. this.$store.dispatch("delVisitedViews", this.$route);
  220. this.$router.push({
  221. path: "/cloudDate?tabrouter=exerciseDuration"
  222. });
  223. },
  224. onReSet() {
  225. this.pageInfo = {
  226. ...this.pageInfo,
  227. page: 1
  228. };
  229. this.$refs.searchForm.resetFields();
  230. // this.searchForm.dates.push(getNowDateAndMonday(nowTime));
  231. // this.searchForm.dates.push(getNowDateAndSunday(nowTime));
  232. this.getList();
  233. },
  234. getDefaultTime() {
  235. const dayjs = this.$helpers.dayjs;
  236. let nowDate = dayjs(new Date()).format("YYYY-MM-DD");
  237. let lastWeek = dayjs(nowDate)
  238. .subtract(1, "week")
  239. .format("YYYY-MM-DD");
  240. this.searchForm.dates = [
  241. getNowDateAndMonday(lastWeek),
  242. getNowDateAndSunday(nowDate)
  243. ];
  244. },
  245. changeWeek(val) {
  246. if (val) {
  247. // this.searchForm.dates = [
  248. // getNowDateAndMonday(val[0]),
  249. // getNowDateAndSunday(val[1])
  250. // ];
  251. } else {
  252. this.getDefaultTime();
  253. }
  254. },
  255. async getList() {
  256. // cloudTeacherSumDetail
  257. try {
  258. const { dates, organId } = this.searchForm;
  259. let params = {
  260. ...getTimes(dates, ["startDate", "endDate"]),
  261. organId
  262. };
  263. const res = await cloudTeacherSumDetail({
  264. page: 1,
  265. rows: 10,
  266. ...params
  267. });
  268. this.tableList = [];
  269. this.tableList = res.data.rows || [];
  270. } catch {}
  271. }
  272. }
  273. };
  274. </script>
  275. <style lang="scss" scoped>
  276. ::v-deep .el-date-editor.el-input {
  277. width: 100% !important;
  278. }
  279. ::v-deep .el-select {
  280. width: 100% !important;
  281. }
  282. ::v-deep .el-table .cell {
  283. display: -webkit-box;
  284. overflow: hidden;
  285. max-height: 45px;
  286. text-overflow: ellipsis;
  287. -webkit-line-clamp: 3;
  288. -webkit-box-orient: vertical;
  289. }
  290. ::v-deep .el-dialog__body {
  291. padding: 10px 20px;
  292. }
  293. .newBand {
  294. display: inline-block;
  295. }
  296. ::v-deep .el-tabs__active-bar {
  297. background-color: transparent !important;
  298. }
  299. ::v-deep.el-tabs__nav-wrap {
  300. &:after {
  301. background-color: transparent !important;
  302. }
  303. }
  304. /*去掉切换时el-tab-pane底部的蓝色下划线*/
  305. ::v-deep .el-tabs__nav-wrap::after {
  306. background-color: transparent !important;
  307. }
  308. /*去掉tabs底部的下划线*/
  309. </style>