followDetail.jsx 21 KB

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