followDetail.jsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. import React from "react";
  2. import ajax from "jquery/src/ajax/xhr.js";
  3. import $ from "jquery/src/ajax";
  4. import {
  5. Modal,
  6. Form,
  7. layout,
  8. Radio,
  9. Button,
  10. Input,
  11. Spin,
  12. Table,
  13. Select,
  14. Popconfirm,
  15. message,
  16. } from "antd";
  17. import { intentionalService, newFollow, customerStatus } from "@/dataDic.js";
  18. import { getCompanyIntention } from "@/tools.js";
  19. const FormItem = Form.Item;
  20. import AddContact from "../signCustomer/followDetail/addContact";
  21. import BusName from "./followDetail/businessName.jsx";
  22. const FollowDetail = React.createClass({
  23. getInitialState() {
  24. return {
  25. visitModul: false,
  26. loading: false,
  27. data: [],
  28. businessName: "",
  29. projectName: "",
  30. busModul: false,
  31. intentionList: [
  32. {
  33. title: "业务名称",
  34. dataIndex: "businessGlossoryId",
  35. width: 120,
  36. key: "businessGlossoryId",
  37. render: (text, record, index) => {
  38. return (
  39. <div>
  40. {!record.id ? (
  41. <Select
  42. placeholder="选择业务名称"
  43. value={record.businessGlossoryId}
  44. onChange={(e) => {
  45. record.businessGlossoryId = e;
  46. this.setState({ data: this.state.data });
  47. }}
  48. >
  49. {this.props.categoryArr.map(function (item) {
  50. return (
  51. <Select.Option key={item.value}>
  52. {item.key}
  53. </Select.Option>
  54. );
  55. })}
  56. </Select>
  57. ) : (
  58. <span>{record.businessVarietiesName}</span>
  59. )}
  60. </div>
  61. );
  62. },
  63. },
  64. {
  65. title: "项目名称",
  66. dataIndex: "businessName",
  67. key: "businessName",
  68. width: 120,
  69. render: (text, record, index) => {
  70. return (
  71. <div>
  72. {!record.id ? (
  73. <div>
  74. <Button
  75. onClick={(e) => {
  76. e.stopPropagation(), this.businessFn(record, index);
  77. }}
  78. type="small"
  79. >
  80. {record.projectName}
  81. </Button>
  82. </div>
  83. ) : (
  84. <span>{record.businessProjectName}</span>
  85. )}
  86. </div>
  87. );
  88. },
  89. },
  90. {
  91. title: "最新进度",
  92. width: 120,
  93. dataIndex: "followSituation",
  94. key: "followSituation",
  95. render: (text, record, index) => {
  96. if (text == 5 && !record.isEdit) {
  97. return newFollow.map(function (item) {
  98. if (item.value == text) {
  99. return item.key;
  100. }
  101. });
  102. } else {
  103. return (
  104. <Select
  105. placeholder="选择最新进度"
  106. value={record.followSituation}
  107. onChange={(e) => {
  108. record.followSituation = e;
  109. record.isEdit = true;
  110. this.setState({ data: this.state.data });
  111. }}
  112. >
  113. {newFollow
  114. .filter((v) => {
  115. return v.value !== "5";
  116. })
  117. .map(function (item) {
  118. return (
  119. <Select.Option key={item.value}>
  120. {item.key}
  121. </Select.Option>
  122. );
  123. })}
  124. </Select>
  125. );
  126. }
  127. },
  128. },
  129. {
  130. title: "最新状态",
  131. width: 120,
  132. dataIndex: "customerStatus",
  133. key: "customerStatus",
  134. render: (text, record, index) => {
  135. if (record.followSituation == 5 && !record.isEdit) {
  136. return customerStatus.map(function (item) {
  137. if (item.value == text) {
  138. return item.key;
  139. }
  140. });
  141. } else {
  142. return (
  143. <Select
  144. value={record.customerStatus}
  145. placeholder="选择最新状态"
  146. onChange={(e) => {
  147. record.customerStatus = e;
  148. this.setState({ data: this.state.data });
  149. }}
  150. >
  151. {customerStatus.map(function (item) {
  152. return (
  153. <Select.Option key={item.value}>{item.key}</Select.Option>
  154. );
  155. })}
  156. </Select>
  157. );
  158. }
  159. },
  160. },
  161. {
  162. title: "跟进说明",
  163. width: 120,
  164. dataIndex: "remarks",
  165. key: "remarks",
  166. render: (text, record, index) => {
  167. if (record.followSituation == 5 && !record.isEdit) {
  168. return text;
  169. } else {
  170. return (
  171. <Input
  172. value={record.remarks}
  173. placeholder="跟进说明"
  174. onChange={(e) => {
  175. record.remarks = e.target.value;
  176. this.setState({ data: this.state.data });
  177. }}
  178. />
  179. );
  180. }
  181. },
  182. },
  183. {
  184. title: "操作",
  185. width: 120,
  186. dataIndex: "rrr",
  187. key: "rrr",
  188. render: (text, record, index) => {
  189. return (
  190. <div>
  191. {!record.id && (
  192. <Popconfirm
  193. title="是否删除?"
  194. onConfirm={(e) => {
  195. this.intentionDelet(record, index);
  196. }}
  197. okText="删除"
  198. cancelText="不删除"
  199. >
  200. <Button
  201. style={{
  202. marginRight: "10px",
  203. color: "#ffffff",
  204. background: "#f00",
  205. border: "none",
  206. }}
  207. >
  208. 删除
  209. </Button>
  210. </Popconfirm>
  211. )}
  212. </div>
  213. );
  214. },
  215. },
  216. ],
  217. };
  218. },
  219. //选择子项目
  220. businessFn(record, index) {
  221. if (!record.businessGlossoryId) {
  222. message.warn("请先选择业务名称!");
  223. return;
  224. }
  225. this.setState({
  226. businessId: record.businessGlossoryId,
  227. busModul: true,
  228. index: index,
  229. addcontactModul: false,
  230. });
  231. },
  232. closeBus(datas, e, s) {
  233. this.state.addcontactModul = e;
  234. this.state.busModul = false;
  235. if (s) {
  236. this.state.data[this.state.index].businessName = datas.id;
  237. this.state.data[this.state.index].projectName = datas.name;
  238. this.setState({
  239. busModul: false,
  240. data: this.state.data,
  241. });
  242. }
  243. },
  244. //拜访意向服务列表单个删除
  245. intentionDelet(e, index) {
  246. let deteluserBusinessList = this.state.data.splice(index, 1);
  247. this.setState({
  248. selectedRowKeys: [],
  249. });
  250. },
  251. //拜访modul函数
  252. visitOk(e) {
  253. this.setState({
  254. addcontactModul: false,
  255. visitModul: false,
  256. });
  257. },
  258. visitCancel(e) {
  259. this.setState({
  260. addcontactModul: false,
  261. visitModul: false,
  262. });
  263. this.props.closeDesc(false, false);
  264. },
  265. //获取联系人下拉框
  266. getNewWoman(ids) {
  267. this.state.data = [];
  268. $.ajax({
  269. method: "get",
  270. dataType: "json",
  271. crossDomain: false,
  272. url: globalConfig.context + "/api/admin/customer/findCustomerContacts",
  273. data: {
  274. uid: ids,
  275. },
  276. success: function (data) {
  277. let theArr = [];
  278. let thedata = data.data;
  279. if (!thedata) {
  280. if (data.error && data.error.length) {
  281. message.warning(data.error[0].message);
  282. }
  283. thedata = {};
  284. }
  285. var telNum = [];
  286. var contactIds = [];
  287. thedata.map(function (item, index) {
  288. contactIds.push(thedata[index].id);
  289. telNum.push(thedata[index].mobile);
  290. });
  291. for (let item in data.data) {
  292. let theData = data.data[item];
  293. theData.name != "***" &&
  294. theArr.push(
  295. <Select.Option value={item} key={theData.name}>
  296. {theData.name}
  297. </Select.Option>
  298. );
  299. }
  300. this.setState({
  301. contactsIdArr: thedata,
  302. telNum: telNum,
  303. orderStatusOption: theArr,
  304. });
  305. }.bind(this),
  306. }).always(
  307. function () {
  308. this.setState({
  309. deletId: ids,
  310. loading: false,
  311. });
  312. }.bind(this)
  313. );
  314. },
  315. //刷新新增拜访记录刷新
  316. deletelist(e) {
  317. this.setState({
  318. loading: true,
  319. });
  320. $.ajax({
  321. method: "get",
  322. dataType: "json",
  323. url: globalConfig.context + this.props.isLimit
  324. ? "/api/restrict/Project/getFollowDetails"
  325. : "/api/admin/customer/toAddFollowOnHistory",
  326. data: {
  327. uid: e,
  328. },
  329. success: function (data) {
  330. let listArr = [];
  331. let thedata = data.data;
  332. if (!thedata) {
  333. if (data.error && data.error.length) {
  334. message.warning(data.error[0].message);
  335. }
  336. thedata = {};
  337. }
  338. for (let i = 0; i < data.data.userBusinessList.length; i++) {
  339. let thisdata = data.data.userBusinessList[i];
  340. listArr.push({
  341. id: thisdata.businessId,
  342. businessName: thisdata.businessProjectId,
  343. businessGlossoryId: i,
  344. businessVarietiesName: thisdata.businessVarietiesName,
  345. businessProjectName: thisdata.businessProjectName,
  346. followSituation: String(thisdata.followSituation),
  347. customerStatus: String(thisdata.customerStatus),
  348. remarks: thisdata.remarks,
  349. });
  350. }
  351. this.setState({
  352. contacts: thedata.contacts,
  353. uid: thedata.uid,
  354. data: listArr,
  355. followTime: thedata.followTime,
  356. remarks: thedata.remarks,
  357. });
  358. }.bind(this),
  359. }).always(
  360. function () {
  361. this.setState({
  362. loading: false,
  363. });
  364. }.bind(this)
  365. );
  366. },
  367. //当选择联系人的列表变化时,则执行
  368. hundleName(e) {
  369. let changNub = this.state.telNum[e];
  370. this.setState({
  371. nub: this.state.telNum[e],
  372. lastName: e,
  373. });
  374. },
  375. //点击添加联系人
  376. newContacts() {
  377. this.setState({
  378. busModul: false,
  379. uids: this.state.uid,
  380. addcontactModul: true,
  381. });
  382. },
  383. //页面刷新
  384. closeFollow(e, s) {
  385. this.state.addcontactModul = false;
  386. this.state.visitModul = true;
  387. if (s) {
  388. this.getNewWoman(this.props.followData.id);
  389. this.deletelist(this.props.followData.id);
  390. }
  391. },
  392. //详情保存
  393. visitSubmit(e) {
  394. e.preventDefault();
  395. let GlossoryId = false;
  396. this.state.data.map(function (item) {
  397. if (!item.followSituation || !item.customerStatus || !item.businessName) {
  398. GlossoryId = true;
  399. }
  400. });
  401. if (this.state.contactType == undefined) {
  402. message.warning("请选择拜访方式");
  403. return false;
  404. }
  405. if (this.state.lastName == undefined) {
  406. message.warning("请选择联系人");
  407. return false;
  408. }
  409. if (this.state.result.length < 10) {
  410. message.warning("备注不少于10个字符!");
  411. return false;
  412. }
  413. if (this.state.data.length && GlossoryId) {
  414. message.warning("项目名称/最新进度/最新状态不能为空!");
  415. return false;
  416. }
  417. let dataList = this.state.data,
  418. idsList = [];
  419. dataList.map((item, index) => {
  420. idsList.push({
  421. businessId: item.id || "",
  422. businessProjectId: item.businessName,
  423. customerStatus: item.customerStatus,
  424. followSituation: item.followSituation,
  425. remarks: item.remarks || "",
  426. });
  427. });
  428. this.setState({
  429. loading: true,
  430. });
  431. let contactsId = "";
  432. let conts = this.state.lastName;
  433. contactsId = this.state.contactsIdArr[conts].id;
  434. //新增
  435. $.ajax({
  436. method: "post",
  437. dataType: "json",
  438. url: globalConfig.context + "/api/admin/customer/addFollow",
  439. data: {
  440. userBusinessList: JSON.stringify(idsList),
  441. uid: this.state.uid,
  442. ocbId: contactsId,
  443. contactType: this.state.contactType,
  444. result: this.state.result,
  445. followTime: this.state.followTime,
  446. type: this.props.isLimit ? 1 : 0,
  447. pid: this.props.isLimit ? this.props.details.pid : undefined,
  448. },
  449. }).done(
  450. function (data) {
  451. this.setState({
  452. loading: false,
  453. });
  454. if (!data.error.length) {
  455. message.success("保存成功!");
  456. this.props.closeDesc(false, true);
  457. this.visitCancel();
  458. } else {
  459. message.warning(data.error[0].message);
  460. }
  461. }.bind(this)
  462. );
  463. },
  464. //添加新业务
  465. addNew() {
  466. this.state.data.push({
  467. isEdit: true,
  468. projectName: "选择",
  469. businessName: "",
  470. customerStatus: undefined,
  471. businessGlossoryId: undefined,
  472. followSituation: undefined,
  473. remarks: "",
  474. });
  475. this.setState({
  476. addcontactModul: false,
  477. data: this.state.data,
  478. });
  479. },
  480. componentWillReceiveProps(nextProps) {
  481. if (nextProps.visitModul && nextProps.followData.id) {
  482. this.setState({
  483. result: "",
  484. contactType: undefined,
  485. visitModul: true,
  486. loading: true,
  487. lastName: undefined,
  488. nub: "",
  489. busModul: false,
  490. addcontactModul: false,
  491. });
  492. this.getNewWoman(nextProps.followData.id);
  493. this.deletelist(nextProps.followData.id);
  494. }
  495. },
  496. render() {
  497. const formItemLayout = {
  498. labelCol: { span: 8 },
  499. wrapperCol: { span: 14 },
  500. };
  501. return (
  502. <div>
  503. <Modal
  504. maskClosable={false}
  505. className="customeDetails"
  506. footer=""
  507. title="新增跟进"
  508. width="1200px"
  509. visible={this.state.visitModul}
  510. onOk={this.visitOk}
  511. onCancel={this.visitCancel}
  512. >
  513. <Form
  514. layout="horizontal"
  515. id="demand-form"
  516. onSubmit={this.visitSubmit}
  517. >
  518. <Spin spinning={this.state.loading}>
  519. <div className="clearfix">
  520. <FormItem
  521. labelCol={{ span: 4 }}
  522. wrapperCol={{ span: 20 }}
  523. label="跟进方式"
  524. >
  525. <Radio.Group
  526. value={this.state.contactType}
  527. onChange={(e) => {
  528. this.setState({ contactType: e.target.value });
  529. }}
  530. >
  531. {/*<Radio value={0}>外出</Radio>*/}
  532. <Radio value={1}>电话</Radio>
  533. <Radio value={2}>QQ</Radio>
  534. <Radio value={3}>微信</Radio>
  535. <Radio value={4}>邮箱</Radio>
  536. <Radio value={6}>来访面谈</Radio>
  537. </Radio.Group>
  538. <span className="mandatory" style={{ color: "red" }}>
  539. *
  540. </span>
  541. </FormItem>
  542. <div className="clearfix">
  543. {this.state.contacts ? (
  544. <span></span>
  545. ) : (
  546. <FormItem
  547. className="half-item"
  548. {...formItemLayout}
  549. label="联系人"
  550. >
  551. <Select
  552. placeholder="选择联系人"
  553. style={{ width: 140 }}
  554. value={this.state.lastName}
  555. onChange={this.hundleName}
  556. >
  557. {this.state.orderStatusOption}
  558. </Select>
  559. <span className="mandatory" style={{ color: "red" }}>
  560. {" "}
  561. *
  562. </span>
  563. </FormItem>
  564. )}
  565. <FormItem className="half-item" {...formItemLayout}>
  566. <Button
  567. type="primary"
  568. onClick={this.newContacts}
  569. style={{ marginLeft: "100px" }}
  570. >
  571. 添加新联系人
  572. </Button>
  573. </FormItem>
  574. <FormItem
  575. className="half-item"
  576. {...formItemLayout}
  577. label="联系电话"
  578. >
  579. <span>{this.state.nub}</span>
  580. </FormItem>
  581. <FormItem
  582. className="half-item"
  583. {...formItemLayout}
  584. label="跟进时间"
  585. >
  586. <span>{this.state.followTime}</span>
  587. </FormItem>
  588. </div>
  589. <div className="clearfix">
  590. <FormItem
  591. labelCol={{ span: 4 }}
  592. wrapperCol={{ span: 16 }}
  593. label="跟进备注"
  594. >
  595. <span className="mandatory" style={{ color: "red" }}>
  596. *
  597. <span style={{ marginLeft: "10px" }}>
  598. 客户跟进情况描述(企业上年度销售额,互动情况等.)
  599. </span>
  600. </span>
  601. <Input
  602. type="textarea"
  603. rows={4}
  604. value={this.state.result}
  605. placeholder="渠道跟进"
  606. required="required"
  607. onChange={(e) => {
  608. this.setState({ result: e.target.value });
  609. }}
  610. />
  611. </FormItem>
  612. </div>
  613. <div className="clearfix">
  614. <div
  615. style={{
  616. fontSize: "18px",
  617. marginLeft: "100px",
  618. marginTop: "15px",
  619. marginBottom: "10px",
  620. }}
  621. >
  622. 业务意向
  623. <Button
  624. onClick={this.addNew}
  625. style={{
  626. marginLeft: "420px",
  627. background: "green",
  628. color: "#ffffff",
  629. }}
  630. >
  631. 添加新业务
  632. </Button>
  633. </div>
  634. <div className="clearfix">
  635. <Spin spinning={this.state.loading}>
  636. <Table
  637. size="middle"
  638. rowKey={(record) => record.id}
  639. pagination={false}
  640. columns={this.state.intentionList}
  641. dataSource={this.state.data}
  642. />
  643. </Spin>
  644. </div>
  645. </div>
  646. </div>
  647. <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  648. <Button
  649. type="primary"
  650. size="large"
  651. htmlType="submit"
  652. style={{ marginRight: "150px", marginTop: "20px" }}
  653. >
  654. 保存
  655. </Button>
  656. <Button size="large" onClick={this.visitCancel}>
  657. 取消
  658. </Button>
  659. </FormItem>
  660. </Spin>
  661. </Form>
  662. </Modal>
  663. <AddContact
  664. isLimit={this.props.isLimit}
  665. addcontactModul={this.state.addcontactModul}
  666. uids={this.state.uids}
  667. closeFollow={this.closeFollow}
  668. />
  669. <BusName
  670. businessId={this.state.businessId}
  671. mid={this.props.followData ? this.props.followData.id : ""}
  672. busModul={this.state.busModul}
  673. closeBus={this.closeBus}
  674. />
  675. </div>
  676. );
  677. },
  678. });
  679. export default FollowDetail;