在这里,我从回送中获得了所有缺席的员工详细信息,并将其放入数组(data [])。下面的代码
getAbsentDet() {
this.props.actions.getAbsentDetails().then(() => {
if (!this.props.common.getAbsentDetailsPending) {
this.setState({ data: this.props.common.absDetails.emp });
}
});
}
这里仅显示今天请假的员工详细信息。明天该怎么办? .my代码在下面...
render() {
return (
<div className="common-right-coll-bar" id="rightMenu">
<Sider style={{ overflow: 'auto', height: '100vh', width: 300, right: 0, backgroundColor: '#f5f5f5', position: 'fixed', color: '#036cd2' }}>
{/* <Sider style={{ height: 150, width: 300, backgroundColor: '#fff', }}> */}
{this.state.data.length !== 0?<ul style={{ marginTop: 30 }}>
<h1> Absent Today</h1>
{this.state.data.map(data =>
(
<li key={data .id} style={{ padding: 5, margin: 5, marginLeft: 10 }}>
<div>
<span>
<Badge><Avatar style={{ color: '#ffffff', borderStyle: 'solid', borderWidth: 2 }} size="large" src={`./${data.profile_img}`} /></Badge>
</span>
<span style={{ marginLeft: 10, color: '#036cd2' }}>
{data.f_name} {data.l_name}
</span>
</div>
</li>)
)}
<div className="check" id="rightMenu" ref="check" style={{ padding: 5 }}>
</div>
</ul> : <div style={{ marginTop: 100, marginLeft: 10, fontSize: 30, borderStyle: 'solid', borderColor: 'black', textAlign: 'center', color: 'lightGray' }}>No one is absent today </div>}
</Sider>
</div>
);
}
}
这是我的服务器代码(环回)。这里仅显示今天请假的员工详细信息。明天要怎么办?
LeaveDetails.tomo_absentEmp = function(cb) {
var log = bunyan.createLogger({
name: 'leaveServer-logger', streams: [
{
level: 'info',
path: './log/info/log_' + moment().format('YYYY-MM-DD').toString() + '.log',
},
{
level: 'error',
path: './log/error/log_' + moment().format('YYYY-MM-DD').toString() + '.log',
}],
serializers: { err: bunyan.stdSerializers.err },
});
console.log('Request for the employee absent sheet');
log.info({
type: 'info', time: moment().format('YYYY-MM-DD HH:mm').toString(),
model: 'leave-details',
method: 'tomo_absentEmp',
}, 'request for absent employee');
let filter = { where: { leave_status: 3 }, fields: ['user_id', 'leave_start_time', 'leave_end_time','number_of_days']};
LeaveDetails.find(filter, function(err, leaves) {
var returnArray = [];
var returnEle;
var employee = app.models.employee;
var ids = [];
async.eachOf(leaves, function(leave, index, acb) {
var leaveStart = moment(leave.leave_start_time).startOf('day');
var leaveEnd = moment(leave.leave_end_time).endOf('day');
var now = moment();
if (now.isBetween(leaveStart, leaveEnd) && !ids.includes(leave.user_id)) {
ids.push(leave.user_id);
employee.findById(leave.user_id, {fields: ['f_name', 'l_name', 'profile_img', 'id']}, function(err, tomoabsemp) {
returnEle = {};
returnEle['id'] = tomoabsemp.id;
returnEle['f_name'] = tomoabsemp.f_name;
returnEle['l_name'] = tomoabsemp.l_name;
returnEle['profile_img'] = tomoabsemp.profile_img;
returnEle['leave_start_time'] = leaveStart;
returnEle['leave_end_time'] =leaveEnd;
returnEle['number_of_days'] =leave.number_of_days;
returnArray.push(returnEle);
return acb(null);
});
} else {
return acb(null);
}
},
function(err) {
if (err) {
return cb(null, err);
log.error({
type: 'error', time: moment().format('YYYY-MM-DD HH:mm').toString(),
model: 'leave-details',
method: 'tomo_absentEmp',
}, 'absent employee responce failed');
} else {
console.log('send the absent employee details successfuly');
log.info({
type: 'success',
model: 'leave-details',
method: 'tomo_absentEmp',
}, 'absent employee responce successfull');
return cb(null, returnArray);
}
}
);
});
};