publicCustomer.jsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. import React from 'react';
  2. import { Button,Cascader,Input, Select, Spin, Table, message, Form, Tabs} 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 {TabPane} = Tabs
  189. const rowSelection = {
  190. selectedRowKeys: this.state.selectedRowKeys,
  191. onChange: (selectedRowKeys, selectedRows) => {
  192. this.setState({
  193. selectedRows:selectedRows,
  194. selectedRowKeys: selectedRowKeys
  195. });
  196. },
  197. onSelect: (recordt, selected, selectedData) => {
  198. this.setState({
  199. selectedData:selectedData,
  200. recordt: recordt.id
  201. })
  202. },
  203. };
  204. return (
  205. <div className="user-content">
  206. <ShowModalDiv ShowModal={this.state.showModal} />
  207. <div className="content-title">
  208. <span>{!intentionState ? "单位公共客户" : "个人公共客户"}</span>
  209. </div>
  210. <Tabs
  211. defaultActiveKey="1"
  212. onChange={this.callback}
  213. className="test">
  214. <TabPane tab="搜索" key="1">
  215. <div className="user-search">
  216. <Input
  217. placeholder="客户名称"
  218. value={this.state.nameSearch}
  219. style={{width:150}}
  220. onChange={e => {
  221. this.setState({ nameSearch: e.target.value });
  222. }}
  223. />
  224. <Select
  225. placeholder="省"
  226. style={{ width: 80 }}
  227. value={this.state.provinceSearch}
  228. onChange={e => {
  229. this.setState({ provinceSearch: e });
  230. }}
  231. >
  232. {this.state.Provinces}
  233. </Select>
  234. <span style={{ marginRight: "10px" }}>
  235. <Cascader
  236. options={citySelect()}
  237. value={this.state.addressSearch}
  238. placeholder="选择城市"
  239. onChange={(e, pre) => {
  240. this.setState({ addressSearch: e });
  241. }}
  242. />
  243. </span>
  244. <Button type="primary" onClick={this.search}>
  245. 搜索
  246. </Button>
  247. <Button onClick={this.reset}>重置</Button>
  248. </div>
  249. </TabPane>
  250. </Tabs>
  251. <div className="patent-table">
  252. <Spin spinning={this.state.loading}>
  253. <Table
  254. columns={this.state.columns}
  255. dataSource={this.state.dataSource}
  256. rowSelection={rowSelection}
  257. pagination={this.state.pagination}
  258. />
  259. </Spin>
  260. </div>
  261. </div>
  262. );
  263. }
  264. })
  265. export default QueryCustomer;