import "../css/Signinstatistics.css"; import React,{ Component } from "react"; import { Row, Col,Card,Select} from 'antd'; import {getImageUrl} from 'educoder'; import axios from 'axios'; import { Chart, Geom, Axis, Tooltip, } from "bizcharts"; const { Option } = Select; class Signinstatistics extends Component { constructor(props) { super(props) this.state={ datas:null, newlist:[], course_groups:[{id:"全部",name:"全部"}] } } getdata=(group_id)=>{ const coursesId=this.props.match.params.coursesId; let url=`/weapps/courses/${coursesId}/attendances.json` axios.get(url,{params:{ group_id:group_id==="全部"?undefined:group_id } }).then((response) => { if(response){ if(response.data){ let newlists=[] if(response.data.history_attendances.length>0){ response.data.history_attendances.map((item,key)=>{ newlists.push({ month: item.index, city:"到课率", temperature: (item.normal_rate).toFixed(0) }) newlists.push({ month: item.index, city: "旷课率", temperature: (item.absence_rate).toFixed(0) }) newlists.push({ month: item.index, city: "请假率", temperature: (item.leave_rate).toFixed(0) }) }) } this.setState({ datas:response.data, newlist:newlists }) } } }) } componentDidMount() { const coursesId=this.props.match.params.coursesId; let newurl=`/courses/${coursesId}/all_course_groups.json`; axios.get(newurl).then((response) => { let newlist=this.state.course_groups; response.data.course_groups.map((item,key)=>{ newlist.push(item) }) this.setState({ course_groups:newlist }) }) this.getdata() } handleChange=(value)=>{ this.getdata(value) } render() { let {datas,newlist,course_groups}=this.state; const cols = { month: { range: [0, 1] } }; return(
{datas&&datas.all_history_count}
{datas?(datas&&datas.avg_normal_rate*100).toFixed(0)+"%":""}
{datas?(datas&&datas.avg_absence_rate*100).toFixed(0)+"%":""}
{datas?(datas&&datas.avg_leave_rate*100).toFixed(0)+"%":""}
到课率 旷课率 请假率 显示最近十次签到
{/**/} `${val}%` }} />
) } } export default Signinstatistics;