publicCustomer.jsx 6.7 KB

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