123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594 |
- import React from 'react';
- import { Icon, Form, Button, Input, Spin, Table, message, Select, Modal, InputNumber, Upload } from 'antd';
- import './techProduct.less';
- import { beforeUploadFile, newDownloadFile } from '../../tools.js';
- import moment from 'moment';
- import ajax from 'jquery/src/ajax/xhr.js';
- import $ from 'jquery/src/ajax';
- const FinanceDescFrom = Form.create()(React.createClass({
- loadData(year) {
- this.setState({
- loading: true
- });
- $.ajax({
- method: "get",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/user/cognizance/financeDetail",
- data: {
- year: year != undefined ? year : this.props.data.year
- }
- }).done((data) => {
- if (!data.data) {
- if (data.error && data.error.length) {
- message.warning(data.error[0].message);
- };
- return;
- };
- this.setState({
- managementCost: data.data.managementCost,
- researchCost: data.data.researchCost,
- grossProfit: data.data.grossProfit,
- operatingProfit: data.data.operatingProfit
- });
- }).always(function () {
- this.setState({
- loading: false
- });
- }.bind(this));
- },
- 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(
- <Select.Option value={i.toString()} key={i}>{i}</Select.Option>
- )
- };
- if (this.props.data.year) {
- this.loadData();
- };
- },
- 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 + "/api/user/cognizance/disposeFinance",
- data: {
- id: this.props.data.id,
- mainBusinessIncome: values.mainBusinessIncome,
- managementCost: values.managementCost,
- researchCost: values.researchCost,
- operatingProfit: values.operatingProfit,
- variousTax: values.variousTax,
- currentAsset: values.currentAsset,
- netFixedAsset: values.netFixedAsset,
- totalAsset: values.totalAsset,
- netAsset: values.netAsset,
- grossProfit: values.grossProfit,
- netProfit: values.netProfit,
- salesRevenue: values.salesRevenue,
- year: this.state.year || this.props.data.year,
- financeUrl: this.state.financeUrl
- }
- }).done(function (data) {
- if (!data.error.length) {
- message.success('保存成功!');
- this.props.clickOk();
- this.props.spinState(false);
- this.props.form.resetFields();
- } else {
- message.warning(data.error[0].message);
- this.props.spinState(false);
- }
- }.bind(this));
- }
- });
- },
- componentWillReceiveProps(nextProps) {
- if (!this.props.visible && nextProps.visible) {
- if (nextProps.data.year) {
- this.loadData(nextProps.data.year);
- };
- this.props.form.resetFields();
- this.state.managementCost = undefined;
- this.state.researchCost = undefined;
- this.state.grossProfit = undefined;
- this.state.operatingProfit = undefined;
- this.state.fileList = [];
- this.state.financeUrl = undefined;
- };
- },
- checkResearchCost(rule, value, callback) {
- const form = this.props.form;
- if (value > form.getFieldValue('managementCost')) {
- callback('管理费用小于研发费用!');
- } else {
- callback();
- }
- },
- render() {
- const FormItem = Form.Item;
- const { getFieldDecorator } = this.props.form;
- const theData = this.props.data;
- const formItemLayout = {
- labelCol: { span: 8 },
- wrapperCol: { span: 16 },
- };
- const _me = this;
- return (
- <Form onSubmit={this.handleSubmit} className="activityCost-form">
- <div className="activityCost-title"><span>年份: </span>
- {
- theData.year ? <span>{theData.year}</span> :
- <Select placeholder="请选择年份" style={{ width: 200 }}
- onSelect={(e, n) => { this.state.year = e, this.loadData(e); }}>
- {this.state.yearOption}
- </Select>
- }
- </div>
- <div className="clearfix">
- <FormItem className="half-item"
- {...formItemLayout}
- label="主营业务收入(万元)"
- >
- {getFieldDecorator('mainBusinessIncome', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.mainBusinessIncome
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="管理费用(万元)"
- >
- {getFieldDecorator('managementCost', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.managementCost
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- {this.state.managementCost && this.state.managementCost != this.props.form.getFieldValue('managementCost') ? <span style={{ color: '#f50' }}>与财务报表不一致!</span> : <span></span>}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="研发费用(万元)"
- >
- {getFieldDecorator('researchCost', {
- rules: [
- { type: 'number', required: true, message: '此项为必填项!' }, {
- validator: this.checkResearchCost,
- }],
- initialValue: theData.researchCost
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- {this.state.researchCost && this.state.researchCost != this.props.form.getFieldValue('researchCost') ? <span style={{ color: '#f50' }}>与财务报表不一致!</span> : <span></span>}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="营业利润(万元)"
- >
- {getFieldDecorator('operatingProfit', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.operatingProfit
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- {this.state.operatingProfit && this.state.operatingProfit != this.props.form.getFieldValue('operatingProfit') ? <span style={{ color: '#f50' }}>与财务报表不一致!</span> : <span></span>}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="支付的各项税费(万元)"
- >
- {getFieldDecorator('variousTax', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.variousTax
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="流动资产(万元)"
- >
- {getFieldDecorator('currentAsset', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.currentAsset
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="固定资产净额(万元)"
- >
- {getFieldDecorator('netFixedAsset', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.netFixedAsset
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="资产总额(万元)"
- >
- {getFieldDecorator('totalAsset', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.totalAsset
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="所有者权益合计(万元)"
- >
- {getFieldDecorator('netAsset', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.netAsset
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="利润总额(万元)"
- >
- {getFieldDecorator('grossProfit', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.grossProfit
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- {this.state.grossProfit && this.state.grossProfit != this.props.form.getFieldValue('grossProfit') ? <span style={{ color: '#f50' }}>与财务报表不一致!</span> : <span></span>}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="净利润(万元)"
- >
- {getFieldDecorator('netProfit', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.netProfit
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="销售收入(万元)"
- >
- {getFieldDecorator('salesRevenue', {
- rules: [{ type: 'number', required: true, message: '此项为必填项!' }],
- initialValue: theData.salesRevenue
- })(
- <InputNumber min={0} max={999999} step={0.01} />
- )}
- </FormItem>
- </div>
- <div className="hrSituation-roster">
- <Upload
- name="ratepay"
- action={globalConfig.context + "/api/user/cognizance/uploadFinance"}
- data={{ 'sign': 'finance', year: this.state.year || theData.year }}
- beforeUpload={beforeUploadFile}
- fileList={this.state.fileList}
- onChange={(info) => {
- 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.financeUrl = info.file.response.data;
- } else if (info.file.status === 'error') {
- message.error(`${info.file.name} 文件上传失败。`);
- };
- this.setState({ fileList: info.fileList.slice(-1) });
- }}
- >
- <Button><Icon type="upload" /> 上传企业财务报表 </Button>
- </Upload>
- <p style={{ marginTop: '10px' }}>{theData.financeUrl ? <a onClick={newDownloadFile.bind(null, theData.id, 'finance', '/api/user/cognizance/downloadFinance')}>{theData.financeDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
- </div>
- <FormItem style={{ marginTop: '20px' }}>
- <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
- <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
- </FormItem>
- </Form >
- );
- },
- }));
- const FinanceDesc = 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 (
- <div className="patent-addNew">
- <Modal maskClosable={false} title="财务报表信息" visible={this.state.visible}
- onOk={this.handleOk} onCancel={this.handleCancel}
- width='800px'
- footer='' >
- <Spin spinning={this.state.loading} className='spin-box'>
- <FinanceDescFrom
- visible={this.state.visible}
- data={this.props.data}
- spinState={this.spinChange} closeModal={this.handleCancel} clickOk={this.handleOk} />
- </Spin>
- </Modal>
- </div>
- );
- },
- });
- const Finance = React.createClass({
- loadData(pageNo) {
- this.state.data = [];
- this.setState({
- loading: true
- });
- $.ajax({
- method: "get",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/user/cognizance/finance",
- data: {
- pageNo: pageNo || 1,
- pageSize: this.state.pagination.pageSize,
- }
- }).done((data) => {
- if (!data.data) {
- if (data.error && data.error.length) {
- message.warning(data.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,
- mainBusinessIncome: thisdata.mainBusinessIncome,
- managementCost: thisdata.managementCost,
- operatingProfit: thisdata.operatingProfit,
- variousTax: thisdata.variousTax,
- currentAsset: thisdata.currentAsset,
- netFixedAsset: thisdata.netFixedAsset,
- totalAsset: thisdata.totalAsset,
- netAsset: thisdata.netAsset,
- grossProfit: thisdata.grossProfit,
- netProfit: thisdata.netProfit,
- salesRevenue: thisdata.salesRevenue,
- researchCost: thisdata.researchCost,
- year: thisdata.year,
- financeUrl: thisdata.financeUrl,
- financeDownloadFileName: thisdata.financeDownloadFileName,
- finance: [thisdata.id, thisdata.financeDownloadFileName]
- });
- };
- 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: 'mainBusinessIncome',
- key: 'mainBusinessIncome'
- }, {
- title: '管理费用(万元)',
- dataIndex: 'managementCost',
- key: 'managementCost'
- }, {
- title: '营业利润(万元)',
- dataIndex: 'operatingProfit',
- key: 'operatingProfit',
- }, {
- title: '支付的各项税费(万元)',
- dataIndex: 'variousTax',
- key: 'variousTax',
- }, {
- title: '资产总额(万元)',
- dataIndex: 'totalAsset',
- key: 'totalAsset',
- }, {
- title: '所有者权益(净资产)(万元)',
- dataIndex: 'netAsset',
- key: 'netAsset',
- }, {
- title: '相关附件',
- dataIndex: 'finance',
- key: 'finance',
- render: (text) => {
- return <a onClick={newDownloadFile.bind(null, text[0], 'finance', '/api/user/cognizance/downloadFinance')}>{text[1]}</a>
- }
- }
- ],
- 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 + "/api/user/cognizance/deleteFinance",
- 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.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 (
- <div className="user-content" >
- <div className="content-title">
- <span>财务报表信息</span>
- </div>
- <div className="user-search">
- <p>
- <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
- disabled={this.state.ButtonDisabled}
- onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
- <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
- disabled={!hasSelected}
- onClick={this.delectRow}>删除<Icon type="minus" /></Button>
- </p>
- </div>
- <div className="patent-table">
- <Spin spinning={this.state.loading}>
- <Table size="middle" columns={this.state.columns}
- dataSource={this.state.dataSource}
- pagination={this.state.pagination}
- rowSelection={rowSelection}
- style={{
- cursor: 'pointer',
- }}
- onRowClick={this.tableRowClick} />
- </Spin>
- </div>
- <FinanceDesc
- data={this.state.RowData}
- showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
- </div >
- );
- }
- });
- export default Finance;
|