highTechFoster.jsx 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. import React from 'react';
  2. import { Icon, Button, Input, Select, Spin, Table, message, Cascader } from 'antd';
  3. import { provinceArr } from '../../../dataDic.js';
  4. import { getTime, getCognizanceState, companySearch } from '../../../tools.js';
  5. import ajax from 'jquery/src/ajax/xhr.js';
  6. import $ from 'jquery/src/ajax';
  7. import moment from 'moment';
  8. import './highTechFoster.less';
  9. import FosterDesc from './fosterDesc/content.jsx';
  10. const Patent = React.createClass({
  11. loadData(pageNo) {
  12. this.state.data = [];
  13. this.setState({
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "post",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + "/api/admin/cultivate",
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. locationProvince: this.state.province,
  25. uid: this.state.unitName,
  26. },
  27. success: function (data) {
  28. if (data.error.length || !data.data || !data.data.list) {
  29. message.warning(data.error[0].message);
  30. return;
  31. }
  32. for (let i = 0; i < data.data.list.length; i++) {
  33. let thisdata = data.data.list[i];
  34. this.state.data.push({
  35. key: i,
  36. certificateNumber: thisdata.certificateNumber,
  37. contacts: [thisdata.cogContacts, {
  38. '1': thisdata.firstContacts,
  39. '2': thisdata.secondContacts,
  40. '3': thisdata.thirdContacts
  41. }],
  42. cogContacts: thisdata.cogContacts,
  43. consultant: thisdata.consultant,
  44. firstContacts: thisdata.firstContacts,
  45. issuingDate: thisdata.issuingDate,
  46. issuingDateFormattedDate: thisdata.issuingDateFormattedDate,
  47. endtime: thisdata.issuingDateFormattedDate ? getTime(thisdata.issuingDateFormattedDate, 36) : null,
  48. province: thisdata.province,
  49. secondContacts: thisdata.secondContacts,
  50. thirdContacts: thisdata.thirdContacts,
  51. uid: thisdata.uid,
  52. unitName: thisdata.unitName,
  53. state: thisdata.issuingDateFormattedDate ? getTime(thisdata.issuingDateFormattedDate, 36) : null,
  54. });
  55. };
  56. this.state.pagination.current = data.data.pageNo;
  57. this.state.pagination.total = data.data.totalCount;
  58. this.setState({
  59. dataSource: this.state.data,
  60. pagination: this.state.pagination
  61. });
  62. }.bind(this),
  63. }).always(function () {
  64. this.setState({
  65. loading: false
  66. });
  67. }.bind(this));
  68. },
  69. getCompanyList() {
  70. this.setState({
  71. loading: true
  72. });
  73. $.ajax({
  74. method: "get",
  75. dataType: "json",
  76. crossDomain: false,
  77. url: globalConfig.context + "/api/admin/getUnitNames",
  78. success: function (data) {
  79. if (!data.data) {
  80. if (data.error && data.error.length) {
  81. message.warning(data.error[0].message);
  82. };
  83. return;
  84. };
  85. let _me = this;
  86. for (var item in data.data) {
  87. _me.state.companyOption.push(
  88. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  89. )
  90. };
  91. }.bind(this),
  92. }).always(function () {
  93. this.setState({
  94. loading: false
  95. });
  96. }.bind(this));
  97. },
  98. getInitialState() {
  99. return {
  100. provinceOption: [],
  101. companyOption: [],
  102. fosterDescDisplay: 'none',
  103. fosterDisplay: 'block',
  104. data: [],
  105. loading: false,
  106. pagination: {
  107. defaultCurrent: 1,
  108. defaultPageSize: 10,
  109. showQuickJumper: true,
  110. pageSize: 10,
  111. onChange: function (page) {
  112. this.loadData(page);
  113. }.bind(this),
  114. showTotal: function (total) {
  115. return '共' + total + '条数据';
  116. }
  117. },
  118. columns: [
  119. {
  120. title: '省份',
  121. dataIndex: 'province',
  122. key: 'province',
  123. }, {
  124. title: '公司名称',
  125. dataIndex: 'unitName',
  126. key: 'unitName',
  127. }, {
  128. title: '联系人',
  129. dataIndex: 'contacts',
  130. key: 'contacts',
  131. render: (text) => {
  132. for (let item in text[1]) {
  133. if (text[0] == item) {
  134. return text[1][item];
  135. };
  136. };
  137. }
  138. }, {
  139. title: '状态',
  140. dataIndex: 'state',
  141. key: 'state',
  142. render: text => {
  143. if (text) {
  144. let n = moment(new Date()).format("YYYY-MM-DD");
  145. if (text > n) {
  146. return '已下证';
  147. } else {
  148. return '已到期';
  149. }
  150. } else {
  151. return '培育中';
  152. }
  153. }
  154. }, {
  155. title: '证书编号',
  156. dataIndex: 'certificateNumber',
  157. key: 'certificateNumber',
  158. }, {
  159. title: '发证日期',
  160. dataIndex: 'issuingDateFormattedDate',
  161. key: 'issuingDateFormattedDate',
  162. }, {
  163. title: '到期日期',
  164. dataIndex: 'endtime',
  165. key: 'endtime'
  166. }, {
  167. title: '负责人',
  168. dataIndex: 'consultant',
  169. key: 'consultant',
  170. }
  171. ],
  172. dataSource: []
  173. };
  174. },
  175. componentWillMount() {
  176. let _me = this;
  177. provinceArr.map(function (item) {
  178. _me.state.provinceOption.push(
  179. <Select.Option value={item} key={item}>{item}</Select.Option>
  180. )
  181. });
  182. this.loadData();
  183. this.getCompanyList();
  184. },
  185. tableRowClick(record, index) {
  186. this.state.RowData = record;
  187. this.setState({
  188. fosterDisplay: 'none',
  189. fosterDescDisplay: 'block'
  190. });
  191. },
  192. search() {
  193. this.loadData();
  194. },
  195. reset() {
  196. this.state.province = undefined;
  197. this.state.unitName = undefined;
  198. this.loadData();
  199. },
  200. returnBtn() {
  201. this.setState({
  202. fosterDisplay: 'block',
  203. fosterDescDisplay: 'none'
  204. });
  205. this.loadData();
  206. },
  207. render() {
  208. return (
  209. <div className="foster-box">
  210. <div className="foster-content" style={{ display: this.state.fosterDisplay }}>
  211. <div className="content-title">
  212. <span>高企认定培育</span>
  213. </div>
  214. <div className="foster-query">
  215. <Select placeholder="选择省份"
  216. style={{ width: 200 }}
  217. value={this.state.province}
  218. showSearch
  219. filterOption={companySearch}
  220. onChange={(e) => { this.setState({ province: e }) }}>
  221. {this.state.provinceOption}
  222. </Select>
  223. <Select placeholder="选择公司"
  224. style={{ width: 200 }}
  225. value={this.state.unitName}
  226. showSearch
  227. filterOption={companySearch}
  228. onChange={(e) => { this.setState({ unitName: e }) }}>
  229. {this.state.companyOption}
  230. </Select>
  231. <Button type="primary" onClick={this.search}>搜索</Button>
  232. <Button onClick={this.reset}>重置</Button>
  233. </div>
  234. <div className="foster-table">
  235. <Spin spinning={this.state.loading}>
  236. <Table columns={this.state.columns}
  237. dataSource={this.state.dataSource}
  238. pagination={this.state.pagination}
  239. onRowClick={this.tableRowClick} />
  240. </Spin>
  241. </div>
  242. </div >
  243. <FosterDesc
  244. style={this.state.fosterDescDisplay}
  245. data={this.state.RowData}
  246. returnBtn={this.returnBtn} />
  247. </div>
  248. );
  249. }
  250. });
  251. export default Patent;