Untitled
unknown
jsx
3 years ago
2.4 kB
12
Indexable
addRow = (idx, item, childId, childText, done = () => { }) => {
const permission = this.getUserPermission(this.props.prefixPermission || 'sdhChuongTrinhDaoTao', ['write', 'manage']);
idx = childId !== null && childId >= 0 ? `${childId}_${idx}` : idx;
const id = item ? item.id : -1;
const editFlag = (permission.write || permission.manage) ? (id > 0 ? false : true) : false;
const isDeleted = false;
this.rows[idx] = {
maMonHoc: null,
// tenMonHoc: null,
loaiMonHoc: null,
// soTinChi: null,
tcLyThuyet: null,
tcThucHanh: null,
// soTiet: null,
// hocKyDuKien: null,
// khoa: null
};
this.setEditState(idx, childId, childText, editFlag, id, isDeleted, () => {
// this.rows[idx].ten = item ? item?.tenMonHoc : '';
this.rows[idx].loaiMonHoc.value(item ? item.loaiMonHoc : 0);
this.rows[idx].tcLyThuyet.value(item ? (item.tinChiLyThuyet || 0).toString() : '0');
this.rows[idx].tcThucHanh.value(item ? (item.tinChiThucHanh || 0).toString() : '0');
// this.rows[idx].hocKyDuKien.value(item ? item.hocKyDuKien : null);
// this.rows[idx].soTinChi.value(item ? (item.soTinChi || 0).toString() : '0');
// id != -1 && this.rows[idx]?.tenMonHoc?.value(item && item.tenMonHoc ? item.tenMonHoc : '');
this.rows[idx].maMonHoc.value(item ? item.maMonHoc : '');
// item && item.maMonHoc && this.props.pushMonHocChosen(item.maMonHoc);
// this.rows[idx].ma.value((item && item.maMonHoc) ? item.maMonHoc : '');
// this.rows[idx].khoa.value(item ? item.khoa : '');
// this.rows[idx].soTiet.value(item ? (item.tongSoTiet || 0).toString() : '0');
done();
});
}
setEditState = (idx, childId, childText, editFlag, id, isDeleted, done) => {
this.setState({
datas: {
...this.state.datas,
[idx]: {
idx: idx,
childText: childText,
childId: childId,
edit: editFlag,
id: id,
isDeleted: isDeleted,
}
}
}, () => {
done && done();
});
}Editor is loading...