visitDetail.jsx 18 KB

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