publicCustomer.jsx 12 KB

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