import React from 'react'; import { Icon, Form, Upload, Button, Input, Spin, Table, message, Select, Modal, DatePicker, InputNumber } from 'antd'; import './activityCostList.less'; import { beforeUploadFile, newDownloadFile } from '../../tools.js'; import YearSelect from '../../yearSelect.jsx'; import moment from 'moment'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; const mathRound = function(p){ if ( !isNaN(p) ) { return Math.round(p*100)/100 } else { return p } } const ActivityDescFrom = Form.create()(React.createClass({ getInitialState() { return { loading: false, activityNumberOption: [], activityNumberObj: {}, yearOption: [] }; }, getYearOption() { let Option = Select.Option, d = new Date(), thisYear = d.getFullYear(), theArr = []; for (let i = thisYear; i >= 2000; i--) { theArr.push() }; this.state.yearOption = theArr; }, allCostCount(formData) { let theData = formData || this.props.form; let internalAllCost = theData.getFieldValue('internalLaborCost') + theData.getFieldValue('internalDirectCost') + theData.getFieldValue('internalDepreciationCost') + theData.getFieldValue('internalAmortizationCost') + theData.getFieldValue('internalDesignCost') + theData.getFieldValue('internalEquipmentCost') + theData.getFieldValue('internalOtherCost'); this.state.internalAllCost = mathRound(internalAllCost) let allCost = theData.getFieldValue('internalLaborCost') + theData.getFieldValue('internalDirectCost') + theData.getFieldValue('internalDepreciationCost') + theData.getFieldValue('internalAmortizationCost') + theData.getFieldValue('internalDesignCost') + theData.getFieldValue('internalEquipmentCost') + theData.getFieldValue('internalOtherCost') + theData.getFieldValue('externalTotalCost'); this.state.allCost = mathRound(allCost) }, componentDidMount() { this.allCostCount(); this.setState({ loading: false }); }, componentWillMount() { this.getYearOption(); let _me = this; if (this.props.activityNumberList) { this.props.activityNumberList.map(function (item) { _me.state.activityNumberOption.push( {item.activityNumber} ); _me.state.activityNumberObj[item.aid] = item.activityNumber; }); }; }, componentWillReceiveProps(nextProps) { this.allCostCount(nextProps.form); let _me = this; if (!this.props.visible && nextProps.visible) { this.state.fileList = []; this.state.accountUrl = undefined; let internalAllCost = nextProps.data.internalLaborCost + nextProps.data.internalDirectCost + nextProps.data.internalDepreciationCost + nextProps.data.internalAmortizationCost + nextProps.data.internalDesignCost + nextProps.data.internalEquipmentCost + nextProps.data.internalOtherCost; this.state.internalAllCost = mathRound(internalAllCost) this.state.allCost = this.state.internalAllCost + nextProps.data.externalTotalCost; }; }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.props.spinState(true); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/cognizance/activityCost", data: { id: this.props.data.id, aid: values.activityNumber, activityNumber: this.state.activityNumberObj[values.activityNumber], year: values.year, internalLaborCost: values.internalLaborCost, internalDirectCost: values.internalDirectCost, internalDepreciationCost: values.internalDepreciationCost, internalAmortizationCost: values.internalAmortizationCost, internalDesignCost: values.internalDesignCost, internalEquipmentCost: values.internalEquipmentCost, internalOtherCost: values.internalOtherCost, externalTotalCost: values.externalTotalCost, externalAbroadCost: values.externalAbroadCost, //enterpriseFiller: values.enterpriseFiller, //signDateFormattedDate: values.signDate.format('YYYY-MM-DD'), sortNumber: values.sortNumber, accountUrl: this.state.accountUrl } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); } else { message.warning(data.error[0].message); } }.bind(this)).always(function () { this.props.spinState(false); this.props.clickOk(); this.props.form.resetFields(); }.bind(this)); } }); }, render() { const FormItem = Form.Item; const { getFieldDecorator } = this.props.form; const theData = this.props.data; const formItemLayout = { labelCol: { span: 14 }, wrapperCol: { span: 8 }, }; const _me = this; return (

项目编号

{getFieldDecorator('activityNumber', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: theData.aid })( )}

费用年份

{getFieldDecorator('year', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: theData.year })( )}

内部研究开发费用(万元)

{getFieldDecorator('internalAllCost')( {this.state.internalAllCost || 0} )} {getFieldDecorator('internalLaborCost', { rules: [{ type: "number", required: true, message: '此项为必填项!' }], initialValue: theData.internalLaborCost })( )} {getFieldDecorator('internalDirectCost', { rules: [{ type: "number", required: true, message: '此项为必填项!' }], initialValue: theData.internalDirectCost })( )} {getFieldDecorator('internalDepreciationCost', { rules: [{ type: "number", required: true, message: '此项为必填项!' }], initialValue: theData.internalDepreciationCost })( )} {getFieldDecorator('internalAmortizationCost', { rules: [{ type: "number", required: true, message: '此项为必填项!' }], initialValue: theData.internalAmortizationCost })( )} {getFieldDecorator('internalDesignCost', { rules: [{ type: "number", required: true, message: '此项为必填项!' }], initialValue: theData.internalDesignCost })( )} {getFieldDecorator('internalEquipmentCost', { rules: [{ type: "number", required: true, message: '此项为必填项!' }], initialValue: theData.internalEquipmentCost })( )} {getFieldDecorator('internalOtherCost', { rules: [{ type: "number", required: true, message: '此项为必填项!' }], initialValue: theData.internalOtherCost })( )}

委托外部研究开发费用(万元)

{getFieldDecorator('externalTotalCost', { rules: [{ type: "number", required: true, message: '此项为必填项!' }], initialValue: theData.externalTotalCost })( )} {getFieldDecorator('externalAbroadCost', { rules: [{ type: "number", required: true, message: '此项为必填项!' }], initialValue: theData.externalAbroadCost })( )}

研发开发费用(内、外部)小计(万元)

{getFieldDecorator('allCost')( {this.state.allCost || 0} )} {getFieldDecorator('sortNumber', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: theData.sortNumber })( )}
{ 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.accountUrl = info.file.response.data; } else if (info.file.status === 'error') { message.error(`${info.file.name} 文件上传失败。`); }; this.setState({ fileList: info.fileList.slice(-1) }); }} >

