highTechSearch.jsx 8.1 KB

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