import React from 'react';
import { Icon, Form, Button, Input, Spin, Table, message, Select, Modal, InputNumber, Upload } from 'antd';
import './techProduct.less';
import { beforeUpload } from '../../tools.js';
import moment from 'moment';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
const RatepayDescFrom = Form.create()(React.createClass({
getInitialState() {
return {
loading: false,
targetKeys: [],
selectedKeys: [],
yearOption: [],
};
},
componentWillMount() {
let d = new Date();
let _me = this;
d = d.getFullYear();
for (let i = d; i > d - 20; i--) {
_me.state.yearOption.push(
{i}
)
}
},
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 + "/techservice/cognizance/disposeRatepay",
data: {
id: this.props.data.id,
operatingIncome: values.operatingIncome,
managementCost: values.managementCost,
operatingProfit: values.operatingProfit,
nonOperatingIncome: values.nonOperatingIncome,
nonTaxableIncome: values.nonTaxableIncome,
taxExemptIncome: values.taxExemptIncome,
subsidyIncome: values.subsidyIncome,
year: this.state.year,
taxReturnUrl: this.state.ratepayUrl,
}
}).done(function (data) {
if (!data.error.length) {
message.success('保存成功!');
this.props.closeModal();
this.props.spinState(false);
this.props.form.resetFields();
} else {
message.warning(data.error[0].message);
this.props.spinState(false);
}
}.bind(this));
}
});
},
render() {
const FormItem = Form.Item;
const { getFieldDecorator } = this.props.form;
const theData = this.props.data;
const formItemLayout = {
labelCol: { span: 10 },
wrapperCol: { span: 12 },
};
const _me = this;
return (
);
},
}));
const RatepayDesc = 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 (
);
},
});
const Ratepay = React.createClass({
loadData(pageNo) {
this.state.data = [];
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/techservice/cognizance/ratepay",
data: {
pageNo: pageNo || 1,
pageSize: this.state.pagination.pageSize
}
}).done((data) => {
if (data.error.length || !data.data || !data.data.list) {
message.warning(data.error[0].message);
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,
operatingIncome: thisdata.operatingIncome,
managementCost: thisdata.managementCost,
operatingProfit: thisdata.operatingProfit,
nonOperatingIncome: thisdata.nonOperatingIncome,
nonTaxableIncome: thisdata.nonTaxableIncome,
taxExemptIncome: thisdata.taxExemptIncome,
subsidyIncome: thisdata.subsidyIncome,
year: thisdata.year,
taxReturnUrl: thisdata.taxReturnUrl
});
};
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));
},
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: 'year',
key: 'year'
}, {
title: '营业收入(万元)',
dataIndex: 'operatingIncome',
key: 'operatingIncome'
}, {
title: '管理费用(万元)',
dataIndex: 'managementCost',
key: 'managementCost'
}, {
title: '营业利润(万元)',
dataIndex: 'operatingProfit',
key: 'operatingProfit',
}, {
title: '营业外收入(万元)',
dataIndex: 'nonOperatingIncome',
key: 'nonOperatingIncome',
}, {
title: '相关附件',
dataIndex: 'other',
key: 'other',
render: (text) => {
{
window.open(globalConfig.context + "/techservice/patent/downloadFile?path=" + "url" + "&sign=" + "type")
}}>
}
}
],
dataSource: []
};
},
componentWillMount() {
this.loadData();
},
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 + "/techservice/cognizance/deleteTechProduct",
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) {
this.state.showDesc = e;
this.loadData();
},
search() {
this.loadData();
},
reset() {
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 (
);
}
});
export default Ratepay;