highTechSearch.jsx 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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.state.city = undefined;
  138. this.state.province = undefined;
  139. this.state.searchUnitName = undefined;
  140. this.state.searchYear = undefined;
  141. this.loadData();
  142. },
  143. render() {
  144. return (
  145. <div className="user-content" >
  146. <div className="content-title">
  147. <span>高企查询</span>
  148. </div>
  149. <Row className="clearfix" style={{ marginBottom: '20px' }}>
  150. <Col style={{ width: 60, float: 'left' }}>
  151. <span>企业名称</span>
  152. </Col>
  153. <Col span={5}>
  154. <Input placeholder="请输入用户全称"
  155. value={this.state.searchName}
  156. onChange={(e) => { this.setState({ searchName: e.target.value }) }} />
  157. </Col>
  158. <Col style={{ width: 20, float: 'left' }}></Col>
  159. <Col style={{ width: 40, float: 'left' }}>
  160. <span>地区</span>
  161. </Col>
  162. <Col span={6}>
  163. <Select style={{ width: '40%' }}
  164. value={this.state.province}
  165. placeholder="请选择省份"
  166. notFoundContent="未获取到省份列表"
  167. showSearch
  168. filterOption={companySearch}
  169. onChange={this.provinceChange}>
  170. {this.state.provinceOption}
  171. </Select>
  172. <Select style={{ width: '50%', marginLeft: '10px' }}
  173. value={this.state.city}
  174. placeholder="请选择城市"
  175. notFoundContent="未获取到城市列表"
  176. showSearch
  177. filterOption={companySearch}
  178. onChange={this.cityChange}>
  179. {this.state.cityOption}
  180. </Select>
  181. </Col>
  182. <Col style={{ width: 40, float: 'left' }}>
  183. <span>年份</span>
  184. </Col>
  185. <Col span={2}>
  186. <Select style={{ width: 80 }}
  187. value={this.state.searchYear}
  188. onChange={(e) => { this.setState({ searchYear: e }) }} >
  189. {this.state.yearOption}
  190. </Select>
  191. </Col>
  192. <Col span={4}>
  193. <Button style={{ marginRight: '20px' }} type="primary" onClick={this.search}>搜索</Button>
  194. <Button style={{ marginRight: '20px' }} type="ghost" onClick={this.reset}>重置</Button>
  195. </Col>
  196. <BatchImport
  197. yearOption={this.state.yearOption}
  198. provinceOption={this.state.provinceOption}
  199. provinceList={provinceList}
  200. companySearch={companySearch} />
  201. </Row>
  202. <Spin spinning={this.state.loading}>
  203. <Table columns={this.state.columns}
  204. dataSource={this.state.dataSource}
  205. pagination={this.state.pagination} />
  206. </Spin>
  207. </div >
  208. );
  209. }
  210. });
  211. export default HighTechSearch;