198 lines
10 KiB
JavaScript
198 lines
10 KiB
JavaScript
|
||
import {Button,Row,Col,Icon,message,Modal} from 'antd';
|
||
import {WeaTab,WeaProgress,WeaLocaleProvider} from 'ecCom';
|
||
import {inject, observer} from "mobx-react";
|
||
import {toJS} from 'mobx';
|
||
import {Condition} from '../list/listCondition';
|
||
import {WeaTableNew} from 'comsMobx';
|
||
import ShareDialog from '../dialog/shareDialog'
|
||
import ExchangeDialog from '../dialog/exchangeDialog'
|
||
import TaskInfoDialog from '../dialog/taskDialog'
|
||
import ModifyLogDialog from "../dialog/modifyLogDialog"
|
||
const WeaTable = WeaTableNew.WeaTable;
|
||
const getLabel = WeaLocaleProvider.getLabel;
|
||
|
||
@observer
|
||
export default class TaskSub extends React.Component {
|
||
constructor(props) {
|
||
super(props);
|
||
this.state = {
|
||
taskid: "",
|
||
coWorkVisiable: false,
|
||
workPlanVisible: false
|
||
}
|
||
|
||
}
|
||
componentDidMount(){
|
||
if(!window.weaWorkplan && !window.weaCowork){
|
||
eventRegister.loadModule('f_workplan', ()=> {
|
||
eventRegister.loadModule('f_cowork', ()=> {
|
||
}, ()=> {
|
||
// 加载文件失败 的业务处理, 网络超时,没文件之类
|
||
alert("加载协作模块失败,请联系系统管理员!");
|
||
});
|
||
}, ()=> {
|
||
// 加载文件失败 的业务处理, 网络超时,没文件之类
|
||
alert("加载日程模块失败,请联系系统管理员!");
|
||
});
|
||
return;
|
||
}
|
||
if(window.weaWorkplan && !window.weaCowork){
|
||
eventRegister.loadModule('f_cowork', ()=> {
|
||
}, ()=> {
|
||
// 加载文件失败 的业务处理, 网络超时,没文件之类
|
||
alert("加载协作模块失败,请联系系统管理员!");
|
||
});
|
||
}else{
|
||
eventRegister.loadModule('f_workplan', ()=> {
|
||
}, ()=> {
|
||
// 加载文件失败 的业务处理, 网络超时,没文件之类
|
||
alert("加载协作模块失败,请联系系统管理员!");
|
||
});
|
||
}
|
||
}
|
||
componentWillReceiveProps(nextProps) {
|
||
|
||
}
|
||
render() {
|
||
const {contentStore, account, boardStore, callBack} = this.props;
|
||
const {showSearchAd,taskSubStore,tasksubform,exchangeStore,taskInfoStore,logVisible,logTableStore,reLoad,prjid} = contentStore;
|
||
const formParams = tasksubform.getFormParams() || {};
|
||
return (
|
||
<div >
|
||
<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@7e5byf`}
|
||
buttonsAd={this.getAdButtons()}
|
||
searchType={['base','advanced']}
|
||
searchsBaseValue={formParams.taskname}
|
||
setShowSearchAd={bool=>{contentStore.setShowSearchAd(bool)}}
|
||
hideSearchAd={()=> contentStore.setShowSearchAd(false)}
|
||
searchsAd={
|
||
<div><Condition ecId={`${this && this.props && this.props.ecId || ''}_Condition@acldbm`} listStore={contentStore} form={tasksubform} onEnterSearch={this.onEnterSearch} ></Condition></div>
|
||
}
|
||
showSearchAd={showSearchAd}
|
||
onSearch={v=>{contentStore.getTaskSubList()}}
|
||
onSearchChange={v=>{contentStore.setFormFields({taskname:{value:v}})}}
|
||
/>
|
||
<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@01knth`}
|
||
comsWeaTableStore={taskSubStore}
|
||
hasOrder={true}
|
||
needScroll={true}
|
||
register_table={()=>reLoad(taskSubStore)}
|
||
getColumns={c=>this.reRenderColumns(c)}
|
||
onOperatesClick={this.onOperatesClick.bind(this)}
|
||
/>
|
||
<ShareDialog ecId={`${this && this.props && this.props.ecId || ''}_ShareDialog@4bfd3z`} contentStore={contentStore} />
|
||
<ExchangeDialog ecId={`${this && this.props && this.props.ecId || ''}_ExchangeDialog@3zxvlu`} contentStore={exchangeStore} />
|
||
<TaskInfoDialog ecId={`${this && this.props && this.props.ecId || ''}_TaskInfoDialog@iusr4g`} contentStore={taskInfoStore} prjid={prjid} callBack={()=>{if(callBack){callBack()};boardStore&&boardStore.getKanbanView();window._table.reLoad();}}/>
|
||
<ModifyLogDialog ecId={`${this && this.props && this.props.ecId || ''}_ModifyLogDialog@e0y7av`} ref="modifyLogDialog" title={getLabel(83905,"任务修改记录")} tableStore={logTableStore}/>
|
||
{window.weaCowork && window.weaCowork.com && window.weaCowork.com.CreateCowork && this.state.coWorkVisiable && this.state.taskid !== "" && (
|
||
<window.weaCowork.com.CreateCowork ecId={`${this && this.props && this.props.ecId || ''}_CreateCowork@ca5bel`}
|
||
initAddQuery={
|
||
{
|
||
relatedType: "task",
|
||
ids: this.state.taskid
|
||
}
|
||
}
|
||
onCancel={() => {
|
||
this.setState({
|
||
coWorkVisiable: false
|
||
});
|
||
}}
|
||
/>)
|
||
}
|
||
|
||
{
|
||
window.weaWorkplan && window.weaWorkplan.com && window.weaWorkplan.com.WorkPlanCreate &&
|
||
(<window.weaWorkplan.com.WorkPlanCreate ecId={`${this && this.props && this.props.ecId || ''}_WorkPlanCreate@5zdtkk`}
|
||
type={"create"}//新建为'create',查看为'preview',编辑edit,共享share
|
||
visible={this.state.workPlanVisible}//显隐受控
|
||
doClose={() => { this.setWorkPlanVisible(false); }}//关闭回调
|
||
onlyClose={() => { this.setWorkPlanVisible(false) }}//关闭回调,只做关闭操作
|
||
workPlanId={""} //日程id,1查看日程时用到
|
||
createConditionParams={[]}//创建的默认值日期和时间,没有传[]
|
||
activeKey={""} //查看页面显示的面板1是基本信息,7是相关交流
|
||
//changeTab={(key) => { }}//查看页面切换面板的回调
|
||
selectUser={account && account.userid}//新建日程的创建人id
|
||
workPlanTypeOptions={"2"}//客户模块的新建日程,普通新建传'',客户新建传3
|
||
crmIDs={[]}//通过客户模块新建日程,并自动带出相关客户,[{'id':'','name':''}]
|
||
projectid={prjid}
|
||
taskid={this.state.taskid}
|
||
description={""}//客户模块需求,支持新建时传入的'基本信息-内容'
|
||
/>)
|
||
}
|
||
</div>)
|
||
}
|
||
|
||
onEnterSearch = () =>{
|
||
const {contentStore} = this.props;
|
||
contentStore.getTaskSubList();
|
||
contentStore.setShowSearchAd(false)
|
||
}
|
||
|
||
getAdButtons = () => {
|
||
const {contentStore} = this.props;
|
||
const {getTaskSubList,setShowSearchAd,clearFormFields} = contentStore;
|
||
return [
|
||
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@0vgf1m@search`} type="primary" onClick={()=>{getTaskSubList();setShowSearchAd(false);}}>{getLabel(197,"搜索")}</Button>),
|
||
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@px783z@reset`} type="ghost" onClick={()=>{clearFormFields();}}>{getLabel(2022,"重置")}</Button>),
|
||
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@naw81q@cancel`} type="ghost" onClick={()=>{setShowSearchAd(false)}}>{getLabel(201,"取消")}</Button>)
|
||
];
|
||
}
|
||
reRenderColumns(columns){
|
||
columns.forEach(c=>{
|
||
if(c.dataIndex=='finish'){
|
||
c.render = function(text, record){
|
||
return <span className='wea-prj-progressStyle' >
|
||
<WeaProgress ecId={`${this && this.props && this.props.ecId || ''}_WeaProgress@8fcx37@cancel`} percent={record.finish||0} 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:{shareStore,exchangeStore,taskInfoStore,viewModifyLog},callBack} = this.props;
|
||
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,"task",record.randomFieldId,{})
|
||
}else if('onNewCowork' == fn){ //新建协作
|
||
this.setState({ taskid: record.randomFieldId, coWorkVisiable: true });
|
||
const coworkStoreMap = window.weaCowork.store && window.weaCowork.store.coworkStoreMap;
|
||
const cowortore = coworkStoreMap && coworkStoreMap.getMapStore(3);
|
||
cowortore && cowortore.setCreateState({ showNewCowork: true, createOrEdit: 0 });
|
||
}else if('onNewWorkplan' == fn){ //新建日程
|
||
this.setState({ taskid: record.randomFieldId, workPlanVisible: true });
|
||
}else if('onApprove' == fn){ //
|
||
|
||
}else if('onReject' == fn){ //
|
||
|
||
}else if('onEdit' == fn){ //编辑
|
||
taskInfoStore.handleDialog(true,"edit",record.randomFieldId);
|
||
}else if('onLog' == fn){ //修改记录
|
||
viewModifyLog(record.randomFieldId);
|
||
this.refs.modifyLogDialog.setVisible(true);
|
||
}else if('onDiscuss' == fn){ //相关交流
|
||
exchangeStore.handleExchangeDialog(true,"task",record.randomFieldId,{})
|
||
}else if('onDel' == fn){ //删除
|
||
taskInfoStore.delTask("del",record.randomFieldId,{callBack:() =>{callBack();window._table.reLoad();}});
|
||
}
|
||
}
|
||
}
|
||
|
||
setWorkPlanVisible = (bool) => {
|
||
this.setState({ workPlanVisible: bool })
|
||
}
|
||
|
||
}
|
||
|