publicCustomer.jsx 11 KB

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