import React from 'react'; import { connect } from 'dva'; import { Button, Row, Col, Form, Input,Select,Checkbox,Modal,Transfer,Spin ,Table,Tabs,Popconfirm,message} from 'antd'; import { extend, extendRule, initFilter, initQueryFilter, getOnlyPropertyData, extendInclude, getDataFieldValue, guid, initFilterGroup, extendGroupRule } from "../../../utils/common"; import FormPage from '../../FormPage'; const FormItem = Form.Item; const Option = Select.Option; const TabPane = Tabs.TabPane; const { TextArea } = Input; class FlowPermitEditPage extends React.Component { constructor(props) { super(props); this.state = { data: {}, btns:[], title:'流程审核', historyData:[], remark:'', }; }; componentDidMount() { this.props.form.resetFields(); this.loadData(); } componentWillReceiveProps(NextProps) { const {data}=this.props; let {id}=data?data:{}; if(!id) id=''; if (NextProps.custom['flowPermitEdit'+id] ) { this.props.form.resetFields(); this.loadData(); this.props.dispatch({ type: 'custom/save', payload: { ['flowPermitEdit'+id]:false }, }); } } loadData=()=> { const {data,formId,login,dispatch}=this.props; const {id}=data?data:{}; if(id){ const json = initFilter(this.props.login.OrgId); extendRule(json, 'ID', 1, id); extendInclude(json,'Form'); this.props.dispatch({ type: 'PFFlowPermitEdit/getFlow', payload: json, onComplete: (ret) => { if(ret){ this.setState({ data: ret, }); } } }); const historyJson = initFilter(this.props.login.OrgId,'','CREATE_TIME',1); extendRule(historyJson, 'InstanceId', 1, id); this.props.dispatch({ type: 'PFFlowPermitEdit/getOperHistoryList', payload: historyJson, onComplete: (ret) => { this.setState({ historyData: ret, }); } }); } if(formId){ const btnJson = initFilter(this.props.login.OrgId,'','NUM',0); extendRule(btnJson, 'PAGE_CUSTOM_FORM_ID', 1, formId); this.props.dispatch({ type: 'PFFlowPermitEdit/getBtnList', payload: btnJson, onComplete: (ret) => { if(ret){ this.setState({ btns: ret, }); } } }); } }; getBtns=()=>{ const isShow=this.props.data?this.props.data.isShow:false; if(isShow)return; if(this.state.btns){ return this.state.btns.map(item=>{ if(item.BTN_TYPE==7) { if (item.CLICK_EVENT == 'agree') {//同意 return this.handleOk("1")}> ; } else if (item.CLICK_EVENT == 'reject') {//驳回 return this.handleOk("3")}> ; } else if (item.CLICK_EVENT == 'disagree') {//不同意 return this.handleOk("2")}> ; } } }); } }; handleOk = (flag) => { const {form,dispatch,data} = this.props; const {getFieldValue, getFieldDecorator, validateFields, validateFieldsAndScroll, setFieldsValue} = form; validateFieldsAndScroll((errors, values) => { if (errors) return; const updateData={ FlowInstanceId:this.state.data.ID, VerificationOpinion:this.state.remark, VerificationFinally:flag, UserId:this.props.login.userId, UserName:this.props.login.user.NAME, }; dispatch({ type: 'PFFlowPermitEdit/permitFlow', payload: updateData, onComplete: (ret) => { if(ret) { if(this.state.saveFunc) { this.state.saveFunc(); } else{ this.handleClose(); }; } } }); }); }; handleClose=()=> { const {form, dispatch, data} = this.props; if (data.close) { data.close(); } message.success('执行成功'); }; handleRegSave=(saveFunc)=>{ this.setState({ saveFunc:saveFunc, }); }; showBillData=()=>{ if(this.state.data&&this.state.data.EntityId&&this.state.data.Form&&this.state.data.Form.CODE) { const isShow=this.props.data?this.props.data.isShow:false; const data = { id: this.state.data.EntityId, isShow:isShow,// this.state.data.ActivityEditable == 0, isPermit: !isShow,//this.state.data.ActivityEditable == 1, }; if(data.isPermit){//为审核才注册 data.onRegSaveFunc=this.handleRegSave; data.onCancel=this.handleClose; }; return }; }; render() { const {form, location, dispatch, match,loading} = this.props; const {getFieldValue, getFieldDecorator, validateFields, validateFieldsAndScroll, setFieldsValue} = form; const {data}=this.state; console.log(data); const isShow=this.props.data?this.props.data.isShow:false; const tableColumns=[ {title: '审核人', dataIndex: 'CreateUserName', key: 'CreateUserName'}, {title: '审核时间', dataIndex: 'CreateDate', key: 'CreateDate'}, {title: '审核结果', dataIndex: 'Content', key: 'Content'}, ] const formItemLayout = { labelCol: {span: 6}, wrapperCol: {span: 14}, }; const onChangeRemark=(e)=>{ this.setState({ remark:e.target.value, }); } const onChangeTabKey=(actionKey)=>{ if(actionKey=='2'){ if(this.state.data.FrmId) { this.props.dispatch({ type: 'editPage/save', payload: { [this.state.data.FrmId + '_reload']: true }, }); } } }; return (

{this.state.title}

{getFieldDecorator('CustomName', { validateTrigger: 'onBlur', initialValue: getDataFieldValue(data,'CustomName'), })()} {getFieldDecorator('Code', { initialValue: getDataFieldValue(data,'Code'), })()} {getFieldDecorator('CreateUserName', { initialValue: getDataFieldValue(data,'CreateUserName'), })()} {getFieldDecorator('CreateDate', { initialValue: getDataFieldValue(data,'CreateDate'), })()} {getFieldDecorator('ActivityName', { initialValue: getDataFieldValue(data,'ActivityName'), })()} {getFieldDecorator('REMARK', { })(