intentionCustomer.jsx 40 KB

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