This commit is contained in:
zhaoxinyu
2024-07-03 14:53:24 +08:00
parent 6c65eb929c
commit e67b63616e
9 changed files with 293 additions and 114 deletions
@@ -1,5 +1,7 @@
package io.v.nutz.mobile.trainEducation; package io.v.nutz.mobile.trainEducation;
import cn.hutool.core.date.DateUtil;
import cn.wizzer.framework.base.Result;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.service.BaseService; import io.v.nutz.base.service.BaseService;
import io.v.nutz.trainEducation.models.TrainEduVideo; import io.v.nutz.trainEducation.models.TrainEduVideo;
@@ -20,6 +22,8 @@ import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param; import org.nutz.mvc.annotation.Param;
import java.util.Date;
@IocBean @IocBean
@At("/mobile/trainEducation") @At("/mobile/trainEducation")
@Ok("json:full") @Ok("json:full")
@@ -70,6 +74,7 @@ public class MTrainEducationController {
$condition $condition
"""); """);
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
cnd.and("tea.disabled", "=", 0);
cnd.and(new Static("tea.id = (select albumId from train_edu_video order by createdAt desc LIMIT 0,1)")); cnd.and(new Static("tea.id = (select albumId from train_edu_video order by createdAt desc LIMIT 0,1)"));
sql.setCondition(cnd); sql.setCondition(cnd);
sql.setCallback(Sqls.callback.map()); sql.setCallback(Sqls.callback.map());
@@ -103,6 +108,7 @@ public class MTrainEducationController {
$condition $condition
"""); """);
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
cnd.and("tea.disabled","=",0);
cnd.andEX("tea.typeId", "=", typeId); cnd.andEX("tea.typeId", "=", typeId);
cnd.groupBy("tea.id"); cnd.groupBy("tea.id");
sql.setCondition(cnd); sql.setCondition(cnd);
@@ -182,28 +188,40 @@ public class MTrainEducationController {
@Param(value = "albumId", required = false) String albumId, @Param(value = "albumId", required = false) String albumId,
@Param(value = "currentTime", required = false) long currentTime) { @Param(value = "currentTime", required = false) long currentTime) {
String userId = (String) ShiroUtil.getPrincipalProperty("id"); String userId = (String) ShiroUtil.getPrincipalProperty("id");
TrainEduVideo video = dao.fetch(TrainEduVideo.class, Cnd.where("id", "=", videoId)); TrainEduVideo video = dao.fetch(TrainEduVideo.class, videoId);
TrainEduVideoWatchRecord thisVideoRecord = dao.fetch(TrainEduVideoWatchRecord.class, Cnd.where("userId", "=", userId).and("videoId", "=", videoId)); // if (video.getEveryDayMaxWatchNum() != null && video.getEveryDayMaxWatchNum() > 0) {
// //限制了每天的观看次数
// //查询今天的观看次数
// int count = dao.count(TrainEduVideoWatchRecord.class, Cnd.where("userId", "=", userId).and("videoId", "=", videoId).and("watchTime", "=", DateUtil.today()));
// if (count == video.getEveryDayMaxWatchNum()) {
// return Result.error("每天最多只能打卡学习" + video.getEveryDayMaxWatchNum() + "次,明天再来吧!");
// }
// }
if(Lang.isNotEmpty(thisVideoRecord) && thisVideoRecord.getFinish()){ //继续判断是否有未看完的记录
//已看完的就不要更改了 Cnd cnd = Cnd.where("userId", "=", userId).and("videoId", "=", videoId).and("finish", "=", 0);
return null; if (video.getEveryDayMaxWatchNum() != null && video.getEveryDayMaxWatchNum() > 0) {
cnd.and("watchTime", "=", DateUtil.today());
} }
if (Lang.isEmpty(thisVideoRecord)) { TrainEduVideoWatchRecord notWatchFinishRecord = dao.fetch(TrainEduVideoWatchRecord.class, cnd);
if (Lang.isNotEmpty(notWatchFinishRecord)) {
//做更新
notWatchFinishRecord.setFinish(video.getFileDuration() == currentTime);
notWatchFinishRecord.setWatchDuration(currentTime);
dao.update(notWatchFinishRecord, "finish|watchDuration");
} else {
//新插入一条
TrainEduVideoWatchRecord videoWatchRecord = new TrainEduVideoWatchRecord(); TrainEduVideoWatchRecord videoWatchRecord = new TrainEduVideoWatchRecord();
videoWatchRecord.setVideoId(videoId); videoWatchRecord.setVideoId(videoId);
videoWatchRecord.setWatchDuration(currentTime); videoWatchRecord.setWatchDuration(currentTime);
videoWatchRecord.setAlbumId(albumId); videoWatchRecord.setAlbumId(albumId);
videoWatchRecord.setUserId((String) ShiroUtil.getPrincipalProperty("id")); videoWatchRecord.setUserId((String) ShiroUtil.getPrincipalProperty("id"));
videoWatchRecord.setFinish(video.getFileDuration() == currentTime); videoWatchRecord.setFinish(video.getFileDuration() == currentTime);
videoWatchRecord.setWatchTime(new Date());
dao.insert(videoWatchRecord); dao.insert(videoWatchRecord);
} else {
Chain updateChain = Chain.make("watchDuration", currentTime);
updateChain.add("finish", video.getFileDuration() == currentTime ? 1 : 0);
Cnd cnd = Cnd.where("userId", "=", userId).and("videoId", "=", videoId);
dao.update(TrainEduVideoWatchRecord.class, updateChain, cnd);
} }
return null; return null;
} }
@@ -1,7 +1,7 @@
package io.v.nutz.trainEducation.controller.statistics; package io.v.nutz.trainEducation.controller.statistics;
import cn.wizzer.framework.page.Pagination;
import io.v.nutz.annontation.ViReturn; import io.v.nutz.annontation.ViReturn;
import io.v.nutz.base.page.Pagination;
import io.v.nutz.base.service.BaseService; import io.v.nutz.base.service.BaseService;
import io.v.nutz.base.utils.Vi; import io.v.nutz.base.utils.Vi;
import io.v.nutz.modules.models.PageForm; import io.v.nutz.modules.models.PageForm;
@@ -12,11 +12,13 @@ import org.nutz.dao.Cnd;
import org.nutz.dao.Dao; import org.nutz.dao.Dao;
import org.nutz.dao.Sqls; import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql; import org.nutz.dao.sql.Sql;
import org.nutz.dao.util.cri.Static;
import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At; import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param; import org.nutz.mvc.annotation.Param;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
@@ -44,26 +46,53 @@ public class TrainEduStatisticsVideoController {
@At @At
@ViReturn @ViReturn
@RequiresPermissions("trainEdu.statistics.video") @RequiresPermissions("trainEdu.statistics.video")
public Object pageData() { public Object pageData(String albumId, PageForm pageForm) {
// Sql sql = Sqls.create("""
// SELECT
// tea.*,
// tet.typeName,
// ( SELECT sum( fileDuration ) FROM train_edu_video WHERE albumId = tea.id ) AS sumDuration,
// ( SELECT count( DISTINCT ( userid )) FROM train_edu_video_watch_record WHERE albumId = tea.id ) AS studyNum
// FROM
// train_edu_album tea
// LEFT JOIN train_edu_type tet ON tet.id = tea.typeId\s
// $condition
// """);
// Cnd cnd = Cnd.NEW();
// if (!ShiroUtil.hasAnyRoles("sysadmin, A06")) {
// cnd.and("tea.createType", "=", 1).and("tea.unionId", "=", Vi.getUnionId());
// }
// sql.setCondition(cnd);
// List list = baseService.listMap(sql);
// Pagination pagination = new Pagination();
// pagination.setList(list);
// return pagination;
Sql sql = Sqls.create(""" Sql sql = Sqls.create("""
SELECT SELECT
tea.*, u.username,
tet.typeName, u.loginname,
( SELECT sum( fileDuration ) FROM train_edu_video WHERE albumId = tea.id ) AS sumDuration, u.unitname,
( SELECT count( DISTINCT ( userid )) FROM train_edu_video_watch_record WHERE albumId = tea.id ) AS studyNum u.unionname,
(
SELECT
SUM(IF( cnt > 2, 2, cnt )) AS count
FROM
( SELECT watchTime, COUNT( 1 ) AS cnt FROM train_edu_video_watch_record where userId = tevwr.userId and albumId = tevwr.albumId GROUP BY watchTime ) AS subquery
) as watchCount
FROM FROM
train_edu_album tea `train_edu_video_watch_record` tevwr
LEFT JOIN train_edu_type tet ON tet.id = tea.typeId\s LEFT JOIN train_edu_album tea on tea.id = tevwr.albumId
LEFT JOIN `user` u ON u.id = tevwr.userId
$condition $condition
"""); """);
Cnd cnd = Cnd.NEW(); Cnd cnd = Cnd.NEW();
if(!ShiroUtil.hasAnyRoles("sysadmin, A06")) { cnd.and("tevwr.albumId", "=", albumId);
cnd.and("tea.createType", "=", 1).and("tea.unionId", "=", Vi.getUnionId()); cnd.and(new Static("IF(tea.createType = 1, u.unionId = tea.unionId , 1=1)"));
} cnd.groupBy("tevwr.userId");
sql.setCondition(cnd); sql.setCondition(cnd);
List list = baseService.listMap(sql); Pagination pagination = baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
Pagination pagination = new Pagination();
pagination.setList(list);
return pagination; return pagination;
} }
@@ -86,7 +115,13 @@ public class TrainEduStatisticsVideoController {
u.loginname, u.loginname,
u.unitname, u.unitname,
u.unionname, u.unionname,
sum( tevwr.watchDuration ) AS studyDuration (
SELECT
SUM(IF( cnt > 2, 2, cnt )) AS count
FROM
( SELECT watchTime, COUNT( 1 ) AS cnt FROM train_edu_video_watch_record where userId = tevwr.userId and albumId = tevwr.albumId GROUP BY watchTime ) AS subquery
) as watchCount
FROM FROM
`train_edu_video_watch_record` tevwr `train_edu_video_watch_record` tevwr
LEFT JOIN train_edu_album tea on tea.id = tevwr.albumId LEFT JOIN train_edu_album tea on tea.id = tevwr.albumId
@@ -57,4 +57,9 @@ public class TrainEduAlbum {
@Comment("单位id") @Comment("单位id")
private String unitId; private String unitId;
@Column
@ColDefine(type = ColType.BOOLEAN)
@Comment("是否禁用")
private Boolean disabled;
} }
@@ -9,6 +9,7 @@ import org.nutz.dao.interceptor.annotation.PrevInsert;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Table @Table
@Data @Data
@Comment("教育培训视频")
public class TrainEduVideo extends BaseModel { public class TrainEduVideo extends BaseModel {
@Name @Name
@@ -43,12 +44,12 @@ public class TrainEduVideo extends BaseModel {
@Column @Column
@ColDefine(type = ColType.INT) @ColDefine(type = ColType.INT)
@Comment("排序编号") @Comment("排序编号")
private int sortNo; private Integer sortNo;
@Column @Column
@Comment("是否禁用") @Comment("是否禁用")
@ColDefine(type = ColType.BOOLEAN) @ColDefine(type = ColType.BOOLEAN)
private boolean disabled; private Boolean disabled;
@Column @Column
@Comment("视频大小") @Comment("视频大小")
@@ -59,4 +60,9 @@ public class TrainEduVideo extends BaseModel {
@Comment("视频时常") @Comment("视频时常")
private Long fileDuration; private Long fileDuration;
@Column
@Comment("每天最多观看次数")
@ColDefine(type = ColType.INT)
private Integer everyDayMaxWatchNum;
} }
@@ -1,14 +1,25 @@
package io.v.nutz.trainEducation.models; package io.v.nutz.trainEducation.models;
import io.v.nutz.base.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.entity.annotation.*; import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import java.util.Date;
/** /**
* 视频播放记录 * 视频播放记录
*/ */
@EqualsAndHashCode(callSuper = true)
@Table @Table
@Data @Data
public class TrainEduVideoWatchRecord { @Comment("教育培训学习记录")
public class TrainEduVideoWatchRecord extends BaseModel {
@Name
@PrevInsert(uu32 = true)
private String id;
@Column @Column
@ColDefine(type = ColType.VARCHAR, width = 32) @ColDefine(type = ColType.VARCHAR, width = 32)
@@ -34,4 +45,9 @@ public class TrainEduVideoWatchRecord {
@Comment("是否看完") @Comment("是否看完")
private Boolean finish; private Boolean finish;
@Column
@ColDefine(type = ColType.DATE)
@Comment("观看日期")
private Date watchTime;
} }
@@ -75,6 +75,10 @@ layout("/mobile/platform.html"){
word-break: break-all; word-break: break-all;
} }
.myWatchRecord{
font-size: 14px;
}
</style> </style>
@@ -135,7 +139,7 @@ layout("/mobile/platform.html"){
</span> </span>
</template> </template>
<template #label> <template #label>
{{getWatchStatus(o)}} <!-- {{getWatchStatus(o)}}-->
</template> </template>
<template> <template>
@@ -143,10 +147,45 @@ layout("/mobile/platform.html"){
</van-cell> </van-cell>
</van-cell-group> </van-cell-group>
</van-tab> </van-tab>
<van-tab title="学习记录">
<div style="height: 5px;background-color: #f6f7f9"></div>
<van-cell-group class="video-list">
<van-cell v-for="(o,i) in videoList" :key="o.id" @click="playVideo(o)">
<template #title>
<van-tag plain type="primary" style="margin-right: 10px">视频</van-tag>
<span style="margin-right: 10px">
{{i+1}}.
</span>
<span>
{{o.title}}
</span>
</template>
<template #label>
<div v-if="o.everyDayMaxWatchNum && o.everyDayMaxWatchNum>0" style="padding: 10px 0;color: #0a84ff;white-space: normal">
本视频在活动结束时每天最多只会统计
<span style="color: #0a84ff;font-weight: bold">{{o.everyDayMaxWatchNum}}</span>
次完整观看记录,您可以无限制的观看。
</div>
<div v-for="(v,k) in Object.groupBy(watchRecordList,v=>v.watchTime)" :key="k" class="myWatchRecord">
<div style="display: flex;justify-content: space-between">
<div>
{{moment(k).format('YYYY年MM月DD日')}}
</div>
<div style="color: #000000;">
观看次数
<span style="font-weight: bold">{{v.length}}</span>
</div>
</div>
</div>
</template>
</van-cell>
</van-cell-group>
</van-tab>
</van-tabs> </van-tabs>
<div class="bottom-wrap"> <div class="bottom-wrap" v-show="isPlay">
<van-button type="danger" block @click="endLearn">结束本次学习</van-button> <van-button type="info" block @click="endLearn">上传学习记录</van-button>
</div> </div>
</div> </div>
@@ -176,6 +215,9 @@ layout("/mobile/platform.html"){
} }
}, },
computed: {},
methods: { methods: {
async getVideoInfo() { async getVideoInfo() {
const {data} = await $.get('/mobile/trainEducation/getVideoList', {albumId: this.albumId}) const {data} = await $.get('/mobile/trainEducation/getVideoList', {albumId: this.albumId})
@@ -197,7 +239,6 @@ layout("/mobile/platform.html"){
return return
} }
this.currentVideo = o this.currentVideo = o
const playVideo_ = (time = 0) => { const playVideo_ = (time = 0) => {
@@ -223,9 +264,10 @@ layout("/mobile/platform.html"){
const v = this.watchRecordList.find(v => v.videoId === o.id) const v = this.watchRecordList.find(v => v.videoId === o.id)
if (v && v.finish) { if (v && v.finish) {
this.$modal.confirm('本视频您已学习完成,是否重新观看,不会影响到完成的学习记录').then(() => { playVideo_(0)
playVideo_(0) // this.$modal.confirm('本视频您已学习完成,是否重新观看,不会影响到完成的学习记录').then(() => {
}) // playVideo_(0)
// })
} else if (v && !v.finish) { } else if (v && !v.finish) {
playVideo_(v.watchDuration) playVideo_(v.watchDuration)
} else { } else {
@@ -235,10 +277,10 @@ layout("/mobile/platform.html"){
playEnd() { playEnd() {
this.player.on('ended', async () => { this.player.on('ended', async () => {
const v = this.watchRecordList.find(v => v.videoId === this.currentVideo.id) // const v = this.watchRecordList.find(v => v.videoId === this.currentVideo.id)
if (v.finish) { // if (v.finish) {
return // return
} // }
const loading = this.$toast.loading({ const loading = this.$toast.loading({
duration: 0, duration: 0,
@@ -253,14 +295,6 @@ layout("/mobile/platform.html"){
setTimeout(() => { setTimeout(() => {
loading.clear() loading.clear()
}, 2000) }, 2000)
// this.addWatchRecord()
// this.getMyWatchRecord()
// const currentIndex = this.videoList.findIndex(v => v.id === this.currentVideo.id)
// const nextVideo = this.videoList[currentIndex + 1]
// if (nextVideo) {
// this.playVideo(nextVideo)
// }
}) })
}, },
@@ -272,19 +306,23 @@ layout("/mobile/platform.html"){
albumId: this.currentVideo.albumId albumId: this.currentVideo.albumId
} }
const resp = await $.post('/mobile/trainEducation/addWatchRecord', params) const resp = await $.post('/mobile/trainEducation/addWatchRecord', params)
this.getMyWatchRecord() if (resp.code === 0) {
return resp this.getMyWatchRecord()
return resp
} else {
this.$modal.msgError(resp.msg)
}
}, },
//监听页面关闭 隐藏 //监听页面关闭 隐藏
watchPage() { // watchPage() {
document.addEventListener('visibilitychange', () => { // document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') { // if (document.visibilityState === 'hidden') {
if (this.player && this.currentVideo) { // if (this.player && this.currentVideo) {
this.addWatchRecord() // this.addWatchRecord()
} // }
} // }
}) // })
}, // },
async getMyWatchRecord() { async getMyWatchRecord() {
const {data} = await $.get('/mobile/trainEducation/getMyWatchRecord') const {data} = await $.get('/mobile/trainEducation/getMyWatchRecord')
this.watchRecordList = data this.watchRecordList = data
@@ -310,10 +348,10 @@ layout("/mobile/platform.html"){
endLearn() { endLearn() {
const v = this.watchRecordList.find(v => v.videoId === this.currentVideo.id) const v = this.watchRecordList.find(v => v.videoId === this.currentVideo.id)
console.log(v) console.log(v)
if (v && v.finish) { // if (v && v.finish) {
this.$modal.msg('本视频您已学习完成,无需重复上传') // this.$modal.msg('本视频您已学习完成,无需重复上传')
return // return
} // }
this.$modal.confirm('您是否要结束本视频学习?').then(() => { this.$modal.confirm('您是否要结束本视频学习?').then(() => {
//暂停 //暂停
@@ -336,7 +374,7 @@ layout("/mobile/platform.html"){
}, },
created() { created() {
this.watchPage() // this.watchPage()
const id = this.GetQueryString("id") const id = this.GetQueryString("id")
if (id) { if (id) {
this.albumId = id this.albumId = id
@@ -113,12 +113,16 @@ layout("/layouts/platform.html"){
<span v-if="row.createType === 1">分工会</span> <span v-if="row.createType === 1">分工会</span>
<span v-else>校工会</span> <span v-else>校工会</span>
</template> </template>
<template v-else-if="column.prop==='disabled'" scope="{row}">
<span v-if="row.disabled" class="text-danger">否</span>
<span v-else class="text-success">是</span>
</template>
</el-table-column> </el-table-column>
<el-table-column align="center" header-align="center" label="操作" width="250"> <el-table-column align="center" header-align="center" label="操作" width="250">
<template scope="{row}"> <template scope="{row}">
<el-button size="small" @click="openView(row)">查看</el-button> <el-button size="mini" @click="openView(row)">查看</el-button>
<el-button size="small" type="primary" @click="openEdit(row)">编辑</el-button> <el-button size="mini" type="primary" @click="openEdit(row)">编辑</el-button>
<el-button size="small" type="danger" @click="doDelete(row.id)">删除 <el-button size="mini" type="danger" @click="doDelete(row.id)">删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@@ -128,7 +132,7 @@ layout("/layouts/platform.html"){
<template #edit> <template #edit>
<el-form :model="formData" :rules="rules" ref="ruleForm" label-width="100px" <el-form :model="formData" :rules="rules" ref="ruleForm" label-width="100px"
> >
<el-form-item label="专辑标题" prop="title"> <el-form-item label="专辑标题" prop="title">
<el-input v-model="formData.title" maxlength="30" placeholder="请输入专辑标题"></el-input> <el-input v-model="formData.title" maxlength="30" placeholder="请输入专辑标题"></el-input>
</el-form-item> </el-form-item>
@@ -165,6 +169,17 @@ layout("/layouts/platform.html"){
<i v-else class="el-icon-plus avatar-uploader-icon"></i> <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="是否开启" prop="disabled">
<el-switch
v-model="formData.disabled"
active-color="#13ce66"
inactive-color="#ff4949"
:active-value="false"
:inactive-value="true">
</el-switch>
</el-form-item>
<el-form-item class="text-right"> <el-form-item class="text-right">
<el-button type="primary" @click="doHandle">确定</el-button> <el-button type="primary" @click="doHandle">确定</el-button>
<el-button @click="$refs.guava.index()">取消</el-button> <el-button @click="$refs.guava.index()">取消</el-button>
@@ -231,6 +246,7 @@ layout("/layouts/platform.html"){
{prop: 'videoCount', label: '视频数量'}, {prop: 'videoCount', label: '视频数量'},
{prop: 'typeName', label: '专辑类型'}, {prop: 'typeName', label: '专辑类型'},
{prop: 'createType', label: '创建类型'}, {prop: 'createType', label: '创建类型'},
{prop: 'disabled', label: '是否开启'}
], ],
rules: { rules: {
title: [{required: true, message: '请输入标题', trigger: ['change', 'blur']}], title: [{required: true, message: '请输入标题', trigger: ['change', 'blur']}],
@@ -5,6 +5,33 @@ layout("/layouts/platform.html"){
<div id="app" v-cloak> <div id="app" v-cloak>
<guava ref="guava"> <guava ref="guava">
<el-card shadow="never">
<div class="btn-group tool-button mt5">
<el-select v-model="pageForm.albumId" placeholder="请选择专辑" filterable clearable @change="doSearch">
<el-option
v-for="item in albumList"
:key="item.id"
:label="item.title"
:value="item.id">
</el-option>
</el-select>
</div>
<div class="btn-group tool-button mt5">
<el-input placeholder="请输入内容" v-model="pageForm.searchKeyword" clearable
@keyup.enter.native="doSearch">
<el-select v-model="pageForm.searchName" slot="prepend" placeholder="查询类型"
style="width: 120px;">
<el-option label="标题" value="tev.title"></el-option>
</el-select>
</el-input>
</div>
<div class="btn-group tool-button mt5">
<el-button type="primary" icon="el-icon-search" @click="doSearch">搜索</el-button>
</div>
</el-card>
<el-card shadow="never" class="mt10"> <el-card shadow="never" class="mt10">
<table-tool label="统计" :app="this"></table-tool> <table-tool label="统计" :app="this"></table-tool>
@@ -23,68 +50,75 @@ layout("/layouts/platform.html"){
{{(row.sumDuration / 60 / 60).toFixed(2) + 'h'}} {{(row.sumDuration / 60 / 60).toFixed(2) + 'h'}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" header-align="center" label="操作" width="200"> <!-- <el-table-column align="center" header-align="center" label="操作" width="200">-->
<template scope="{row}"> <!-- <template scope="{row}">-->
<el-button size="small" type="primary" @click="openView(row)">查看具体学习情况</el-button> <!-- <el-button size="mini" type="primary" @click="openView(row)">查看具体学习情况</el-button>-->
</template> <!-- </template>-->
</el-table-column> <!-- </el-table-column>-->
</el-table> </el-table>
<!--#include("/layouts/pagination.html"){}#-->
</el-card> </el-card>
<template #view> <!-- <template #view>-->
<el-table :data="viewTableData" stripe border style="width: 100%"> <!-- <el-table :data="viewTableData" stripe border style="width: 100%">-->
<el-table-column type="index" label="序号" width="80px"> <!-- <el-table-column type="index" label="序号" width="80px">-->
<template scope="scope"> <!-- <template scope="scope">-->
<span>{{ scope.$index + (viewPageForm.pageNumber - 1) * viewPageForm.pageSize + 1 }} </span> <!-- <span>{{ scope.$index + (viewPageForm.pageNumber - 1) * viewPageForm.pageSize + 1 }} </span>-->
</template> <!-- </template>-->
</el-table-column> <!-- </el-table-column>-->
<el-table-column <!-- <el-table-column-->
align="center" <!-- align="center"-->
header-align="center" <!-- header-align="center"-->
v-for="column in viewTableColumns" <!-- v-for="column in viewTableColumns"-->
show-overflow-tooltip <!-- show-overflow-tooltip-->
:label="column.label" <!-- :label="column.label"-->
:prop="column.prop" <!-- :prop="column.prop"-->
:sortable="column.sortable" <!-- :sortable="column.sortable"-->
> <!-- >-->
<template v-if="column.prop==='studyDuration'" scope="{row}"> <!-- <template v-if="column.prop==='studyDuration'" scope="{row}">-->
{{(row.studyDuration / 60 / 60).toFixed(2) + 'h'}} <!-- {{(row.studyDuration / 60 / 60).toFixed(2) + 'h'}}-->
</template> <!-- </template>-->
</el-table-column> <!-- </el-table-column>-->
</el-table> <!-- </el-table>-->
<el-row class="el-pagination-container" style="margin-bottom: 0px"> <!-- <el-row class="el-pagination-container" style="margin-bottom: 0px">-->
<el-pagination <!-- <el-pagination-->
@current-change="(val)=>{viewPageForm.pageNumber=val;viewPageData()}" <!-- @current-change="(val)=>{viewPageForm.pageNumber=val;viewPageData()}"-->
:current-page="viewPageForm.pageNumber" <!-- :current-page="viewPageForm.pageNumber"-->
:page-size="viewPageForm.pageSize" <!-- :page-size="viewPageForm.pageSize"-->
layout="total, sizes, prev, pager, next" <!-- layout="total, sizes, prev, pager, next"-->
:total="viewPageForm.totalCount"> <!-- :total="viewPageForm.totalCount">-->
</el-pagination> <!-- </el-pagination>-->
</el-row> <!-- </el-row>-->
</template> <!-- </template>-->
</guava> </guava>
</div> </div>
<script> <script>
<!--#include("/platform/trainEdu/include/include.js"){}#-->
const vue = new Vue({ const vue = new Vue({
el: '#app', el: '#app',
mixins: [initTableMixins], mixins: [initTableMixins],
data() { data() {
return { return {
tableColumns: [ tableColumns: [
{prop: 'title', label: '专辑名称'}, {prop: 'username', label: '姓名'},
{prop: 'typeName', label: '类型'}, {prop: 'loginname', label: '工号'},
{prop: 'studyNum', label: '已看人数', sortable: true}, {prop: 'unitname', label: '单位'},
{prop: 'sumDuration', label: '课程总时长', sortable: true}, {prop: 'unionname', label: '分工会'},
// {prop: 'studyDuration', label: '观看总时长'},
{prop: 'watchCount', label: '学习总次数'}
], ],
viewTableColumns: [ viewTableColumns: [
{prop: 'username', label: '姓名'}, {prop: 'username', label: '姓名'},
{prop: 'loginname', label: '工号'}, {prop: 'loginname', label: '工号'},
{prop: 'unitname', label: '单位'}, {prop: 'unitname', label: '单位'},
{prop: 'unionname', label: '分工会'}, {prop: 'unionname', label: '分工会'},
{prop: 'studyDuration', label: '观看总时长'}, // {prop: 'studyDuration', label: '观看总时长'},
{prop: 'watchCount', label: '学习总次数'}
], ],
viewPageForm: { viewPageForm: {
pageNumber: 1, pageNumber: 1,
@@ -92,7 +126,10 @@ layout("/layouts/platform.html"){
totalCount: 0, totalCount: 0,
albumId: null albumId: null
}, },
viewTableData: [] viewTableData: [],
albumList: [],
} }
}, },
methods: { methods: {
@@ -111,8 +148,12 @@ layout("/layouts/platform.html"){
viewPageNumberChange(val) { viewPageNumberChange(val) {
} }
}, },
created() { async created() {
this.pageData() this.albumList = await getAllAlbum()
if (this.albumList) {
this.pageForm.albumId = this.albumList[0].id
await this.pageData()
}
} }
}) })
</script> </script>
@@ -101,7 +101,7 @@ layout("/layouts/platform.html"){
</el-card> </el-card>
<template #edit> <template #edit>
<el-form :model="formData" :rules="rules" ref="ruleForm" label-width="100px"> <el-form :model="formData" :rules="rules" ref="ruleForm" label-width="150px">
<el-form-item label="所属专辑" prop="albumId"> <el-form-item label="所属专辑" prop="albumId">
<el-select v-model="formData.albumId" placeholder="请选择专辑" style="width: 100%"> <el-select v-model="formData.albumId" placeholder="请选择专辑" style="width: 100%">
@@ -136,6 +136,10 @@ layout("/layouts/platform.html"){
<el-input-number :min="1" :max="128" v-model="formData.sortNo"></el-input-number> <el-input-number :min="1" :max="128" v-model="formData.sortNo"></el-input-number>
</el-form-item> </el-form-item>
<el-form-item label="每天最多观看次数" prop="everyDayMaxWatchNum">
<el-input-number :min="1" :max="100" v-model="formData.everyDayMaxWatchNum"></el-input-number>
</el-form-item>
<el-form-item label="是否启用" prop="disabled"> <el-form-item label="是否启用" prop="disabled">
<el-switch <el-switch
v-model="formData.disabled" v-model="formData.disabled"