PCqiandao
杨树明 5 years ago
parent f448cbe62f
commit d52a07bec9

@ -121,4 +121,44 @@
#form_in_modal_end_time{
height:40px;
background: #fafafa !important;
}
.Signedinlistbox .ant-select-selection--single{
height:40px !important;
background:rgba(255,255,255,1);
border:1px solid rgba(234,234,234,1);
border-radius:4px;
}
.Signedinlistbox .ant-select-selection__rendered{
line-height: 40px !important;
}
.Signedintextright{
text-align: right;
}
.color26C7C9{
color:#26C7C9;
}
.colorEAAE4E{
color:#EAAE4E;
}
.colorFF835C{
color:#FF835C;
}
.color1890FF{
color:#1890FF;
}
.backfff .ant-table-thead tr th{
background: #fff;
border-bottom:1px solid #EBEBEB !important;
}
.textcenter{
text-align: center !important;
}

@ -1,35 +1,264 @@
import "../css/Signinstatistics.css"
import React,{ Component } from "react";
import { Row, Col,Select } from 'antd';
import { Row, Col,Select,Table,Pagination } from 'antd';
import axios from 'axios';
const { Option } = Select;
class Signedinlist extends Component {
constructor(props) {
super(props)
this.state={
limit:5,
page:1,
loading:false,
attendanceslist:[{id:undefined,name:"全部分班"}],
data:null,
group_ids:[],
members_count:0,
attendance_status:undefined,
state:[
{id:undefined,name:"全部状态"},
{id:"NORMAL",name:"正常出勤"},
{id:"LEAVE",name:"请假"},
{id:"ABSENCE",name:"旷课"},
],
newstate:[
{id:"NORMAL",name:"正常出勤"},
{id:"LEAVE",name:"请假"},
{id:"ABSENCE",name:"旷课"},
]
}
}
componentDidMount() {
console.log(this.props.headdata)
let {attendanceslist}=this.state;
let listattendanceslist=attendanceslist
let url=`/weapps/attendances/${this.props&&this.props.switattendance_id}.json`;
axios.get(url).then((response) => {
if(response.data){
if(response.data.course_groups.length>0){
response.data.course_groups.map((item,key)=>{
listattendanceslist.push(item)
})
}
this.setState({
listattendanceslist:attendanceslist,
data:response.data
})
}
})
this.getdatas(this.props&&this.props.switattendance_id,1,[],undefined)
}
getdatas=(id,page,group_ids,attendance_status)=>{
this.setState({
loading:true,
member_attendances:[],
})
let that=this;
let url=`/weapps/course_member_attendances.json`;
axios.get(url,{params:{
group_ids:group_ids,
attendance_id:id,
attendance_status:attendance_status,
page:page,
limit:5,
}
}).then((response) => {
if(response){
this.setState({
member_attendances:response.data.member_attendances,
members_count:response.data.members_count,
loading:false
})
}
}).catch((error) => {
that.setState({
loading:false
})
});
}
handleChange=(value)=>{
console.log(`selected ${value}`);
handleChangegroup_ids=(e)=>{
console.log(this.props.headdata)
console.log(e)
return
let neval
if(!value){
neval=[]
this.setState({
group_ids: [],
})
}else{
neval=[value]
this.setState({
group_ids: [value],
})
}
let {page,attendance_status}=this.state;
this.getdatas(this.props&&this.props.switattendance_id,page,neval,attendance_status)
}
handleChangestate=(value)=>{
let neval
if(!value){
neval=undefined
this.setState({
attendance_status:undefined,
})
}else{
neval=value
this.setState({
attendance_status: value,
})
}
let {page,group_ids}=this.state;
this.getdatas(this.props&&this.props.switattendance_id,page,group_ids,neval)
}
paginationonChange = (pageNumber) => {
this.setState({
page: pageNumber,
})
let {group_ids,attendance_status}=this.state;
this.getdatas(this.props&&this.props.switattendance_id,pageNumber,group_ids,attendance_status)
}
handleChange=(attendance_status,value)=>{
let url=`/weapps/course_member_attendances/update_status.json`;
axios.post(url, {
attendance_id:this.props.switattendance_id,
attendance_status:attendance_status,
course_id:this.props.match.params.coursesId,
user_id: value,
})
.then((response) => {
if (response.data.status == 0) {
this.props.showNotification(`修改状态成功`);
}
})
.catch(function (error) {
console.log(error);
});
}
render() {
let {attendanceslist,state,data,member_attendances,newstate}=this.state;
const columns = [
{
title: '序号',
dataIndex: 'index',
key: 'index',
className: "textcenter",
},
{
title: '姓名',
dataIndex: 'user_name',
key: 'user_name',
className: "textcenter",
},
{
title: '学号',
dataIndex: 'student_id',
key: 'student_id',
className: "textcenter",
},
{
title: '状态',
key: 'attendance_status',
dataIndex: 'attendance_status',
render: (text, record) => (
<span>
<Select key={record.index} defaultValue={record.attendance_status} className={"Signedinlistbox"} style={{ width: 167 }} onChange={(e)=>this.handleChange(e,record.user_id)}>
{
newstate&&newstate.map((item,key)=>{
return(
<Option value={item.id} key={key}>{item.name}</Option>
)
})
}
</Select>
</span>
),
},
];
return(
<React.Fragment>
<Row className={"mt20"}>
<Col span={12}>
<Row type="flex" justify="space-between">
<Col span={4}>
<Select defaultValue="lucy" style={{ width: 120 }} onChange={this.handleChange}>
<Option value="jack">Jack</Option>
</Select>
<Select defaultValue="lucy" style={{ width: 120 }} onChange={this.handleChange}>
<Option value="jack">Jack</Option>
<Row gutter={[{ xs: 8, sm: 16, md: 24, lg: 32 }, 20]}>
<Col className="gutter-row" span={9}>
<Select defaultValue="全部分班" className={"Signedinlistbox"} style={{ width: 167 }} onChange={this.handleChangegroup_ids}>
{attendanceslist&&attendanceslist.map((item,key)=>{
return(
<Option value={item}>{item.name}</Option>
)
})}
</Select>
</Col>
<Col className="gutter-row ml20" span={6}>
<Select defaultValue="全部状态" className={"Signedinlistbox"} style={{ width: 167 }} onChange={this.handleChangestate}>
{
state&&state.map((item,key)=>{
return(
<Option value={item.id}>{item.name}</Option>
)
})
}
</Select>
</Col>
</Row>
</Col>
<Col span={12}>
<Row type="flex" justify="end">
{this.props.defaultActiveKey==="2"?<Col className={"Signedintextright "}>
<span className={"color26C7C9 mr20"}>正常签到{data&&data.normal_count}</span>
<span className={"colorEAAE4E mr20"}>请假{data&&data.leave_count}</span>
<span className={"colorFF835C"}>旷课{data&&data.absence_count}</span>
</Col>:<Col className={"Signedintextright "}>
<span className={"mr20"}>已签到<span className={"color1890FF"}>33</span></span>
<span>应签到<span className={"color1890FF"}>33</span></span>
</Col>}
</Row>
</Col>
<Col span={12}>col-12</Col>
</Row>
<div className={"backfff mt10"}>
<Table columns={columns} dataSource={member_attendances} pagination={false} loading={this.state.loading}/>
</div>
<div className="mb30 clearfix educontent mt40 intermediatecenter">
<Pagination showQuickJumper current={this.state.page} onChange={this.paginationonChange}
pageSize={this.state.limit}
total={this.state.members_count}></Pagination>
</div>
</React.Fragment>
)

Loading…
Cancel
Save