publicCustomer.jsx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. 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. type: thisdata.type,
  39. name: thisdata.name,
  40. status: thisdata.status,
  41. contacts: thisdata.contacts,
  42. contactMobile: thisdata.contactMobile,
  43. industry: thisdata.industry,
  44. createTime: thisdata.createTime,
  45. businessAudit: thisdata.businessAudit,
  46. auditStatus: thisdata.auditStatus,
  47. });
  48. };
  49. this.state.pagination.current = data.data.pageNo;
  50. this.state.pagination.total = data.data.totalCount;
  51. };
  52. if(data.data&&data.data.list&&!data.data.list.length){
  53. this.state.pagination.current=0;
  54. this.state.pagination.total=0;
  55. }
  56. this.setState({
  57. dataSource: theArr,
  58. pagination: this.state.pagination,
  59. selectedRowKeys:[]
  60. });
  61. }.bind(this),
  62. }).always(function() {
  63. this.setState({
  64. loading: false
  65. });
  66. }.bind(this));
  67. },
  68. getInitialState(){
  69. return {
  70. addressSearch: [],
  71. dataSource:[],
  72. loading:false,
  73. selectedRowKeys: [],
  74. selectedRowKey: [],
  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: 'contactss',
  104. key: 'contactss',
  105. },
  106. {
  107. title: '创建时间',
  108. dataIndex: 'createTime',
  109. key: 'createTime',
  110. },
  111. {
  112. title: '转换时间',
  113. dataIndex: 'createTimes',
  114. key: 'createTimes',
  115. },
  116. {
  117. title: '客户状态',
  118. dataIndex: 'contactst',
  119. key: 'contactst',
  120. },
  121. {
  122. title: '操作',
  123. dataIndex: 'abc',
  124. key: 'abc',
  125. render: (text, record, index) => {
  126. return <div>
  127. <Button onClick={(e) =>{ e.stopPropagation(), this.receive(record)}} type="primary">领取</Button>
  128. </div>
  129. }
  130. }
  131. ],
  132. }
  133. },
  134. /*领取所有*/
  135. receiveAll(){
  136. this.setState({
  137. laodingt:true
  138. });
  139. let selectIds=[];
  140. this.state.selectedData.map((item)=>{
  141. selectIds.push(`${item.id}`)
  142. });
  143. $.ajax({
  144. type:"get",
  145. url:"http://abc",
  146. crossDomain: false,
  147. data:{
  148. id:`${selectIds}`
  149. },
  150. success:function(data){
  151. if(data.error && data.error.length) {
  152. message.warning(data.error[0].message);
  153. }else{
  154. message.success('领取成功!')
  155. this.loadData(this.state.ispage);
  156. };
  157. }.bind(this),
  158. }).always(function(){
  159. this.setState({
  160. loading:false
  161. });
  162. }.bind(this));
  163. },
  164. /*单个领取*/
  165. receive(record){
  166. this.setState({
  167. laodingt:true
  168. });
  169. $.ajax({
  170. type:"get",
  171. url:"http://abcttt",
  172. crossDomain: false,
  173. data:{
  174. id:record.id
  175. },
  176. success:function(data){
  177. if(data.error && data.error.length) {
  178. message.warning(data.error[0].message);
  179. }else{
  180. message.success('领取成功!')
  181. this.loadData(this.state.ispage);
  182. };
  183. }.bind(this),
  184. }).always(function(){
  185. this.setState({
  186. loading:false
  187. });
  188. }.bind(this));
  189. },
  190. closeDesc(e) {
  191. this.state.visitModul = e;
  192. },
  193. search() {
  194. this.loadData();
  195. },
  196. reset() {
  197. this.state.nameSearch='';
  198. this.state.provinceSearch=undefined;
  199. this.state.addressSearch=[];
  200. this.loadData()
  201. },
  202. componentWillReceiveProps(nextProps) {
  203. if(nextProps.ApiUrl!=this.props.ApiUrl) {
  204. this.loadData(null,nextProps.ApiUrl);
  205. };
  206. },
  207. componentWillMount() {
  208. //城市
  209. let Province = [];
  210. provinceList.map(function(item) {
  211. var id = String(item.id)
  212. Province.push(
  213. <Select.Option value={id} key={item.name}>{item.name}</Select.Option>
  214. )
  215. });
  216. this.state.Provinces = Province;
  217. this.loadData();
  218. },
  219. render(){
  220. const intentionState=this.props.intentionState;
  221. const FormItem = Form.Item;
  222. const rowSelection = {
  223. selectedRowKeys: this.state.selectedRowKeys,
  224. onChange: (selectedRowKeys, selectedRows) => {
  225. this.setState({
  226. selectedRows: selectedRows,
  227. selectedRowKeys: selectedRowKeys
  228. });
  229. },
  230. onSelect: (recordt, selected, selectedData) => {
  231. this.setState({
  232. selectedData:selectedData,
  233. recordt: recordt.id
  234. })
  235. },
  236. };
  237. const hasSelected = this.state.selectedRowKeys.length > 0;
  238. return(
  239. <div className="user-content" >
  240. <div className="content-title">
  241. <span>{!intentionState?'单位公共客户':'个人公共客户'}</span>
  242. </div>
  243. <div className="user-search">
  244. <Input placeholder="客户名称"
  245. value={this.state.nameSearch}
  246. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  247. <Select placeholder="省"
  248. style={{ width: 80 }}
  249. value={this.state.provinceSearch}
  250. onChange={(e) => {this.setState({ provinceSearch: e});}}>
  251. {this.state.Provinces}
  252. </Select>
  253. <span style={{marginRight:'10px'}}>
  254. <Cascader options={citySelect()} value={this.state.addressSearch} placeholder="选择城市"
  255. onChange={(e,pre) => { this.setState({ addressSearch: e }) }} />
  256. </span>
  257. <Button type="primary" onClick={this.search}>搜索</Button>
  258. <Button onClick={this.reset}>重置</Button>
  259. <Button disabled={!hasSelected} onClick={this.receiveAll}>一键领取</Button>
  260. </div>
  261. <div className="patent-table">
  262. <Spin spinning={this.state.loading}>
  263. <Table columns={this.state.columns}
  264. dataSource={this.state.dataSource}
  265. rowSelection={rowSelection}
  266. pagination={this.state.pagination}
  267. />
  268. </Spin>
  269. </div>
  270. </div>
  271. )
  272. }
  273. })
  274. export default QueryCustomer;