intentionCustomer.jsx 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  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, record) => {
  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 if (!record.level && record.level != 0) {
  318. Modal.warning({
  319. title: '系统提示',
  320. content: (
  321. <div>
  322. <p>请先设置客户类型。操作位置:</p>
  323. <p>1.勾选客户名称</p>
  324. <p>2.点击切换至“操作”项</p>
  325. <p>3.选择相应的客户类型即可。</p>
  326. </div>
  327. ),
  328. });
  329. } else {
  330. this.visit(record);
  331. }
  332. }}
  333. type="primary"
  334. >
  335. 客户跟进
  336. </Button>
  337. </div>
  338. );
  339. },
  340. },
  341. {
  342. title: "指导意见",
  343. dataIndex: "guidance",
  344. key: "guidance",
  345. render: (text, record, index) => {
  346. return (
  347. <div
  348. style={{
  349. display: "flex",
  350. flexFlow: "row",
  351. alignItems: "center",
  352. }}
  353. >
  354. {/*指导 0无 1未读 2已读*/}
  355. {text === 1 || text === 2 ? (
  356. <Button
  357. style={
  358. text === 1
  359. ? {
  360. background: "#F00000",
  361. borderColor: "#F00000",
  362. }
  363. : {}
  364. }
  365. onClick={(e) => {
  366. e.stopPropagation();
  367. this.guidanceRead(record.uid).then(() => {
  368. this.setState(
  369. {
  370. tabsKey: "4",
  371. },
  372. () => {
  373. this.tableRowClick(record);
  374. }
  375. );
  376. });
  377. }}
  378. type="primary"
  379. >
  380. {text === 1 ? "未读" : "查看"}
  381. </Button>
  382. ) : (
  383. <div>暂无指导</div>
  384. )}
  385. </div>
  386. );
  387. },
  388. },
  389. ],
  390. tabsKey: "",
  391. data: [],
  392. dataman: [],
  393. dataSource: [],
  394. visitArrList: [],
  395. searchTime: [,],
  396. selList: [],
  397. };
  398. },
  399. //已读指导记录
  400. guidanceRead(id) {
  401. return new Promise((resolve, reject) => {
  402. $.ajax({
  403. method: "post",
  404. dataType: "json",
  405. crossDomain: false,
  406. url: globalConfig.context + "/api/admin/customer/pushGuidance",
  407. data: {
  408. uid: id,
  409. },
  410. }).done(
  411. function (data) {
  412. if (!data.error.length) {
  413. resolve();
  414. } else {
  415. message.warning(data.error[0].message);
  416. reject();
  417. }
  418. }.bind(this)
  419. );
  420. });
  421. },
  422. rankO(rank) {
  423. let deletedIds = "";
  424. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  425. let rowItem = this.state.selectedRows[idx];
  426. if (rowItem.id) {
  427. deletedIds =
  428. this.state.selectedRows.length - 1 === idx
  429. ? deletedIds + rowItem.id
  430. : deletedIds + rowItem.id + ",";
  431. }
  432. }
  433. $.ajax({
  434. method: "get",
  435. dataType: "json",
  436. crossDomain: false,
  437. url: globalConfig.context + "/api/admin/customer/updateUserLevel",
  438. data: {
  439. id: deletedIds, //客户的ID
  440. level: rank,
  441. },
  442. }).done(
  443. function (data) {
  444. if (!data.error.length && data.data !== 0) {
  445. message.success("操作成功!");
  446. this.setState({
  447. loading: false,
  448. });
  449. this.loadData(this.state.ispage);
  450. } else {
  451. message.warning(
  452. data.data === 0 ? "操作失败,请联系管理员!" : data.error[0].message
  453. );
  454. }
  455. }.bind(this)
  456. );
  457. },
  458. //进入新增拜访记录
  459. visit(e) {
  460. this.setState({
  461. followData: e,
  462. visitModul: true,
  463. modalVisible: false,
  464. });
  465. },
  466. //列表删除功能
  467. delectRow() {
  468. let deletedIds = "";
  469. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  470. let rowItem = this.state.selectedRows[idx];
  471. if (rowItem.id) {
  472. deletedIds =
  473. this.state.selectedRows.length - 1 === idx
  474. ? deletedIds + rowItem.id
  475. : deletedIds + rowItem.id + ",";
  476. }
  477. }
  478. this.setState({
  479. loading: true,
  480. selectedRowKeys: [],
  481. });
  482. $.ajax({
  483. method: "get",
  484. dataType: "json",
  485. crossDomain: false,
  486. url: globalConfig.context + "/api/admin/customer/deleteCustomer",
  487. data: {
  488. uid: deletedIds, //删除的ID
  489. },
  490. }).done(
  491. function (data) {
  492. if (!data.error.length) {
  493. message.success("删除成功!");
  494. this.setState({
  495. loading: false,
  496. });
  497. } else {
  498. message.warning(data.error[0].message);
  499. }
  500. this.loadData(this.state.ispage);
  501. }.bind(this)
  502. );
  503. },
  504. componentWillMount() {
  505. //城市
  506. let Province = [];
  507. provinceList.map(function (item) {
  508. var id = String(item.id);
  509. Province.push(
  510. <Select.Option value={id} key={item.name}>
  511. {item.name}
  512. </Select.Option>
  513. );
  514. });
  515. //行业
  516. let intentionalArr = [];
  517. industry.map(function (item) {
  518. intentionalArr.push(
  519. <Select.Option value={item.value} key={item.key}>
  520. {item.key}
  521. </Select.Option>
  522. );
  523. });
  524. //会员等级
  525. let lvlArr = [];
  526. lvl.map(function (item) {
  527. lvlArr.push(
  528. <Select.Option value={item.value} key={item.key}>
  529. {item.key}
  530. </Select.Option>
  531. );
  532. });
  533. //会员状态customerStatus
  534. let currentMemberArr = [];
  535. currentMember.map(function (item) {
  536. currentMemberArr.push(
  537. <Select.Option value={item.value} key={item.key}>
  538. {item.key}
  539. </Select.Option>
  540. );
  541. });
  542. this.state.Provinces = Province;
  543. this.state.intentionalOption = intentionalArr;
  544. this.state.lvlArrOption = lvlArr;
  545. this.state.currentMemberArrOption = currentMemberArr;
  546. this.loadData();
  547. this.category();
  548. },
  549. addClick() {
  550. this.setState({
  551. loading: true,
  552. });
  553. $.ajax({
  554. method: "get",
  555. dataType: "json",
  556. crossDomain: false,
  557. url: globalConfig.context + "/api/admin/customer/queryUserMax",
  558. data: {},
  559. success: function (data) {
  560. let thedata = data.data;
  561. if (!thedata) {
  562. if (data.error && data.error.length) {
  563. message.warning(data.error[0].message);
  564. } else {
  565. if (thedata == 1) {
  566. Modal.warning({
  567. title: '温馨提示',
  568. content: (
  569. <div>
  570. <p>不可添加!您的客户数已达最大值,可移除部分客户后添加!</p>
  571. </div>
  572. ),
  573. onOk() { },
  574. });
  575. return
  576. }
  577. this.state.RowData = {};
  578. this.setState({
  579. detailApi: this.props.detailApi,
  580. showDesc: true,
  581. modalVisible: false,
  582. visitModul: false,
  583. });
  584. }
  585. }
  586. }.bind(this),
  587. }).always(
  588. function () {
  589. this.setState({
  590. loading: false,
  591. });
  592. }.bind(this)
  593. );
  594. },
  595. closeDesc(e, s) {
  596. this.state.basicState = e;
  597. this.state.visitModul = e;
  598. this.state.modalVisible = e;
  599. this.state.showDesc = e;
  600. this.setState({
  601. tabsKey: "",
  602. });
  603. if (s) {
  604. this.loadData(this.state.ispage);
  605. }
  606. },
  607. search() {
  608. this.loadData();
  609. },
  610. reset() {
  611. this.state.nameSearch = "";
  612. this.state.level = undefined;
  613. this.state.addressSearch = [];
  614. this.state.provinceSearch = undefined;
  615. this.state.citySearch = undefined;
  616. this.state.releaseDate[0] = undefined;
  617. this.state.releaseDate[1] = undefined;
  618. this.loadData();
  619. },
  620. searchSwitch() {
  621. this.setState({
  622. visitModul: false,
  623. searchMore: !this.state.searchMore,
  624. });
  625. },
  626. //整行点击
  627. tableRowClick(record, index) {
  628. this.state.visitModul = false;
  629. this.setState({
  630. // selectedRowKeys: [],
  631. modalVisible: true,
  632. basicState: true,
  633. contactState: true,
  634. modalName: record.name,
  635. RowData: record,
  636. });
  637. },
  638. //指定转交人自动补全
  639. supervisor(e) {
  640. $.ajax({
  641. method: "get",
  642. dataType: "json",
  643. crossDomain: false,
  644. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  645. data: {
  646. adminName: e,
  647. },
  648. success: function (data) {
  649. let thedata = data.data;
  650. if (!thedata) {
  651. if (data.error && data.error.length) {
  652. message.warning(data.error[0].message);
  653. }
  654. thedata = {};
  655. }
  656. this.setState({
  657. customerArr: thedata,
  658. });
  659. }.bind(this),
  660. }).always(
  661. function () {
  662. this.setState({
  663. loading: false,
  664. });
  665. }.bind(this)
  666. );
  667. },
  668. //上级主管输入框失去焦点是判断客户是否存在
  669. selectAuto(value, options) {
  670. this.setState({
  671. auto: value,
  672. });
  673. },
  674. blurChange(e) {
  675. let theType = "";
  676. let contactLists = this.state.customerArr || [];
  677. if (e) {
  678. contactLists.map(function (item) {
  679. if (item.name == e.toString()) {
  680. theType = item.id;
  681. }
  682. });
  683. }
  684. this.setState({
  685. theTypes: theType,
  686. });
  687. },
  688. //值改变时请求客户名称
  689. httpChange(e) {
  690. if (e.length >= 1) {
  691. this.supervisor(e);
  692. }
  693. this.setState({
  694. auto: e,
  695. });
  696. },
  697. //转交
  698. changeAssigner(infor) {
  699. let type = infor
  700. if (infor == 1) {
  701. if (this.state.selList.length == 0) {
  702. message.warn("请勾选您需要转交的信息!")
  703. return
  704. } else if (this.state.selList.length == 2) {
  705. type = 3
  706. } else {
  707. type = this.state.selList[0]
  708. }
  709. }
  710. if (this.state.theTypes) {
  711. this.setState({
  712. informationTransferVisible: false,
  713. });
  714. let changeIds = "";
  715. let oldAid = "";
  716. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  717. let rowItem = this.state.selectedRows[idx];
  718. if (rowItem.id) {
  719. oldAid = rowItem.aid;
  720. changeIds =
  721. this.state.selectedRows.length - 1 === idx
  722. ? changeIds + rowItem.id
  723. : changeIds + rowItem.id + ",";
  724. }
  725. }
  726. let loading = message.loading("加载中...");
  727. $.ajax({
  728. method: "get",
  729. dataType: "json",
  730. crossDomain: false,
  731. url: globalConfig.context + "/api/admin/customer/transferToOther",
  732. data: {
  733. uid: changeIds, //这一行数据的ID
  734. aid: this.state.theTypes, //指定转交人的ID
  735. oldAid: oldAid,
  736. operatorType: 3,
  737. data: type,
  738. },
  739. }).done(
  740. function (data) {
  741. loading();
  742. this.setState({
  743. selList: [],
  744. })
  745. if (!data.error.length) {
  746. this.setState({
  747. auto: "",
  748. loading: false,
  749. selectedRowKeys: [],
  750. });
  751. if (data.data.length == 0) {
  752. message.success("转交成功!");
  753. } else {
  754. data.data.forEach(function (e) { message.warning(e) })
  755. }
  756. } else {
  757. message.warning(data.error[0].message);
  758. }
  759. this.loadData(
  760. Math.min(
  761. this.state.ispage == undefined ? 1 : this.state.ispage,
  762. Math.ceil((this.state.pagination.total - 1) / 10)
  763. )
  764. );
  765. }.bind(this)
  766. );
  767. } else {
  768. message.warning("请输入转交人姓名");
  769. }
  770. },
  771. //导出
  772. exportExec() {
  773. let departmentName = "",
  774. depart = this.state.departmentArr || [];
  775. depart.map((item) => {
  776. if (this.state.departmentId == item.id) {
  777. departmentName = item.name;
  778. return;
  779. }
  780. });
  781. let data = {
  782. name: this.state.nameSearch,
  783. province: this.state.provinceSearch,
  784. city: this.state.addressSearch,
  785. level: this.state.level,
  786. startDate: this.state.releaseDate[0],
  787. endDate: this.state.releaseDate[1],
  788. };
  789. window.location.href =
  790. globalConfig.context +
  791. "/api/admin/customer/privateUnitCustomerOutXls?" +
  792. $.param(data);
  793. },
  794. componentWillReceiveProps(nextProps) {
  795. if (nextProps.ApiUrl != this.props.ApiUrl) {
  796. if (!this.state.searchMore) {
  797. this.state.searchMore = true;
  798. }
  799. this.state.nameSearch = "";
  800. this.state.addressSearch = [];
  801. this.state.provinceSearch = undefined;
  802. this.state.citySearch = undefined;
  803. this.state.releaseDate[0] = undefined;
  804. this.state.releaseDate[1] = undefined;
  805. this.loadData(null, nextProps.ApiUrl);
  806. }
  807. },
  808. zhuanjiaoDetail(record) {
  809. this.setState({
  810. zhuanjiaoVisible: true,
  811. zhuanjiaoId: record.id,
  812. });
  813. },
  814. zhuanjiaoDetailCancel() {
  815. this.setState({
  816. zhuanjiaoVisible: false,
  817. });
  818. },
  819. showConfirm() {
  820. let _this = this;
  821. Modal.confirm({
  822. title: "提示",
  823. content: (
  824. <span style={{ color: "red" }}>
  825. 确定要转交以下客户吗?
  826. {this.state.selectedRows.map((value, index) => (
  827. <div key={index} style={{ marginTop: "5px", color: "#000" }}>
  828. {value.name}
  829. </div>
  830. ))}
  831. </span>
  832. ),
  833. onOk() {
  834. _this.setState({
  835. informationTransferVisible: true,
  836. });
  837. },
  838. onCancel() { },
  839. });
  840. },
  841. changeList(arr) {
  842. const newArr = [];
  843. this.state.columns.forEach((item) => {
  844. arr.forEach((val) => {
  845. if (val === item.title) {
  846. newArr.push(item);
  847. }
  848. });
  849. });
  850. this.setState({
  851. changeList: newArr,
  852. });
  853. },
  854. showConfirms(fn, record) {
  855. Modal.confirm({
  856. title: "您确定将以下客户移至公共客户吗?",
  857. content: (
  858. <span style={{ color: "red" }}>
  859. 移除后,以下客户将被别人领取!
  860. {this.state.selectedRows.map((value, index) => (
  861. <div key={index} style={{ marginTop: "5px", color: "#000" }}>
  862. {value.name}
  863. </div>
  864. ))}
  865. </span>
  866. ),
  867. onOk() {
  868. fn(record);
  869. },
  870. onCancel() { },
  871. });
  872. },
  873. release() {
  874. this.setState({
  875. loading: true,
  876. });
  877. let deletedIds = "";
  878. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  879. let rowItem = this.state.selectedRows[idx];
  880. if (rowItem.id) {
  881. deletedIds =
  882. this.state.selectedRows.length - 1 === idx
  883. ? deletedIds + rowItem.id
  884. : deletedIds + rowItem.id + ",";
  885. }
  886. }
  887. $.ajax({
  888. method: "get",
  889. dataType: "json",
  890. crossDomain: false,
  891. url: globalConfig.context + "/api/admin/customer/pushReleaseUser",
  892. data: {
  893. id: deletedIds,
  894. },
  895. success: function (data) {
  896. let thedata = data.data;
  897. if (!thedata) {
  898. if (data.error && data.error.length) {
  899. message.warning(data.error[0].message);
  900. }
  901. thedata = {};
  902. } else {
  903. message.success("移除成功");
  904. this.loadData(
  905. this.state.dataSource.length === 1
  906. ? this.state.ispage === 1
  907. ? 1
  908. : this.state.ispage - 1
  909. : this.state.ispage
  910. );
  911. }
  912. }.bind(this),
  913. }).always(
  914. function () {
  915. this.setState({
  916. loading: false,
  917. });
  918. }.bind(this)
  919. );
  920. },
  921. render() {
  922. const FormItem = Form.Item;
  923. const rowSelection = {
  924. hideDefaultSelections: true,
  925. selectedRowKeys: this.state.selectedRowKeys,
  926. onChange: (selectedRowKeys, selectedRows) => {
  927. this.setState({
  928. modalVisible: false,
  929. selectedRows: selectedRows,
  930. selectedRowKeys: selectedRowKeys,
  931. });
  932. },
  933. onSelect: (recordt, selected, selectedRows) => {
  934. this.setState({
  935. modalVisible: false,
  936. recordt: recordt.id,
  937. });
  938. },
  939. };
  940. const hasSelected = this.state.selectedRowKeys.length > 0;
  941. const { RangePicker } = DatePicker;
  942. const dataSources = this.state.customerArr || [];
  943. const options = dataSources.map((group) => (
  944. <Select.Option key={group.id} value={group.name}>
  945. {group.name}
  946. </Select.Option>
  947. ));
  948. const intentionState = this.props.intentionState || "";
  949. return (
  950. <div className="user-content">
  951. <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
  952. <div className="content-title" style={{ marginBottom: 10 }}>
  953. <span style={{ fontWeight: 900, fontSize: 16 }}>{!intentionState ? "私有单位客户" : "私有专家客户"}</span>
  954. </div>
  955. <div className="user-search">
  956. <Tabs
  957. defaultActiveKey="1"
  958. onChange={this.callback}
  959. className="test"
  960. >
  961. <TabPane tab="搜索" key="1">
  962. {
  963. // 新需求 除湖南和内蒙古外 不让其他省操作
  964. (adminData.province == "21" || adminData.province == "11") &&
  965. <Button
  966. type="primary"
  967. style={{
  968. float: "right",
  969. marginTop: 10,
  970. marginLeft: 10,
  971. marginRight: 10,
  972. }}
  973. onClick={this.addClick}
  974. >
  975. 新增客户
  976. <Icon type="plus" />
  977. </Button>
  978. }
  979. <Input
  980. placeholder="客户名称"
  981. value={this.state.nameSearch}
  982. style={{ width: 150, marginRight: 10, marginLeft: 10 }}
  983. onChange={(e) => {
  984. this.setState({ nameSearch: e.target.value });
  985. }}
  986. />
  987. <Select
  988. placeholder="省"
  989. style={{ width: 80 }}
  990. value={this.state.provinceSearch}
  991. onChange={(e) => {
  992. this.setState({ provinceSearch: e });
  993. }}
  994. >
  995. {this.state.Provinces}
  996. </Select>
  997. <span style={{ marginRight: "10px" }}>
  998. <Cascader
  999. options={citySelect()}
  1000. value={this.state.addressSearch}
  1001. placeholder="选择城市"
  1002. onChange={(e, pre) => {
  1003. this.setState({ addressSearch: e });
  1004. }}
  1005. />
  1006. </span>
  1007. <Select
  1008. style={{ width: 180 }}
  1009. value={this.state.level}
  1010. onChange={(e) => {
  1011. this.setState({ level: e });
  1012. }}
  1013. placeholder="请选择客户等级"
  1014. >
  1015. <Select.Option value="0">一般客户(一年以上预签)</Select.Option>
  1016. <Select.Option value="1">意向客户(半年内预签)</Select.Option>
  1017. <Select.Option value="2">重点客户(一个月内预签)</Select.Option>
  1018. </Select>
  1019. <RangePicker
  1020. value={[
  1021. this.state.releaseDate[0]
  1022. ? moment(this.state.releaseDate[0])
  1023. : null,
  1024. this.state.releaseDate[1]
  1025. ? moment(this.state.releaseDate[1])
  1026. : null,
  1027. ]}
  1028. onChange={(data, dataString) => {
  1029. this.setState({ releaseDate: dataString });
  1030. }}
  1031. />
  1032. <Button
  1033. type="primary"
  1034. style={{ marginLeft: "10px", marginRight: 10 }}
  1035. onClick={this.search}
  1036. >
  1037. 搜索
  1038. </Button>
  1039. <Button onClick={this.reset}>重置</Button>
  1040. </TabPane>
  1041. {/*<Button onClick={() => { window.open(globalConfig.context + '/api/admin/customer/downloadTemplate?type=1') }}>下载批量导入模板</Button>
  1042. <Upload
  1043. name="file"
  1044. action={globalConfig.context + "/api/admin/customer/uploadExcel"}
  1045. beforeUpload={beforeUploadFile}
  1046. showUploadList={false}
  1047. onChange={(info) => {
  1048. if (info.file.status !== 'uploading') {
  1049. console.log(info.file, info.fileList);
  1050. }
  1051. if (info.file.status === 'done') {
  1052. if (!info.file.response.error.length) {
  1053. message.success(`${info.file.name} 文件上传成功!`);
  1054. this.loadData();
  1055. } else {
  1056. message.warning(info.file.response.error[0].message);
  1057. return;
  1058. };
  1059. } else if (info.file.status === 'error') {
  1060. message.error(`${info.file.name} 文件上传失败。`);
  1061. };
  1062. }} >
  1063. <Button>上传批量内容</Button>
  1064. </Upload>
  1065. {adminData.isSuperAdmin?<Popconfirm title="是否删除?" onConfirm={this.delectRow} okText="是" cancelText="否">
  1066. <Button type="danger" style={{marginLeft:'10px'}}
  1067. disabled={!hasSelected}
  1068. >删除<Icon type="minus" />
  1069. </Button>
  1070. </Popconfirm>:''
  1071. }*/}
  1072. <TabPane tab="操作" key="2">
  1073. <AutoComplete
  1074. className="certain-category-search"
  1075. dropdownClassName="certain-category-search-dropdown"
  1076. dropdownMatchSelectWidth={false}
  1077. style={{ width: "120px" }}
  1078. dataSource={options}
  1079. placeholder="输入转交人姓名"
  1080. value={this.state.auto}
  1081. onChange={this.httpChange}
  1082. filterOption={true}
  1083. onBlur={this.blurChange}
  1084. onSelect={this.selectAuto}
  1085. disabled={!hasSelected}
  1086. >
  1087. <Input />
  1088. </AutoComplete>
  1089. <Button
  1090. type="primary"
  1091. // onClick={this.changeAssigner}
  1092. onClick={(e) => {
  1093. e.stopPropagation();
  1094. this.showConfirm();
  1095. }}
  1096. disabled={!hasSelected}
  1097. style={{ marginRight: 10 }}
  1098. >
  1099. 转交
  1100. </Button>
  1101. {
  1102. // 新需求 除湖南和内蒙古外 不让其他省操作
  1103. (adminData.province == "21" || adminData.province == "11") &&
  1104. <Button
  1105. type="primary"
  1106. style={{
  1107. float: "right",
  1108. marginTop: 10,
  1109. marginLeft: 10,
  1110. marginRight: 10,
  1111. }}
  1112. onClick={this.addClick}
  1113. >
  1114. 新增客户
  1115. <Icon type="plus" />
  1116. </Button>
  1117. }
  1118. {/*<Button type="default" className="addButton" onClick={this.exportExec}>导出excel<Icon type="plus" /></Button>*/}
  1119. {/* <div className="clearfix" style={{ marginTop: "5px" }}> */}
  1120. <Button
  1121. onClick={(e) => {
  1122. e.stopPropagation(), this.rankO(0);
  1123. }}
  1124. type="primary"
  1125. style={{ marginRight: "10px" }}
  1126. disabled={!hasSelected}
  1127. >
  1128. 一般客户
  1129. </Button>
  1130. <Button
  1131. onClick={(e) => {
  1132. e.stopPropagation(), this.rankO(1);
  1133. }}
  1134. type="primary"
  1135. style={{ marginRight: "10px" }}
  1136. disabled={!hasSelected}
  1137. >
  1138. 意向客户
  1139. </Button>
  1140. <Button
  1141. onClick={(e) => {
  1142. e.stopPropagation(), this.rankO(2);
  1143. }}
  1144. type="primary"
  1145. disabled={!hasSelected}
  1146. >
  1147. 重点客户
  1148. </Button>
  1149. <Button
  1150. style={{ marginLeft: 10 }}
  1151. onClick={(e) => {
  1152. e.stopPropagation(),
  1153. this.zhuanjiaoDetail(this.state.selectedRows[0]);
  1154. }}
  1155. type="primary"
  1156. disabled={!hasSelected || this.state.selectedRows.length > 1}
  1157. >
  1158. 客户日志
  1159. </Button>
  1160. <Button
  1161. style={{ marginLeft: 10 }}
  1162. onClick={(e) => {
  1163. e.stopPropagation(), this.showConfirms(this.release);
  1164. }}
  1165. type="primary"
  1166. disabled={!hasSelected}
  1167. >
  1168. 移除客户
  1169. </Button>
  1170. <EnterpriseNameChange
  1171. type="journal"
  1172. disabled={
  1173. !(hasSelected && this.state.selectedRows.length === 1)
  1174. }
  1175. style={{ marginLeft: 10 }}
  1176. enterpriseId={
  1177. this.state.selectedRows[0] && this.state.selectedRows[0].id
  1178. }
  1179. />
  1180. </TabPane>
  1181. <TabPane tab="更改表格显示数据" key="3">
  1182. <div style={{ marginLeft: 10 }}>
  1183. <ChooseList
  1184. columns={this.state.columns}
  1185. changeFn={this.changeList}
  1186. changeList={this.state.changeList}
  1187. top={55}
  1188. margin={11}
  1189. />
  1190. </div>
  1191. </TabPane>
  1192. </Tabs>
  1193. </div>
  1194. <div className="patent-table">
  1195. <Spin spinning={this.state.loading}>
  1196. <Table
  1197. size="middle"
  1198. className={"intentionCustomerTable"}
  1199. columns={
  1200. this.state.changeList
  1201. ? this.state.changeList
  1202. : this.state.columns
  1203. }
  1204. dataSource={this.state.dataSource}
  1205. rowSelection={rowSelection}
  1206. pagination={this.state.pagination}
  1207. onRowDoubleClick={this.tableRowClick}
  1208. />
  1209. </Spin>
  1210. </div>
  1211. <AddIntention
  1212. api={this.state.detailApi}
  1213. showDesc={this.state.showDesc}
  1214. closeDesc={this.closeDesc}
  1215. />
  1216. <FollowDetail
  1217. categoryArr={this.state.categoryArr}
  1218. followData={this.state.followData}
  1219. visitModul={this.state.visitModul}
  1220. closeDesc={this.closeDesc}
  1221. />
  1222. <IntentionDetail
  1223. isLimit={this.props.isLimit}
  1224. tabsKey={this.state.tabsKey}
  1225. categoryArr={this.state.categoryArr}
  1226. detailApi={this.props.detailApi}
  1227. IntentionData={this.state.RowData}
  1228. modalVisible={this.state.modalVisible}
  1229. name={this.state.modalName}
  1230. closeDesc={this.closeDesc}
  1231. basicState={this.state.basicState}
  1232. contactState={this.state.contactState}
  1233. />
  1234. {this.state.zhuanjiaoVisible ? (
  1235. <ZhuanjiaoDetail
  1236. cancel={this.zhuanjiaoDetailCancel}
  1237. visible={this.state.zhuanjiaoVisible}
  1238. id={this.state.zhuanjiaoId}
  1239. />
  1240. ) : (
  1241. ""
  1242. )}
  1243. {this.state.informationTransferVisible && (
  1244. <Modal
  1245. visible={this.state.informationTransferVisible}
  1246. title="提醒"
  1247. onCancel={() => {
  1248. this.setState({
  1249. informationTransferVisible: false,
  1250. selList: [],
  1251. });
  1252. }}
  1253. footer={[
  1254. <Button
  1255. key="1"
  1256. size="large"
  1257. type={"primary"}
  1258. onClick={() => {
  1259. this.changeAssigner(1);
  1260. }}
  1261. >
  1262. 需要
  1263. </Button>,
  1264. <Button
  1265. key="2"
  1266. size="large"
  1267. type={"danger"}
  1268. onClick={() => {
  1269. this.changeAssigner(0);
  1270. }}
  1271. >
  1272. 不需要
  1273. </Button>,
  1274. ]}
  1275. >
  1276. <div style={{ padding: "0px 40px 20px" }}>
  1277. 请确定,是否一并转交以下信息,如单个资料无法转交成功,则去掉对应“勾选”项,转交单一信息!
  1278. </div>
  1279. <div style={{ width: "50%", margin: "0 auto" }}>
  1280. <Checkbox.Group onChange={e => { this.setState({ selList: e }); }}>
  1281. <Checkbox value={1}>1.需要转交该客户资料</Checkbox>
  1282. <br />
  1283. <Checkbox value={2}>2.需要转交该客户名下的订单</Checkbox>
  1284. </Checkbox.Group>
  1285. </div>
  1286. </Modal>
  1287. )}
  1288. <textarea id="copyText" style={{ opacity: 0 }} />
  1289. </div>
  1290. );
  1291. },
  1292. })
  1293. );
  1294. export default IntentionCustomer;