publicCustomer.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. import React from 'react';
  2. import { Button, Cascader, Input, Select, Spin, Table, message, Form, Tabs, Modal } 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, onReplace } from '../../../../tools.js'
  7. import ShowModalDiv from "@/showModal.jsx";
  8. import { ChooseList } from "../../../order/orderNew/chooseList";
  9. const QueryCustomer = React.createClass({
  10. loadData(pageNo, apiUrl) {
  11. // 新需求 除湖南和内蒙古外 不让其他省操作
  12. if (adminData.province != "21" && adminData.province != "11") {
  13. return
  14. }
  15. this.setState({
  16. loading: true,
  17. ispage: pageNo,
  18. });
  19. let api = apiUrl ? apiUrl : this.props.ApiUrl;
  20. $.ajax({
  21. method: "post",
  22. dataType: "json",
  23. crossDomain: false,
  24. url: globalConfig.context + api,
  25. data: {
  26. pageNo: pageNo || 1,
  27. pageSize: this.state.pagination.pageSize,
  28. name: this.state.nameSearch,
  29. province: !this.state.addressSearch.length
  30. ? this.state.provinceSearch
  31. : this.state.addressSearch[0],
  32. city: !this.state.addressSearch.length
  33. ? ""
  34. : this.state.addressSearch[1],
  35. sort: this.state.sort
  36. },
  37. success: function (data) {
  38. ShowModal(this);
  39. let theArr = [];
  40. if (data.error.length || data.data.list == "") {
  41. if (data.error && data.error.length) {
  42. message.warning(data.error[0].message);
  43. }
  44. } else {
  45. for (let i = 0; i < data.data.list.length; i++) {
  46. let thisdata = data.data.list[i];
  47. theArr.push({
  48. key: i,
  49. id: thisdata.uid,
  50. name: thisdata.name,
  51. contacts: thisdata.contacts,
  52. contactMobile: thisdata.contactMobile,
  53. createTime:
  54. thisdata.createTime && thisdata.createTime.split(" ")[0],
  55. transferTime:
  56. thisdata.transferTime && thisdata.transferTime.split(" ")[0],
  57. locationProvince: thisdata.province
  58. ? (thisdata.province || '') + (thisdata.city ? "-" + thisdata.city : '') + (thisdata.area ? "-" + thisdata.area : '')
  59. : "--",
  60. });
  61. }
  62. this.state.pagination.current = data.data.pageNo;
  63. this.state.pagination.total = data.data.totalCount;
  64. }
  65. if (data.data && data.data.list && !data.data.list.length) {
  66. this.state.pagination.current = 0;
  67. this.state.pagination.total = 0;
  68. }
  69. this.setState({
  70. dataSource: theArr,
  71. pagination: this.state.pagination,
  72. selectedRowKeys: [],
  73. });
  74. }.bind(this),
  75. }).always(
  76. function () {
  77. this.setState({
  78. loading: false,
  79. });
  80. }.bind(this)
  81. );
  82. },
  83. getInitialState() {
  84. return {
  85. sort: 0,
  86. addressSearch: [],
  87. dataSource: [],
  88. loading: false,
  89. selectedRowKeys: [],
  90. selectedRows: [],
  91. selectedData: [],
  92. pagination: {
  93. defaultCurrent: 1,
  94. defaultPageSize: 10,
  95. showQuickJumper: true,
  96. pageSize: 10,
  97. onChange: function (page) {
  98. this.loadData(page);
  99. }.bind(this),
  100. showTotal: function (total) {
  101. return '共' + total + '条数据';
  102. }
  103. },
  104. columns: [{
  105. title: '客户名称',
  106. dataIndex: 'name',
  107. key: 'name',
  108. render: (text, record, index) =>
  109. onReplace(text)
  110. },
  111. {
  112. title: '地区',
  113. dataIndex: 'locationProvince',
  114. key: 'locationProvince',
  115. },
  116. // {
  117. // title: '联系人',
  118. // dataIndex: 'contacts',
  119. // key: 'contacts',
  120. // },{
  121. // title: '联系电话',
  122. // dataIndex: 'contactMobile',
  123. // key: 'contactss',
  124. // },
  125. {
  126. title: '创建时间',
  127. dataIndex: 'createTime',
  128. key: 'createTime',
  129. },
  130. {
  131. title: '转换时间',
  132. dataIndex: 'transferTime',
  133. key: 'transferTime',
  134. },
  135. {
  136. title: '操作',
  137. dataIndex: 'abc',
  138. key: 'abc',
  139. width: 250,
  140. render: (text, record, index) => {
  141. return <div>
  142. <Button onClick={(e) => { e.stopPropagation(), this.receive(record) }} type="primary">领取</Button>
  143. <Button
  144. onClick={(e) => {
  145. e.stopPropagation(),
  146. this.rTips(record)
  147. }}
  148. style={{ marginLeft: 10 }}
  149. type="primary">领取为私有渠道信息</Button>
  150. </div>
  151. }
  152. }
  153. ],
  154. }
  155. },
  156. /*单个领取*/
  157. receive(e) {
  158. this.setState({
  159. loading: true,
  160. selectedRowKeys: [],
  161. });
  162. $.ajax({
  163. method: "get",
  164. dataType: "json",
  165. crossDomain: false,
  166. url: globalConfig.context + "/api/admin/customer/receiveCustomer",
  167. data: {
  168. uid: e.id,
  169. }
  170. }).done(function (data) {
  171. if (!data.error.length) {
  172. message.success('领取成功!');
  173. this.setState({
  174. loading: false,
  175. });
  176. } else {
  177. message.warning(data.error[0].message);
  178. };
  179. this.loadData(this.state.ispage);
  180. }.bind(this));
  181. },
  182. rTips(e) {
  183. let _this = this;
  184. Modal.confirm({
  185. title: "温馨提示",
  186. content: (
  187. <span style={{ color: "red" }}>
  188. <p>名称中含“协会”“商会”等名称为渠道信息!</p>
  189. <p>您是否确定将客户信息,领取为“私有渠道”信息,领取后,该信息即成为渠道信息不可再修改!!!</p>
  190. <p>领取成功后,您可以通过:渠道管理-渠道列表-私有渠道,查询到此条信息</p>
  191. </span>
  192. ),
  193. onOk() {
  194. _this.receiveNew(e)
  195. },
  196. onCancel() { },
  197. });
  198. },
  199. /*领取为私有渠道信息*/
  200. receiveNew(e) {
  201. this.setState({
  202. loading: true,
  203. selectedRowKeys: [],
  204. });
  205. $.ajax({
  206. method: "post",
  207. dataType: "json",
  208. crossDomain: false,
  209. url: globalConfig.context + "/api/admin/customer/receiveAsChannel",
  210. data: {
  211. uid: e.id,
  212. }
  213. }).done(function (data) {
  214. if (!data.error.length) {
  215. message.success('领取成功!');
  216. this.setState({
  217. loading: false,
  218. });
  219. } else {
  220. message.warning(data.error[0].message);
  221. };
  222. this.loadData(this.state.ispage);
  223. }.bind(this));
  224. },
  225. closeDesc(e) {
  226. this.state.visitModul = e;
  227. },
  228. search() {
  229. this.loadData();
  230. },
  231. reset() {
  232. this.state.nameSearch = '';
  233. this.state.provinceSearch = undefined;
  234. this.state.addressSearch = [];
  235. this.state.sort = 0
  236. this.loadData()
  237. },
  238. componentWillReceiveProps(nextProps) {
  239. if (nextProps.ApiUrl != this.props.ApiUrl) {
  240. this.state.nameSearch = '';
  241. this.state.provinceSearch = undefined;
  242. this.state.addressSearch = [];
  243. this.loadData(null, nextProps.ApiUrl);
  244. };
  245. },
  246. componentWillMount() {
  247. //城市
  248. let Province = [];
  249. provinceList.map(function (item) {
  250. var id = String(item.id)
  251. Province.push(
  252. <Select.Option value={id} key={item.name}>{item.name}</Select.Option>
  253. )
  254. });
  255. this.state.Provinces = Province;
  256. this.loadData();
  257. },
  258. changeList(arr) {
  259. const newArr = [];
  260. this.state.columns.forEach(item => {
  261. arr.forEach(val => {
  262. if (val === item.title) {
  263. newArr.push(item);
  264. }
  265. });
  266. });
  267. this.setState({
  268. changeList: newArr
  269. });
  270. },
  271. render() {
  272. const intentionState = this.props.intentionState;
  273. const FormItem = Form.Item;
  274. const { TabPane } = Tabs
  275. const rowSelection = {
  276. selectedRowKeys: this.state.selectedRowKeys,
  277. onChange: (selectedRowKeys, selectedRows) => {
  278. this.setState({
  279. selectedRows: selectedRows,
  280. selectedRowKeys: selectedRowKeys
  281. });
  282. },
  283. onSelect: (recordt, selected, selectedData) => {
  284. this.setState({
  285. selectedData: selectedData,
  286. recordt: recordt.id
  287. })
  288. },
  289. };
  290. return (
  291. <div className="user-content">
  292. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  293. <div className="content-title" style={{ marginBottom: 10 }}>
  294. <span style={{ fontWeight: 900, fontSize: 16 }}>{!intentionState ? "单位公共客户" : "个人公共客户"}</span>
  295. </div>
  296. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  297. <TabPane tab="搜索" key="1">
  298. <div className="user-search">
  299. <Input
  300. placeholder="客户名称"
  301. value={this.state.nameSearch}
  302. style={{ width: 150 }}
  303. onChange={(e) => {
  304. this.setState({ nameSearch: e.target.value });
  305. }}
  306. />
  307. <Select
  308. placeholder="省"
  309. style={{ width: 80 }}
  310. value={this.state.provinceSearch}
  311. onChange={(e) => {
  312. this.setState({ provinceSearch: e });
  313. }}
  314. >
  315. {this.state.Provinces}
  316. </Select>
  317. <span style={{ marginRight: "10px" }}>
  318. <Cascader
  319. options={citySelect()}
  320. value={this.state.addressSearch}
  321. placeholder="选择城市"
  322. onChange={(e, pre) => {
  323. this.setState({ addressSearch: e });
  324. }}
  325. />
  326. </span>
  327. <span>排序:</span>
  328. <Select style={{ width: 120 }} value={this.state.sort} onChange={e => { this.setState({ sort: e }) }} placeholder="选择排序">
  329. <Option value={0}>默认</Option>
  330. <Option value={1}>降序</Option>
  331. <Option value={2}>升序</Option>
  332. </Select>
  333. <Button type="primary" onClick={this.search}>
  334. 搜索
  335. </Button>
  336. <Button onClick={this.reset}>重置</Button>
  337. </div>
  338. </TabPane>
  339. <TabPane tab="更改表格显示数据" key="2">
  340. <div style={{ marginLeft: 10 }}>
  341. <ChooseList
  342. columns={this.state.columns}
  343. changeFn={this.changeList}
  344. changeList={this.state.changeList}
  345. top={55}
  346. margin={11}
  347. />
  348. </div>
  349. </TabPane>
  350. </Tabs>
  351. <div className="patent-table">
  352. <Spin spinning={this.state.loading}>
  353. <Table
  354. size="middle"
  355. columns={
  356. this.state.changeList
  357. ? this.state.changeList
  358. : this.state.columns
  359. }
  360. dataSource={this.state.dataSource}
  361. // rowSelection={rowSelection}
  362. pagination={this.state.pagination}
  363. />
  364. </Spin>
  365. </div>
  366. </div>
  367. );
  368. }
  369. })
  370. export default QueryCustomer;