contactPerson.jsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. import React from "react";
  2. import {
  3. Table,
  4. Button,
  5. Spin,
  6. message,
  7. Alert,
  8. Modal,
  9. Input,
  10. InputNumber,
  11. } from "antd";
  12. import $ from "jquery/src/ajax";
  13. import EnterpriseNameChange from "../../../../../../common/enterpriseNameChange";
  14. import AddContact from "../../followDetail/addContact";
  15. import "./index.less"
  16. const { TextArea } = Input;
  17. const ContactPerson = React.createClass({
  18. getInitialState() {
  19. return {
  20. upType: 0,
  21. visible: false,
  22. upData: {},
  23. detail: {},
  24. loading: false,
  25. addcontactModul: false,
  26. ContactsLists: [
  27. {
  28. title: "姓名",
  29. dataIndex: "name",
  30. key: "name",
  31. render: (text, record, index) => {
  32. if (record.id) return <div>{text}</div>
  33. }
  34. },
  35. {
  36. title: "联系人部门",
  37. dataIndex: "department",
  38. key: "department",
  39. render: (text, record, index) => {
  40. if (record.id) return <div>{text}</div>
  41. }
  42. },
  43. {
  44. title: "联系人职务",
  45. dataIndex: "position",
  46. key: "position",
  47. render: (text, record, index) => {
  48. if (record.id) return <div>{text}</div>
  49. }
  50. },
  51. {
  52. title: "主要联系人",
  53. dataIndex: "major",
  54. width: 100,
  55. key: "major",
  56. render: text => {
  57. return text == 1 ? "是" : "否";
  58. }
  59. },
  60. {
  61. title: "地区",
  62. dataIndex: "cityName",
  63. key: "cityName",
  64. render: (text, record, index) => {
  65. if (record.id) return <div>{text}</div>
  66. }
  67. },
  68. {
  69. title: "手机号码",
  70. dataIndex: "mobile",
  71. key: "mobile",
  72. render: (text, record, index) => {
  73. if (record.id) return <div>{text}</div>
  74. }
  75. },
  76. {
  77. title: "座机",
  78. dataIndex: "fixedTel",
  79. key: "fixedTel",
  80. render: (text, record, index) => {
  81. if (record.id) return <div>{text}</div>
  82. }
  83. },
  84. {
  85. title: "微信",
  86. dataIndex: "wechat",
  87. key: "wechat",
  88. render: (text, record, index) => {
  89. if (record.id) return <div>{text}</div>
  90. }
  91. },
  92. {
  93. title: "联系人QQ",
  94. dataIndex: "qq",
  95. key: "qq",
  96. render: (text, record, index) => {
  97. if (record.id) return <div>{text}</div>
  98. }
  99. },
  100. {
  101. title: "电子邮箱",
  102. dataIndex: "email",
  103. key: "email",
  104. render: (text, record, index) => {
  105. if (record.id) return <div>{text}</div>
  106. }
  107. },
  108. {
  109. title: "更新时间",
  110. dataIndex: "createTimes",
  111. key: "createTimes",
  112. render: (text, record, index) => {
  113. if (record.id) return <div>{text}</div>
  114. }
  115. },
  116. {
  117. title: "跟进人",
  118. dataIndex: "aname",
  119. key: "aname",
  120. render: (text, record, index) => {
  121. if (record.id) return <div>{text}</div>
  122. }
  123. },
  124. {
  125. title: "操作",
  126. dataIndex: "dels",
  127. key: "dels",
  128. render: (text, record, index) => {
  129. return (
  130. <div>
  131. {/* 禁止管理员删除联系人 */}
  132. {/* {adminData.isSuperAdmin || !record.id? (
  133. <Popconfirm
  134. title="是否删除?"
  135. onConfirm={e => {
  136. this.confirmDelet(record);
  137. }}
  138. okText="删除"
  139. cancelText="不删除"
  140. >
  141. <Button
  142. style={{
  143. marginRight: "10px",
  144. color: "#ffffff",
  145. background: "#f00",
  146. border: "none"
  147. }}
  148. >
  149. 删除
  150. </Button>
  151. </Popconfirm>
  152. ) : (
  153. ""
  154. )} */}
  155. {record.major != 1 ? (
  156. <Button
  157. style={{
  158. marginRight: "10px",
  159. color: "#ffffff",
  160. background: "green",
  161. border: "none"
  162. }}
  163. onClick={e => {
  164. e.stopPropagation(), this.mainContact(record);
  165. }}
  166. >
  167. 设为主要联系人
  168. </Button>
  169. ) : (
  170. ""
  171. )}
  172. </div>
  173. );
  174. }
  175. }
  176. ]
  177. };
  178. },
  179. //tab2删除
  180. confirmDelet(e) {
  181. this.setState({
  182. loading: true
  183. });
  184. if (e.id) {
  185. $.ajax({
  186. method: "get",
  187. dataType: "json",
  188. crossDomain: false,
  189. url: globalConfig.context + "/api/admin/customer/deleteOneContact",
  190. data: {
  191. ocbId: e.id //删除的ID
  192. }
  193. }).done(
  194. function (data) {
  195. if (!data.error.length) {
  196. message.success("删除成功!");
  197. this.setState({
  198. loading: false
  199. });
  200. } else {
  201. message.warning(data.error[0].message);
  202. }
  203. this.contactLists();
  204. }.bind(this)
  205. );
  206. } else {
  207. this.contactLists();
  208. }
  209. },
  210. //选择主要联系人
  211. mainContact(record) {
  212. this.setState({
  213. loading: true
  214. });
  215. $.ajax({
  216. method: "get",
  217. dataType: "json",
  218. crossDomain: false,
  219. url: globalConfig.context + "/api/admin/customer/updateMainContact",
  220. data: {
  221. uid: this.props.data.id,
  222. ocbId: record.id
  223. }
  224. }).done(function (data) {
  225. if (!data.error.length) {
  226. message.success('设为主要联系人成功!');
  227. this.setState({
  228. loading: false,
  229. });
  230. } else {
  231. message.warning(data.error[0].message);
  232. };
  233. this.contactLists();
  234. }.bind(this));
  235. this.state.contactList.forEach(item => {
  236. item.major = 0;
  237. });
  238. record.major = 1;
  239. // console.log(record);
  240. this.setState({
  241. contactList: this.state.contactList
  242. });
  243. },
  244. //tab2获取联系人详情
  245. contactLists(ids) {
  246. this.setState({
  247. loading: true
  248. });
  249. $.ajax({
  250. method: "get",
  251. dataType: "json",
  252. crossDomain: false,
  253. url: globalConfig.context + "/api/admin/customer/findCustomerContacts",
  254. data: {
  255. uid: ids || this.props.data.id //名称1
  256. },
  257. success: function (data) {
  258. let theArr = [];
  259. if (data.error.length || data.data.list == "") {
  260. if (data.error && data.error.length) {
  261. message.warning(data.error[0].message);
  262. }
  263. } else {
  264. for (let i = 0; i < data.data.length; i++) {
  265. let thisdata = data.data[i];
  266. theArr.push({
  267. key: i,
  268. id: thisdata.id,
  269. name: thisdata.name,
  270. mobile: thisdata.mobile,
  271. email: thisdata.email,
  272. qq: thisdata.qq,
  273. wechat: thisdata.wechat,
  274. department: thisdata.department,
  275. position: thisdata.position,
  276. major: thisdata.major,
  277. createTimes: thisdata.createTimes,
  278. fixedTel: thisdata.fixedTel,
  279. aname: thisdata.aname,
  280. cityName: thisdata.provinceName + thisdata.cityName + thisdata.areaName
  281. });
  282. }
  283. }
  284. this.setState({
  285. contactList: theArr
  286. });
  287. }.bind(this)
  288. }).always(
  289. function () {
  290. this.setState({
  291. loading: false
  292. });
  293. }.bind(this)
  294. );
  295. },
  296. //新增
  297. //tab2新增联系人
  298. addcontact() {
  299. this.setState({
  300. addcontactModul: true
  301. });
  302. },
  303. componentWillMount() {
  304. this.contactLists(this.props.data.id);
  305. this.queryByUid(this.props.data.id)
  306. },
  307. detailsModal() {
  308. this.props.closeDetail(false, false);
  309. },
  310. componentWillReceiveProps(nextProps) {
  311. if (nextProps.data.id && nextProps.contactState) {
  312. this.contactLists(nextProps.data.id);
  313. }
  314. },
  315. // 查询企业信息
  316. queryByUid() {
  317. this.setState({
  318. loading: true
  319. });
  320. $.ajax({
  321. method: "get",
  322. dataType: "json",
  323. crossDomain: false,
  324. url: globalConfig.context + "/api/admin/userArchives/queryByUid",
  325. data: {
  326. id: this.props.data.id,
  327. },
  328. success: function (data) {
  329. if (data.error.length || data.data.list == "") {
  330. if (data.error && data.error.length) {
  331. message.warning(data.error[0].message);
  332. }
  333. } else {
  334. this.setState({
  335. detail: data.data
  336. })
  337. }
  338. }.bind(this)
  339. }).always(
  340. function () {
  341. this.setState({
  342. loading: false
  343. });
  344. }.bind(this)
  345. );
  346. },
  347. // 修改
  348. update() {
  349. const { upData } = this.state
  350. $.ajax({
  351. method: "post",
  352. dataType: "json",
  353. crossDomain: false,
  354. url: globalConfig.context + "/api/admin/userArchives/update",
  355. data: upData,
  356. success: function (data) {
  357. if (data.error.length || data.data.list == "") {
  358. if (data.error && data.error.length) {
  359. message.warning(data.error[0].message);
  360. }
  361. } else {
  362. message.success("修改成功!")
  363. this.queryByUid()
  364. this.setState({
  365. visible: false
  366. })
  367. }
  368. }.bind(this)
  369. }).always(
  370. function () {
  371. this.setState({
  372. loading: false
  373. });
  374. }.bind(this)
  375. );
  376. },
  377. onUpCancel() {
  378. this.setState({
  379. visible: false
  380. })
  381. },
  382. render() {
  383. const { detail, upType, upData } = this.state
  384. return (
  385. <div>
  386. <div className="clearfix">
  387. <Alert message="注:已保存信息不可修改,可新增正确的信息并设置为主要联系人" banner />
  388. <span
  389. style={{
  390. fontSize: 14,
  391. fontWeight: "bold",
  392. marginTop: 20,
  393. display: "inline-block",
  394. }}
  395. >
  396. 公司名称:{this.state.enterpriseName ? this.state.enterpriseName : this.props.name}
  397. <EnterpriseNameChange
  398. type='modify'
  399. changeOtherInfor
  400. style={{ marginLeft: '20px' }}
  401. enterpriseId={this.props.data.uid}
  402. enterpriseName={this.props.name}
  403. data={this.props.data}
  404. onCancel={this.props.onCancel}
  405. onChangeSuccess={(value) => {
  406. this.setState({
  407. enterpriseName: value
  408. })
  409. }} />
  410. </span>
  411. <Button
  412. className="ContactsList"
  413. type="primary"
  414. onClick={this.addcontact}
  415. >
  416. 新增联系人
  417. </Button>
  418. </div>
  419. <div className="clearfix">
  420. <Spin spinning={this.state.loading}>
  421. <Table
  422. size="middle"
  423. pagination={false}
  424. columns={this.state.ContactsLists}
  425. dataSource={this.state.contactList}
  426. />
  427. </Spin>
  428. </div>
  429. <div style={{
  430. fontSize: 14,
  431. marginTop: 20,
  432. }}>
  433. <div style={{ fontWeight: "bold", marginBottom: 5, color: "#58A3FF" }}>企业情况及前期准备工作</div>
  434. <div style={{ fontWeight: "bold", marginTop: 10 }}>
  435. 1.知识产权情况&nbsp;&nbsp;
  436. <Button
  437. type="primary"
  438. onClick={() => {
  439. this.setState({
  440. visible: true,
  441. upType: 1,
  442. upData: {
  443. uid: this.props.data.id,
  444. id: detail.id || undefined,
  445. inventionPatentCount: detail.inventionPatentCount,
  446. utilityModelCount: detail.utilityModelCount,
  447. appearancePatentCount: detail.appearancePatentCount,
  448. softwareWorksCount: detail.softwareWorksCount,
  449. otherCount: detail.otherCount,
  450. }
  451. })
  452. }}
  453. >
  454. 修改
  455. </Button>
  456. </div>
  457. <div style={{ fontSize: 12, }}>
  458. 专利总数&nbsp;{detail.patentCount || 0}&nbsp;&nbsp;&nbsp;&nbsp;
  459. 发明专利&nbsp;{detail.inventionPatentCount || 0}&nbsp;&nbsp;&nbsp;&nbsp;
  460. 实用新型&nbsp;{detail.utilityModelCount || 0}&nbsp;&nbsp;&nbsp;&nbsp;
  461. 外观专利&nbsp;{detail.appearancePatentCount || 0}&nbsp;&nbsp;&nbsp;&nbsp;
  462. 软著&nbsp;{detail.softwareWorksCount || 0}&nbsp;&nbsp;&nbsp;&nbsp;
  463. 其他&nbsp;{detail.otherCount || 0}&nbsp;&nbsp;&nbsp;&nbsp;
  464. </div>
  465. <div style={{ fontWeight: "bold", marginTop: 10 }}>
  466. 2.财务数据<span style={{ color: "red" }}>(包括营收、税收、资产、研发费用等)</span>&nbsp;&nbsp;
  467. <Button
  468. type="primary"
  469. onClick={() => {
  470. this.setState({
  471. visible: true,
  472. upType: 2,
  473. upData: {
  474. uid: this.props.data.id,
  475. id: detail.id || undefined,
  476. financialData: detail.financialData,
  477. }
  478. })
  479. }}
  480. >
  481. 修改
  482. </Button>
  483. </div>
  484. <div style={{ fontSize: 12, }}>{detail.financialData || "无"}</div>
  485. <div style={{ fontWeight: "bold", marginTop: 10 }}>
  486. 3.前期沟通<span style={{ color: "red" }}>(客户的难处、需求)</span>&nbsp;&nbsp;
  487. <Button
  488. type="primary"
  489. onClick={() => {
  490. this.setState({
  491. visible: true,
  492. upType: 3,
  493. upData: {
  494. uid: this.props.data.id,
  495. id: detail.id || undefined,
  496. earlyCommunication: detail.earlyCommunication,
  497. }
  498. })
  499. }}
  500. >
  501. 修改
  502. </Button>
  503. </div>
  504. <div style={{ fontSize: 12, }}>{detail.earlyCommunication || "无"}</div>
  505. <div style={{ fontWeight: "bold", marginTop: 10 }}>
  506. 4.面谈思路及目的&nbsp;&nbsp;
  507. <Button
  508. type="primary"
  509. onClick={() => {
  510. this.setState({
  511. visible: true,
  512. upType: 4,
  513. upData: {
  514. uid: this.props.data.id,
  515. id: detail.id || undefined,
  516. interviewIdeas: detail.interviewIdeas,
  517. }
  518. })
  519. }}
  520. >
  521. 修改
  522. </Button>
  523. </div>
  524. <div style={{ fontSize: 12, }}>{detail.interviewIdeas || "无"}</div>
  525. </div>
  526. <AddContact
  527. addcontactModul={this.state.addcontactModul}
  528. uids={this.props.data.id}
  529. closeFollow={() => {
  530. this.setState({
  531. addcontactModul: false
  532. }, () => {
  533. this.contactLists()
  534. })
  535. }}
  536. />
  537. <Modal
  538. footer={null}
  539. maskClosable={false}
  540. width="400px"
  541. title='信息修改'
  542. visible={this.state.visible}
  543. onCancel={this.onUpCancel}
  544. >
  545. <div>
  546. {
  547. upType == 1 &&
  548. <div>
  549. <div className='enterpriseNameItem'>
  550. <div className='enterpriseNameTitle'>发明专利:</div>
  551. <div className='enterpriseNameValue'>
  552. <InputNumber
  553. value={upData.inventionPatentCount || 0}
  554. onChange={e => {
  555. this.setState({
  556. upData: Object.assign(upData, {
  557. inventionPatentCount: e,
  558. }),
  559. })
  560. }}
  561. />
  562. </div>
  563. </div>
  564. <div className='enterpriseNameItem'>
  565. <div className='enterpriseNameTitle'>实用新型:</div>
  566. <div className='enterpriseNameValue'>
  567. <InputNumber
  568. value={upData.utilityModelCount || 0}
  569. onChange={e => {
  570. this.setState({
  571. upData: Object.assign(upData, {
  572. utilityModelCount: e,
  573. }),
  574. })
  575. }}
  576. />
  577. </div>
  578. </div>
  579. <div className='enterpriseNameItem'>
  580. <div className='enterpriseNameTitle'>外观专利:</div>
  581. <div className='enterpriseNameValue'>
  582. <InputNumber
  583. value={upData.appearancePatentCount || 0}
  584. onChange={e => {
  585. this.setState({
  586. upData: Object.assign(upData, {
  587. appearancePatentCount: e,
  588. }),
  589. })
  590. }}
  591. />
  592. </div>
  593. </div>
  594. <div className='enterpriseNameItem'>
  595. <div className='enterpriseNameTitle'>软著:</div>
  596. <div className='enterpriseNameValue'>
  597. <InputNumber
  598. value={upData.softwareWorksCount || 0}
  599. onChange={e => {
  600. this.setState({
  601. upData: Object.assign(upData, {
  602. softwareWorksCount: e,
  603. }),
  604. })
  605. }}
  606. />
  607. </div>
  608. </div>
  609. <div className='enterpriseNameItem'>
  610. <div className='enterpriseNameTitle'>其他:</div>
  611. <div className='enterpriseNameValue'>
  612. <InputNumber
  613. value={upData.otherCount || 0}
  614. onChange={e => {
  615. this.setState({
  616. upData: Object.assign(upData, {
  617. otherCount: e,
  618. }),
  619. })
  620. }}
  621. />
  622. </div>
  623. </div>
  624. </div>
  625. }
  626. {
  627. upType == 2 &&
  628. <div>
  629. <div className='enterpriseNameItem'>
  630. <div className='enterpriseNameTitle'>财务数据:</div>
  631. <div className='enterpriseNameValue'>
  632. <TextArea
  633. style={{ width: "250px" }}
  634. rows={4}
  635. value={upData.financialData}
  636. onChange={e => {
  637. this.setState({
  638. upData: Object.assign(upData, {
  639. financialData: e.target.value,
  640. }),
  641. })
  642. }}
  643. />
  644. </div>
  645. </div>
  646. </div>
  647. }
  648. {
  649. upType == 3 &&
  650. <div>
  651. <div className='enterpriseNameItem'>
  652. <div className='enterpriseNameTitle'>前期沟通:</div>
  653. <div className='enterpriseNameValue'>
  654. <TextArea
  655. style={{ width: "250px" }}
  656. rows={4}
  657. value={upData.earlyCommunication}
  658. onChange={e => {
  659. this.setState({
  660. upData: Object.assign(upData, {
  661. earlyCommunication: e.target.value,
  662. }),
  663. })
  664. }}
  665. />
  666. </div>
  667. </div>
  668. </div>
  669. }
  670. {
  671. upType == 4 &&
  672. <div>
  673. <div className='enterpriseNameItem'>
  674. <div className='enterpriseNameTitle'>面谈思路及目的:</div>
  675. <div className='enterpriseNameValue'>
  676. <TextArea
  677. style={{ width: "250px" }}
  678. rows={4}
  679. value={upData.interviewIdeas}
  680. onChange={e => {
  681. this.setState({
  682. upData: Object.assign(upData, {
  683. interviewIdeas: e.target.value,
  684. }),
  685. })
  686. }}
  687. />
  688. </div>
  689. </div>
  690. </div>
  691. }
  692. <div>
  693. <Button type='primary'
  694. onClick={this.update}
  695. >
  696. 确定修改
  697. </Button>
  698. </div>
  699. </div>
  700. </Modal>
  701. </div>
  702. );
  703. }
  704. });
  705. export default ContactPerson;