intentionCustomer.jsx 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245
  1. import React from "react";
  2. import {
  3. Icon,
  4. Button,
  5. AutoComplete,
  6. Cascader,
  7. Input,
  8. Select,
  9. Spin,
  10. Table,
  11. message,
  12. DatePicker,
  13. Tooltip,
  14. Form,
  15. Tabs,
  16. Modal,
  17. Tag,
  18. Checkbox,
  19. } from "antd";
  20. import $ from "jquery/src/ajax";
  21. import moment from "moment";
  22. import { citySelect, provinceList } from "@/NewDicProvinceList";
  23. import AddIntention from "./addIntention.jsx";
  24. import { industry, lvl, currentMember } from "@/dataDic.js";
  25. import ZhuanjiaoDetail from "@/zhuanjiaoDetail.jsx";
  26. import { getSocialAttribute, ShowModal } from "@/tools.js";
  27. import FollowDetail from "./followDetail.jsx";
  28. import IntentionDetail from "./intentionDetail/intentionDetail";
  29. import ShowModalDiv from "@/showModal.jsx";
  30. import "./customer.less";
  31. import { ChooseList } from "../../../order/orderNew/chooseList";
  32. import EnterpriseNameChange from "../../../../common/enterpriseNameChange";
  33. const { TabPane } = Tabs;
  34. const confirm = Modal.confirm;
  35. const IntentionCustomer = Form.create()(
  36. React.createClass({
  37. loadData(pageNo, apiUrl) {
  38. this.setState({
  39. visitModul: false,
  40. loading: true,
  41. modalVisible: false,
  42. });
  43. let api = apiUrl ? apiUrl : this.props.ApiUrl;
  44. $.ajax({
  45. method: "post",
  46. dataType: "json",
  47. crossDomain: false,
  48. url: globalConfig.context + api,
  49. data: {
  50. pageNo: pageNo || 1,
  51. pageSize: this.state.pagination.pageSize,
  52. level: this.state.level ? this.state.level : undefined,
  53. name: this.state.nameSearch,
  54. province: !this.state.addressSearch.length
  55. ? this.state.provinceSearch
  56. : this.state.addressSearch[0],
  57. city: !this.state.addressSearch.length
  58. ? undefined
  59. : this.state.addressSearch[1],
  60. startDate: this.state.releaseDate[0],
  61. endDate: this.state.releaseDate[1],
  62. },
  63. success: function (data) {
  64. ShowModal(this);
  65. let theArr = [];
  66. if (data.error.length || data.data.list == "") {
  67. if (data.error && data.error.length) {
  68. message.warning(data.error[0].message);
  69. }
  70. } else {
  71. for (let i = 0; i < data.data.list.length; i++) {
  72. let thisdata = data.data.list[i];
  73. let diqu =
  74. (thisdata.province == null ? "" : thisdata.province) +
  75. (thisdata.city == null ? "" : "-" + thisdata.city) +
  76. (thisdata.area == null ? "" : "-" + thisdata.area);
  77. thisdata.key = i;
  78. thisdata.id = thisdata.uid;
  79. thisdata.lastFollowTime =
  80. thisdata.lastFollowTime &&
  81. thisdata.lastFollowTime.split(" ")[0];
  82. thisdata.transferTime =
  83. thisdata.transferTime && thisdata.transferTime.split(" ")[0];
  84. thisdata.surplusFollowTime =
  85. thisdata.surplusFollowTime &&
  86. thisdata.surplusFollowTime.split(" ")[0];
  87. thisdata.surplusSignTime =
  88. thisdata.surplusSignTime &&
  89. thisdata.surplusSignTime.split(" ")[0];
  90. thisdata.locationProvince = diqu;
  91. theArr.push(thisdata);
  92. }
  93. this.state.pagination.current = data.data.pageNo;
  94. this.state.pagination.total = data.data.totalCount;
  95. this.setState({
  96. ispage: data.data.pageNo,
  97. });
  98. }
  99. if (data.data && data.data.list && !data.data.list.length) {
  100. this.state.pagination.current = 0;
  101. this.state.pagination.total = 0;
  102. }
  103. if (
  104. JSON.stringify(theArr) !== JSON.stringify(this.state.dataSource)
  105. ) {
  106. this.setState({
  107. selectedRowKeys: [],
  108. });
  109. }
  110. this.setState({
  111. dataSource: theArr,
  112. pagination: this.state.pagination,
  113. });
  114. }.bind(this),
  115. }).always(
  116. function () {
  117. this.setState({
  118. loading: false,
  119. });
  120. }.bind(this)
  121. );
  122. },
  123. //品类数据获取
  124. category() {
  125. $.ajax({
  126. method: "get",
  127. dataType: "json",
  128. crossDomain: false,
  129. url: globalConfig.context + "/api/admin/Varieties/getSuperList",
  130. data: {},
  131. success: function (data) {
  132. let thedata = data.data;
  133. let theArr = [];
  134. if (!thedata) {
  135. if (data.error && data.error.length) {
  136. message.warning(data.error[0].message);
  137. }
  138. thedata = {};
  139. } else {
  140. thedata.map(function (item, index) {
  141. theArr.push({
  142. value: item.id,
  143. key: item.cname,
  144. });
  145. });
  146. }
  147. this.setState({
  148. categoryArr: theArr,
  149. });
  150. }.bind(this),
  151. });
  152. },
  153. getInitialState() {
  154. return {
  155. addressSearch: [],
  156. orgCodeUrl: [],
  157. companyLogoUrl: [],
  158. visible: false,
  159. zhuanjiaoVisible: false,
  160. searchMore: true,
  161. releaseDate: [],
  162. categoryArr: [],
  163. visitModul: false,
  164. keys: false,
  165. detailApi: "",
  166. followData: {},
  167. selectedRowKeys: [],
  168. selectedRowKey: [],
  169. selectedRows: [],
  170. loading: false,
  171. modalVisible: false,
  172. pagination: {
  173. defaultCurrent: 1,
  174. defaultPageSize: 10,
  175. showQuickJumper: true,
  176. pageSize: 10,
  177. onChange: function (page) {
  178. this.loadData(page);
  179. }.bind(this),
  180. showTotal: function (total) {
  181. return "共" + total + "条数据";
  182. },
  183. },
  184. columns: [
  185. {
  186. title: "客户名称",
  187. dataIndex: "name",
  188. key: "name",
  189. width: 150,
  190. render: (text) => {
  191. return (
  192. <Tooltip title={text}>
  193. <div
  194. onClick={(e) => {
  195. e.stopPropagation();
  196. let input = document.getElementById("copyText");
  197. input.value = text;
  198. input.select();
  199. document.execCommand("copy");
  200. message.success("复制成功");
  201. }}
  202. // style={{
  203. // maxWidth: "150px",
  204. // overflow: "hidden",
  205. // textOverflow: "ellipsis",
  206. // whiteSpace: "nowrap",
  207. // cursor: "pointer",
  208. // }}
  209. >
  210. {text}
  211. </div>
  212. </Tooltip>
  213. );
  214. },
  215. },
  216. {
  217. title: "统一社会信用代码",
  218. dataIndex: "orgCode",
  219. key: "orgCode",
  220. render: (text) => {
  221. return <div style={{ color: !text ? "red" : "#000000A6" }}>
  222. {!text ? "待补充" : text}
  223. </div>;
  224. },
  225. },
  226. {
  227. title: "地区",
  228. dataIndex: "locationProvince",
  229. key: "locationProvince",
  230. },
  231. // {
  232. // title: "联系人",
  233. // dataIndex: "contacts",
  234. // key: "contacts",
  235. // },
  236. // {
  237. // title: "联系电话",
  238. // dataIndex: "contactMobile",
  239. // key: "contactMobile",
  240. // },
  241. {
  242. title: "社会性质",
  243. dataIndex: "societyTag",
  244. key: "societyTag",
  245. render: (text) => {
  246. return getSocialAttribute(text);
  247. },
  248. },
  249. {
  250. title: "客户初始时间",
  251. dataIndex: "transferTime",
  252. key: "transferTime",
  253. },
  254. {
  255. title: "剩余私有天数",
  256. dataIndex: "surplusFollowTime",
  257. key: "surplusFollowTime",
  258. },
  259. {
  260. title: "剩余签单天数",
  261. dataIndex: "surplusSignTime",
  262. key: "surplusSignTime",
  263. },
  264. {
  265. title: "最新跟进时间",
  266. dataIndex: "lastFollowTime",
  267. key: "lastFollowTime",
  268. },
  269. {
  270. title: "客户等级",
  271. dataIndex: "level",
  272. key: "level",
  273. render: (text) => {
  274. if (text == 0) {
  275. return <Tag color="#87d068">一般客户</Tag>;
  276. } else if (text == 1) {
  277. return <Tag color="#D2691E">意向客户</Tag>;
  278. } else if (text == 2) {
  279. return <Tag color="#FF0000">重点客户</Tag>;
  280. } else {
  281. return "";
  282. }
  283. },
  284. },
  285. {
  286. title: "跟进操作",
  287. dataIndex: "abc",
  288. key: "abc",
  289. render: (text, record, index) => {
  290. return (
  291. <div
  292. style={{
  293. display: "flex",
  294. flexFlow: "row",
  295. alignItems: "center",
  296. }}
  297. >
  298. <Button
  299. onClick={(e) => {
  300. const _this = this
  301. e.stopPropagation()
  302. if (!record.orgCode) {
  303. confirm({
  304. title: '您暂时不可以跟进客户',
  305. content: `请先完善"企业统一社会信用代码"`,
  306. cancelText: '取消',
  307. okText: '去完善',
  308. onOk() {
  309. _this.tableRowClick(record)
  310. },
  311. onCancel() { },
  312. });
  313. } else {
  314. this.visit(record);
  315. }
  316. }}
  317. type="primary"
  318. >
  319. 客户跟进
  320. </Button>
  321. </div>
  322. );
  323. },
  324. },
  325. {
  326. title: "指导意见",
  327. dataIndex: "guidance",
  328. key: "guidance",
  329. render: (text, record, index) => {
  330. return (
  331. <div
  332. style={{
  333. display: "flex",
  334. flexFlow: "row",
  335. alignItems: "center",
  336. }}
  337. >
  338. {/*指导 0无 1未读 2已读*/}
  339. {text === 1 || text === 2 ? (
  340. <Button
  341. style={
  342. text === 1
  343. ? {
  344. background: "#F00000",
  345. borderColor: "#F00000",
  346. }
  347. : {}
  348. }
  349. onClick={(e) => {
  350. e.stopPropagation();
  351. this.guidanceRead(record.uid).then(() => {
  352. this.setState(
  353. {
  354. tabsKey: "4",
  355. },
  356. () => {
  357. this.tableRowClick(record);
  358. }
  359. );
  360. });
  361. }}
  362. type="primary"
  363. >
  364. {text === 1 ? "未读" : "查看"}
  365. </Button>
  366. ) : (
  367. <div>暂无指导</div>
  368. )}
  369. </div>
  370. );
  371. },
  372. },
  373. ],
  374. tabsKey: "",
  375. data: [],
  376. dataman: [],
  377. dataSource: [],
  378. visitArrList: [],
  379. searchTime: [,],
  380. selList: [],
  381. };
  382. },
  383. //已读指导记录
  384. guidanceRead(id) {
  385. return new Promise((resolve, reject) => {
  386. $.ajax({
  387. method: "post",
  388. dataType: "json",
  389. crossDomain: false,
  390. url: globalConfig.context + "/api/admin/customer/pushGuidance",
  391. data: {
  392. uid: id,
  393. },
  394. }).done(
  395. function (data) {
  396. if (!data.error.length) {
  397. resolve();
  398. } else {
  399. message.warning(data.error[0].message);
  400. reject();
  401. }
  402. }.bind(this)
  403. );
  404. });
  405. },
  406. rankO(rank) {
  407. let deletedIds = "";
  408. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  409. let rowItem = this.state.selectedRows[idx];
  410. if (rowItem.id) {
  411. deletedIds =
  412. this.state.selectedRows.length - 1 === idx
  413. ? deletedIds + rowItem.id
  414. : deletedIds + rowItem.id + ",";
  415. }
  416. }
  417. $.ajax({
  418. method: "get",
  419. dataType: "json",
  420. crossDomain: false,
  421. url: globalConfig.context + "/api/admin/customer/updateUserLevel",
  422. data: {
  423. id: deletedIds, //客户的ID
  424. level: rank,
  425. },
  426. }).done(
  427. function (data) {
  428. if (!data.error.length && data.data !== 0) {
  429. message.success("操作成功!");
  430. this.setState({
  431. loading: false,
  432. });
  433. this.loadData(this.state.ispage);
  434. } else {
  435. message.warning(
  436. data.data === 0 ? "操作失败,请联系管理员!" : data.error[0].message
  437. );
  438. }
  439. }.bind(this)
  440. );
  441. },
  442. //进入新增拜访记录
  443. visit(e) {
  444. this.setState({
  445. followData: e,
  446. visitModul: true,
  447. modalVisible: false,
  448. });
  449. },
  450. //列表删除功能
  451. delectRow() {
  452. let deletedIds = "";
  453. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  454. let rowItem = this.state.selectedRows[idx];
  455. if (rowItem.id) {
  456. deletedIds =
  457. this.state.selectedRows.length - 1 === idx
  458. ? deletedIds + rowItem.id
  459. : deletedIds + rowItem.id + ",";
  460. }
  461. }
  462. this.setState({
  463. loading: true,
  464. selectedRowKeys: [],
  465. });
  466. $.ajax({
  467. method: "get",
  468. dataType: "json",
  469. crossDomain: false,
  470. url: globalConfig.context + "/api/admin/customer/deleteCustomer",
  471. data: {
  472. uid: deletedIds, //删除的ID
  473. },
  474. }).done(
  475. function (data) {
  476. if (!data.error.length) {
  477. message.success("删除成功!");
  478. this.setState({
  479. loading: false,
  480. });
  481. } else {
  482. message.warning(data.error[0].message);
  483. }
  484. this.loadData(this.state.ispage);
  485. }.bind(this)
  486. );
  487. },
  488. componentWillMount() {
  489. //城市
  490. let Province = [];
  491. provinceList.map(function (item) {
  492. var id = String(item.id);
  493. Province.push(
  494. <Select.Option value={id} key={item.name}>
  495. {item.name}
  496. </Select.Option>
  497. );
  498. });
  499. //行业
  500. let intentionalArr = [];
  501. industry.map(function (item) {
  502. intentionalArr.push(
  503. <Select.Option value={item.value} key={item.key}>
  504. {item.key}
  505. </Select.Option>
  506. );
  507. });
  508. //会员等级
  509. let lvlArr = [];
  510. lvl.map(function (item) {
  511. lvlArr.push(
  512. <Select.Option value={item.value} key={item.key}>
  513. {item.key}
  514. </Select.Option>
  515. );
  516. });
  517. //会员状态customerStatus
  518. let currentMemberArr = [];
  519. currentMember.map(function (item) {
  520. currentMemberArr.push(
  521. <Select.Option value={item.value} key={item.key}>
  522. {item.key}
  523. </Select.Option>
  524. );
  525. });
  526. this.state.Provinces = Province;
  527. this.state.intentionalOption = intentionalArr;
  528. this.state.lvlArrOption = lvlArr;
  529. this.state.currentMemberArrOption = currentMemberArr;
  530. this.loadData();
  531. this.category();
  532. },
  533. addClick() {
  534. this.state.RowData = {};
  535. this.setState({
  536. detailApi: this.props.detailApi,
  537. showDesc: true,
  538. modalVisible: false,
  539. visitModul: false,
  540. });
  541. },
  542. closeDesc(e, s) {
  543. this.state.basicState = e;
  544. this.state.visitModul = e;
  545. this.state.modalVisible = e;
  546. this.state.showDesc = e;
  547. this.setState({
  548. tabsKey: "",
  549. });
  550. if (s) {
  551. this.loadData(this.state.ispage);
  552. }
  553. },
  554. search() {
  555. this.loadData();
  556. },
  557. reset() {
  558. this.state.nameSearch = "";
  559. this.state.level = undefined;
  560. this.state.addressSearch = [];
  561. this.state.provinceSearch = undefined;
  562. this.state.citySearch = undefined;
  563. this.state.releaseDate[0] = undefined;
  564. this.state.releaseDate[1] = undefined;
  565. this.loadData();
  566. },
  567. searchSwitch() {
  568. this.setState({
  569. visitModul: false,
  570. searchMore: !this.state.searchMore,
  571. });
  572. },
  573. //整行点击
  574. tableRowClick(record, index) {
  575. this.state.visitModul = false;
  576. this.setState({
  577. // selectedRowKeys: [],
  578. modalVisible: true,
  579. basicState: true,
  580. contactState: true,
  581. modalName: record.name,
  582. RowData: record,
  583. });
  584. },
  585. //指定转交人自动补全
  586. supervisor(e) {
  587. $.ajax({
  588. method: "get",
  589. dataType: "json",
  590. crossDomain: false,
  591. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  592. data: {
  593. adminName: e,
  594. },
  595. success: function (data) {
  596. let thedata = data.data;
  597. if (!thedata) {
  598. if (data.error && data.error.length) {
  599. message.warning(data.error[0].message);
  600. }
  601. thedata = {};
  602. }
  603. this.setState({
  604. customerArr: thedata,
  605. });
  606. }.bind(this),
  607. }).always(
  608. function () {
  609. this.setState({
  610. loading: false,
  611. });
  612. }.bind(this)
  613. );
  614. },
  615. //上级主管输入框失去焦点是判断客户是否存在
  616. selectAuto(value, options) {
  617. this.setState({
  618. auto: value,
  619. });
  620. },
  621. blurChange(e) {
  622. let theType = "";
  623. let contactLists = this.state.customerArr || [];
  624. if (e) {
  625. contactLists.map(function (item) {
  626. if (item.name == e.toString()) {
  627. theType = item.id;
  628. }
  629. });
  630. }
  631. this.setState({
  632. theTypes: theType,
  633. });
  634. },
  635. //值改变时请求客户名称
  636. httpChange(e) {
  637. if (e.length >= 1) {
  638. this.supervisor(e);
  639. }
  640. this.setState({
  641. auto: e,
  642. });
  643. },
  644. //转交
  645. changeAssigner(infor) {
  646. let type = infor
  647. if (infor == 1) {
  648. if (this.state.selList.length == 0) {
  649. message.warn("请勾选您需要转交的信息!")
  650. return
  651. } else if (this.state.selList.length == 2) {
  652. type = 3
  653. } else {
  654. type = this.state.selList[0]
  655. }
  656. }
  657. if (this.state.theTypes) {
  658. this.setState({
  659. informationTransferVisible: false,
  660. });
  661. let changeIds = "";
  662. let oldAid = "";
  663. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  664. let rowItem = this.state.selectedRows[idx];
  665. if (rowItem.id) {
  666. oldAid = rowItem.aid;
  667. changeIds =
  668. this.state.selectedRows.length - 1 === idx
  669. ? changeIds + rowItem.id
  670. : changeIds + rowItem.id + ",";
  671. }
  672. }
  673. let loading = message.loading("加载中...");
  674. $.ajax({
  675. method: "get",
  676. dataType: "json",
  677. crossDomain: false,
  678. url: globalConfig.context + "/api/admin/customer/transferToOther",
  679. data: {
  680. uid: changeIds, //这一行数据的ID
  681. aid: this.state.theTypes, //指定转交人的ID
  682. oldAid: oldAid,
  683. operatorType: 3,
  684. data: type,
  685. },
  686. }).done(
  687. function (data) {
  688. loading();
  689. this.setState({
  690. selList: [],
  691. })
  692. if (!data.error.length) {
  693. this.setState({
  694. auto: "",
  695. loading: false,
  696. selectedRowKeys: [],
  697. });
  698. if (data.data.length == 0) {
  699. message.success("转交成功!");
  700. } else {
  701. data.data.forEach(function (e) { message.warning(e) })
  702. }
  703. } else {
  704. message.warning(data.error[0].message);
  705. }
  706. this.loadData(
  707. Math.min(
  708. this.state.ispage == undefined ? 1 : this.state.ispage,
  709. Math.ceil((this.state.pagination.total - 1) / 10)
  710. )
  711. );
  712. }.bind(this)
  713. );
  714. } else {
  715. message.warning("请输入转交人姓名");
  716. }
  717. },
  718. //导出
  719. exportExec() {
  720. let departmentName = "",
  721. depart = this.state.departmentArr || [];
  722. depart.map((item) => {
  723. if (this.state.departmentId == item.id) {
  724. departmentName = item.name;
  725. return;
  726. }
  727. });
  728. let data = {
  729. name: this.state.nameSearch,
  730. province: this.state.provinceSearch,
  731. city: this.state.addressSearch,
  732. level: this.state.level,
  733. startDate: this.state.releaseDate[0],
  734. endDate: this.state.releaseDate[1],
  735. };
  736. window.location.href =
  737. globalConfig.context +
  738. "/api/admin/customer/privateUnitCustomerOutXls?" +
  739. $.param(data);
  740. },
  741. componentWillReceiveProps(nextProps) {
  742. if (nextProps.ApiUrl != this.props.ApiUrl) {
  743. if (!this.state.searchMore) {
  744. this.state.searchMore = true;
  745. }
  746. this.state.nameSearch = "";
  747. this.state.addressSearch = [];
  748. this.state.provinceSearch = undefined;
  749. this.state.citySearch = undefined;
  750. this.state.releaseDate[0] = undefined;
  751. this.state.releaseDate[1] = undefined;
  752. this.loadData(null, nextProps.ApiUrl);
  753. }
  754. },
  755. zhuanjiaoDetail(record) {
  756. this.setState({
  757. zhuanjiaoVisible: true,
  758. zhuanjiaoId: record.id,
  759. });
  760. },
  761. zhuanjiaoDetailCancel() {
  762. this.setState({
  763. zhuanjiaoVisible: false,
  764. });
  765. },
  766. showConfirm() {
  767. let _this = this;
  768. Modal.confirm({
  769. title: "提示",
  770. content: (
  771. <span style={{ color: "red" }}>
  772. 确定要转交以下客户吗?
  773. {this.state.selectedRows.map((value, index) => (
  774. <div key={index} style={{ marginTop: "5px", color: "#000" }}>
  775. {value.name}
  776. </div>
  777. ))}
  778. </span>
  779. ),
  780. onOk() {
  781. _this.setState({
  782. informationTransferVisible: true,
  783. });
  784. },
  785. onCancel() { },
  786. });
  787. },
  788. changeList(arr) {
  789. const newArr = [];
  790. this.state.columns.forEach((item) => {
  791. arr.forEach((val) => {
  792. if (val === item.title) {
  793. newArr.push(item);
  794. }
  795. });
  796. });
  797. this.setState({
  798. changeList: newArr,
  799. });
  800. },
  801. showConfirms(fn, record) {
  802. Modal.confirm({
  803. title: "您确定将以下客户移至公共客户吗?",
  804. content: (
  805. <span style={{ color: "red" }}>
  806. 移除后,以下客户将被别人领取!
  807. {this.state.selectedRows.map((value, index) => (
  808. <div key={index} style={{ marginTop: "5px", color: "#000" }}>
  809. {value.name}
  810. </div>
  811. ))}
  812. </span>
  813. ),
  814. onOk() {
  815. fn(record);
  816. },
  817. onCancel() { },
  818. });
  819. },
  820. release() {
  821. this.setState({
  822. loading: true,
  823. });
  824. let deletedIds = "";
  825. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  826. let rowItem = this.state.selectedRows[idx];
  827. if (rowItem.id) {
  828. deletedIds =
  829. this.state.selectedRows.length - 1 === idx
  830. ? deletedIds + rowItem.id
  831. : deletedIds + rowItem.id + ",";
  832. }
  833. }
  834. $.ajax({
  835. method: "get",
  836. dataType: "json",
  837. crossDomain: false,
  838. url: globalConfig.context + "/api/admin/customer/pushReleaseUser",
  839. data: {
  840. id: deletedIds,
  841. },
  842. success: function (data) {
  843. let thedata = data.data;
  844. if (!thedata) {
  845. if (data.error && data.error.length) {
  846. message.warning(data.error[0].message);
  847. }
  848. thedata = {};
  849. } else {
  850. message.success("移除成功");
  851. this.loadData(
  852. this.state.dataSource.length === 1
  853. ? this.state.ispage === 1
  854. ? 1
  855. : this.state.ispage - 1
  856. : this.state.ispage
  857. );
  858. }
  859. }.bind(this),
  860. }).always(
  861. function () {
  862. this.setState({
  863. loading: false,
  864. });
  865. }.bind(this)
  866. );
  867. },
  868. render() {
  869. const FormItem = Form.Item;
  870. const rowSelection = {
  871. hideDefaultSelections: true,
  872. selectedRowKeys: this.state.selectedRowKeys,
  873. onChange: (selectedRowKeys, selectedRows) => {
  874. this.setState({
  875. modalVisible: false,
  876. selectedRows: selectedRows,
  877. selectedRowKeys: selectedRowKeys,
  878. });
  879. },
  880. onSelect: (recordt, selected, selectedRows) => {
  881. this.setState({
  882. modalVisible: false,
  883. recordt: recordt.id,
  884. });
  885. },
  886. };
  887. const hasSelected = this.state.selectedRowKeys.length > 0;
  888. const { RangePicker } = DatePicker;
  889. const dataSources = this.state.customerArr || [];
  890. const options = dataSources.map((group) => (
  891. <Select.Option key={group.id} value={group.name}>
  892. {group.name}
  893. </Select.Option>
  894. ));
  895. const intentionState = this.props.intentionState || "";
  896. return (
  897. <div className="user-content">
  898. <ShowModalDiv ShowModal={this.state.showModal} />
  899. <div className="content-title" style={{ marginBottom: 10 }}>
  900. <span style={{ fontWeight: 900, fontSize: 16 }}>{!intentionState ? "私有单位客户" : "私有专家客户"}</span>
  901. </div>
  902. <div className="user-search">
  903. <Tabs
  904. defaultActiveKey="1"
  905. onChange={this.callback}
  906. className="test"
  907. >
  908. <TabPane tab="搜索" key="1">
  909. <Button
  910. type="primary"
  911. style={{
  912. float: "right",
  913. marginTop: 10,
  914. marginLeft: 10,
  915. marginRight: 10,
  916. }}
  917. onClick={this.addClick}
  918. >
  919. 新增客户
  920. <Icon type="plus" />
  921. </Button>
  922. <Input
  923. placeholder="客户名称"
  924. value={this.state.nameSearch}
  925. style={{ width: 150, marginRight: 10, marginLeft: 10 }}
  926. onChange={(e) => {
  927. this.setState({ nameSearch: e.target.value });
  928. }}
  929. />
  930. <Select
  931. placeholder="省"
  932. style={{ width: 80 }}
  933. value={this.state.provinceSearch}
  934. onChange={(e) => {
  935. this.setState({ provinceSearch: e });
  936. }}
  937. >
  938. {this.state.Provinces}
  939. </Select>
  940. <span style={{ marginRight: "10px" }}>
  941. <Cascader
  942. options={citySelect()}
  943. value={this.state.addressSearch}
  944. placeholder="选择城市"
  945. onChange={(e, pre) => {
  946. this.setState({ addressSearch: e });
  947. }}
  948. />
  949. </span>
  950. <Select
  951. style={{ width: 120 }}
  952. value={this.state.level}
  953. onChange={(e) => {
  954. this.setState({ level: e });
  955. }}
  956. placeholder="请选择客户等级"
  957. >
  958. <Select.Option value="0">一般客户</Select.Option>
  959. <Select.Option value="1">意向客户</Select.Option>
  960. <Select.Option value="2">重点客户</Select.Option>
  961. </Select>
  962. <RangePicker
  963. value={[
  964. this.state.releaseDate[0]
  965. ? moment(this.state.releaseDate[0])
  966. : null,
  967. this.state.releaseDate[1]
  968. ? moment(this.state.releaseDate[1])
  969. : null,
  970. ]}
  971. onChange={(data, dataString) => {
  972. this.setState({ releaseDate: dataString });
  973. }}
  974. />
  975. <Button
  976. type="primary"
  977. style={{ marginLeft: "10px", marginRight: 10 }}
  978. onClick={this.search}
  979. >
  980. 搜索
  981. </Button>
  982. <Button onClick={this.reset}>重置</Button>
  983. </TabPane>
  984. {/*<Button onClick={() => { window.open(globalConfig.context + '/api/admin/customer/downloadTemplate?type=1') }}>下载批量导入模板</Button>
  985. <Upload
  986. name="file"
  987. action={globalConfig.context + "/api/admin/customer/uploadExcel"}
  988. beforeUpload={beforeUploadFile}
  989. showUploadList={false}
  990. onChange={(info) => {
  991. if (info.file.status !== 'uploading') {
  992. console.log(info.file, info.fileList);
  993. }
  994. if (info.file.status === 'done') {
  995. if (!info.file.response.error.length) {
  996. message.success(`${info.file.name} 文件上传成功!`);
  997. this.loadData();
  998. } else {
  999. message.warning(info.file.response.error[0].message);
  1000. return;
  1001. };
  1002. } else if (info.file.status === 'error') {
  1003. message.error(`${info.file.name} 文件上传失败。`);
  1004. };
  1005. }} >
  1006. <Button>上传批量内容</Button>
  1007. </Upload>
  1008. {adminData.isSuperAdmin?<Popconfirm title="是否删除?" onConfirm={this.delectRow} okText="是" cancelText="否">
  1009. <Button type="danger" style={{marginLeft:'10px'}}
  1010. disabled={!hasSelected}
  1011. >删除<Icon type="minus" />
  1012. </Button>
  1013. </Popconfirm>:''
  1014. }*/}
  1015. <TabPane tab="操作" key="2">
  1016. <AutoComplete
  1017. className="certain-category-search"
  1018. dropdownClassName="certain-category-search-dropdown"
  1019. dropdownMatchSelectWidth={false}
  1020. style={{ width: "120px" }}
  1021. dataSource={options}
  1022. placeholder="输入转交人姓名"
  1023. value={this.state.auto}
  1024. onChange={this.httpChange}
  1025. filterOption={true}
  1026. onBlur={this.blurChange}
  1027. onSelect={this.selectAuto}
  1028. disabled={!hasSelected}
  1029. >
  1030. <Input />
  1031. </AutoComplete>
  1032. <Button
  1033. type="primary"
  1034. // onClick={this.changeAssigner}
  1035. onClick={(e) => {
  1036. e.stopPropagation();
  1037. this.showConfirm();
  1038. }}
  1039. disabled={!hasSelected}
  1040. style={{ marginRight: 10 }}
  1041. >
  1042. 转交
  1043. </Button>
  1044. <Button
  1045. type="primary"
  1046. style={{
  1047. float: "right",
  1048. marginTop: 10,
  1049. marginLeft: 10,
  1050. marginRight: 10,
  1051. }}
  1052. onClick={this.addClick}
  1053. >
  1054. 新增客户
  1055. <Icon type="plus" />
  1056. </Button>
  1057. {/*<Button type="default" className="addButton" onClick={this.exportExec}>导出excel<Icon type="plus" /></Button>*/}
  1058. {/* <div className="clearfix" style={{ marginTop: "5px" }}> */}
  1059. <Button
  1060. onClick={(e) => {
  1061. e.stopPropagation(), this.rankO(0);
  1062. }}
  1063. type="primary"
  1064. style={{ marginRight: "10px" }}
  1065. disabled={!hasSelected}
  1066. >
  1067. 一般客户
  1068. </Button>
  1069. <Button
  1070. onClick={(e) => {
  1071. e.stopPropagation(), this.rankO(1);
  1072. }}
  1073. type="primary"
  1074. style={{ marginRight: "10px" }}
  1075. disabled={!hasSelected}
  1076. >
  1077. 意向客户
  1078. </Button>
  1079. <Button
  1080. onClick={(e) => {
  1081. e.stopPropagation(), this.rankO(2);
  1082. }}
  1083. type="primary"
  1084. disabled={!hasSelected}
  1085. >
  1086. 重点客户
  1087. </Button>
  1088. <Button
  1089. style={{ marginLeft: 10 }}
  1090. onClick={(e) => {
  1091. e.stopPropagation(),
  1092. this.zhuanjiaoDetail(this.state.selectedRows[0]);
  1093. }}
  1094. type="primary"
  1095. disabled={!hasSelected || this.state.selectedRows.length > 1}
  1096. >
  1097. 客户日志
  1098. </Button>
  1099. <Button
  1100. style={{ marginLeft: 10 }}
  1101. onClick={(e) => {
  1102. e.stopPropagation(), this.showConfirms(this.release);
  1103. }}
  1104. type="primary"
  1105. disabled={!hasSelected}
  1106. >
  1107. 移除客户
  1108. </Button>
  1109. <EnterpriseNameChange
  1110. type="journal"
  1111. disabled={
  1112. !(hasSelected && this.state.selectedRows.length === 1)
  1113. }
  1114. style={{ marginLeft: 10 }}
  1115. enterpriseId={
  1116. this.state.selectedRows[0] && this.state.selectedRows[0].id
  1117. }
  1118. />
  1119. </TabPane>
  1120. <TabPane tab="更改表格显示数据" key="3">
  1121. <div style={{ marginLeft: 10 }}>
  1122. <ChooseList
  1123. columns={this.state.columns}
  1124. changeFn={this.changeList}
  1125. changeList={this.state.changeList}
  1126. top={55}
  1127. margin={11}
  1128. />
  1129. </div>
  1130. </TabPane>
  1131. </Tabs>
  1132. </div>
  1133. <div className="patent-table">
  1134. <Spin spinning={this.state.loading}>
  1135. <Table
  1136. size="middle"
  1137. className={"intentionCustomerTable"}
  1138. columns={
  1139. this.state.changeList
  1140. ? this.state.changeList
  1141. : this.state.columns
  1142. }
  1143. dataSource={this.state.dataSource}
  1144. rowSelection={rowSelection}
  1145. pagination={this.state.pagination}
  1146. onRowDoubleClick={this.tableRowClick}
  1147. />
  1148. </Spin>
  1149. </div>
  1150. <AddIntention
  1151. api={this.state.detailApi}
  1152. showDesc={this.state.showDesc}
  1153. closeDesc={this.closeDesc}
  1154. />
  1155. <FollowDetail
  1156. categoryArr={this.state.categoryArr}
  1157. followData={this.state.followData}
  1158. visitModul={this.state.visitModul}
  1159. closeDesc={this.closeDesc}
  1160. />
  1161. <IntentionDetail
  1162. tabsKey={this.state.tabsKey}
  1163. categoryArr={this.state.categoryArr}
  1164. detailApi={this.props.detailApi}
  1165. IntentionData={this.state.RowData}
  1166. modalVisible={this.state.modalVisible}
  1167. name={this.state.modalName}
  1168. closeDesc={this.closeDesc}
  1169. basicState={this.state.basicState}
  1170. contactState={this.state.contactState}
  1171. />
  1172. {this.state.zhuanjiaoVisible ? (
  1173. <ZhuanjiaoDetail
  1174. cancel={this.zhuanjiaoDetailCancel}
  1175. visible={this.state.zhuanjiaoVisible}
  1176. id={this.state.zhuanjiaoId}
  1177. />
  1178. ) : (
  1179. ""
  1180. )}
  1181. {this.state.informationTransferVisible && (
  1182. <Modal
  1183. visible={this.state.informationTransferVisible}
  1184. title="提醒"
  1185. onCancel={() => {
  1186. this.setState({
  1187. informationTransferVisible: false,
  1188. selList: [],
  1189. });
  1190. }}
  1191. footer={[
  1192. <Button
  1193. key="1"
  1194. size="large"
  1195. type={"primary"}
  1196. onClick={() => {
  1197. this.changeAssigner(1);
  1198. }}
  1199. >
  1200. 需要
  1201. </Button>,
  1202. <Button
  1203. key="2"
  1204. size="large"
  1205. type={"danger"}
  1206. onClick={() => {
  1207. this.changeAssigner(0);
  1208. }}
  1209. >
  1210. 不需要
  1211. </Button>,
  1212. ]}
  1213. >
  1214. <div style={{ padding: "0px 40px 20px" }}>
  1215. 请确定,是否一并转交以下信息,如单个资料无法转交成功,则去掉对应“勾选”项,转交单一信息!
  1216. </div>
  1217. <div style={{ width: "50%", margin: "0 auto" }}>
  1218. <Checkbox.Group onChange={e => { this.setState({ selList: e }); }}>
  1219. <Checkbox value={1}>1.需要转交该客户资料</Checkbox>
  1220. <br />
  1221. <Checkbox value={2}>2.需要转交该客户名下的订单</Checkbox>
  1222. </Checkbox.Group>
  1223. </div>
  1224. </Modal>
  1225. )}
  1226. <textarea id="copyText" style={{ opacity: 0 }} />
  1227. </div>
  1228. );
  1229. },
  1230. })
  1231. );
  1232. export default IntentionCustomer;