intentionCustomer.jsx 40 KB

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