visitDetail.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. import React from "react";
  2. import $ from "jquery/src/ajax";
  3. import { Modal, Form, Button, Spin, Table, message, Tag, Tooltip } from "antd";
  4. import {
  5. getfllowSituation,
  6. getcustomerStatue,
  7. getClockState,
  8. splitUrl,
  9. getContactType,
  10. } from "@/tools.js";
  11. import ImgList from "../../../../../../common/imgList";
  12. const FormItem = Form.Item;
  13. const VisitDetail = React.createClass({
  14. getInitialState() {
  15. return {
  16. visitModul: false,
  17. loading: false,
  18. data: [],
  19. publicReleaseLog: [],
  20. followDtails: {},
  21. enclosure: [],
  22. intentionPublicReleaseLog: [
  23. {
  24. title: "状态",
  25. dataIndex: "status",
  26. key: "status",
  27. render: (text) => (
  28. <Tag color={getClockState(text, true).color}>
  29. {getClockState(text, true).title}
  30. </Tag>
  31. ),
  32. },
  33. {
  34. title: "操作人",
  35. dataIndex: "aname",
  36. key: "aname",
  37. },
  38. {
  39. title: "操作时间",
  40. dataIndex: "createTimes",
  41. key: "createTimes",
  42. },
  43. {
  44. title: "备注",
  45. width: 120,
  46. dataIndex: "remarks",
  47. key: "remarks",
  48. render: (text) => {
  49. return (
  50. <Tooltip placement="topLeft" title={text}>
  51. <div
  52. style={{
  53. maxWidth: "120px",
  54. overflow: "hidden",
  55. textOverflow: "ellipsis",
  56. whiteSpace: "nowrap",
  57. }}
  58. >
  59. {text}
  60. </div>
  61. </Tooltip>
  62. );
  63. },
  64. },
  65. {
  66. title: "操作",
  67. width: 120,
  68. dataIndex: "photoUrl",
  69. key: "photoUrl",
  70. render: (text) => {
  71. let arr = splitUrl(text, ",", globalConfig.avatarHost + "/upload");
  72. return arr.length !== 0 ? (
  73. <Button
  74. ype="primary"
  75. onClick={() => {
  76. // console.log(arr);
  77. this.setState({
  78. visitImgModul: true,
  79. enclosure: arr,
  80. });
  81. }}
  82. >
  83. 查看附件
  84. </Button>
  85. ) : null;
  86. },
  87. },
  88. ],
  89. //业务意向列表
  90. intentionList: [
  91. {
  92. title: "业务名称",
  93. dataIndex: "businessVarietiesName",
  94. width: 120,
  95. key: "businessVarietiesName",
  96. },
  97. {
  98. title: "项目名称",
  99. dataIndex: "businessProjectName",
  100. key: "businessProjectName",
  101. width: 120,
  102. },
  103. {
  104. title: "最新进度",
  105. width: 120,
  106. dataIndex: "followSituation",
  107. key: "followSituation",
  108. render: (text, record, index) => {
  109. return (
  110. <div>
  111. <span>{getfllowSituation(text)}</span>
  112. </div>
  113. );
  114. },
  115. },
  116. {
  117. title: "最新状态",
  118. width: 120,
  119. dataIndex: "customerStatus",
  120. key: "customerStatus",
  121. render: (text, record, index) => {
  122. return (
  123. <div>
  124. <span>{getcustomerStatue(text)}</span>
  125. </div>
  126. );
  127. },
  128. },
  129. {
  130. title: "跟进说明",
  131. width: 120,
  132. dataIndex: "remarks",
  133. key: "remarks",
  134. render: (text, record, index) => {
  135. return (
  136. <div>
  137. <span title={text}>
  138. {text && text.length > 8 ? text.substr(0, 8) + "…" : text}
  139. </span>
  140. </div>
  141. );
  142. },
  143. },
  144. ],
  145. };
  146. },
  147. //进入修改拜访记录
  148. visitModify(e) {
  149. this.setState({
  150. visitModul: true,
  151. loading: true,
  152. });
  153. $.ajax({
  154. method: "get",
  155. dataType: "json",
  156. url: globalConfig.context + "/api/admin/customer/toUpdateFollow",
  157. data: {
  158. followId: e,
  159. },
  160. success: function (data) {
  161. let theArr = [];
  162. let thedata = data.data;
  163. if (!thedata) {
  164. if (data.error && data.error.length) {
  165. message.warning(data.error[0].message);
  166. }
  167. thedata = {};
  168. }
  169. for (let i = 0; i < data.data.userBusinessList.length; i++) {
  170. let thisdata = data.data.userBusinessList[i];
  171. theArr.push({
  172. key: i,
  173. readOnly: this.props.followData.readOnly,
  174. id: thisdata.ufbId,
  175. businessName: thisdata.businessProjectId,
  176. businessVarietiesName: thisdata.businessVarietiesName,
  177. businessProjectName: thisdata.businessProjectName,
  178. followSituation:
  179. thisdata.followSituation == null
  180. ? undefined
  181. : String(thisdata.followSituation),
  182. customerStatus:
  183. thisdata.customerStatus == null
  184. ? undefined
  185. : String(thisdata.customerStatus),
  186. remarks: thisdata.remarks,
  187. });
  188. }
  189. this.setState({
  190. followIds: thedata.followId,
  191. contacts: thedata.contacts,
  192. uid: thedata.uid,
  193. data: theArr,
  194. result: thedata.result,
  195. contactMobile: thedata.contactMobile,
  196. contactType: getContactType(thedata.contactType),
  197. followTime: thedata.followTime,
  198. followSituation: thedata.followSituation,
  199. customerStatus: thedata.customerStatus,
  200. });
  201. }.bind(this),
  202. }).always(
  203. function () {
  204. this.setState({
  205. loading: false,
  206. });
  207. }.bind(this)
  208. );
  209. },
  210. //拜访意向服务列表单个删除
  211. intentionDelet(e, index) {
  212. let detId = this.state.followIds;
  213. if (e.id) {
  214. this.setState({
  215. selectedRowKeys: [],
  216. });
  217. $.ajax({
  218. method: "get",
  219. dataType: "json",
  220. crossDomain: false,
  221. url:
  222. globalConfig.context + "/api/admin/customer/deleteFollowOneBusiness",
  223. data: {
  224. ufbId: e.id,
  225. },
  226. }).done(
  227. function (data) {
  228. if (!data.error.length) {
  229. message.success("删除成功");
  230. this.setState({
  231. loading: false,
  232. });
  233. } else {
  234. message.warning(data.error[0].message);
  235. }
  236. this.visitModify(detId);
  237. }.bind(this)
  238. );
  239. } else {
  240. this.visitModify(detId);
  241. }
  242. },
  243. //拜访modul函数
  244. visitOk(e) {
  245. this.setState({
  246. addcontactModul: false,
  247. visitModul: false,
  248. });
  249. },
  250. visitCancel(e) {
  251. this.setState({
  252. addcontactModul: false,
  253. visitModul: false,
  254. });
  255. },
  256. //详情保存
  257. visitSubmit(e) {
  258. e.preventDefault();
  259. this.setState({
  260. loading: true,
  261. });
  262. let contactsId = "";
  263. if (this.state.keys) {
  264. let conts = this.state.lastName;
  265. contactsId = this.state.contactsIdArr[conts].id;
  266. }
  267. let GlossoryId = false;
  268. this.state.data.map(function (item) {
  269. if (!item.followSituation || !item.customerStatus || !item.businessName) {
  270. GlossoryId = true;
  271. }
  272. });
  273. if (this.state.data.length && GlossoryId) {
  274. message.warning("项目名称/最新进度/最新状态不能为空!");
  275. return false;
  276. }
  277. let dataList = this.state.data,
  278. idsList = [];
  279. dataList.map((item, index) => {
  280. idsList.push({
  281. ufbId: item.id || "",
  282. businessProjectId: item.businessName,
  283. customerStatus: item.customerStatus,
  284. followSituation: item.followSituation,
  285. remarks: item.remarks || "",
  286. });
  287. });
  288. //新增
  289. $.ajax({
  290. method: "post",
  291. dataType: "json",
  292. url: globalConfig.context + "/api/admin/customer/updateFollow",
  293. data: {
  294. followId: this.state.followIds,
  295. userBusinessList: JSON.stringify(idsList),
  296. uid: this.state.uid,
  297. contactType: this.state.contactType,
  298. result: this.state.result,
  299. followTime: this.state.followTime,
  300. },
  301. }).done(
  302. function (data) {
  303. this.setState({
  304. loading: false,
  305. });
  306. if (!data.error.length) {
  307. message.success("保存成功!");
  308. this.props.closeDesc(false, true);
  309. this.visitCancel();
  310. } else {
  311. message.warning(data.error[0].message);
  312. }
  313. }.bind(this)
  314. );
  315. },
  316. getFollowDtails(e) {
  317. this.setState({
  318. loading: true,
  319. });
  320. $.ajax({
  321. method: "get",
  322. dataType: "json",
  323. url: globalConfig.context + "/api/admin/release/followDtails",
  324. data: {
  325. id: e,
  326. },
  327. success: function (data) {
  328. if (data.error.length === 0) {
  329. this.setState({
  330. followDtails: data.data || {},
  331. });
  332. } else {
  333. message.warning(data.error[0].message);
  334. }
  335. }.bind(this),
  336. }).always(
  337. function () {
  338. this.setState({
  339. loading: false,
  340. });
  341. }.bind(this)
  342. );
  343. },
  344. getListPublicReleaseLog(e) {
  345. this.setState({
  346. loading: true,
  347. });
  348. $.ajax({
  349. method: "get",
  350. dataType: "json",
  351. url: globalConfig.context + "/api/admin/release/listPublicReleaseLog",
  352. data: {
  353. ufid: e,
  354. },
  355. success: function (data) {
  356. if (data.error.length === 0) {
  357. this.setState({
  358. publicReleaseLog: data.data || [],
  359. });
  360. } else {
  361. message.warning(data.error[0].message);
  362. }
  363. }.bind(this),
  364. }).always(
  365. function () {
  366. this.setState({
  367. loading: false,
  368. });
  369. }.bind(this)
  370. );
  371. },
  372. componentWillReceiveProps(nextProps) {
  373. if (nextProps.visitModul && nextProps.followData.followId) {
  374. this.setState({
  375. visitModul: true,
  376. loading: true,
  377. });
  378. if (nextProps.followData.contactType === "5") {
  379. this.getListPublicReleaseLog(nextProps.followData.followId);
  380. this.getFollowDtails(nextProps.followData.followId);
  381. }
  382. this.visitModify(nextProps.followData.followId);
  383. }
  384. },
  385. render() {
  386. const formItemLayout = {
  387. labelCol: { span: 8 },
  388. wrapperCol: { span: 14 },
  389. };
  390. const followData = this.props.followData || [];
  391. return (
  392. <div>
  393. <Modal
  394. className="customeDetails"
  395. footer=""
  396. title="客户跟进详情"
  397. width="1200px"
  398. visible={this.state.visitModul}
  399. onOk={this.visitOk}
  400. onCancel={this.visitCancel}
  401. >
  402. <Form
  403. layout="horizontal"
  404. id="demand-form"
  405. onSubmit={this.visitSubmit}
  406. >
  407. <Spin spinning={this.state.loading}>
  408. <div className="clearfix">
  409. {!(
  410. this.state.contactType === "公出打卡" &&
  411. Object.keys(this.state.followDtails).length > 0
  412. ) ? (
  413. <div>
  414. <FormItem
  415. labelCol={{ span: 4 }}
  416. wrapperCol={{ span: 20 }}
  417. label="跟进方式"
  418. >
  419. <span>{this.state.contactType}</span>
  420. </FormItem>
  421. <div className="clearfix">
  422. {!followData.readOnly && (
  423. <FormItem
  424. className="half-item"
  425. {...formItemLayout}
  426. label="当前联系人"
  427. >
  428. <span>{this.state.contacts}</span>
  429. </FormItem>
  430. )}
  431. <FormItem
  432. className="half-item"
  433. {...formItemLayout}
  434. label="跟进时间"
  435. >
  436. <span>{this.state.followTime}</span>
  437. </FormItem>
  438. {!followData.readOnly && (
  439. <FormItem
  440. className="half-item"
  441. {...formItemLayout}
  442. label="联系电话"
  443. >
  444. <span>{this.state.contactMobile}</span>
  445. </FormItem>
  446. )}
  447. </div>
  448. <div className="clearfix">
  449. <FormItem
  450. labelCol={{ span: 4 }}
  451. wrapperCol={{ span: 16 }}
  452. label="跟进备注"
  453. >
  454. {
  455. <span style={{ wordWrap: "breakWord" }}>
  456. {this.state.result}
  457. </span>
  458. }
  459. </FormItem>
  460. </div>
  461. </div>
  462. ) : null}
  463. {this.state.contactType === "公出打卡" &&
  464. Object.keys(this.state.followDtails).length > 0 ? (
  465. <div>
  466. <div className="clearfix">
  467. <FormItem
  468. labelCol={{ span: 4 }}
  469. wrapperCol={{ span: 16 }}
  470. label="公出企业"
  471. >
  472. <span>{this.state.followDtails.nickname}</span>
  473. </FormItem>
  474. <FormItem
  475. labelCol={{ span: 4 }}
  476. wrapperCol={{ span: 16 }}
  477. label="公出时间"
  478. >
  479. <span>
  480. {this.state.followDtails.releaseStarts +
  481. "~" +
  482. this.state.followDtails.releaseEnds}
  483. </span>
  484. </FormItem>
  485. <FormItem
  486. labelCol={{ span: 4 }}
  487. wrapperCol={{ span: 16 }}
  488. label="公出地点"
  489. >
  490. <span>{this.state.followDtails.districtName}</span>
  491. </FormItem>
  492. <FormItem
  493. labelCol={{ span: 4 }}
  494. wrapperCol={{ span: 16 }}
  495. label="当前状态"
  496. >
  497. <span>
  498. <Tag
  499. color={
  500. getClockState(this.state.followDtails.status)
  501. .color
  502. }
  503. >
  504. {
  505. getClockState(this.state.followDtails.status)
  506. .title
  507. }
  508. </Tag>
  509. </span>
  510. </FormItem>
  511. </div>
  512. <div className="clearfix">
  513. <div
  514. style={{
  515. fontSize: "18px",
  516. marginLeft: "100px",
  517. marginTop: "15px",
  518. marginBottom: "10px",
  519. }}
  520. >
  521. 公出日志
  522. </div>
  523. <Table
  524. pagination={false}
  525. columns={this.state.intentionPublicReleaseLog}
  526. dataSource={this.state.publicReleaseLog}
  527. />
  528. </div>
  529. </div>
  530. ) : null}
  531. {!(
  532. this.state.contactType === "公出打卡" &&
  533. Object.keys(this.state.followDtails).length > 0
  534. ) ? (
  535. <div className="clearfix">
  536. <div
  537. style={{
  538. fontSize: "18px",
  539. marginLeft: "100px",
  540. marginTop: "15px",
  541. marginBottom: "10px",
  542. }}
  543. >
  544. 业务意向
  545. </div>
  546. <div className="clearfix">
  547. <Spin spinning={this.state.loading}>
  548. <Table
  549. size="middle"
  550. rowKey={(record) => record.id}
  551. pagination={false}
  552. columns={this.state.intentionList}
  553. dataSource={this.state.data}
  554. />
  555. </Spin>
  556. </div>
  557. </div>
  558. ) : null}
  559. </div>
  560. {!followData.readOnly && (
  561. <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  562. {/* <Button type="primary" size="large" htmlType="submit" style={{marginRight:'150px',marginTop:'20px'}}>保存</Button>
  563. <Button size="large" onClick={this.visitCancel}>取消</Button> */}
  564. </FormItem>
  565. )}
  566. </Spin>
  567. </Form>
  568. </Modal>
  569. {this.state.visitImgModul ? (
  570. <Modal
  571. className="customeDetails"
  572. footer=""
  573. title="附件"
  574. width="600px"
  575. visible={this.state.visitImgModul}
  576. onOk={() => {
  577. this.setState({
  578. visitImgModul: false,
  579. enclosure: [],
  580. });
  581. }}
  582. onCancel={() => {
  583. this.setState({
  584. visitImgModul: false,
  585. enclosure: [],
  586. });
  587. }}
  588. >
  589. <ImgList fileList={this.state.enclosure} domId={"visitDetail"} />
  590. </Modal>
  591. ) : null}
  592. </div>
  593. );
  594. },
  595. });
  596. export default VisitDetail;