publicCustomer.jsx 7.9 KB

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