dev_ec
hjm 5 years ago
parent d7008219e9
commit 6f142a8500

@ -31,7 +31,7 @@ class SelectTable extends Component {
if (index == 0) return <td className="gaugeOutfit"><span>{columns[0][0]}</span><span>{columns[0][1]}</span></td>; if (index == 0) return <td className="gaugeOutfit"><span>{columns[0][0]}</span><span>{columns[0][1]}</span></td>;
return ( return (
<Tooltip title={item}> <Tooltip title={item}>
<td >目标{index}</td> <td >{this.props.columnName || '目标'}{index}</td>
</Tooltip> </Tooltip>
) )
})} })}
@ -45,7 +45,7 @@ class SelectTable extends Component {
const cells = item.map((cell, colIndex) => { const cells = item.map((cell, colIndex) => {
// placement="bottom" // placement="bottom"
if(colIndex == 0) return <Tooltip title={cell}> if(colIndex == 0) return <Tooltip title={cell}>
<td >指标点{rowIndex + 1}</td> <td >指标点{this.props.firstColIndexArray ? this.props.firstColIndexArray[rowIndex] : rowIndex + 1}</td>
</Tooltip> </Tooltip>
return (<Tooltip title={!!cell ? '取消支撑' : '选择支撑'} > return (<Tooltip title={!!cell ? '取消支撑' : '选择支撑'} >
<td onClick={() => this.props.onCellClick(rowIndex, colIndex , !!cell)}> <td onClick={() => this.props.onCellClick(rowIndex, colIndex , !!cell)}>

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

Loading…
Cancel
Save