intentionCustomer.jsx 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  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} />
  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. tabsKey={this.state.tabsKey}
  1212. categoryArr={this.state.categoryArr}
  1213. detailApi={this.props.detailApi}
  1214. IntentionData={this.state.RowData}
  1215. modalVisible={this.state.modalVisible}
  1216. name={this.state.modalName}
  1217. closeDesc={this.closeDesc}
  1218. basicState={this.state.basicState}
  1219. contactState={this.state.contactState}
  1220. />
  1221. {this.state.zhuanjiaoVisible ? (
  1222. <ZhuanjiaoDetail
  1223. cancel={this.zhuanjiaoDetailCancel}
  1224. visible={this.state.zhuanjiaoVisible}
  1225. id={this.state.zhuanjiaoId}
  1226. />
  1227. ) : (
  1228. ""
  1229. )}
  1230. {this.state.informationTransferVisible && (
  1231. <Modal
  1232. visible={this.state.informationTransferVisible}
  1233. title="提醒"
  1234. onCancel={() => {
  1235. this.setState({
  1236. informationTransferVisible: false,
  1237. selList: [],
  1238. });
  1239. }}
  1240. footer={[
  1241. <Button
  1242. key="1"
  1243. size="large"
  1244. type={"primary"}
  1245. onClick={() => {
  1246. this.changeAssigner(1);
  1247. }}
  1248. >
  1249. 需要
  1250. </Button>,
  1251. <Button
  1252. key="2"
  1253. size="large"
  1254. type={"danger"}
  1255. onClick={() => {
  1256. this.changeAssigner(0);
  1257. }}
  1258. >
  1259. 不需要
  1260. </Button>,
  1261. ]}
  1262. >
  1263. <div style={{ padding: "0px 40px 20px" }}>
  1264. 请确定,是否一并转交以下信息,如单个资料无法转交成功,则去掉对应“勾选”项,转交单一信息!
  1265. </div>
  1266. <div style={{ width: "50%", margin: "0 auto" }}>
  1267. <Checkbox.Group onChange={e => { this.setState({ selList: e }); }}>
  1268. <Checkbox value={1}>1.需要转交该客户资料</Checkbox>
  1269. <br />
  1270. <Checkbox value={2}>2.需要转交该客户名下的订单</Checkbox>
  1271. </Checkbox.Group>
  1272. </div>
  1273. </Modal>
  1274. )}
  1275. <textarea id="copyText" style={{ opacity: 0 }} />
  1276. </div>
  1277. );
  1278. },
  1279. })
  1280. );
  1281. export default IntentionCustomer;