visit.jsx 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. import React from 'react';
  2. import {Form, Button, Spin, message, Table, Tooltip, Input, Modal} from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import FollowDetail from '../../followDetail.jsx'
  6. import {getContactType} from '@/tools.js';
  7. import VisitDetail from './visitDetail.jsx';
  8. const confirm = Modal.confirm;
  9. const { TextArea } = Input;
  10. const Visit = React.createClass({
  11. getInitialState(){
  12. return {
  13. visitArrList: [],
  14. loading: false,
  15. visitModul: false,
  16. visitModuls: false,
  17. followId:0,
  18. ispage:1,
  19. paginations: {
  20. defaultCurrent: 1,
  21. defaultPageSize: 10,
  22. showQuickJumper: true,
  23. pageSize: 10,
  24. onChange: function (page) {
  25. this.loadVisit(page);
  26. }.bind(this),
  27. showTotal: function (total) {
  28. return "共" + total + "条数据";
  29. },
  30. },
  31. visitsList: [
  32. {
  33. title: "客户名称",
  34. dataIndex: "nickname",
  35. key: "nickname",
  36. width: 150,
  37. render: (text) => {
  38. return (
  39. <Tooltip title={text}>
  40. <div style={{
  41. maxWidth:'150px',
  42. overflow:'hidden',
  43. textOverflow: "ellipsis",
  44. whiteSpace:'nowrap',
  45. }}>{text}</div>
  46. </Tooltip>
  47. )
  48. },
  49. },
  50. {
  51. title: "跟进方式",
  52. dataIndex: "contactType",
  53. key: "contactType",
  54. width: 100,
  55. render: (text) => {
  56. return getContactType(text);
  57. },
  58. },
  59. {
  60. title: "联系人",
  61. dataIndex: "contacts",
  62. key: "contacts",
  63. render: (text, record) => {
  64. return (
  65. <div>
  66. {record.readOnly ? <span>***</span> : <span>{text}</span>}
  67. </div>
  68. );
  69. },
  70. },
  71. {
  72. title: "联系电话",
  73. dataIndex: "contactMobile",
  74. key: "contactMobile",
  75. width: 120,
  76. render: (text, record) => {
  77. return (
  78. <div>
  79. {record.readOnly ? <span>***</span> : <span>{text}</span>}
  80. </div>
  81. );
  82. },
  83. },
  84. {
  85. title: "跟进人",
  86. dataIndex: "adminName",
  87. key: "adminName",
  88. },
  89. {
  90. title: "跟进说明",
  91. dataIndex: "result",
  92. key: "result",
  93. width: 300,
  94. render: (text, record) => {
  95. return (
  96. <div style={{wordBreak:"break-all"}}>
  97. {text}
  98. </div>
  99. )
  100. }
  101. },
  102. {
  103. title: "跟进时间",
  104. dataIndex: "followTime",
  105. key: "followTime",
  106. width: 125
  107. },
  108. {
  109. title: "指导意见",
  110. dataIndex: "abc",
  111. key: "abc",
  112. width: 150,
  113. render: (text, record) => {
  114. return (
  115. <div>
  116. {record.guidance ?
  117. <Tooltip placement="topLeft" title={<div style={{wordBreak:"break-all"}}>{(record.guidanceName ? '('+record.guidanceName+')' : '') + record.guidance}</div>}>
  118. <div style={{
  119. cursor:"pointer",
  120. width: '150px',
  121. whiteSpace: 'nowrap',
  122. overflow: 'hidden',
  123. textOverflow: 'ellipsis',
  124. }}>
  125. {record.guidanceName ? '('+record.guidanceName+')' : null}
  126. {record.guidance}
  127. </div>
  128. </Tooltip> : (this.props.isEditGuidanceLv ? <Button
  129. onClick={(e) => {
  130. e.stopPropagation();
  131. this.setState({
  132. guidanceVisible: true,
  133. visitModul: false,
  134. followId: record.followId
  135. })
  136. }}
  137. type="primary"
  138. >
  139. 立即指导
  140. </Button> : <span>暂未指导</span>)}
  141. </div>
  142. );
  143. },
  144. },
  145. {
  146. title: "指导时间",
  147. dataIndex: "guidanceTime",
  148. key: "guidanceTime",
  149. width: 125,
  150. render: (text, record) => {
  151. return (
  152. <span>{text ? text : ''}</span>
  153. )
  154. }
  155. }
  156. ],
  157. guidanceVisible: false,
  158. guidance: ''
  159. };
  160. },
  161. //拜访记录删除
  162. visitDelet(e) {
  163. this.setState({
  164. visitModul:false,
  165. loading: true
  166. });
  167. $.ajax({
  168. method: "get",
  169. dataType: "json",
  170. crossDomain: false,
  171. url: globalConfig.context + "/api/admin/customer/deleteFollow",
  172. data: {
  173. followId: e.followId, //删除的ID
  174. }
  175. }).done(function(data) {
  176. if(!data.error.length) {
  177. message.success('删除成功!');
  178. this.setState({
  179. loading: false,
  180. });
  181. } else {
  182. message.warning(data.error[0].message);
  183. };
  184. this.loadVisit();
  185. }.bind(this));
  186. },
  187. //查看跟进记录列表
  188. loadVisit(pageNo) {
  189. this.setState({
  190. loading: true
  191. });
  192. $.ajax({
  193. method: "get",
  194. dataType: "json",
  195. crossDomain: false,
  196. url: globalConfig.context + '/api/admin/customer/listFollowHistory',
  197. data: {
  198. pageNo: pageNo || 1,
  199. pageSize: this.state.paginations.pageSize,
  200. uid: this.props.data.id, //名称1
  201. },
  202. success: function(data) {
  203. let theArr = [];
  204. if(data.error.length || data.data.list == "") {
  205. if(data.error && data.error.length) {
  206. message.warning(data.error[0].message);
  207. };
  208. } else {
  209. for(let i = 0; i < data.data.list.length; i++) {
  210. let thisdata = data.data.list[i];
  211. theArr.push(thisdata);
  212. };
  213. this.state.paginations.current = data.data.pageNo;
  214. this.state.paginations.total = data.data.totalCount;
  215. this.setState({
  216. ispage: data.data.pageNo
  217. })
  218. };
  219. if(data.data.list&&!data.data.list.length){
  220. this.state.paginations.current =0;
  221. this.state.paginations.total =0;
  222. };
  223. this.setState({
  224. visitArrList: theArr,
  225. paginations: this.state.paginations
  226. });
  227. }.bind(this),
  228. }).always(function() {
  229. this.setState({
  230. loading: false
  231. });
  232. }.bind(this));
  233. },
  234. componentWillMount(){
  235. this.loadVisit();
  236. },
  237. detailsModal(){
  238. this.props.closeDetail(false, false)
  239. },
  240. //点击整行
  241. VisitRowClick(record){
  242. this.setState({
  243. followData: record,
  244. visitModul:true,
  245. })
  246. },
  247. //进入新增拜访记录
  248. visit() {
  249. let obj = {
  250. id: this.props.data.id
  251. }
  252. this.setState({
  253. followData:obj,
  254. visitModuls:true,
  255. })
  256. },
  257. closeDesc(e,s){
  258. this.state.visitModul=e
  259. this.state.visitModuls=e
  260. if(s){
  261. this.loadVisit()
  262. }
  263. },
  264. //发布指导意见
  265. releaseGuidance(e){
  266. e.stopPropagation();
  267. if(!this.state.guidance){
  268. message.info('指导意见不能为空')
  269. return;
  270. }
  271. this.setState({
  272. loading: true,
  273. });
  274. $.ajax({
  275. method: "post",
  276. dataType: "json",
  277. crossDomain: false,
  278. url: globalConfig.context + "/api/admin/customer/addGuidance",
  279. data: {
  280. guidance: this.state.guidance,
  281. followId: this.state.followId,
  282. },
  283. }).done(function(data) {
  284. if(!data.error.length) {
  285. message.success("发布成功");
  286. this.loadVisit(this.state.ispage);
  287. this.setState({
  288. loading: false,
  289. guidanceVisible: false,
  290. });
  291. } else {
  292. message.warning(data.error[0].message);
  293. }
  294. }.bind(this));
  295. },
  296. componentWillReceiveProps(nextProps) {
  297. if(nextProps.data.id&&nextProps.visitState){
  298. this.loadVisit()
  299. }
  300. this.setState({
  301. visitModul:false
  302. })
  303. },
  304. render(){
  305. return(
  306. <div className="clearfix">
  307. {!this.props.isGuidanceLv ? <Button
  308. onClick={(e) => {
  309. e.stopPropagation();
  310. this.visit();
  311. }}
  312. type="primary"
  313. style={{marginTop:'10px',float: 'right'}}
  314. >
  315. 客户跟进
  316. </Button> : <div/>}
  317. <Spin spinning={this.state.loading}>
  318. <Table
  319. size="middle"
  320. style={{marginTop:this.props.isGuidanceLv ? '0px' : '60px',cursor: 'pointer',}}
  321. pagination={this.state.paginations}
  322. columns={this.state.visitsList}
  323. dataSource={this.state.visitArrList}
  324. onRowClick={this.VisitRowClick}
  325. scroll={{ y: 440 }}
  326. />
  327. </Spin>
  328. <VisitDetail
  329. categoryArr={this.props.categoryArr}
  330. followData={this.state.followData}
  331. visitModul={this.state.visitModul}
  332. closeDesc={this.closeDesc}
  333. mid={this.props.data.id}
  334. />
  335. <FollowDetail
  336. categoryArr={this.props.categoryArr}
  337. followData={this.state.followData}
  338. visitModul={this.state.visitModuls}
  339. closeDesc={this.closeDesc}
  340. loadData={this.loadVisit}
  341. />
  342. {/*指导意见*/}
  343. {this.state.guidanceVisible ? <Modal
  344. className="customeDetails"
  345. title="指导意见"
  346. width='500px'
  347. visible={this.state.guidanceVisible}
  348. onOk={()=>{
  349. this.setState({
  350. guidanceVisible: false,
  351. guidance: '',
  352. },()=>{
  353. this.loadVisit();
  354. })
  355. }}
  356. onCancel={()=>{
  357. this.setState({
  358. guidanceVisible: false,
  359. guidance: '',
  360. },()=>{
  361. this.loadVisit();
  362. })
  363. }}
  364. footer=''
  365. >
  366. <Spin spinning={this.state.loading}>
  367. <div style={{
  368. display:'flex',
  369. flexFlow:'column',
  370. }}>
  371. <Input
  372. style={{ width: '400px',height:'50px' }}
  373. placeholder="请输入指导意见"
  374. type={'textarea'}
  375. onChange={(e)=>{
  376. this.setState({
  377. guidance: e.target.value,
  378. })
  379. }}
  380. />
  381. <Button
  382. type="primary"
  383. style={{ marginTop: "10px", marginBottom: '10px' }}
  384. onClick={(e)=>{
  385. let _this = this;
  386. confirm({
  387. title: '确定要提交本次指导意见吗?',
  388. content: '指导意见提交成功后无法修改',
  389. onOk() {
  390. _this.releaseGuidance(e);
  391. },
  392. onCancel() {},
  393. });
  394. }}
  395. >
  396. 保存
  397. </Button>
  398. </div>
  399. </Spin>
  400. </Modal> : <div/>}
  401. </div>
  402. )
  403. }
  404. })
  405. export default Visit;