|
|
|
@ -21,9 +21,9 @@ class RequirementVsObjective extends Component {
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
const yearId = this.props.match.params.yearId
|
|
|
|
|
const url = `/ec_years/${yearId}/requirement_support_objectives.json`
|
|
|
|
|
const url = `/ec_years/${yearId}/subitem_support_standards.json`
|
|
|
|
|
axios.get(url).then((response) => {
|
|
|
|
|
if (response.data.graduation_requirements) {
|
|
|
|
|
if (response.data.graduation_subitems) {
|
|
|
|
|
this.setState( {...response.data} , () => {
|
|
|
|
|
this.init()
|
|
|
|
|
})
|
|
|
|
@ -35,39 +35,41 @@ class RequirementVsObjective extends Component {
|
|
|
|
|
init = () => {
|
|
|
|
|
this.graduationRequirementsIdIndexMap = {}
|
|
|
|
|
this.trainingSubitemsIdIndexMap = {}
|
|
|
|
|
this.state.graduation_requirements.forEach((item, index) => {
|
|
|
|
|
this.state.graduation_subitems.forEach((item, index) => {
|
|
|
|
|
this.graduationRequirementsIdIndexMap[item.id] = index
|
|
|
|
|
})
|
|
|
|
|
this.state.training_subitems.forEach((item, index) => {
|
|
|
|
|
this.state.graduation_standards.forEach((item, index) => {
|
|
|
|
|
// 对应table的列数
|
|
|
|
|
this.trainingSubitemsIdIndexMap[item.id] = index + 1
|
|
|
|
|
})
|
|
|
|
|
const tableData = []
|
|
|
|
|
this.state.graduation_requirements.forEach((item, index) => {
|
|
|
|
|
tableData.push([item.content, ...Array(this.state.training_subitems.length)])
|
|
|
|
|
const firstColIndexArray = []
|
|
|
|
|
this.state.graduation_subitems.forEach((item, index) => {
|
|
|
|
|
tableData.push([item.content, ...Array(this.state.graduation_standards.length)])
|
|
|
|
|
firstColIndexArray.push(`${item.position}-${item.graduation_requirement_position}`)
|
|
|
|
|
})
|
|
|
|
|
this.state.requirement_support_objectives.forEach(item => {
|
|
|
|
|
tableData[this.graduationRequirementsIdIndexMap[item.graduation_requirement_id]][this.trainingSubitemsIdIndexMap[item.training_subitem_id]]
|
|
|
|
|
this.state.subitem_support_standards.forEach(item => {
|
|
|
|
|
tableData[this.graduationRequirementsIdIndexMap[item.graduation_subitem_id]][this.trainingSubitemsIdIndexMap[item.graduation_standard_id]]
|
|
|
|
|
= true
|
|
|
|
|
})
|
|
|
|
|
this.setState({ tableData })
|
|
|
|
|
this.setState({ tableData, firstColIndexArray })
|
|
|
|
|
}
|
|
|
|
|
onCellClick = (rowIndex, colIndex, select) => {
|
|
|
|
|
console.log( rowIndex, colIndex, select )
|
|
|
|
|
const ec_graduation_requirement_id = this.state.graduation_requirements[rowIndex].id
|
|
|
|
|
const ec_training_subitem_id = this.state.training_subitems[colIndex - 1].id
|
|
|
|
|
const ec_graduation_subitem_id = this.state.graduation_subitems[rowIndex].id
|
|
|
|
|
const ec_graduation_standard_id = this.state.graduation_standards[colIndex - 1].id
|
|
|
|
|
const yearId = this.props.match.params.yearId
|
|
|
|
|
const url = `/ec_years/${yearId}/requirement_support_objectives.json`
|
|
|
|
|
const url = `/ec_years/${yearId}/subitem_support_standards.json`
|
|
|
|
|
const method = select ? axios.delete : axios.post
|
|
|
|
|
method(url,
|
|
|
|
|
select ? {
|
|
|
|
|
params: {
|
|
|
|
|
ec_graduation_requirement_id,
|
|
|
|
|
ec_training_subitem_id
|
|
|
|
|
ec_graduation_subitem_id,
|
|
|
|
|
ec_graduation_standard_id
|
|
|
|
|
}
|
|
|
|
|
} : {
|
|
|
|
|
ec_graduation_requirement_id,
|
|
|
|
|
ec_training_subitem_id
|
|
|
|
|
ec_graduation_subitem_id,
|
|
|
|
|
ec_graduation_standard_id
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if (response.data.status == 0) {
|
|
|
|
@ -89,9 +91,9 @@ class RequirementVsObjective extends Component {
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
const { match, history, current_user } = this.props
|
|
|
|
|
const { tableData, training_subitems, graduation_requirements, is_manager } = this.state
|
|
|
|
|
const { tableData, graduation_standards, graduation_subitems, is_manager, firstColIndexArray } = this.state
|
|
|
|
|
|
|
|
|
|
const columns = training_subitems && [['毕业要求', '培养目标'], ...training_subitems.map(item => item.content)]
|
|
|
|
|
const columns = graduation_standards && [['毕业要求', '通用标准'], ...graduation_standards.map(item => item.content)]
|
|
|
|
|
const columnIdIndexMap = {}
|
|
|
|
|
console.log(columns, tableData)
|
|
|
|
|
return (
|
|
|
|
@ -116,7 +118,9 @@ class RequirementVsObjective extends Component {
|
|
|
|
|
<SelectTable
|
|
|
|
|
columns={columns}
|
|
|
|
|
tableData={tableData}
|
|
|
|
|
columnName="标准"
|
|
|
|
|
onCellClick={this.onCellClick}
|
|
|
|
|
firstColIndexArray={firstColIndexArray}
|
|
|
|
|
></SelectTable>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|