weaver_trunk_cli/pc4mobx/prj/components/mineProject.js

250 lines
11 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react';
import { inject, observer } from 'mobx-react';
import { Button, Tabs,Card,Pagination,Row,Col } from 'antd';
import {toJS} from "mobx";
import {Condition,getAdButtons} from './list/listCondition';
import {WeaTableNew} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
import {WeaRightMenu,WeaTop,WeaTab,WeaErrorPage,WeaBrowser,WeaTools,WeaLeftRightLayout,WeaProgress,WeaLocaleProvider} from 'ecCom';
import ListLeftTree from './list/listLeftTree'
import ShareDialog from './dialog/shareDialog'
import ExchangeDialog from './dialog/exchangeDialog'
import ProjectDialog from './dialog/projectDialog'
const getLabel = WeaLocaleProvider.getLabel;
@inject('minePrjStore')
@observer
class MineProject extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
this.doInit(this.props);
}
doInit(props){
const { location:{query},minePrjStore } = props;
const {initDatas,doSearch,initTreeDatas} = minePrjStore;
initDatas(query);
//initTreeDatas(query);
}
componentWillReceiveProps(nextProps){
const keyOld = this.props.location.key;
const keyNew = nextProps.location.key;
const oldParams = this.props.location.query;
const newParams = nextProps.location.query;
if (keyOld !== keyNew || oldParams !== newParams) {
const {minePrjStore} = nextProps;
minePrjStore.clearStatus();
this.doInit(nextProps);
}
}
componentWillUnmount(){
const { minePrjStore } = this.props;
minePrjStore.clearStatus();
}
render(){
let title = getLabel(1211,"我的项目");
let topTab = [
{
color: '#000000',
groupid: 'totalCount1',
showcount: true,
title: getLabel(332,"全部"),
tabkey: "all"
},
{
color: '#ff3232',
groupid: 'totalCount2',
showcount: true,
title: getLabel(732,"未完成"),
tabkey: "doing"
},
{
color: '#fea468',
groupid: 'totalCount3',
showcount: true,
title: getLabel(1232,"冻结"),
tabkey: "frozen"
},
{
color: '#9766fd',
groupid: 'totalCount4',
showcount: true,
title: getLabel(555,"完成"),
tabkey: "complete"
}
];
const {minePrjStore} = this.props;
const {loading,tableStore,showSearchAd,showBatchSubmit,form,config,topTabCount,exchangeStore,projectInfoStore,searchParams,reLoad,showLeft} = minePrjStore;
const formParams = form.getFormParams() || {};
return (
<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@2yveh1`} datas={this.getRightMenu()} onClick={this.onRightMenuClick.bind(this)} >
<WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@69e1vl`}
title={title}
loading={loading}
icon={<i className='icon-coms-project' />}
iconBgcolor='#217346'
buttons={[]}
buttonSpace={10}
showDropIcon={true}
dropMenuDatas={this.getRightMenu()}
onDropMenuClick={this.onRightMenuClick.bind(this)}
>
<WeaLeftRightLayout ecId={`${this && this.props && this.props.ecId || ''}_WeaLeftRightLayout@23pnoc`}
isNew = {true}
showLeft = {showLeft}
leftCom={<ListLeftTree ecId={`${this && this.props && this.props.ecId || ''}_ListLeftTree@jmz254`} listStore={minePrjStore} key={this.props.location.key} initkey={"doing"} />}
onCollapse={showLeft => minePrjStore.setLeftShow(showLeft)}
>
<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@ty4e6e`}
datas={topTab}
counts={topTabCount}
keyParam="tabkey" //主键
countParam="groupid" //数量
selectedKey={ searchParams.tabkey }
buttonsAd={getAdButtons(minePrjStore,this.props.ecId || '')}
searchType={['base','advanced']}
searchsBaseValue={formParams.prjname}
setShowSearchAd={bool=>{minePrjStore.setShowSearchAd(bool)}}
hideSearchAd={()=> minePrjStore.setShowSearchAd(false)}
searchsAd={
<div><Condition ecId={`${this && this.props && this.props.ecId || ''}_Condition@1k4c2v`} listStore={minePrjStore} form={form} onEnterSearch={this.onEnterSearch} ></Condition></div>
}
showSearchAd={showSearchAd}
onSearch={v=>{minePrjStore.doSearch()}}
onSearchChange={v=>{minePrjStore.setFormFields({prjname:{value:v}})}}
onChange={ this.changeData }
/>
<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@agucty`}
comsWeaTableStore={tableStore}
hasOrder={true}
needScroll={true}
register_table={()=>reLoad()}
getColumns={c=>this.reRenderColumns(c)}
tableWidth={this.tableWidth}
onOperatesClick={this.onOperatesClick.bind(this)}
/>
</WeaLeftRightLayout>
</WeaTop>
<ShareDialog ecId={`${this && this.props && this.props.ecId || ''}_ShareDialog@6cxkg7`} contentStore={minePrjStore} />
<ExchangeDialog ecId={`${this && this.props && this.props.ecId || ''}_ExchangeDialog@rr5a0b`} contentStore={exchangeStore} />
<ProjectDialog ecId={`${this && this.props && this.props.ecId || ''}_ProjectDialog@zpkkfq`} contentStore={projectInfoStore}/>
{//<TaskListDialog contentStore={taskListStore} />
}
</WeaRightMenu>)
}
getRightMenu(){
const {minePrjStore }= this.props;
const {rightMenu} = minePrjStore;
let btnArr = [];
rightMenu && rightMenu.length>0 && rightMenu.map(m=>{
btnArr.push({
icon: <i className={m.menuIcon} />,
content: m.menuName
})
});
return btnArr
}
onRightMenuClick(key){
const {minePrjStore }= this.props;
const {rightMenu} = minePrjStore;
let that = this;
rightMenu && rightMenu.length>0 && rightMenu.map((m,i)=>{
if(Number(key) == i){
let fn = m.menuFun.indexOf('this') >= 0 ? `${m.menuFun.split('this')[0]})` : m.menuFun;
if(m.type == "BTN_SEARCH"){ //定制列
minePrjStore.doSearch();
}else if(m.type == "BTN_COLUMN"){ //定制列
minePrjStore.onShowColumn();
}
}
});
}
reRenderColumns(columns){
columns.forEach((c,i)=>{
if(c.dataIndex=='finish'){
c.render = function(text, record){
return <span className='wea-prj-progressStyle' >
<WeaProgress ecId={`${this && this.props && this.props.ecId || ''}_WeaProgress@yksmei@${i}`} percent={record.finish} strokeColor={record.finishspan} />
</span>
}
} else {
// c.render = function(text, record){
// let valueSpan = record[c.dataIndex + "span"] !== undefined ? record[c.dataIndex + "span"] : record[c.dataIndex];
// return <span dangerouslySetInnerHTML={{__html: valueSpan}}></span>
// }
}
})
return columns;
}
tableWidth = (columns) => {
let width = 0;
let cols = 0;
columns.map(col => {
if (col.display === 'true') {
let oldwidth = col.oldWidth || '10%';
let widthInt = parseFloat(oldwidth.replace('%', ''));
if (widthInt <= 0) {
widthInt = 10;
}
width += widthInt;
cols++
}
})
//超过10列才出现滚动条width>100才出现滚动条
if(cols<=10){
width = 100 ;
}
return `${width}%`;
}
changeData=(key)=>{
const {minePrjStore} = this.props;
minePrjStore.setShowSearchAd(false);
minePrjStore.doSearch({tabkey:key });
// minePrjStore.initDatas({tabkey:key });
}
onOperatesClick(record,index,operate,flag){
const {minePrjStore} = this.props;
const {shareStore,exchangeStore,projectInfoStore} = minePrjStore;
let _href = operate && operate.href ? operate.href : "";
let fn = _href.replace("javascript:","");
fn = fn.substring(0,fn.indexOf('('));
let that = this;
if(fn != ""){
if("onShare"==fn){ //共享
shareStore.handleShareDialog(true,"prj",record.randomFieldId)
}else if('onNormal' == fn){ //正常
minePrjStore.doPlanOpt({method:'normal',prjid:record.randomFieldId})
}else if('onOver' == fn){ //延期
minePrjStore.doPlanOpt({method:'delay',prjid:record.randomFieldId})
}else if('onFinish' == fn){ //完成
minePrjStore.doPlanOpt({method:'complete',prjid:record.randomFieldId})
}else if('onFrozen' == fn){ //冻结
minePrjStore.doPlanOpt({method:'freeze',prjid:record.randomFieldId})
}else if('onEdit' == fn){ //编辑
projectInfoStore.handleDialog(true,record.randomFieldId,{viewtype:'edit',prjid:record.randomFieldId}) ;
}else if('onListTask' == fn){ //任务列表
// taskListStore.showTaskLiskModal(true,record.randomFieldId);
}else if('onDiscuss' == fn){ //相关交流
exchangeStore.handleExchangeDialog(true,"prj",record.randomFieldId,{})
}else if('onDel' == fn){ //项目删除
minePrjStore.delPrjInfo({method:"del",prjid:record.randomFieldId,from:"mymanagerproject"})
}
}
}
onEnterSearch=() =>{
const {minePrjStore }= this.props;
minePrjStore.doSearch();
minePrjStore.setShowSearchAd(false);
}
}
export default WeaTools.tryCatch(React,
props => <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@urydlw`} msg={ props.error ? props.error : getLabel(383324,"对不起,该页面异常,请联系管理员")} />,
{error: ""}
)(MineProject);