publicCustomer.jsx 6.8 KB

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