weaver_trunk_cli/pc4mobx/prj/components/dialog/taskDialog.js

145 lines
6.0 KiB
JavaScript

import React from 'react';
import { inject, observer } from 'mobx-react';
import {WeaDialog,WeaRightMenu,WeaNewScroll,WeaFormItem,WeaSearchGroup,WeaLocaleProvider} from "ecCom"
import {Button,message, Spin} from "antd"
import {WeaTableNew,WeaSwitch} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
const getLabel = WeaLocaleProvider.getLabel;
import {toJS} from "mobx"
import equal from 'deep-equal'
import TaskInfo from '../common/taskInfo'
import * as Task_Apis from '../../apis/task'
@observer
export default class TaskDialog extends React.Component{
constructor(props) {
super(props);
this.state = {
loading: false,
}
}
componentWillReceiveProps(nextProps){
}
shouldComponentUpdate(){
return true;
}
render(){
const {contentStore} = this.props;
const {visible,taskForm,taskInfo,title,handleDialog} = contentStore;
return (
<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@2wg3ls`}
title={title }
visible={visible}
buttons={this.getBottomButtons()}
icon="icon-coms-project"
iconBgcolor="#217346"
onCancel={()=>{handleDialog(false)}}
style={{width:1000,height:700}}>
<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@0bwnkl`} datas={this.getRightMenu()} onClick={this.onRightMenuClick.bind(this)} >
<WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@5hfoke`} height={"100%"}>
<TaskInfo ecId={`${this && this.props && this.props.ecId || ''}_TaskInfo@d1nn6g`} listStore = {contentStore} form={taskForm} />
</WeaNewScroll>
</WeaRightMenu>
</WeaDialog>
)
}
getBottomButtons(){
const {contentStore} = this.props;
const {handleDialog,rightMenu} = contentStore;
let btnArr = [];
rightMenu && rightMenu.length>0 && rightMenu.map(m=>{
m.isTop == '1' && btnArr.length < 4 && btnArr.push(
<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@r6qjcz@${m.type}`} type="primary"
onClick={()=>{
if(m.type == "BTN_SAVE"){ //保存
this.saveTaskInfo();
}
}}
disabled = {this.state.loading}
>
{m.menuName}
</Button>
);
});
btnArr.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@e8ikk2@close`} type="primary" disabled = {this.state.loading} onClick={()=>{handleDialog(false)}}>{getLabel(309,"关闭")}</Button>)
return btnArr;
}
getRightMenu(){
const {contentStore} = this.props;
const {handleDialog,rightMenu} = contentStore;
let btnArr = [];
rightMenu && rightMenu.length>0 && rightMenu.map(m=>{
btnArr.push({
icon: <i className={m.menuIcon} />,
content: m.menuName,
disabled : this.state.loading
})
});
return btnArr
}
onRightMenuClick(key){
const {contentStore} = this.props;
const {handleDialog,rightMenu} = contentStore;
let that = this;
rightMenu && rightMenu.length>0 && rightMenu.map((m,i)=>{
if(Number(key) == i){
if(m.type == "BTN_SAVE"){ //验收
this.saveTaskInfo();
}else if(m.type == 'BTN_BACK'){ //返回
//showCptInfo(true,{capitalid:capitalid,viewtype:'edit'});
}
}
});
}
saveTaskInfo= (params={})=>{
const {prjid,contentStore,callBack} = this.props;
const {handleDialog,taskForm,taskInfo,type,taskid,baseParams,validateRules} = contentStore;
taskForm.validateForm().then(f=>{
if(f.isValid){
this.setState({loading:true});
let newParams = {...baseParams,...toJS(taskForm.getFormParams()),method:type,taskid:taskid,prjid:prjid||"",...params};
const {field18} = newParams;
Task_Apis.getCheckRole({roleid:field18}).then(data=>{
if(data.data.isAccess){
Task_Apis.saveTaskInfo(newParams).then(data=>{
if(data.success){
handleDialog(false);
message.success(getLabel(18758, "保存成功"));
if(callBack){
callBack();
}else{
window._table.reLoad();
}
}else{
message.error(getLabel(383746,"请求失败")+": "+data.msgcode);
}
this.setState({loading:false});
})
}else{
message.error("审批人选择角色下不存在人员!");
this.setState({loading:false});
}
})
// Task_Apis.saveTaskInfo(newParams).then(data=>{
// if(data.success){
// handleDialog(false);
// message.success(getLabel(18758, "保存成功"));
// if(callBack){
// callBack();
// }else{
// window._table.reLoad();
// }
// }else{
// message.error(getLabel(383746,"请求失败")+": "+data.msgcode);
// }
// this.setState({loading:false});
// })
}else{
f.showErrors();
}
});
}
}