highTechSearch.jsx 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. import React from 'react';
  2. import { Icon, Button, Input, Select, Spin, message, Col, Row, Table } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import './userList.less';
  6. import BatchImport from './batchImport';
  7. import { provinceList, getProvince } from '../../NewDicProvinceList';
  8. import { companySearch } from '../../tools';
  9. const HighTechSearch = React.createClass({
  10. loadData(pageNo) {
  11. if (!this.state.searchUnitName && !this.state.province && !this.state.city && !this.state.searchYear) {
  12. message.warning('请选择至少一个搜索条件!');
  13. return;
  14. };
  15. this.setState({
  16. loading: true
  17. });
  18. $.ajax({
  19. method: "get",
  20. dataType: "json",
  21. crossDomain: false,
  22. url: globalConfig.context + "/api/admin/cognizanceRecord/search",
  23. data: {
  24. "district": this.state.city || this.state.province,
  25. "unitName": this.state.searchUnitName,
  26. "year": this.state.searchYear
  27. },
  28. success: function (data) {
  29. let theArr = [];
  30. if (data.error && data.error.length) {
  31. message.warning(data.error[0].message);
  32. } else {
  33. for (let i = 0; i < data.data.list.length; i++) {
  34. let thisdata = data.data.list[i];
  35. theArr.push({
  36. key: i + 1,
  37. id: thisdata.id,
  38. district: thisdata.district,
  39. unitName: thisdata.unitName,
  40. year: thisdata.year
  41. });
  42. };
  43. this.state.pagination.current = data.data.pageNo;
  44. this.state.pagination.total = data.data.totalCount;
  45. };
  46. this.setState({
  47. dataSource: theArr,
  48. pagination: this.state.pagination
  49. });
  50. }.bind(this),
  51. }).always(function () {
  52. this.setState({
  53. loading: false
  54. });
  55. }.bind(this));
  56. },
  57. getInitialState() {
  58. return {
  59. loading: false,
  60. yearOption: [],
  61. pagination: {
  62. defaultCurrent: 1,
  63. defaultPageSize: 10,
  64. showQuickJumper: true,
  65. pageSize: 10,
  66. onChange: function (page) {
  67. this.loadData(page);
  68. }.bind(this),
  69. showTotal: function (total) {
  70. return '共' + total + '条数据';
  71. }
  72. },
  73. columns: [
  74. {
  75. title: '序号',
  76. dataIndex: 'key',
  77. key: 'key',
  78. }, {
  79. title: '省份',
  80. dataIndex: 'district',
  81. key: 'district',
  82. render: (text) => { return getProvince(text) }
  83. }, {
  84. title: '公司名称',
  85. dataIndex: 'unitName',
  86. key: 'unitName',
  87. }, {
  88. title: '申报年份',
  89. dataIndex: 'year',
  90. key: 'year',
  91. }
  92. ],
  93. dataSource: []
  94. };
  95. },
  96. componentWillMount() {
  97. let theProvinceArr = [];
  98. let d = new Date();
  99. let thisYear = d.getFullYear();
  100. for (let i = thisYear; i >= 2000; i--) {
  101. this.state.yearOption.push(<Select.Option key={i.toString()}>{i}</Select.Option>)
  102. };
  103. provinceList.map((item) => {
  104. theProvinceArr.push(
  105. <Select.Option key={item.id}>{item.name}</Select.Option>
  106. )
  107. });
  108. this.state.provinceOption = theProvinceArr;
  109. //this.loadData();
  110. },
  111. provinceChange(e) {
  112. let theArr = [];
  113. provinceList.map((item) => {
  114. if (item.id == e) {
  115. item.cityList.map((city) => {
  116. theArr.push(
  117. <Select.Option key={city.id}>{city.name}</Select.Option>
  118. )
  119. });
  120. }
  121. });
  122. this.setState({
  123. cityOption: theArr,
  124. province: e,
  125. city: undefined
  126. });
  127. },
  128. cityChange(e) {
  129. this.setState({
  130. city: e
  131. });
  132. },
  133. search() {
  134. this.loadData();
  135. },
  136. reset() {
  137. this.setState({
  138. city: undefined,
  139. province: undefined,
  140. searchUnitName: undefined,
  141. searchYear: undefined,
  142. dataSource: []
  143. });
  144. },
  145. render() {
  146. return (
  147. <div className="user-content" >
  148. <div className="content-title">
  149. <span>高企查询</span>
  150. </div>
  151. <Row className="clearfix" style={{ marginBottom: '20px' }}>
  152. <Col style={{ width: 60, float: 'left' }}>
  153. <span>企业名称</span>
  154. </Col>
  155. <Col span={5}>
  156. <Input placeholder="请输入用户全称"
  157. value={this.state.searchName}
  158. onChange={(e) => { this.setState({ searchName: e.target.value }) }} />
  159. </Col>
  160. <Col style={{ width: 20, float: 'left' }}></Col>
  161. <Col style={{ width: 40, float: 'left' }}>
  162. <span>地区</span>
  163. </Col>
  164. <Col span={6}>
  165. <Select style={{ width: '40%' }}
  166. value={this.state.province}
  167. placeholder="请选择省份"
  168. notFoundContent="未获取到省份列表"
  169. showSearch
  170. filterOption={companySearch}
  171. onChange={this.provinceChange}>
  172. {this.state.provinceOption}
  173. </Select>
  174. <Select style={{ width: '50%', marginLeft: '10px' }}
  175. value={this.state.city}
  176. placeholder="请选择城市"
  177. notFoundContent="未获取到城市列表"
  178. showSearch
  179. filterOption={companySearch}
  180. onChange={this.cityChange}>
  181. {this.state.cityOption}
  182. </Select>
  183. </Col>
  184. <Col style={{ width: 40, float: 'left' }}>
  185. <span>年份</span>
  186. </Col>
  187. <Col span={2}>
  188. <Select style={{ width: 80 }}
  189. value={this.state.searchYear}
  190. onChange={(e) => { this.setState({ searchYear: e }) }} >
  191. {this.state.yearOption}
  192. </Select>
  193. </Col>
  194. <Col span={4}>
  195. <Button style={{ marginRight: '20px' }} type="primary" onClick={this.search}>搜索</Button>
  196. <Button style={{ marginRight: '20px' }} type="ghost" onClick={this.reset}>重置</Button>
  197. </Col>
  198. <BatchImport
  199. yearOption={this.state.yearOption}
  200. provinceOption={this.state.provinceOption}
  201. provinceList={provinceList}
  202. companySearch={companySearch} />
  203. </Row>
  204. <Spin spinning={this.state.loading}>
  205. <Table columns={this.state.columns}
  206. dataSource={this.state.dataSource}
  207. pagination={this.state.pagination} />
  208. </Spin>
  209. </div >
  210. );
  211. }
  212. });
  213. export default HighTechSearch;