import React from 'react';
import { Icon, Form, Button, Input, Spin, Table, message, Select, Modal, InputNumber } from 'antd';
import './annualReport.less';
import { annualReportStateList } from '../../../../dataDic.js';
import { beforeUploadFile, getAnnualReportState } from '../../../../tools.js';
import moment from 'moment';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
const AnnualReportDescFrom = Form.create()(React.createClass({
getInitialState() {
return {
loading: false,
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();
if (!this.state.year && !this.props.data.year) {
message.warning("请选择一个年份!")
return;
};
this.props.form.validateFields((err, values) => {
if (!err) {
this.props.spinState(true);
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/techservice/cognizance/disposeAnnualReport",
data: {
id: this.props.data.id,
uid: this.props.uid,
year: this.state.year || this.props.data.year,
totalTax: values.totalTax,
incomeTaxRelief: values.incomeTaxRelief,
totalExportVolume: values.totalExportVolume,
basicResearchCost: values.basicResearchCost,
state: 0,
}
}).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.detailData;
const theData = {
id: "thisdata.id",
uid: "thisdata.uid",
unitName: "thisdata.unitName",
orgCode: "thisdata.orgCode",
locationProvince: "thisdata.locationProvince",
locationCity: "thisdata.locationCity",
locationArea: "thisdata.locationArea",
certificateNumber: "thisdata.certificateNumber",
issuingDate: "thisdata.issuingDate",
issuingDateFormattedDate: "thisdata.issuingDateFormattedDate",
listed: "thisdata.listed",
listedDate: "thisdata.listedDate",
listedDateFormattedDate: "thisdata.listedDateFormattedDate",
listedType: "thisdata.listedType",
stockCode: "thisdata.stockCode",
contacts: "thisdata.contacts",
inventionPatent: "thisdata.inventionPatent",
defensePatent: "thisdata.defensePatent",
nationalCrop: "thisdata.nationalCrop",
newPlantCariety: "thisdata.newPlantCariety",
nationalDrug: "thisdata.nationalDrug",
chineseMedicine: "thisdata.chineseMedicine",
utilityPatent: "thisdata.utilityPatent",
circuitDesign: "thisdata.circuitDesign",
exteriorPatent: "thisdata.exteriorPatent",
softwareWorks: "thisdata.softwareWorks",
firmTotal: "thisdata.firmTotal",
techTotal: "thisdata.techTotal",
newEmployment: "thisdata.newEmployment",
graduateNumber: "thisdata.graduateNumber",
totalRevenue: 123,
salesRevenue: 223,
netAsset: 333,
lastYearRevenue: 224,
grossProfit: 334,
researchCost: 134,
territory: 67,
basicResearchCost: 234,
totalTax: 234,
incomeTaxRelief: 21,
totalExportVolume: 56
}
const formItemLayout = {
labelCol: { span: 0 },
wrapperCol: { span: 20 },
};
const _me = this;
return (
);
},
}));
const AnnualReportDesc = React.createClass({
loadData(v) {
this.setState({
loading: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/annualReportDetail",
data: {
year: this.props.data ? this.props.data.year : (new Date().getFullYear() - 1),
uid: this.props.uid
}
}).done((data) => {
if (data.error.length || !data.data || !data.data.list) {
message.warning(data.error[0].message);
return;
};
this.state.detailData = {
id: thisdata.id,
uid: thisdata.uid,
unitName: thisdata.unitName,
orgCode: thisdata.orgCode,
locationProvince: thisdata.locationProvince,
locationCity: thisdata.locationCity,
locationArea: thisdata.locationArea,
location: thisdata.locationProvince + " / " + thisdata.locationCity + " / " + thisdata.locationArea,
certificateNumber: thisdata.certificateNumber,
issuingDate: thisdata.issuingDate,
issuingDateFormattedDate: thisdata.issuingDateFormattedDate,
listed: thisdata.listed,
listedDate: thisdata.listedDate,
listedDateFormattedDate: thisdata.listedDateFormattedDate,
listedType: thisdata.listedType,
stockCode: thisdata.stockCode,
contacts: thisdata.contacts,
inventionPatent: thisdata.inventionPatent,
defensePatent: thisdata.defensePatent,
nationalCrop: thisdata.nationalCrop,
newPlantCariety: thisdata.newPlantCariety,
nationalDrug: thisdata.nationalDrug,
chineseMedicine: thisdata.chineseMedicine,
utilityPatent: thisdata.utilityPatent,
circuitDesign: thisdata.circuitDesign,
exteriorPatent: thisdata.exteriorPatent,
softwareWorks: thisdata.softwareWorks,
firmTotal: thisdata.firmTotal,
techTotal: thisdata.techTotal,
newEmployment: thisdata.newEmployment,
graduateNumber: thisdata.graduateNumber,
totalRevenue: thisdata.totalRevenue,
salesRevenue: thisdata.salesRevenue,
netAsset: thisdata.netAsset,
lastYearRevenue: thisdata.lastYearRevenue,
grossProfit: thisdata.grossProfit,
researchCost: thisdata.researchCost,
territory: thisdata.territory,
basicResearchCost: thisdata.basicResearchCost,
totalTax: thisdata.totalTax,
incomeTaxRelief: thisdata.incomeTaxRelief,
totalExportVolume: thisdata.totalExportVolume
};
}).always(function () {
this.setState({
loading: false,
visible: v
});
}.bind(this));
},
getInitialState() {
return {
visible: false,
loading: false
};
},
componentWillReceiveProps(nextProps) {
if (nextProps.showDesc) {
this.loadData(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 AnnualReport = React.createClass({
loadData(pageNo) {
this.state.data = [];
this.setState({
loading: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/annualReport",
data: {
pageNo: pageNo || 1,
pageSize: this.state.pagination.pageSize,
uid: this.props.data.uid
}
}).done((data) => {
if (!data.data || !data.data.list) {
if (data.error.length) {
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,
createTime: thisdata.createTime,
lastUpdateTime: thisdata.lastUpdateTime,
totalTax: thisdata.totalTax,
incomeTaxRelief: thisdata.incomeTaxRelief,
totalExportVolume: thisdata.totalExportVolume,
year: thisdata.year,
state: thisdata.state,
createTimeFormattedDate: thisdata.createTimeFormattedDate,
lastUpdateTimeFormattedDate: thisdata.lastUpdateTimeFormattedDate
});
};
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: 'createTimeFormattedDate',
key: 'createTimeFormattedDate'
}, {
title: '最近更新时间',
dataIndex: 'lastUpdateTimeFormattedDate',
key: 'lastUpdateTimeFormattedDate'
}, {
title: '年报状态',
dataIndex: 'state',
key: 'state',
render: (text) => {
return getAnnualReportState(text)
}
}
],
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/deleteAnnualReport",
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 AnnualReport;