import React from 'react'; import { Icon, Form, Button, Input, Select, Spin, Table, DatePicker, message, Modal, Upload, Radio } from 'antd'; import { technologyStateList } from '../../../dataDic.js'; import { getTechnologyState, beforeUpload, beforeUploadFile, techDownloadFile, getPreview, companySearch } 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/admin/techproject/techProjectDetial", data: { pid: id || this.props.data.id }, success: function (data) { if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; return; }; this.state.data = data.data; this.state.moneyType = undefined; if (data.data.projectMode == 1) { this.state.projectMode = data.data.projectMode; this.setState({ moneyType: 2 }); }; if (data.data.subsidy == 1) { this.state.subsidy = data.data.subsidy; this.setState({ moneyType: 1 }); }; 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/admin/techproject/techProjectLog", data: { pid: id || this.props.data.id }, success: function (data) { if (!data.data) { if (data.error && data.error.length) { 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: data.data[i].recordTime, recordTimeFormattedDate: data.data[i].recordTimeFormattedDate, principal: data.data[i].principal, operator: data.data[i].operator, comment: data.data[i].comment }); }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getContactsList(id) { $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/findAllContacts", data: { "uid": id || this.props.data.uid }, success: function (data) { let theOption = []; if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; return; }; for (let item in data.data) { let theData = data.data[item]; theOption.push( {theData.name} ); }; this.setState({ contactsOption: theOption }); }.bind(this), }); }, getDepartmentList(id) { $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/techproject/getDepartment", data: { "uid": id || this.props.data.uid }, success: function (data) { let theOption = []; if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; return; }; for (let item in data.data) { let theData = data.data[item]; theOption.push( {theData} ); }; this.setState({ departmentOption: theOption, }); }.bind(this), }); }, getOptionList() { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/techproject/status", success: function (data) { let _me = this; if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); return; }; }; _me.state.stateOption = []; for (var item in data.data) { _me.state.stateOption.push( {data.data[item]} ) }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getInitialState() { return { loading: false, stateOption: [], projectDes: '', projectMode: 0, subsidy: 0, projectModeState: false, subsidyState: false, stateColumns: [{ title: '科技项目状态', dataIndex: 'state', key: 'state', render: (text) => { return getTechnologyState(text) } }, { title: '处理时间', dataIndex: 'recordTimeFormattedDate', key: 'recordTimeFormattedDate' }, { title: '负责人', dataIndex: 'principal', key: 'principal', }, { title: '操作人', dataIndex: 'operator', key: 'operator', }, { title: '备注', dataIndex: 'comment', key: 'comment', }], stateTable: [] }; }, componentWillMount() { this.loadData(); this.getOptionList(); this.getStateData(); this.getContactsList(); this.getDepartmentList(); }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (values.state || values.principal || values.recordTime || values.comment) { if (!values.state || !values.principal || !values.recordTime) { message.warning("请填写完整的状态流转信息!"); return; }; }; 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/admin/techproject/updateTechProject", data: { id: this.props.data.id, uid: this.props.data.uid, 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, recordTimeFormattedDate: values.recordTime ? values.recordTime.format("YYYY-MM-DD HH:mm:ss") : undefined, state: values.state, principal: values.principal, comment: values.comment, } }).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.state.fileList = []; this.loadData(nextProps.data.id); this.getStateData(nextProps.data.id); this.getContactsList(nextProps.data.uid); this.getDepartmentList(nextProps.data.uid); this.state.approvalUrl = undefined; this.state.subsidy = undefined; this.props.form.resetFields(); }; }, subsidyCheck(e) { if (e.target.value == 1) { this.state.subsidy = 1; this.state.projectMode = 0; } else if (e.target.value == 2) { this.state.subsidy = 0; this.state.projectMode = 1; }; this.setState({ moneyType: e.target.value }); }, 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.postalAddress}
{getFieldDecorator('contacts', { initialValue: this.state.data.contacts })( )}
状态流转记录:
{getFieldDecorator('state')( )} {getFieldDecorator('recordTime')( )} {getFieldDecorator('principal')( )} {getFieldDecorator('comment')( )}
{getFieldDecorator('department', { initialValue: theData.department })( )}
{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') { } 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} 文件上传失败。`); } this.setState({ fileList: info.fileList.slice(-1) }); }} >

{theData.approvalUrl ? 项目材料 { var newTab = window.open('about:blank'); getPreview(theData.id, 'techProject', 'tech_project', function (data) { newTab.location.href = data; }); }}> : 未上传!}

); } 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, true); }, handleCancel(e) { this.setState({ visible: false, }); this.props.closeDesc(false); }, spinChange(e) { this.setState({ loading: e }); }, render() { return (
); } }); export default ApplyChange;