From b6cf167b1d96ebe2f35be056169734d42f467551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 16 Mar 2020 18:51:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../videostatistics/Videostatistics.js | 5 +- .../component/Videostatisticscomtwo.js | 185 +++++++++++++++++- .../component/Videostatisticslist.js | 2 +- 3 files changed, 187 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/videostatistics/Videostatistics.js b/public/react/src/modules/courses/videostatistics/Videostatistics.js index 0ea61c528..8d88492b1 100644 --- a/public/react/src/modules/courses/videostatistics/Videostatistics.js +++ b/public/react/src/modules/courses/videostatistics/Videostatistics.js @@ -52,7 +52,8 @@ class Videostatistics extends Component{ render(){ - let {watch_staticsdata,tisticsbool}= this.state; + let {watch_staticsdata,tisticsbool,tisid}= this.state; + return(
@@ -82,7 +83,7 @@ class Videostatistics extends Component{
: - this.tisticsbools(b,id)}> + this.tisticsbools(b,id)}> } diff --git a/public/react/src/modules/courses/videostatistics/component/Videostatisticscomtwo.js b/public/react/src/modules/courses/videostatistics/component/Videostatisticscomtwo.js index 45180e1f7..d6b9a4fcb 100644 --- a/public/react/src/modules/courses/videostatistics/component/Videostatisticscomtwo.js +++ b/public/react/src/modules/courses/videostatistics/component/Videostatisticscomtwo.js @@ -19,13 +19,110 @@ class Videostatisticscom extends Component { page:1, limit:10, members_count:0, - columnsstu:[], + columnsstu: [ + { + title: '序号', + dataIndex: 'number', + key: 'number', + align: "center", + className: 'font-14', + width: '50px', + render: (text, record) => ( + {record.number} + ), + }, + { + title: '用户', + dataIndex: 'user_name', + key: 'user_name', + align: "center", + className: 'font-14 maxnamewidth100s', + width: '100px', + render: (text, record) => ( + {record.user_name} + ), + }, + { + title: '视频是否看完', + dataIndex: 'is_finished', + key: 'is_finished', + align: "center", + className: 'font-14', + width: '98px', + render: (text, record) => ( + {record.is_finished} + ), + }, + { + title: '视频累计观看时长', + dataIndex: 'total_duration', + key: 'total_duration', + align: "center", + className: 'font-14 maxnamewidth150s', + width: '150px', + render: (text, record) => ( + {record.total_duration} + ), + }, + { + title: '累计观看次数(次)', + dataIndex: 'feq', + key: 'feq', + align: "center", + className: 'font-14 maxnamewidth100s', + width: '100px', + render: (text, record) => ( + {record.feq} + ), + }, + { + title: '最早观看时间', + dataIndex: 'start_at', + key: 'start_at', + align: "center", + className: 'font-14 maxnamewidth100s', + width: '100px', + render: (text, record) => ( + {record.start_at} + ), + }, + { + title: '最后观看时间', + dataIndex: 'end_at', + key: 'end_at', + align: "center", + className: 'font-14 maxnamewidth100s', + width: '100px', + render: (text, record) => ( + {record.end_at} + ), + } + ], loading:false, + order:undefined, + course_groups:[], } } componentDidMount() { + if(this.props.isAdmin()){ + //老师 + const CourseId=this.props.match.params.coursesId; + var data={ + id:CourseId, + page:this.state.page, + } + this.getdatas(data); + + }else{ + //学生 + var data={ + page:this.state.page, + } + this.getdatas(data); + } + this.fenbans(); } componentDidUpdate = (prevProps) => { @@ -33,6 +130,88 @@ class Videostatisticscom extends Component { } + //分班 + fenbans=()=>{ + const CourseId=this.props.match.params.coursesId; + let url=`/courses/${CourseId}/course_groups.json`; + axios.get(url).then((response) => { + if(response){ + console.log("分班"); + console.log("response"); + console.log(response); + this.setState({ + course_groups:response.data.course_groups, + current_group_id:response.data.current_group_id, + none_group_member_count:response.data.none_group_member_count, + group_count:response.data.group_count, + }) + } + + }).catch((error) => { + + }); + } + + //学生 + getdatas=(data)=>{ + this.setState({ + loading:true + }) + const CourseId=this.props.match.params.coursesId; + let url=""; + if(this.props.isAdmin()){ + url=`/course_videos/${this.props.tisid}/watch_histories.json`; + }else { + url=`/courses/${CourseId}/own_watch_histories.json`; + } + axios.get(url,{params:data}).then((response) => { + if(response){ + if(response.data){ + if(response.data.data.length>0){ + let datalists=[]; + for (var i = 0; i < response.data.data.length; i++) { + datalists.push({ + number: (parseInt(page) - 1) * parseInt(limit) + (i + 1), + user_name:response.data.data[i].user_name, + is_finished:response.data.data[i].is_finished, + total_duration:response.data.data[i].total_duration, + feq:response.data.data[i].feq, + start_at:response.data.data[i].start_at, + end_at:response.data.data[i].end_at, + }) + } + + this.setState({ + data:datalists, + members_count:response.data.count, + }) + }else{ + this.setState({ + data:[], + members_count:response.data.count, + }) + } + }else{ + this.setState({ + data:[], + members_count:response.data.count, + }) + } + + + + } + this.setState({ + loading:false + }) + }).catch((error) => { + this.setState({ + loading:false + }) + }); + } + + paginationonChange = (pageNumber) => { this.setState({ @@ -41,7 +220,9 @@ class Videostatisticscom extends Component { } render() { - let {loading,data,page,limit,members_count,columnsstu}=this.state + let {loading,data,page,limit,members_count,columnsstu}=this.state; + const isAdmin =this.props.isAdmin(); + return (
diff --git a/public/react/src/modules/courses/videostatistics/component/Videostatisticslist.js b/public/react/src/modules/courses/videostatistics/component/Videostatisticslist.js index 6448c5996..3ec3af0fa 100644 --- a/public/react/src/modules/courses/videostatistics/component/Videostatisticslist.js +++ b/public/react/src/modules/courses/videostatistics/component/Videostatisticslist.js @@ -120,7 +120,7 @@ class Videostatisticslist extends Component { if(response){ this.setState({ data:response.data&&response.data.videos?response.data.videos:[], - members_count:count, + members_count:response.data.count, }) }