intentionCustomer.jsx 46 KB

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