contactPerson.jsx 22 KB

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