import React from 'react'; import { Icon, Form, Button, Input, Select, Spin, Table, DatePicker, message, Modal, Checkbox, Upload } from 'antd'; import { cognizanceStateList } from '../../dataDic.js'; import { getCognizanceState, beforeUpload, beforeUploadFile, downloadFile } from '../../tools.js'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; const ApplyChangeFrom = Form.create()(React.createClass({ loadData(id) { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/techproject/techProjectDetial", data: { pid: id || this.props.data.pid }, success: function (data) { if (data.error.length || !data.data) { message.warning(data.error[0].message); return; }; this.state.data = data.data; if (data.data.projectMode == 1) { this.state.projectMode = data.data.projectMode; this.setState({projectModeState:true}); } if (data.data.subsidy == 1) { this.state.subsidy = data.data.subsidy; this.setState({subsidyState:true}); } this.getDepartmentList(); this.getContactsList(); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getStateData(id) { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/techproject/techProjectLog", data: { pid: id || this.props.data.pid }, success: function (data) { if (data.error.length || !data.data) { message.warning(data.error[0].message); return; }; var myDate = new Date(); this.state.stateTable = []; for (let i = 0; i < data.data.length; i++) { this.state.stateTable.push({ key: i, state: data.data[i].state, recordTime: myDate.toLocaleDateString(data.data[i].recordTime), principal: data.data[i].principal, comment: data.data[i].comment }); }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getDepartmentList () { this.setState({ loading: true }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/getDepartment", success: function (data) { this.state.departmentOption = []; if (data.error.length || !data.data) { message.warning(data.error[0].message); return; }; for (var item in data.data) { this.state.departmentOption.push( {data.data[item]} ) }; this.setState({department:data.data[this.state.data.department]}); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getContactsList() { $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/getContacts", success: function (data) { let theOption = []; if (data.error.length || !data.data) { return; }; for (let item in data.data) { let theData = data.data[item]; theOption.push( {theData} ); }; this.setState({ contactsOption: theOption, contacts: data.data[this.state.data.contacts] }); }.bind(this), }); }, getInitialState() { return { loading: false, departmentOption: [], projectDes:'', projectMode: 0, subsidy: 0, projectModeState: false, subsidyState: false, stateColumns: [{ title: '专利状态', dataIndex: 'state', key: 'state', render: (text) => { return getCognizanceState(text) } }, { title: '处理时间', dataIndex: 'recordTime', key: 'recordTime' }, { title: '负责人', dataIndex: 'principal', key: 'principal', }, { title: '备注', dataIndex: 'comment', key: 'comment', }], stateTable: [] }; }, componentWillMount() { this.loadData(); this.getStateData(); }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.props.spinState(true); let contacts = !isNaN(values.contacts) ? values.contacts : this.state.data.contacts; $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/techproject/updateTechProject", data: { id: this.props.data.pid, contacts: contacts, department: values.department, projectName: values.projectName, projectCatagory: values.projectCatagory, techField: values.techField, projectDes: values.projectDes, projectMode: this.state.projectMode, projectApproval: values.projectApproval, subsidy: this.state.subsidy, approvalUrl: this.state.approvalUrl, } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); this.props.closeModal(); this.props.form.resetFields(); this.props.spinState(false); } else { message.warning(data.error[0].message); this.props.spinState(false); } }.bind(this)); } }); }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.loadData(nextProps.data.pid); this.getStateData(nextProps.data.pid); }; }, projectEstablishmentCheck(e) { if (e.target.checked == true) { this.setState({projectModeState:true}) this.state.projectMode = 1; } else if (e.target.checked == false) { this.setState({projectModeState:false}) this.state.projectMode = 0; }; }, subsidyCheck(e) { if (e.target.checked == true) { this.setState({subsidyState:true}) this.state.subsidy = 1; } else if (e.target.checked == false) { this.setState({subsidyState:false}) this.state.subsidy = 0; }; }, render() { const FormItem = Form.Item; const { getFieldDecorator } = this.props.form; const theData = this.state.data; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 12 }, }; const _me = this; if (this.state.data) { return (
公司名称: {theData.unitName}
公司组织机构代码: {theData.orgCode}
公司地址: {theData.province+' '+theData.city+' '+theData.area}
{getFieldDecorator('contacts', { initialValue: this.state.contacts })( )}
{getFieldDecorator('department', { initialValue: this.state.department })( )}
派单信息: {theData.dispatchInfo}
{getFieldDecorator('projectName', { initialValue: theData.projectName })( )}
{getFieldDecorator('projectCatagory', { initialValue: theData.projectCatagory })( )}
{getFieldDecorator('techField', { initialValue: theData.techField })( )}
项目简介: {getFieldDecorator('projectDes', { initialValue: theData.projectDes })( )}
是否立项:
{getFieldDecorator('projectApproval', { initialValue: theData.projectApproval })( )} 万元
是否后补助:
{ if (info.file.status !== 'uploading') { console.log(info.file, info.fileList); } if (info.file.status === 'done') { if (!info.file.response.error.length) { message.success(`${info.file.name} 文件上传成功!`); } else { message.warning(info.file.response.error[0].message); return; }; this.state.approvalUrl = info.file.response.data; } else if (info.file.status === 'error') { message.error(`${info.file.name} 文件上传失败。`); } }} >

{theData.approvalUrl ? {theData.approvalDownloadFileName} : 未上传!}

状态流转记录:
); } else { return (
) }; }, })); const ApplyChange = React.createClass({ getInitialState() { return { visible: false, loading: false }; }, componentWillReceiveProps(nextProps) { this.state.visible = nextProps.showDesc }, showModal() { this.setState({ visible: true, }); }, handleOk() { this.setState({ visible: false, }); this.props.closeDesc(false); }, handleCancel(e) { this.setState({ visible: false, }); this.props.closeDesc(false); }, spinChange(e) { this.setState({ loading: e }); }, render() { return (
); } }); export default ApplyChange;