weaver_trunk_cli/pc4mobx/prj/components/common/projectSub.js

136 lines
6.8 KiB
JavaScript

import {Button,Row,Col,Icon,message,Modal} from 'antd';
import {WeaTab,WeaAlertPage, WeaProgress,WeaLocaleProvider} from 'ecCom';
import {inject, observer} from "mobx-react";
import {toJS} from 'mobx';
import {Condition} from '../list/listCondition';
import ProjectDialog from '../dialog/projectDialog'
import ShareDialog from '../dialog/shareDialog'
import ExchangeDialog from '../dialog/exchangeDialog'
import {WeaTableNew} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
const getLabel = WeaLocaleProvider.getLabel;
@observer
export default class ProjectSub extends React.Component {
constructor(props) {
super(props);
}
componentDidMount(){
}
componentWillReceiveProps(nextProps) {
}
render() {
const {contentStore} = this.props;
const {showSearchAd,prjSubStore,prjSubform,condition,prjsubRight:{hasRight,verified},exchangeStore,projectInfoStore,reLoad} = contentStore;
const formParams = prjSubform.getFormParams() || {};
if (verified && !hasRight) {
return (<WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@f10zei`} >
<div style={{color : '#000'}}>
{getLabel(2012,"对不起,您暂时没有权限!")}
</div>
</WeaAlertPage>
)
}
if (verified && hasRight) {
return (
<div >
<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@hfqond`}
buttonsAd={this.getAdButtons()}
searchType={['base','advanced']}
searchsBaseValue={formParams.prjname}
setShowSearchAd={bool=>{contentStore.setShowSearchAd(bool)}}
hideSearchAd={()=> contentStore.setShowSearchAd(false)}
searchsAd={
<div><Condition ecId={`${this && this.props && this.props.ecId || ''}_Condition@t7d1nt`} listStore={contentStore} form={prjSubform} onEnterSearch={this.onEnterSearch} ></Condition></div>
}
showSearchAd={showSearchAd}
onSearch={v=>{contentStore.getPrjSubList()}}
onSearchChange={v=>{contentStore.appendFormFields({prjname:{value:v}})}}
/>
<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@cni1ev`}
comsWeaTableStore={prjSubStore}
hasOrder={true}
needScroll={true}
register_table={()=>reLoad(prjSubStore)}
getColumns={c=>this.reRenderColumns(c)}
onOperatesClick={this.onOperatesClick.bind(this)}
/>
<ShareDialog ecId={`${this && this.props && this.props.ecId || ''}_ShareDialog@r71zyb`} contentStore={contentStore} />
<ExchangeDialog ecId={`${this && this.props && this.props.ecId || ''}_ExchangeDialog@5ropxi`} contentStore={exchangeStore} />
<ProjectDialog ecId={`${this && this.props && this.props.ecId || ''}_ProjectDialog@dt5qia`} contentStore={projectInfoStore}/>
</div>)
}
return <div></div>
}
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@orj630@${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;
}
onOperatesClick(record,index,operate,flag){
const {contentStore} = this.props;
const {shareStore,exchangeStore,projectInfoStore} = contentStore;
let _href = operate && operate.href ? operate.href : "";
let fn = _href.replace("javascript:","");
fn = fn.substring(0,fn.indexOf('('));
let that = this;
// saveCapitalId(record.randomFieldId); //保存资产id
if(fn != ""){
if("onShare"==fn){ //共享
shareStore.handleShareDialog(true,"prj",record.randomFieldId)
}else if('onNormal' == fn){ //正常
contentStore.doSubPlanOpt({method:'normal',prjid:record.randomFieldId})
}else if('onOver' == fn){ //延期
contentStore.doSubPlanOpt({method:'delay',prjid:record.randomFieldId})
}else if('onFinish' == fn){ //完成
contentStore.doSubPlanOpt({method:'complete',prjid:record.randomFieldId})
}else if('onFrozen' == fn){ //冻结
contentStore.doSubPlanOpt({method:'freeze',prjid:record.randomFieldId})
}else if('onEdit' == fn){ //编辑
projectInfoStore.handleDialog(true,record.randomFieldId,{viewtype:'edit',prjid:record.randomFieldId}) ;
}else if('onListTask' == fn){ //任务列表
}else if('onDiscuss' == fn){ //相关交流
exchangeStore.handleExchangeDialog(true,"prj",record.randomFieldId,{})
}
}
}
getAdButtons = () => {
const {contentStore} = this.props;
const {getPrjSubList,setShowSearchAd,clearFormFields} = contentStore;
return [
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@wlo7kl@search`} type="primary" onClick={()=>{getPrjSubList();setShowSearchAd(false);}}>{getLabel(197,"搜索")}</Button>),
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@wu4o2i@reset`} type="ghost" onClick={()=>{clearFormFields();}}>{getLabel(2022,"重置")}</Button>),
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@cbpg50@cancel`} type="ghost" onClick={()=>{setShowSearchAd(false)}}>{getLabel(201,"取消")}</Button>)
];
}
onEnterSearch=()=>{
const {contentStore} = this.props;
contentStore.getPrjSubList();
contentStore.setShowSearchAd(false);
}
}