나는 작업자 이동 스케줄러를 구현하고 있습니다. 스크린 샷은 아래를 참조하십시오 :React Multi Column Select 체크 박스를 선택하십시오.
내가 백엔드에서 객체의 배열을받을 수 있습니다. ,
class PlanningShiftManagement extends Component {
render() {
const availableShifts = this.props.shifts.map((shift) => {
return (
<th>
{shift.shiftStart} - {shift.shiftEnd}
</th>
)
})
const employees = this.props.employeeList.map((employee) => {
let employeecheckbox = this.props.shifts.map((shift) => {
return(
<td>
<input type="checkbox" />
</td>
)
});
return(
<tr className="table-row">
<td>{employee.title}</td>
{employeecheckbox}
</tr>
)
})
return(
<div>
<table className="scheduler-table">
<thead className="table-head">
<tr>
<th>Employee Name</th>
{availableShifts}
</tr>
</thead>
<tbody className="table-body">
{employees}
</tbody>
</table>
</div>
);
}
}
지금, 내 질문은 :
[{"shiftStart":"00:00","shiftEnd":"08:00"},{"shiftStart":"08:00","shiftEnd":"15:00"},{"shiftStart":"15:00","shiftEnd":"00:00"}]
이 내가 만든 반작용 구성 요소입니다 : 첫 번째는
[{
"employeeId": "id",
"name": "bob"
},{
"employeeId": "id",
"name": "steve",
}]
두 번째 가능한 변화입니다 직원의 목록입니다 직원과 시프트가 선택된 상태를 어떻게 만들 수 있습니까? 그래서 나는 백엔드에 보낼 수있는 객체를 만들고 싶습니다.
[{
"shiftStart": "20170313 10:00",
"shiftEnd": "20170313 17:00",
"employeeId": "id"
}]
더 구체적으로 말씀해주십시오. 백엔드에 이미 시프트 데이터와 직원 데이터가 있지만 React 구성 요소가 데이터의 "모양"을 변경하고 백엔드에 다시 제출하기를 원하십니까? 백엔드에서 데이터가 저장되는 방식을 제어 할 수 있습니까? – radiovisual
당신은 각 직원에 대한 모든 체크 박스 값을 확인하는 것만으로 직원이 선택한 모든 근무 교대를받을 수 있습니다. –