publicCustomer.jsx 7.7 KB

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