From 9d954ea61e6bcaad59f877539b399dbfa1bb1dec Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Mon, 24 Jun 2019 10:49:27 +0800 Subject: [PATCH] connect --- .../courses/busyWork/CommonWorkItem.js | 3 +-- .../courses/busyWork/ConnectProject.js | 20 +++++++++++++------ .../modules/courses/busyWork/commonWork.js | 11 ++++++++-- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkItem.js b/public/react/src/modules/courses/busyWork/CommonWorkItem.js index ad755338c..0a8f990a0 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkItem.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkItem.js @@ -8,7 +8,6 @@ import { WordsBtn } from 'educoder' import AccessoryModal2 from '../coursesPublic/AccessoryModal2' import AccessoryModal from '../coursesPublic/AccessoryModal' import axios from 'axios' -import ConnectProject from './ConnectProject' class CommonWorkItem extends Component{ constructor(props){ super(props); @@ -196,7 +195,7 @@ class CommonWorkItem extends Component{
  • { // item.work_status && item.work_status.indexOf('关联项目') != -1 && - + this.props.openConnectionProject(item)}>关联项目 } { // item.work_status && item.work_status.indexOf('提交作品') != -1 && diff --git a/public/react/src/modules/courses/busyWork/ConnectProject.js b/public/react/src/modules/courses/busyWork/ConnectProject.js index 9d201009d..9c5db1bbc 100644 --- a/public/react/src/modules/courses/busyWork/ConnectProject.js +++ b/public/react/src/modules/courses/busyWork/ConnectProject.js @@ -5,6 +5,7 @@ import '../css/members.css' import { WordsBtn } from 'educoder' import axios from 'axios' import InfiniteScroll from 'react-infinite-scroller'; +import NoneData from "../coursesPublic/NoneData" const Search =Input.Search; const LIMIT = 15 @@ -36,7 +37,7 @@ class ConnectProject extends Component{ this.connectProject(radioValue) } connectProject = (project_id) => { - let workId=this.props.work.homework_id; + let workId=this.work.homework_id; const url = `/homework_commons/${workId}/student_works/relate_project.json` axios.post(url, { project_id: project_id @@ -75,6 +76,9 @@ class ConnectProject extends Component{ loading: false, hasMore: result.data.projects.length != 0 }) + if (page == 1) { + this.setState({ haveProjects: result.data.projects.length > 0 }) + } } }).catch((error)=>{ console.log(error); @@ -84,11 +88,12 @@ class ConnectProject extends Component{ if (window.location.port == 3007) { window.location.href = '/testbdweb.educoder.net/projects/new' } else { - window.location.href = '/educoder.net/projects/new' + window.location.href = '/projects/new' } } //关联项目 - openConnectionProject=()=>{ + openConnectionProject=(work)=>{ + this.work = work; this.fetchData() this.setState({ project_flag:true @@ -107,7 +112,6 @@ class ConnectProject extends Component{ let {project_flag, projects, loading, hasMore }=this.state; return( - 关联项目
    { - projects && !!projects.length && + (projects && !!projects.length || this.state.keyword) &&
    {this.setState({keyword: e.target.value})}} @@ -145,7 +149,11 @@ class ConnectProject extends Component{
    } { - (!projects || projects.length == 0) && + haveProjects && projects.length == 0 && + + } + { + (!haveProjects) &&
    您当前尚未管理任何项目,请先创建项目再关联
    diff --git a/public/react/src/modules/courses/busyWork/commonWork.js b/public/react/src/modules/courses/busyWork/commonWork.js index 9f3d8dda0..a23318097 100644 --- a/public/react/src/modules/courses/busyWork/commonWork.js +++ b/public/react/src/modules/courses/busyWork/commonWork.js @@ -9,6 +9,7 @@ import '../css/busyWork.css' import CoursesListType from '../coursesPublic/CoursesListType' import CommonWorkItem from './CommonWorkItem' import PublishRightnow from './PublishRightnow' +import ConnectProject from './ConnectProject' import { WordsBtn } from 'educoder' import Modals from '../../modals/Modals' @@ -53,7 +54,9 @@ class commonWork extends Component{ let {page,search,order}=this.state; this.getList(page,search,order); } - + openConnectionProject = (work) => { + this.refs['connectProject'].openConnectionProject(work) + } // 新建 createCommonWork=(type)=>{ @@ -338,6 +341,8 @@ class commonWork extends Component{
    */} + + - +