import React from 'react'; import { Button, Row, Col, Modal, message} from 'antd'; import { inject, observer } from 'mobx-react'; import {routerShape} from 'react-router'; import { WeaTab, WeaTop, WeaSteps, WeaNewScroll, WeaRichText, WeaDialog, WeaTextarea, WeaBrowser, WeaRightMenu, WeaTools, WeaReqTop, WeaAlertPage } from 'ecCom'; import { toJS } from "mobx"; import { imgZoom} from '../../util/index'; import { WeaLocaleProvider } from 'ecCom'; const getLabel = WeaLocaleProvider.getLabel; const confirm = Modal.confirm; import "./index.less"; import TaskView from './TaskView'; import ProjectSub from '../single/project/ProjectSub'; import StageSetList from '../single/project/StageSetList'; import ResourcePage from '../single/project/ResourcePage'; import ProjectStastics from '../single/project/ProjectStastics'; import Ovreview from './cardContent/overview.js'; import PrjSelect from './prjSelect/prjSelect.js'; import PrjForm from "../prjForm.js"; import Edit from "./edit"; import { Count } from "./cardContent/count"; import { Header } from "./cardContent/header"; import { JlChild, jlParamsHandle, Daily, Log } from "../tools/dtConfig"; import Report from "../prjReport"; import ProjectDialog from '../dialog/projectDialog' import SaveTemplateDialog from "../dialog/SaveTemplateDialog" import ProjectShare from '../common/sharePage' @inject("projectCardStore", "taskCardNewStore") @observer class ProjectCard extends React.Component { static contextTypes = { router: routerShape } static defaultProps = { prefixCls: 'prj-portal' }; constructor(props) { super(props); this.state = { selectedKey: "1", value: "3", viewAttr: 3, selectedDynamicTab: 0, showDailyDiv: false, showExDiv: false, showReply: {}, showDailyEdit: {}, visible: false, showRich: false, richValue: '', richValueChangeMethod: () =>{}, richMethod: () =>{}, isCreate:true, workPlanVisible:false }; } componentDidMount() { let dom = ReactDOM.findDOMNode(this); imgZoom(dom, ".wea-cl-content"); const {projectCardStore,location,prjid} = this.props; const {prjCardStore} = projectCardStore; // const {prjid} = location.query; if(prjid==''||prjid==null){ projectCardStore.setPrjid(location.query.prjid); prjCardStore.getPrjTabs({prjid : location.query.prjid}); }else{ projectCardStore.setPrjid(prjid); prjCardStore.getPrjTabs({prjid : prjid}); } if (!window.weaWorkplan) { // 异步加载别模块的静态资源 eventRegister.loadModule('f_workplan', () => { prjCardStore.setLoaded(true) }, () => { // 加载文件失败 的业务处理, 网络超时,没文件之类 }) } else { prjCardStore.setLoaded(true) } } componentWillReceiveProps(nextProps, nextState) { const {prjid}= this.props; if(prjid==''||prjid==null){ const { selectedKey } = this.state; const { projectCardStore, location } = nextProps; const { topTab, prjCardStore, getRightMenu, getPortalProjectInfo, setPrjidFun } = projectCardStore; const {prjid} = location.query; projectCardStore.setPrjid(prjid); prjCardStore.getPrjTabs({prjid : prjid}); const tabDatas1 = toJS(topTab); if (tabDatas1) { for (let i = 0; i < tabDatas1.length; i++) { if(tabDatas1[i].shortname == "prjinfo" && tabDatas1[i].key == selectedKey) {//项目卡片 this.setState({ selectedDynamicTab: 0, showDailyDiv: false, showExDiv: false, showReply: {}, showRich: false }); let dom = ReactDOM.findDOMNode(this); imgZoom(dom, ".wea-cl-content"); projectCardStore.setPrjid(prjid); if (!window.weaWorkplan) { // 异步加载别模块的静态资源 eventRegister.loadModule('f_workplan', () => { prjCardStore.setLoaded(true) }, () => { // 加载文件失败 的业务处理, 网络超时,没文件之类 }) } else { prjCardStore.setLoaded(true) } }else if (tabDatas1[i].shortname == "prjshare" && tabDatas1[i].key == selectedKey) {//项目共享 prjCardStore.prjid = prjid; prjCardStore.getPrjShareList(); getRightMenu({'type':'prjshare'}); }else if(tabDatas1[i].shortname == "tasklist" && tabDatas1[i].key == selectedKey){//任务列表 getRightMenu({'type':'taskview'}); }else if(tabDatas1[i].key == selectedKey && tabDatas1[i].shortname == "gantt") { //甘特图 setPrjidFun(prjid); getPortalProjectInfo(); } } } }else{ const { selectedKey } = this.state; const { projectCardStore, prjid } = nextProps; const { topTab, prjCardStore, getRightMenu, setPrjidFun, getPortalProjectInfo } = projectCardStore; projectCardStore.setPrjid(prjid); prjCardStore.getPrjTabs({prjid : prjid}); const tabDatas1 = toJS(topTab); if (tabDatas1) { for (let i = 0; i < tabDatas1.length; i++) { if(tabDatas1[i].shortname == "prjinfo" && tabDatas1[i].key == selectedKey) {//项目卡片 this.setState({ selectedDynamicTab: 0, showDailyDiv: false, showExDiv: false, showReply: {}, showRich: false }); let dom = ReactDOM.findDOMNode(this); imgZoom(dom, ".wea-cl-content"); projectCardStore.setPrjid(prjid); if (!window.weaWorkplan) { // 异步加载别模块的静态资源 eventRegister.loadModule('f_workplan', () => { prjCardStore.setLoaded(true) }, () => { // 加载文件失败 的业务处理, 网络超时,没文件之类 }) } else { prjCardStore.setLoaded(true) } }else if (tabDatas1[i].shortname == "prjshare" && tabDatas1[i].key == selectedKey) {//项目共享 prjCardStore.prjid = prjid; prjCardStore.getPrjShareList(); getRightMenu({'type':'prjshare'}); }else if(tabDatas1[i].shortname == "tasklist" && tabDatas1[i].key == selectedKey){//任务列表 setPrjidFun(prjid); getRightMenu({'type':'taskview'}); }else if(tabDatas1[i].key == selectedKey && tabDatas1[i].shortname == "gantt") { //甘特图 setPrjidFun(prjid); getPortalProjectInfo(); } } } } } componentDidUpdate(prevProps, prevState) { let dom = ReactDOM.findDOMNode(this); imgZoom(dom, ".wea-cl-content"); } initPage = (v) => { const { selectedKey } = this.state; if (selectedKey === "1") { this.props.projectCardStore.setPrjid(v); } } render() { const { prefixCls, projectCardStore, location, fromPortal, changeCallBack = () =>{}, dellCallBack } = this.props; let prjid = this.props.prjid; if(prjid==''||prjid==null){ prjid = location.query.prjid; } const { baseInfo, projectInfo:{fieldinfo}, loading, exchangeList, submitDaily, apiErr, canSubmitDaily, statistics: { rwzs }, projectInfo:{prjname}, projectInfoStore, getPortalProjectInfo, topTab, prjCardStore, getPortalProjectDynamicInfo,isright } = projectCardStore; const { selectedDynamicTab, visible, showRich, richValue, selectedKey } = this.state; const { manager, managericons, planbegindate, planenddate, stages, members, creatername, createdate } = baseInfo; const overviewProp = { loading, manager, managericons, stages, planbegindate, planenddate }; const account = WeaTools.ls.getJSONObj('theme-account'); const checkOptions = [ { title: getLabel('332','全部'), index: 0 }, { title: getLabel('20620','日报'), index: 1 }, { title: getLabel('518347','交流'), index: 2 }, { title: getLabel('83','日志'), index: 3 } ]; const Elem = (
{checkOptions.map((opt, index) => (
{ this.changeDynamicTab(index);this.setState({richValue:''}); }}>{opt.title}
))}
); const height = document.body.offsetHeight - $(".prj-portal-page .wea-new-top-wapper").height() - 56 - 225; let scrollHeight = ($(".e9theme-layout-header").length > 0 || $(".e8theme-layout-header").length > 0) ? height - 55 - 20 : height - 20; if(fromPortal){ scrollHeight = scrollHeight - 51; } const richSubmitfun = selectedDynamicTab == 1 ? submitDaily : this.dosubmit; const richid = { "1": "create_daily", "2": "create_discuss" }[selectedDynamicTab.toString()] let richPlaceholder = { "1": getLabel('518257','填写日报'), "2": getLabel('518258','填写相关交流') }[selectedDynamicTab.toString()]; const canSubmit = { "1": canSubmitDaily, "2": true }[selectedDynamicTab.toString()]; if(!canSubmit){ richPlaceholder += '('+getLabel('520676','一天只能提交一次') +')'; } const richProps = { transfStr: this.transfStr, richChange: this.richChange, richSubmitfun: richSubmitfun, showRichfun: this.showRichfun, showDialogfun: this.showDialogfun, setIsCreate: (bool) =>{this.setState({isCreate:bool})}, exchangeList, richid, showRich, richPlaceholder, loading, canSubmit } const richDom = (hasEdit = true) => (
{hasEdit && } {this.getDynamicContent()}
); if (apiErr === true) { return ( Modal.warning({ title: getLabel('518351','发生错误'), content: getLabel('504523','请联系管理员'), onOk() { window.location.reload() } }) ) } const tabDatas1 = toJS(topTab); const that = this; let tabUrl = function (key) { if (tabDatas1) { for (let i = 0; i < tabDatas1.length; i++) { if (tabDatas1[i].key == key && tabDatas1[i].shortname == "prjinfo") { //基本信息 return
{prjname} 
({creatername} {getLabel('127511','创建于') } {createdate}) } buttons={that.getButtons()} showDropIcon={true} dropMenuDatas={that.getRightMenu()} onDropMenuClick={that.onRightMenuClick.bind(that)} /> {/*
*/}
{getLabel('518262','项目动态')} 
{Elem} { { '0': richDom(false), '1': richDom(), "2": richDom(), '3': richDom(false) }[selectedDynamicTab.toString()] }
{ if(fromPortal){ changeCallBack&&changeCallBack(); } getPortalProjectInfo(); if(selectedDynamicTab==0){ getPortalProjectDynamicInfo("all"); }else if(selectedDynamicTab==3){ getPortalProjectDynamicInfo("log"); } }} dellCallBack={that.dellCallBack} from={'portal'} /> { prjCardStore.isreload && window.weaWorkplan && window.weaWorkplan.com && window.weaWorkplan.com.WorkPlanCreate && ( { that.setWorkPlanVisible(false); }}//关闭回调 onlyClose={() => { that.setWorkPlanVisible(false) }}//关闭回调,只做关闭操作 workPlanId={""} //日程id,1查看日程时用到 createConditionParams={[]}//创建的默认值日期和时间,没有传[] activeKey={""} //查看页面显示的面板1是基本信息,7是相关交流 //{(key) => { }}//查看页面切换面板的回调 selectUser={account && account.userid}//新建日程的创建人id workPlanTypeOptions={"2"}//客户模块的新建日程,普通新建传'',客户新建传3 crmIDs={[]}//通过客户模块新建日程,并自动带出相关客户,[{'id':'','name':''}] projectid={prjid} description={""}//客户模块需求,支持新建时传入的'基本信息-内容' />) }
} else if (tabDatas1[i].key == key && tabDatas1[i].shortname == "tasklist") {//任务列表 return {changeCallBack();}}/> } else if (tabDatas1[i].key == key && tabDatas1[i].shortname == "childprj") { //子项目 return } else if (tabDatas1[i].key == key && tabDatas1[i].shortname == "prjshare") { //共享设置 return } else if (tabDatas1[i].key == key && tabDatas1[i].shortname == "stareport") { //统计报告 return } else if (tabDatas1[i].key == key && tabDatas1[i].shortname == "gantt") { //甘特图 return tabDatas1[i].linkurl; //"/proj/gantt/gantt.jsp?projectid=8&ProjID=8"; } else if (tabDatas1[i].key == key && tabDatas1[i].shortname == "stageset") { //阶段设置 return } else if (tabDatas1[i].key == key && tabDatas1[i].shortname == "resources") { //相关资源 return } else if (tabDatas1[i].key == key && tabDatas1[i].shortname == "") { if(tabDatas1[i].linkurl.indexOf("/main/prj/prjReport") > -1){ return ; }else if (tabDatas1[i].linkurl.indexOf("noright") > -1) { return
{getLabel(2012, "对不起,您暂时没有权限!")}
} else { return tabDatas1[i].linkurl; } } } return "" } }(selectedKey); const editHeight = window.screen.width>=1920?"600px":"400px"; if (!isright) { return
{getLabel(2012, "对不起,您暂时没有权限!")}
}else{ return (
{ this.forwardProjectCard(v); }} /> } icon={fromPortal?'':} iconBgcolor={fromPortal?'':'#217346'} /> {this.changeTab(v);}} />
{ typeof tabUrl === "object" ? { tabUrl } :