queryCutomer.jsx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. import React from 'react';
  2. import { Button,Cascader,Input, Select, Spin, Table, message, Form } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import { citySelect, provinceList } from '@/NewDicProvinceList';
  6. import Detaile from './detail.jsx';
  7. const QueryCustomer = React.createClass({
  8. loadData(pageNo, apiUrl) {
  9. this.setState({
  10. visitModul:false,
  11. loading: true,
  12. ispage:pageNo,
  13. modalVisible:false
  14. });
  15. let api=apiUrl?apiUrl:this.props.ApiUrl;
  16. $.ajax({
  17. method: "post",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + api,
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. name: this.state.nameSearch,
  25. province: !(this.state.addressSearch).length ? this.state.provinceSearch : this.state.addressSearch[0],
  26. city: !(this.state.addressSearch).length ? '' : this.state.addressSearch[1],
  27. },
  28. success: function(data) {
  29. let theArr = [];
  30. if(data.error.length || data.data.list == "") {
  31. if(data.error && data.error.length) {
  32. message.warning(data.error[0].message);
  33. };
  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,
  39. id: thisdata.uid,
  40. type: thisdata.type,
  41. name: thisdata.name,
  42. status: thisdata.status,
  43. contacts: thisdata.contacts,
  44. contactMobile: thisdata.contactMobile,
  45. industry: thisdata.industry,
  46. createTime: thisdata.createTime,
  47. businessAudit: thisdata.businessAudit,
  48. auditStatus: thisdata.auditStatus,
  49. });
  50. };
  51. this.state.pagination.current = data.data.pageNo;
  52. this.state.pagination.total = data.data.totalCount;
  53. };
  54. if(data.data&&data.data.list&&!data.data.list.length){
  55. this.state.pagination.current=0
  56. this.state.pagination.total=0
  57. }
  58. this.setState({
  59. dataSource: theArr,
  60. pagination: this.state.pagination,
  61. selectedRowKeys:[]
  62. });
  63. }.bind(this),
  64. }).always(function() {
  65. this.setState({
  66. loading: false
  67. });
  68. }.bind(this));
  69. },
  70. getInitialState(){
  71. return {
  72. addressSearch: [],
  73. dataSource:[],
  74. loading:false,
  75. selectedRowKeys: [],
  76. selectedRowKey: [],
  77. selectedRows: [],
  78. pagination: {
  79. defaultCurrent: 1,
  80. defaultPageSize: 10,
  81. showQuickJumper: true,
  82. pageSize: 10,
  83. onChange: function(page) {
  84. this.loadData(page);
  85. }.bind(this),
  86. showTotal: function(total) {
  87. return '共' + total + '条数据';
  88. }
  89. },
  90. columns: [{
  91. title: '客户名称',
  92. dataIndex: 'name',
  93. key: 'name',
  94. }, {
  95. title: '地区',
  96. dataIndex: 'locationProvince',
  97. key: 'locationProvince',
  98. },{
  99. title: '创建时间',
  100. dataIndex: 'createTime',
  101. key: 'createTime',
  102. },
  103. {
  104. title: '所属人',
  105. dataIndex: 'contacts',
  106. key: 'contacts',
  107. },
  108. {
  109. title: '操作',
  110. dataIndex: 'abc',
  111. key: 'abc',
  112. render: (text, record, index) => {
  113. return <div>
  114. <Button onClick={(e) =>{ e.stopPropagation(), this.seeDetail(record)}} type="primary">查看详情</Button>
  115. </div>
  116. }
  117. }
  118. ],
  119. }
  120. },
  121. seeDetail(record){
  122. this.setState({
  123. data:record,
  124. visitModul:true
  125. })
  126. },
  127. closeDesc(e) {
  128. this.state.visitModul = e;
  129. },
  130. search() {
  131. this.loadData();
  132. },
  133. reset() {
  134. this.state.nameSearch='';
  135. this.state.provinceSearch=undefined;
  136. this.state.addressSearch=[];
  137. this.loadData()
  138. },
  139. componentWillReceiveProps(nextProps) {
  140. if(nextProps.ApiUrl!=this.props.ApiUrl) {
  141. this.loadData(null,nextProps.ApiUrl);
  142. };
  143. },
  144. componentWillMount() {
  145. //城市
  146. let Province = [];
  147. provinceList.map(function(item) {
  148. var id = String(item.id)
  149. Province.push(
  150. <Select.Option value={id} key={item.name}>{item.name}</Select.Option>
  151. )
  152. });
  153. this.state.Provinces = Province;
  154. this.loadData();
  155. },
  156. render(){
  157. const intentionState=this.props.intentionState;
  158. const FormItem = Form.Item;
  159. const rowSelection = {
  160. selectedRowKeys: this.state.selectedRowKeys,
  161. onChange: (selectedRowKeys, selectedRows) => {
  162. this.setState({
  163. modalVisible:false,
  164. selectedRows: selectedRows.slice(-1),
  165. selectedRowKeys: selectedRowKeys.slice(-1)
  166. });
  167. },
  168. onSelect: (recordt, selected, selectedRows) => {
  169. this.setState({
  170. modalVisible:false,
  171. recordt: recordt.id
  172. })
  173. },
  174. };
  175. const hasSelected = this.state.selectedRowKeys.length > 0;
  176. return(
  177. <div className="user-content" >
  178. <div className="content-title">
  179. <span>{!intentionState?'单位客户查询':'个人客户查询'}</span>
  180. </div>
  181. <div className="user-search">
  182. <Input placeholder="客户名称"
  183. value={this.state.nameSearch}
  184. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  185. <Select placeholder="省"
  186. style={{ width: 80 }}
  187. value={this.state.provinceSearch}
  188. onChange={(e) => {this.setState({ provinceSearch: e});}}>
  189. {this.state.Provinces}
  190. </Select>
  191. <span style={{marginRight:'10px'}}>
  192. <Cascader options={citySelect()} value={this.state.addressSearch} placeholder="选择城市"
  193. onChange={(e,pre) => { this.setState({ addressSearch: e }) }} />
  194. </span>
  195. <Button type="primary" onClick={this.search}>搜索</Button>
  196. <Button onClick={this.reset}>重置</Button>
  197. </div>
  198. <div className="patent-table">
  199. <Spin spinning={this.state.loading}>
  200. <Table columns={this.state.columns}
  201. dataSource={this.state.dataSource}
  202. rowSelection={rowSelection}
  203. pagination={this.state.pagination}
  204. />
  205. </Spin>
  206. </div>
  207. <Detaile
  208. visitModul={this.state.visitModul}
  209. data={this.state.data}
  210. detailApi={this.props.detailApi}
  211. closeDesc={this.closeDesc}
  212. />
  213. </div>
  214. )
  215. }
  216. })
  217. export default QueryCustomer;