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