index.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. import React, { Component } from 'react';
  2. import { AutoComplete, Button, DatePicker, Input, Spin, Table, Select, message, Tabs, Tag, Tooltip, } from "antd";
  3. import $ from "jquery/src/ajax";
  4. import ShowModalDiv from "@/showModal.jsx";
  5. import { ChooseList } from "../../../order/orderNew/chooseList";
  6. import moment from "moment";
  7. import './index.less';
  8. const { TabPane } = Tabs;
  9. const { RangePicker } = DatePicker;
  10. class FinalFollowup extends Component {
  11. constructor(props) {
  12. super(props);
  13. this.state = {
  14. pageNo: 1,
  15. totalPage: 0,
  16. searchInfor: {},//查询条件
  17. loading: false,
  18. changeList: undefined,// 子组件改变的表格title数组
  19. pagination: {
  20. defaultCurrent: 1,
  21. defaultPageSize: 10,
  22. showQuickJumper: true,
  23. pageSize: 10,
  24. onChange: function (page) {
  25. this.setState({
  26. pageNo: page,
  27. });
  28. this.loadData(page);
  29. }.bind(this),
  30. showTotal: function (total) {
  31. return "共" + total + "条数据";
  32. },
  33. },
  34. columns: [
  35. {
  36. title: "客户名称",
  37. dataIndex: "nickname",
  38. key: "nickname",
  39. },
  40. {
  41. title: "签单类型",
  42. dataIndex: "shareType",
  43. key: "shareType",
  44. render: (text) => (
  45. <div>{["私有", "公共", "签单", "外联", "渠道"][text]}</div>
  46. )
  47. },
  48. {
  49. title: "跟单人",
  50. dataIndex: "name",
  51. key: "name",
  52. },
  53. {
  54. title: "最新跟进时间",
  55. dataIndex: "lastFollowTimeStr",
  56. key: "lastFollowTimeStr",
  57. },
  58. {
  59. title: "未跟进天数",
  60. dataIndex: "days",
  61. key: "days",
  62. }
  63. ],
  64. dataSource: [],
  65. };
  66. this.loadData = this.loadData.bind(this);
  67. this.exportAll = this.exportAll.bind(this);
  68. this.search = this.search.bind(this);
  69. this.reset = this.reset.bind(this);
  70. this.changeList = this.changeList.bind(this);
  71. this.selectSuperId = this.selectSuperId.bind(this);
  72. this.supervisor = this.supervisor.bind(this);
  73. this.httpChange = this.httpChange.bind(this);
  74. this.selectAuto = this.selectAuto.bind(this);
  75. this.blurChange = this.blurChange.bind(this);
  76. }
  77. componentWillMount() {
  78. this.loadData();
  79. }
  80. // 列表数据
  81. loadData(pageNo, pageSize) {
  82. const { searchInfor, pagination } = this.state
  83. this.setState({
  84. loading: true,
  85. });
  86. let datas = Object.assign(searchInfor, {
  87. pageNo: pageNo || 1,
  88. pageSize: pageSize || 10,
  89. });
  90. $.ajax({
  91. method: "get",
  92. dataType: "json",
  93. crossDomain: false,
  94. url: globalConfig.context + "/api/admin/customer/selectUserLastSign",
  95. data: datas,
  96. success: function (data) {
  97. this.setState({
  98. loading: false,
  99. });
  100. if (data.error && data.error.length === 0) {
  101. if (data.data.list) {
  102. pagination.current = data.data.pageNo;
  103. pagination.total = data.data.totalCount;
  104. if (data.data && data.data.list && !data.data.list.length) {
  105. pagination.current = 0;
  106. pagination.total = 0;
  107. }
  108. this.setState({
  109. dataSource: data.data.list,
  110. pagination: this.state.pagination,
  111. pageNo: data.data.pageNo,
  112. totalPage: data.data.totalPage,
  113. });
  114. } else {
  115. this.setState({
  116. dataSource: data.data,
  117. pagination: false,
  118. });
  119. }
  120. } else {
  121. message.warning(data.error[0].message);
  122. }
  123. }.bind(this),
  124. }).always(
  125. function () {
  126. this.setState({
  127. loading: false,
  128. });
  129. }.bind(this)
  130. );
  131. }
  132. // 更改表格显示数据
  133. changeList(arr) {
  134. const newArr = [];
  135. this.state.columns.forEach((item) => {
  136. arr.forEach((val) => {
  137. if (val === item.title) {
  138. newArr.push(item);
  139. }
  140. });
  141. });
  142. this.setState({
  143. changeList: newArr,
  144. });
  145. }
  146. // 导出当前列表
  147. exportAll() {
  148. message.config({
  149. duration: 20,
  150. });
  151. let loading = message.loading("下载中...");
  152. this.setState({
  153. exportPendingLoading: true,
  154. });
  155. let obj1 = JSON.parse(JSON.stringify(this.state.searchInfor));
  156. // data = Object.assign(data, obj1);
  157. $.ajax({
  158. method: "get",
  159. dataType: "json",
  160. crossDomain: false,
  161. url: "/api/admin/customer/selectUserLastSign/export",
  162. data: obj1,
  163. success: function (data) {
  164. if (data.error.length === 0) {
  165. this.download(data.data);
  166. } else {
  167. message.warning(data.error[0].message);
  168. }
  169. }.bind(this),
  170. }).always(
  171. function () {
  172. loading();
  173. this.setState({
  174. exportPendingLoading: false,
  175. });
  176. }.bind(this)
  177. );
  178. }
  179. // 下载
  180. download(fileName) {
  181. window.location.href =
  182. globalConfig.context + "/open/download?fileName=" + fileName;
  183. }
  184. //获取上级组织
  185. selectSuperId() {
  186. $.ajax({
  187. method: "get",
  188. dataType: "json",
  189. crossDomain: false,
  190. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  191. data: {},
  192. success: function (data) {
  193. let theArr = [];
  194. if (data.error && data.error.length === 0) {
  195. for (let i = 0; i < data.data.length; i++) {
  196. let theData = data.data[i];
  197. theArr.push(
  198. <Select.Option value={theData.id} key={theData.id}>
  199. {theData.name}
  200. </Select.Option>
  201. );
  202. }
  203. this.setState({
  204. contactsOption: theArr,
  205. });
  206. } else {
  207. message.warning(data.error[0].message);
  208. }
  209. }.bind(this),
  210. }).always(
  211. function () {
  212. this.setState({
  213. // loading: false,
  214. });
  215. }.bind(this)
  216. );
  217. }
  218. supervisor(e) {
  219. $.ajax({
  220. method: "get",
  221. dataType: "json",
  222. crossDomain: false,
  223. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  224. data: {
  225. adminName: e,
  226. status: "2",
  227. },
  228. success: function (data) {
  229. if (data.error && data.error.length === 0) {
  230. this.setState({
  231. customerArr: data.data,
  232. });
  233. } else {
  234. message.warning(data.error[0].message);
  235. }
  236. }.bind(this),
  237. }).always(function () { }.bind(this));
  238. }
  239. httpChange(e) {
  240. if (e.length >= 1) {
  241. this.supervisor(e);
  242. }
  243. this.setState({
  244. followAname: e,
  245. });
  246. }
  247. selectAuto(value, options) {
  248. this.setState({
  249. followAname: value,
  250. });
  251. }
  252. blurChange(e) {
  253. const { searchInfor } = this.state
  254. let theType = undefined;
  255. let contactLists = this.state.customerArr || [];
  256. if (e) {
  257. contactLists.map(function (item) {
  258. if (item.name == e.toString()) {
  259. theType = item.id;
  260. }
  261. });
  262. }
  263. this.setState({
  264. searchInfor: Object.assign(searchInfor, {
  265. aid: theType,
  266. }),
  267. });
  268. }
  269. // 搜索
  270. search() {
  271. this.setState({
  272. selectedRowKeys: []
  273. })
  274. this.loadData();
  275. }
  276. // 重置
  277. reset() {
  278. this.setState({
  279. searchInfor: JSON.parse(JSON.stringify({})),
  280. followAname: undefined
  281. }, () => {
  282. this.loadData();
  283. })
  284. }
  285. render() {
  286. const { searchInfor } = this.state
  287. const dataSources = this.state.customerArr || [];
  288. const options = dataSources.map((group) => (
  289. <Select.Option key={group.id} value={group.name}>
  290. {group.name}
  291. </Select.Option>
  292. ));
  293. return (
  294. <div className="user-content finalfollowup">
  295. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  296. <div className="content-title" style={{ marginBottom: 10 }}>
  297. <span style={{ fontWeight: 900, fontSize: 16 }}>客户最后跟进表</span>
  298. </div>
  299. <Tabs defaultActiveKey="1">
  300. <TabPane tab="搜索" key="1">
  301. <div
  302. className="user-search"
  303. style={{
  304. marginTop: "10px",
  305. marginLeft: "10px",
  306. marginRight: "10px",
  307. }}
  308. >
  309. <span style={{ marginRight: "10px" }}>
  310. <Input
  311. style={{ width: 160 }}
  312. placeholder="输入客户名称"
  313. value={searchInfor.nickname}
  314. onChange={e => {
  315. this.setState({
  316. searchInfor: Object.assign(searchInfor, {
  317. nickname: e.target.value,
  318. }),
  319. });
  320. }}
  321. />
  322. </span>
  323. <span style={{ marginRight: "10px" }}>
  324. <AutoComplete
  325. className="certain-category-search"
  326. dropdownClassName="certain-category-search-dropdown"
  327. dropdownMatchSelectWidth={false}
  328. style={{ width: 160 }}
  329. dataSource={options}
  330. placeholder="跟进人姓名"
  331. value={this.state.followAname}
  332. onChange={this.httpChange}
  333. filterOption={true}
  334. onBlur={this.blurChange}
  335. onSelect={this.selectAuto}
  336. >
  337. <Input />
  338. </AutoComplete>
  339. </span>
  340. <span style={{ marginRight: "10px" }}>
  341. <Select
  342. style={{ width: 120 }}
  343. placeholder="类型"
  344. value={searchInfor.shareType}
  345. onChange={(e) => {
  346. this.setState({
  347. searchInfor: Object.assign(searchInfor, {
  348. shareType: e,
  349. }),
  350. });
  351. }}
  352. >
  353. <Option value={0}>私有</Option>
  354. <Option value={2}>签单</Option>
  355. <Option value={3}>外联</Option>
  356. <Option value={4}>渠道</Option>
  357. </Select>
  358. </span>
  359. <span style={{ marginRight: "10px" }}>
  360. <Select
  361. style={{ width: 120 }}
  362. placeholder="未跟进天数"
  363. value={searchInfor.daysType}
  364. onChange={(e) => {
  365. this.setState({
  366. searchInfor: Object.assign(searchInfor, {
  367. daysType: e,
  368. }),
  369. });
  370. }}
  371. >
  372. <Option value={0}>15天</Option>
  373. <Option value={1}>30天</Option>
  374. <Option value={2}>60天</Option>
  375. <Option value={3}>90天</Option>
  376. <Option value={4}>180天</Option>
  377. <Option value={5}>1年</Option>
  378. <Option value={6}>2年</Option>
  379. </Select>
  380. </span>
  381. <Button
  382. type="primary"
  383. onClick={this.search}
  384. style={{ marginRight: "10px", marginBottom: "10px" }}
  385. >
  386. 搜索
  387. </Button>
  388. <Button
  389. onClick={this.reset}
  390. style={{ marginRight: "10px", marginBottom: "10px" }}
  391. >
  392. 重置
  393. </Button>
  394. </div>
  395. </TabPane>
  396. <TabPane tab="更改表格显示数据" key="2">
  397. <div style={{ marginLeft: 10 }}>
  398. <ChooseList
  399. columns={this.state.columns}
  400. changeFn={this.changeList}
  401. changeList={this.state.changeList}
  402. top={55}
  403. margin={11}
  404. />
  405. </div>
  406. </TabPane>
  407. <TabPane tab="导出Excel" key="3">
  408. <Button
  409. type="primary"
  410. style={{ margin: "11px 0px 10px 10px" }}
  411. onClick={this.exportAll}
  412. >
  413. 导出当前列表
  414. </Button>
  415. </TabPane>
  416. </Tabs>
  417. <div className="patent-table">
  418. <Spin spinning={this.state.loading}>
  419. <Table
  420. bordered
  421. columns={
  422. this.state.changeList == undefined
  423. ? this.state.columns
  424. : this.state.changeList
  425. }
  426. dataSource={this.state.dataSource}
  427. pagination={this.state.pagination}
  428. />
  429. </Spin>
  430. </div>
  431. </div>
  432. )
  433. }
  434. }
  435. export default FinalFollowup;