import React from 'react';
import { Icon, InputNumber, Form, Button, Input, Radio, Select, Spin, Table, DatePicker, message, Cascader, Modal } from 'antd';
import { cognizanceStateList } from '../../../dataDic.js';
import { provinceSelect, getProvince } from '../../../NewDicProvinceList';
import { techFieldList } from '../../../DicTechFieldList.js';
import { getTime, getCognizanceState, companySearch, getSearchUrl } from '../../../tools.js';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import moment from 'moment';
import './highTechFoster.less';
const CognizanceDescFrom = Form.create()(React.createClass({
loadData(uid, cid, year) {
this.setState({
loading: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/cognizanceDetail",
data: {
cid: cid || this.props.data.cid,
uid: uid || this.props.data.uid,
year: year || this.props.data.year
},
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.cid = this.props.data.cid;
this.state.moneyTable = [{
key: 1,
year: '前一年',
netAsset: data.data.netAsset1,
salesRevenue: data.data.salesRevenue1,
grossProfit: data.data.grossProfit1
}, {
key: 2,
year: '前二年',
netAsset: data.data.netAsset2,
salesRevenue: data.data.salesRevenue2,
grossProfit: data.data.grossProfit2
}, {
key: 3,
year: '前三年',
netAsset: data.data.netAsset3,
salesRevenue: data.data.salesRevenue3,
grossProfit: data.data.grossProfit3
}];
if (data.data.netAsset2 == 0) {
this.state.netAssetRate = 0;
} else if (data.data.netAsset3 == 0) {
this.state.netAssetRate = (data.data.netAsset1 / data.data.netAsset2) - 1;
} else {
this.state.netAssetRate = 1 / 2 * (data.data.netAsset2 / data.data.netAsset3 + data.data.netAsset1 / data.data.netAsset2) - 1;
};
if (this.state.netAssetRate < 0 || isNaN(this.state.netAssetRate)) {
this.state.netAssetRate = 0
};
if (data.data.salesRevenue2 == 0) {
this.state.salesRevenueRate = 0;
} else if (data.data.salesRevenue3 == 0) {
this.state.salesRevenueRate = (data.data.salesRevenue1 / data.data.salesRevenue2) - 1;
} else {
this.state.salesRevenueRate = 1 / 2 * (data.data.salesRevenue2 / data.data.salesRevenue3 + data.data.salesRevenue1 / data.data.salesRevenue2) - 1;
};
if (this.state.salesRevenueRate < 0 || isNaN(this.state.salesRevenueRate)) {
this.state.salesRevenueRate = 0
};
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getStateData(cid) {
this.setState({
loading: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/cognizanceLog",
data: {
cid: cid || this.props.data.cid
},
success: function (data) {
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
return;
};
this.state.stateTable = [];
for (let i = 0; i < data.data.length; i++) {
this.state.stateTable.push({
key: i,
recordTimeFormattedDate: data.data[i].recordTimeFormattedDate,
state: data.data[i].state,
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));
},
getBusinessCount(uid, year) {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/getBusinessCount",
data: {
uid: uid || this.props.data.uid,
year: year || this.props.data.year
},
success: function (data) {
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
return;
};
this.setState({
patentDone: data.data.patentDone, //专利已下证数量
patentUndone: data.data.patentUndone, //专利未下证数量
copyrightDone: data.data.copyrightDone,//软著已下证数量
copyrightUndone: data.data.copyrightUndone,//软著未下证数量
techProjectDone: data.data.techProjectDone,//科技项目申报审批已通过数量
techProjectUndone: data.data.techProjectUndone//科技项目申报审批未通过数量
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getContactsList(uid) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/customer/findAllContacts",
data: {
uid: uid || this.props.data.uid
},
success: function (data) {
let theOption = [];
if (data.error.length || !data.data) {
return;
};
for (let item in data.data) {
let theData = data.data[item];
theOption.push(
{theData.name}
);
};
this.setState({
contactsOption: theOption
});
}.bind(this),
});
},
getOptionList() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/cognizanceStatus",
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: [],
moneyColumns: [{
title: '',
dataIndex: 'year',
key: 'year',
}, {
title: '净资产',
dataIndex: 'netAsset',
key: 'netAsset',
}, {
title: '销售收入',
dataIndex: 'salesRevenue',
key: 'salesRevenue',
}, {
title: '利润总额',
dataIndex: 'grossProfit',
key: 'grossProfit',
}],
stateColumns: [{
title: '认证状态',
dataIndex: 'state',
key: 'state',
render: (text) => { return getCognizanceState(text) }
}, {
title: '处理时间',
dataIndex: 'recordTimeFormattedDate',
key: 'recordTimeFormattedDate',
}, {
title: '负责人',
dataIndex: 'principal',
key: 'principal',
}, {
title: '操作人',
dataIndex: 'operator',
key: 'operator',
}, {
title: '备注',
dataIndex: 'comment',
key: 'comment',
}]
};
},
componentWillMount() {
this.loadData();
this.getBusinessCount();
this.getOptionList();
this.getStateData();
this.getContactsList();
},
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);
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/disposeCognizanceDetail",
data: {
id: this.props.data.cid,
uid: this.props.data.uid,
technicalField1: values.technicalField[0],
technicalField2: values.technicalField[1],
technicalField3: values.technicalField[2],
basicResearchCost: values.basicResearchCost,
largeOrder: values.largeOrder,
contacts: values.contacts,
accident: values.accident,
certificateNumber: values.certificateNumber,
recordTimeFormattedDate: values.recordTime ? values.recordTime.format("YYYY-MM-DD HH:mm:ss") : undefined,
state: values.state,
principal: values.principal,
comment: values.comment,
year: this.state.data.year
}
}).done(function (data) {
if (!data.error.length) {
message.success('保存成功!');
this.props.clickOk();
this.props.form.resetFields();
this.state.targetKeys = [];
this.state.selectedKeys = [];
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.getStateData(nextProps.data.cid);
this.getBusinessCount(nextProps.data.uid, nextProps.data.year);
this.loadData(nextProps.data.uid, nextProps.data.cid, nextProps.data.year);
this.getContactsList(nextProps.data.uid);
this.props.form.resetFields();
};
},
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 (
);
} else {
return (
)
};
},
}));
const CognizanceDesc = 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 CognizanceAdd = React.createClass({
getInitialState() {
return {
visible: false,
loading: false,
yearOption: []
};
},
getContactsList(theUid) {
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/getContacts",
data: {
uid: theUid
},
success: function (data) {
let theOption = [];
if (data.error.length || !data.data) {
return;
};
for (let item in data.data) {
let theData = data.data[item];
theOption.push(
{theData}
);
};
this.setState({
contactsOption: theOption
});
}.bind(this),
});
},
componentWillReceiveProps(nextProps) {
if (!this.props.showAdd && nextProps.showAdd) {
this.state.year = undefined;
this.state.contacts = undefined;
this.state.comment = undefined;
this.state.consultant = undefined;
this.state.salesman = undefined;
this.state.uid = undefined;
};
this.state.visible = nextProps.showAdd;
},
componentWillMount() {
let d = new Date();
let _me = this;
d = d.getFullYear() - 1;
this.state.thisYear = d;
for (let i = d; i < d + 20; i++) {
_me.state.yearOption.push(
{i}
)
};
},
showModal() {
this.setState({
visible: true,
});
},
handleOk() {
this.setState({
loading: true
});
if (!this.state.year) {
message.warning('请选择年份!');
this.setState({
loading: false
});
return;
};
if (!this.state.contacts) {
message.warning('请选择一个联系人!');
this.setState({
loading: false
});
return;
};
if (!this.state.salesman) {
message.warning('请选择一个营销员!');
this.setState({
loading: false
});
return;
};
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/applyCognizance",
data: {
year: this.state.year,
contacts: this.state.contacts,
comment: this.state.comment,
consultant: this.state.consultant,
salesman: this.state.salesman,
largeOrder: this.state.largeOrder,
uid: this.state.uid
}
}).done(function (data) {
if (!data.error.length) {
message.success('保存成功!');
this.setState({
visible: false,
loading: false
});
this.props.closeAdd(false, true);
} else {
message.warning(data.error[0].message);
this.setState({
loading: false
});
}
}.bind(this));
},
handleCancel(e) {
this.setState({
visible: false,
});
this.props.closeAdd(false);
},
spinChange(e) {
this.setState({
loading: e
});
},
render() {
return (
提交
,
,
]} >
选择公司:
选择申请年份:
订单金额超过十万:
{ this.state.largeOrder = e.target.value }}>
否
是
选择联系人:
选择营销员:
);
}
});
const Cognizance = React.createClass({
loadData(pageNo) {
this.state.data = [];
this.setState({
loading: true
});
$.ajax({
method: "post",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/listCognizance",
data: {
pageNo: pageNo || 1,
pageSize: this.state.pagination.pageSize,
locationProvince: this.state.province ? this.state.province[0] : undefined,
uid: this.state.unitName,
contractId: this.state.contractId
},
success: function (data) {
let theArr = [];
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];
theArr.push({
key: i,
uid: thisdata.uid,
cid: thisdata.cid,
year: thisdata.year,
contractNumber: thisdata.contractNumber,
serialNumber: thisdata.serialNumber,
locationProvince: thisdata.locationProvince,
unitName: thisdata.unitName,
largeOrder: thisdata.largeOrder,
contacts: [thisdata.contacts, {
'1': thisdata.firstContacts,
'2': thisdata.secondContacts,
'3': thisdata.thirdContacts
}],
createTime: thisdata.createTime,
comment: thisdata.comment,
state: thisdata.state,
certificateNumber: thisdata.certificateNumber,
issuingDate: thisdata.issuingDate,
consultant: thisdata.consultant,
createTimeFormattedDate: thisdata.createTimeFormattedDate,
issuingDateFormattedDate: thisdata.issuingDateFormattedDate,
founder: thisdata.founder
});
};
this.state.pagination.current = data.data.pageNo;
this.state.pagination.total = data.data.totalCount;
this.setState({
dataSource: theArr,
pagination: this.state.pagination
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getAuthorList() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/getPrincipal",
success: function (data) {
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
return;
};
let _me = this;
for (var item in data.data) {
_me.state.authorOption.push(
{data.data[item]}
)
};
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getSalesmanList() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/salesman",
success: function (data) {
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
return;
};
let _me = this, theArr = [];
for (var item in data.data) {
theArr.push(
{data.data[item]}
)
};
this.setState({
salesmanOption: theArr
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getCompanyList() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/getUnitNames",
success: function (data) {
if (data.error.length || !data.data) {
return;
};
let _me = this;
for (var item in data.data) {
_me.state.companyOption.push(
{data.data[item]}
)
};
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
getInitialState() {
return {
companyOption: [],
authorOption: [],
selectedRowKeys: [],
selectedRows: [],
loading: false,
showAdd: false,
showDesc: 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: 'serialNumber',
key: 'serialNumber'
}, {
title: '省份',
dataIndex: 'locationProvince',
key: 'locationProvince',
render: text => { return getProvince(text) }
}, {
title: '公司',
dataIndex: 'unitName',
key: 'unitName'
}, {
title: '联系人',
dataIndex: 'contacts',
key: 'contacts',
render: (text) => {
for (let item in text[1]) {
if (text[0] == item) {
return text[1][item];
};
};
}
}, {
title: '合同编号',
dataIndex: 'contractNumber',
key: 'contractNumber'
}, {
title: '年份',
dataIndex: 'year',
key: 'year'
}, {
title: '派单日',
dataIndex: 'createTimeFormattedDate',
key: 'createTimeFormattedDate'
}, {
title: '状态',
dataIndex: 'state',
key: 'state',
render: (text) => { return getCognizanceState(text) }
}, {
title: '证书编号',
dataIndex: 'certificateNumber',
key: 'certificateNumber'
}, {
title: '发证日',
dataIndex: 'issuingDateFormattedDate',
key: 'issuingDateFormattedDate'
}, {
title: '到期日',
dataIndex: 'issuingDate',
key: 'issuingDate',
render: (text) => { return getTime(text, 36) }
}, {
title: '创建人',
dataIndex: 'founder',
key: 'founder'
}
],
dataSource: []
};
},
getContractList() {
this.setState({
loading: true
});
$.ajax({
method: "get",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/contract/serialNumber",
success: function (data) {
if (!data.data) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
};
return;
};
let theArr = [];
for (let i = 0; i < data.data.length; i++) {
let item = data.data[i];
theArr.push(
{item.serialNumber}
);
};
this.setState({
contractListOption: theArr
});
}.bind(this),
}).always(function () {
this.setState({
loading: false
});
}.bind(this));
},
componentWillMount() {
let _me = this;
this.getAuthorList();
this.getSalesmanList();
this.getCompanyList();
this.getContractList();
if (window.location.search) {
let theObj = getSearchUrl(window.location.search);
if (theObj.rid) {
theObj.cid = theObj.rid;
if (theObj.rid != 'null' && theObj.uid != 'null' && theObj.year != 'null') {
this.tableRowClick(theObj);
};
} else {
if (theObj.uid) {
this.state.unitName = theObj.uid;
} else if (theObj.contractId) {
this.state.contractId = theObj.contractId;
};
};
};
this.loadData();
// this.getContactsList();
},
tableRowClick(record, index) {
this.state.RowData = record;
if(index!=undefined){
this.setState({
showDesc: true
});
}
},
addClick() {
this.setState({
showAdd: true
});
},
delectRow() {
let deletedIds = [];
for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
let rowItem = this.state.selectedRows[idx];
if (rowItem.cid) {
deletedIds.push(rowItem.cid)
}
}
this.setState({
selectedRowKeys: [],
loading: deletedIds.length > 0
});
$.ajax({
method: "POST",
dataType: "json",
crossDomain: false,
url: globalConfig.context + "/api/admin/deleteCognizance",
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();
};
},
closeAdd(e, s) {
this.state.showAdd = e;
if (s) {
this.loadData();
};
},
search() {
this.loadData();
},
reset() {
this.state.province = undefined;
this.state.unitName = undefined;
this.state.contractId = 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({ province: e }) }} />
);
}
});
export default Cognizance;
//