{theData.accountUrl ? {theData.accountDownloadFileName} : 未上传!}

); }, })); const ActivityDesc = 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 (
); }, }); const Activity = React.createClass({ loadData(pageNo) { this.state.data = []; this.setState({ loading: true }); $.when($.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/cognizance/activityCostList", data: { pageNo: pageNo || 1, pageSize: this.state.pagination.pageSize, activityNumber: this.state.activityNumber, year: this.state.year } }), $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/cognizance/activityNumber", })).done((data1, data2) => { let data = data1[0]; let activityNumber = data2[0]; if (!data.data || !data.data.list) { if (data.error && data.error.length) { message.warning(data.error[0].message); this.state.ButtonDisabled = true; }; return; }; if (!activityNumber.data) { if (activityNumber.error && activityNumber.error.length) { message.warning(activityNumber.error[0].message); this.state.ButtonDisabled = true; }; return; }; for (let i = 0; i < data.data.list.length; i++) { let thisdata = data.data.list[i]; this.state.data.push({ key: i, id: thisdata.id, uid: thisdata.uid, aid: thisdata.aid, activityNumber: thisdata.activityNumber, year: thisdata.year ? String(thisdata.year) : undefined, startDate: thisdata.startDate, endDate: thisdata.endDate, internalAllCost: mathRound(thisdata.internalLaborCost + thisdata.internalDirectCost + thisdata.internalDepreciationCost + thisdata.internalAmortizationCost + thisdata.internalAmortizationCost + thisdata.internalDesignCost + thisdata.internalEquipmentCost + thisdata.internalOtherCost), internalLaborCost: thisdata.internalLaborCost, internalDirectCost: thisdata.internalDirectCost, internalDepreciationCost: thisdata.internalDepreciationCost, internalAmortizationCost: thisdata.internalAmortizationCost, internalDesignCost: thisdata.internalDesignCost, internalEquipmentCost: thisdata.internalEquipmentCost, internalOtherCost: thisdata.internalOtherCost, externalTotalCost: thisdata.externalTotalCost, externalAbroadCost: thisdata.externalAbroadCost, allCost: mathRound(thisdata.internalLaborCost + thisdata.internalDirectCost + thisdata.internalDepreciationCost + thisdata.internalAmortizationCost + thisdata.internalAmortizationCost + thisdata.internalDesignCost + thisdata.internalEquipmentCost + thisdata.internalOtherCost + thisdata.externalTotalCost), //enterpriseFiller: thisdata.enterpriseFiller, //signDate: thisdata.signDate, //signDateFormattedDate: thisdata.signDateFormattedDate, sortNumber: thisdata.sortNumber, startDateFormattedDate: thisdata.startDateFormattedDate, endDateFormattedDate: thisdata.endDateFormattedDate, accountDownloadFileName: thisdata.accountDownloadFileName, accountUrl: thisdata.accountUrl }); }; this.state.activityNumberList = activityNumber.data; this.state.pagination.current = data.data.pageNo; this.state.pagination.total = data.data.totalCount; this.setState({ dataSource: this.state.data, pagination: this.state.pagination }); }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getYearOption() { let Option = Select.Option, d = new Date(), thisYear = d.getFullYear(), theArr = []; for (let i = thisYear; i >= 2000; i--) { theArr.push() }; this.state.yearOption = theArr; }, getInitialState() { return { selectedRowKeys: [], selectedRows: [], loading: false, pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.loadData(page); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, columns: [ { title: '研发活动编号', dataIndex: 'activityNumber', key: 'activityNumber' }, { title: '费用年份', dataIndex: 'year', key: 'year' }, { title: '内部研究开发费用', dataIndex: 'internalAllCost', key: 'internalAllCost' }, { title: '人员人工费用', dataIndex: 'internalLaborCost', key: 'internalLaborCost' }, { title: '直接投入费用', dataIndex: 'internalDirectCost', key: 'internalDirectCost' }, { title: '折旧费用与长期待摊费用', dataIndex: 'internalDepreciationCost', key: 'internalDepreciationCost' }, { title: '设计费用', dataIndex: 'internalDesignCost', key: 'internalDesignCost' }, { title: '装备调试费用与试验费用', dataIndex: 'internalEquipmentCost', key: 'internalEquipmentCost' }, { title: '无形资产摊销费用', dataIndex: 'internalAmortizationCost', key: 'internalAmortizationCost' }, { title: '其他费用', dataIndex: 'internalOtherCost', key: 'internalOtherCost' }, { title: '委托外部研究开发费用', dataIndex: 'externalTotalCost', key: 'externalTotalCost' }, { title: '境内外部研发费用', dataIndex: 'externalAbroadCost', key: 'externalAbroadCost' }, { title: '研发费用合计', dataIndex: 'allCost', key: 'allCost' }, { title: '排序号', dataIndex: 'sortNumber', key: 'sortNumber' } ], dataSource: [] }; }, componentWillMount() { this.loadData(); this.getYearOption(); }, tableRowClick(record, index) { this.state.RowData = record; this.setState({ showDesc: true }); }, delectRow() { let deletedIds = []; for (let idx = 0; idx < this.state.selectedRows.length; idx++) { let rowItem = this.state.selectedRows[idx]; if (rowItem.id) { deletedIds.push(rowItem.id) } } this.setState({ selectedRowKeys: [], loading: deletedIds.length > 0 }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/cognizance/deleteActivityCost", data: { ids: deletedIds } }).done(function (data) { if (!data.error.length) { message.success('删除成功!'); this.setState({ loading: false, }); } else { message.warning(data.error[0].message); }; this.loadData(); }.bind(this)); }, closeDesc(e, s) { this.state.showDesc = e; if (s) { this.loadData(); }; }, search() { this.loadData(); }, reset() { this.state.year = undefined; this.state.activityNumber = undefined; this.loadData(); }, render() { const rowSelection = { selectedRowKeys: this.state.selectedRowKeys, onChange: (selectedRowKeys, selectedRows) => { this.setState({ selectedRows: selectedRows, selectedRowKeys: selectedRowKeys }); } }; const hasSelected = this.state.selectedRowKeys.length > 0; return (
企业研究开发费用结构明细
{ this.setState({ activityNumber: e.target.value }); }} /> 年份:

); } }); export default Activity;