publicCustomer.jsx 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. // {
  109. // title: '联系人',
  110. // dataIndex: 'contacts',
  111. // key: 'contacts',
  112. // },{
  113. // title: '联系电话',
  114. // dataIndex: 'contactMobile',
  115. // key: 'contactss',
  116. // },
  117. {
  118. title: '创建时间',
  119. dataIndex: 'createTime',
  120. key: 'createTime',
  121. },
  122. {
  123. title: '转换时间',
  124. dataIndex: 'transferTime',
  125. key: 'transferTime',
  126. },
  127. {
  128. title: '操作',
  129. dataIndex: 'abc',
  130. key: 'abc',
  131. render: (text, record, index) => {
  132. return <div>
  133. <Button onClick={(e) =>{ e.stopPropagation(), this.receive(record)}} type="primary">领取</Button>
  134. </div>
  135. }
  136. }
  137. ],
  138. }
  139. },
  140. /*单个领取*/
  141. receive(e) {
  142. this.setState({
  143. loading: true,
  144. selectedRowKeys: [],
  145. });
  146. $.ajax({
  147. method: "get",
  148. dataType: "json",
  149. crossDomain: false,
  150. url: globalConfig.context + "/api/admin/customer/receiveCustomer",
  151. data: {
  152. uid: e.id,
  153. }
  154. }).done(function(data) {
  155. if(!data.error.length) {
  156. message.success('领取成功!');
  157. this.setState({
  158. loading: false,
  159. });
  160. } else {
  161. message.warning(data.error[0].message);
  162. };
  163. this.loadData(this.state.ispage);
  164. }.bind(this));
  165. },
  166. closeDesc(e) {
  167. this.state.visitModul = e;
  168. },
  169. search() {
  170. this.loadData();
  171. },
  172. reset() {
  173. this.state.nameSearch='';
  174. this.state.provinceSearch=undefined;
  175. this.state.addressSearch=[];
  176. this.state.sort = 0
  177. this.loadData()
  178. },
  179. componentWillReceiveProps(nextProps) {
  180. if(nextProps.ApiUrl!=this.props.ApiUrl) {
  181. this.state.nameSearch='';
  182. this.state.provinceSearch=undefined;
  183. this.state.addressSearch=[];
  184. this.loadData(null,nextProps.ApiUrl);
  185. };
  186. },
  187. componentWillMount() {
  188. //城市
  189. let Province = [];
  190. provinceList.map(function(item) {
  191. var id = String(item.id)
  192. Province.push(
  193. <Select.Option value={id} key={item.name}>{item.name}</Select.Option>
  194. )
  195. });
  196. this.state.Provinces = Province;
  197. this.loadData();
  198. },
  199. render(){
  200. const intentionState=this.props.intentionState;
  201. const FormItem = Form.Item;
  202. const {TabPane} = Tabs
  203. const rowSelection = {
  204. selectedRowKeys: this.state.selectedRowKeys,
  205. onChange: (selectedRowKeys, selectedRows) => {
  206. this.setState({
  207. selectedRows:selectedRows,
  208. selectedRowKeys: selectedRowKeys
  209. });
  210. },
  211. onSelect: (recordt, selected, selectedData) => {
  212. this.setState({
  213. selectedData:selectedData,
  214. recordt: recordt.id
  215. })
  216. },
  217. };
  218. return (
  219. <div className="user-content">
  220. <ShowModalDiv ShowModal={this.state.showModal} />
  221. <div className="content-title">
  222. <span>{!intentionState ? "单位公共客户" : "个人公共客户"}</span>
  223. </div>
  224. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  225. <TabPane tab="搜索" key="1">
  226. <div className="user-search">
  227. <Input
  228. placeholder="客户名称"
  229. value={this.state.nameSearch}
  230. style={{ width: 150 }}
  231. onChange={(e) => {
  232. this.setState({ nameSearch: e.target.value });
  233. }}
  234. />
  235. <Select
  236. placeholder="省"
  237. style={{ width: 80 }}
  238. value={this.state.provinceSearch}
  239. onChange={(e) => {
  240. this.setState({ provinceSearch: e });
  241. }}
  242. >
  243. {this.state.Provinces}
  244. </Select>
  245. <span style={{ marginRight: "10px" }}>
  246. <Cascader
  247. options={citySelect()}
  248. value={this.state.addressSearch}
  249. placeholder="选择城市"
  250. onChange={(e, pre) => {
  251. this.setState({ addressSearch: e });
  252. }}
  253. />
  254. </span>
  255. <span>排序:</span>
  256. <Select style={{ width: 120 }} value={this.state.sort} onChange={e => {this.setState({sort: e})}} placeholder="选择排序">
  257. <Option value={0}>默认</Option>
  258. <Option value={1}>降序</Option>
  259. <Option value={2}>升序</Option>
  260. </Select>
  261. <Button type="primary" onClick={this.search}>
  262. 搜索
  263. </Button>
  264. <Button onClick={this.reset}>重置</Button>
  265. </div>
  266. </TabPane>
  267. </Tabs>
  268. <div className="patent-table">
  269. <Spin spinning={this.state.loading}>
  270. <Table
  271. size="middle"
  272. columns={this.state.columns}
  273. dataSource={this.state.dataSource}
  274. rowSelection={rowSelection}
  275. pagination={this.state.pagination}
  276. />
  277. </Spin>
  278. </div>
  279. </div>
  280. );
  281. }
  282. })
  283. export default QueryCustomer;