publicCustomer.jsx 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. oldAid:e.aid
  138. }
  139. }).done(function(data) {
  140. if(!data.error.length) {
  141. message.success('领取成功!');
  142. this.setState({
  143. loading: false,
  144. });
  145. } else {
  146. message.warning(data.error[0].message);
  147. };
  148. this.loadData(this.state.ispage);
  149. }.bind(this));
  150. },
  151. closeDesc(e) {
  152. this.state.visitModul = e;
  153. },
  154. search() {
  155. this.loadData();
  156. },
  157. reset() {
  158. this.state.nameSearch='';
  159. this.state.provinceSearch=undefined;
  160. this.state.addressSearch=[];
  161. this.loadData()
  162. },
  163. componentWillReceiveProps(nextProps) {
  164. if(nextProps.ApiUrl!=this.props.ApiUrl) {
  165. this.loadData(null,nextProps.ApiUrl);
  166. };
  167. },
  168. componentWillMount() {
  169. //城市
  170. let Province = [];
  171. provinceList.map(function(item) {
  172. var id = String(item.id)
  173. Province.push(
  174. <Select.Option value={id} key={item.name}>{item.name}</Select.Option>
  175. )
  176. });
  177. this.state.Provinces = Province;
  178. this.loadData();
  179. },
  180. render(){
  181. const intentionState=this.props.intentionState;
  182. const FormItem = Form.Item;
  183. const rowSelection = {
  184. selectedRowKeys: this.state.selectedRowKeys,
  185. onChange: (selectedRowKeys, selectedRows) => {
  186. this.setState({
  187. selectedRows:selectedRows,
  188. selectedRowKeys: selectedRowKeys
  189. });
  190. },
  191. onSelect: (recordt, selected, selectedData) => {
  192. this.setState({
  193. selectedData:selectedData,
  194. recordt: recordt.id
  195. })
  196. },
  197. };
  198. return(
  199. <div className="user-content" >
  200. <div className="content-title">
  201. <span>{!intentionState?'单位公共客户':'个人公共客户'}</span>
  202. </div>
  203. <div className="user-search">
  204. <Input placeholder="客户名称"
  205. value={this.state.nameSearch}
  206. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  207. <Select placeholder="省"
  208. style={{ width: 80 }}
  209. value={this.state.provinceSearch}
  210. onChange={(e) => {this.setState({ provinceSearch: e});}}>
  211. {this.state.Provinces}
  212. </Select>
  213. <span style={{marginRight:'10px'}}>
  214. <Cascader options={citySelect()} value={this.state.addressSearch} placeholder="选择城市"
  215. onChange={(e,pre) => { this.setState({ addressSearch: e }) }} />
  216. </span>
  217. <Button type="primary" onClick={this.search}>搜索</Button>
  218. <Button onClick={this.reset}>重置</Button>
  219. </div>
  220. <div className="patent-table">
  221. <Spin spinning={this.state.loading}>
  222. <Table columns={this.state.columns}
  223. dataSource={this.state.dataSource}
  224. rowSelection={rowSelection}
  225. pagination={this.state.pagination}
  226. />
  227. </Spin>
  228. </div>
  229. </div>
  230. )
  231. }
  232. })
  233. export default QueryCustomer;