diff --git a/public/react/src/modules/ecs/EcSetting/RequirementVsObjective/SelectTable.js b/public/react/src/modules/ecs/EcSetting/RequirementVsObjective/SelectTable.js new file mode 100644 index 000000000..9e95d9eb8 --- /dev/null +++ b/public/react/src/modules/ecs/EcSetting/RequirementVsObjective/SelectTable.js @@ -0,0 +1,123 @@ +import React, { Component } from 'react'; + +import classNames from 'classnames' + +import axios from 'axios'; + +import { Table, Divider, Tag, Checkbox, InputNumber, Spin, Icon, Tooltip } from 'antd'; + +class SelectTable extends Component { + constructor(props) { + super(props) + this.state={ + + } + } + + componentDidMount(){ + + } + + render() { + const { match, columns, tableData } = this.props + if (!tableData || !tableData.length) return ''; + return ( + + + + + + {columns.map((item, index) => { + if (index == 0) return ; + return ( + + + + ) + })} + {/* + + + + */} + + { tableData.map((item, rowIndex) => { + const cells = item.map((cell, colIndex) => { + if(colIndex == 0) return + + + return ( + + ) + }) + return ( + + {cells} + + ) + })} + {/* + + + + + + + */} + {/* + + + + + + + + + + + + + + + */} + +
{columns[0][0]}{columns[0][1]}目标{index}目标1目标2目标3目标4目标5
指标点{rowIndex + 1} this.props.onCellClick(rowIndex, colIndex, !!cell)}> + +
指标点1 + + + + + + + + + +
指标点2 + + + + + + + + + +
指标点3 + + + + + + + + + +
+ + + ); + } +} + +export default (SelectTable) ; diff --git a/public/react/src/modules/ecs/EcSetting/RequirementVsObjective/index.js b/public/react/src/modules/ecs/EcSetting/RequirementVsObjective/index.js new file mode 100644 index 000000000..49b056950 --- /dev/null +++ b/public/react/src/modules/ecs/EcSetting/RequirementVsObjective/index.js @@ -0,0 +1,144 @@ +import React, { Component } from 'react'; + +import classNames from 'classnames' + +import axios from 'axios'; + +import { Table, Divider, Tag, Checkbox, InputNumber, Spin, Icon } from 'antd'; +import SelectTable from './SelectTable' +import update from 'immutability-helper' +const testState = { + "graduation_requirements": [ + { + "id": 1, + "position": 1, + "content": "毕业要求一" + }, + { + "id": 2, + "position": 2, + "content": "毕业要求二" + } + ], + "training_subitems": [ + { + "id": 1, + "content": "培养目标一" + }, + { + "id": 2, + "content": "培养目标二" + } + ], + "requirement_support_objectives": [ + { + "graduation_requirement_id": 1, + "training_subitem_id": 1 + }, + { + "graduation_requirement_id": 2, + "training_subitem_id": 2 + }, + ] +} +class RequirementVsObjective extends Component { + constructor(props) { + super(props) + this.state={ + ...testState + } + } + + componentDidMount(){ + // this.init() + // return; + + const yearId = this.props.match.params.yearId + const url = `/ec_years/${yearId}/requirement_support_objectives.json` + axios.get(url).then((response) => { + if (response.data.graduation_requirements) { + this.setState( {...response.data} , () => { + this.init() + }) + } + }).catch((e) => { + + }) + } + init = () => { + this.graduationRequirementsIdIndexMap = {} + this.trainingSubitemsIdIndexMap = {} + this.state.graduation_requirements.forEach((item, index) => { + this.graduationRequirementsIdIndexMap[item.id] = index + }) + this.state.training_subitems.forEach((item, index) => { + this.trainingSubitemsIdIndexMap[item.id] = index + }) + const tableData = [] + this.state.graduation_requirements.forEach((item, index) => { + tableData.push([item.content, ...Array(this.state.training_subitems.length)]) + }) + this.state.requirement_support_objectives.forEach(item => { + tableData[this.graduationRequirementsIdIndexMap[item.graduation_requirement_id]][this.trainingSubitemsIdIndexMap[item.training_subitem_id]] + = true + }) + this.setState({ tableData }) + } + 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].id + const yearId = this.props.match.params.yearId + const url = `/ec_years/${yearId}/requirement_support_objectives.json` + const method = select ? axios.delete : axios.post + method(url, + select ? { + params: { + ec_graduation_requirement_id, + ec_training_subitem_id + } + } : { + ec_graduation_requirement_id, + ec_training_subitem_id + } + ).then((response) => { + if (response.data.status == 0) { + this.setState( + (prevState) => ({ + tableData : update(prevState.tableData, {[rowIndex]: {[colIndex]: {$set: select ? false : true}}}) + }) + ) + this.props.showNotification(`${select ? '取消' : '选择'}成功`) + } + }).catch((e) => { + + }) + if (select) { // 取消 + + } else { // 选择 + + } + } + render() { + const { match, history, current_user } = this.props + const { tableData, training_subitems, graduation_requirements, is_manager } = this.state + + const columns = training_subitems && [['毕业要求', '培养目标'], ...training_subitems.map(item => item.content)] + const columnIdIndexMap = {} + console.log(columns, tableData) + return ( + +
+ requirementVsObjective + +
+ + ); + } +} + +export default (RequirementVsObjective) ; diff --git a/public/react/src/modules/ecs/EcSetting/index.js b/public/react/src/modules/ecs/EcSetting/index.js index 69d309c46..fd3ac436a 100644 --- a/public/react/src/modules/ecs/EcSetting/index.js +++ b/public/react/src/modules/ecs/EcSetting/index.js @@ -40,6 +40,11 @@ const ReachCalculationInfo=Loadable({ loader: () => import('./reachCalculationInfo/index'), loading: Loading, }); +const RequirementVsObjective=Loadable({ + loader: () => import('./RequirementVsObjective/index'), + loading: Loading, +}); + class EcSetting extends React.Component { @@ -132,8 +137,13 @@ class EcSetting extends React.Component { render={ (props) => () }> () }> + () }> - + {/* 毕业要求对培养目标的支撑 */} + () }> + {/*学生*/} () }>