visitDetail.jsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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,getContactType} from '@/tools.js';
  7. const FormItem =Form.Item;
  8. const VisitDetail = React.createClass({
  9. getInitialState(){
  10. return{
  11. visitModul:false,
  12. loading:false,
  13. data:[],
  14. //业务意向列表
  15. intentionList:[
  16. {
  17. title: '业务名称',
  18. dataIndex: 'businessVarietiesName',
  19. width:120,
  20. key: 'businessVarietiesName'
  21. },
  22. {
  23. title: '项目名称',
  24. dataIndex: 'businessProjectName',
  25. key:'businessProjectName',
  26. width:120
  27. },
  28. {
  29. title: '最新进度',
  30. width:120,
  31. dataIndex: 'followSituation',
  32. key: 'followSituation',
  33. render: (text, record, index) => {
  34. return <Select placeholder="选择最新进度" value={record.followSituation} onChange={(e) => { record.followSituation = e; this.setState({ data: this.state.data }); }}>
  35. {
  36. newFollow.map(function (item) {
  37. return <Select.Option key={item.value} >{item.key}</Select.Option>
  38. })
  39. }
  40. </Select>
  41. }
  42. }, {
  43. title: '最新状态',
  44. width:120,
  45. dataIndex: 'customerStatus',
  46. key: 'customerStatus',
  47. render: (text, record, index) => {
  48. return <Select value={record.customerStatus} placeholder="选择最新状态" onChange={(e) => { record.customerStatus = e; this.setState({ data: this.state.data }); }}>
  49. {
  50. customerStatus.map(function (item) {
  51. return <Select.Option key={item.value} >{item.key}</Select.Option>
  52. })
  53. }
  54. </Select>
  55. }
  56. }, {
  57. title: '跟进说明',
  58. width:120,
  59. dataIndex: 'remarks',
  60. key: 'remarks',
  61. render: (text, record, index) => {
  62. return <Input value={record.remarks} placeholder="跟进说明"
  63. onChange={(e) => { record.remarks = e.target.value; this.setState({ data: this.state.data }); }}
  64. />
  65. }
  66. }
  67. ],
  68. }
  69. },
  70. //进入修改拜访记录
  71. visitModify(e) {
  72. this.setState({
  73. visitModul: true,
  74. loading: true
  75. });
  76. $.ajax({
  77. method: "get",
  78. dataType: "json",
  79. url: globalConfig.context + '/api/admin/customer/toUpdateFollow',
  80. data: {
  81. followId: e,
  82. },
  83. success: function(data) {
  84. let theArr = [];
  85. let thedata = data.data;
  86. if(!thedata) {
  87. if(data.error && data.error.length) {
  88. message.warning(data.error[0].message);
  89. };
  90. thedata = {};
  91. };
  92. for(let i = 0; i < data.data.userBusinessList.length; i++) {
  93. let thisdata = data.data.userBusinessList[i];
  94. theArr.push({
  95. id: thisdata.businessId,
  96. businessName:thisdata.businessProjectId,
  97. businessVarietiesName:thisdata.businessVarietiesName,
  98. businessProjectName:thisdata.businessProjectName,
  99. followSituation: thisdata.followSituation==null?undefined : String(thisdata.followSituation),
  100. customerStatus: thisdata.customerStatus==null?undefined : String(thisdata.customerStatus),
  101. remarks: thisdata.remarks,
  102. });
  103. };
  104. this.setState({
  105. followIds: thedata.followId,
  106. contacts: thedata.contacts,
  107. uid: thedata.uid,
  108. dataBus: theArr,
  109. result: thedata.result,
  110. contactMobile:thedata.contactMobile,
  111. contactType: parseInt(thedata.contactType),
  112. followTime: thedata.followTime,
  113. followSituation: thedata.followSituation,
  114. customerStatus: thedata.customerStatus,
  115. });
  116. }.bind(this),
  117. }).always(function() {
  118. this.setState({
  119. loading: false
  120. });
  121. }.bind(this));
  122. },
  123. //拜访意向服务列表单个删除
  124. intentionDelet(e, index) {
  125. let detId = this.state.followIds;
  126. if(e.id) {
  127. this.setState({
  128. selectedRowKeys: [],
  129. });
  130. $.ajax({
  131. method: "get",
  132. dataType: "json",
  133. crossDomain: false,
  134. url: globalConfig.context + "/api/admin/customer/deleteFollowOneBusiness",
  135. data: {
  136. ufbId: e.id
  137. }
  138. }).done(function(data) {
  139. if(!data.error.length) {
  140. message.success('删除成功');
  141. this.setState({
  142. loading: false,
  143. });
  144. } else {
  145. message.warning(data.error[0].message);
  146. };
  147. this.visitModify(detId);
  148. }.bind(this));
  149. } else {
  150. this.visitModify(detId);
  151. }
  152. },
  153. //拜访modul函数
  154. visitOk(e) {
  155. this.setState({
  156. addcontactModul:false,
  157. visitModul: false
  158. });
  159. },
  160. visitCancel(e) {
  161. this.setState({
  162. addcontactModul:false,
  163. visitModul: false
  164. });
  165. },
  166. //详情保存
  167. visitSubmit(e){
  168. e.preventDefault();
  169. this.setState({
  170. loading: true
  171. });
  172. let contactsId = '';
  173. if(this.state.keys) {
  174. let conts = this.state.lastName;
  175. contactsId = this.state.contactsIdArr[conts].id;
  176. }
  177. //新增
  178. $.ajax({
  179. method: "post",
  180. dataType: "json",
  181. url: globalConfig.context + '/api/admin/customer/updateFollow',
  182. data: {
  183. followId: this.state.followIds,
  184. userBusinessList: JSON.stringify(this.state.data),
  185. uid: this.state.uid,
  186. contactType: this.state.contactType,
  187. result: this.state.result,
  188. followTime: this.state.followTime,
  189. }
  190. }).done(function(data) {
  191. this.setState({
  192. loading: false
  193. });
  194. if(!data.error.length) {
  195. message.success('保存成功!');
  196. this.props.closeDesc(false,true);
  197. this.visitCancel();
  198. } else {
  199. message.warning(data.error[0].message);
  200. }
  201. }.bind(this));
  202. },
  203. componentWillReceiveProps(nextProps) {
  204. if (nextProps.visitModul && nextProps.followData.followId) {
  205. this.setState({
  206. visitModul: true,
  207. loading: true,
  208. })
  209. this.visitModify(nextProps.followData.followId)
  210. };
  211. },
  212. render() {
  213. const formItemLayout = {
  214. labelCol: { span: 8 },
  215. wrapperCol: { span: 14 },
  216. };
  217. const followData= this.props.followData || []
  218. return(
  219. <div>
  220. <Modal
  221. className="customeDetails"
  222. footer=''
  223. title="客户跟进详情"
  224. width='1000px'
  225. visible={this.state.visitModul}
  226. onOk={this.visitOk}
  227. onCancel={this.visitCancel}
  228. >
  229. <Form layout="horizontal" id="demand-form" onSubmit={this.visitSubmit}>
  230. <Spin spinning={this.state.loading}>
  231. <div className="clearfix">
  232. <FormItem
  233. labelCol={{ span:4 }}
  234. wrapperCol={{ span: 20 }}
  235. style={{marginBottom:12}}
  236. label="拜访方式" >
  237. {!followData.readOnly?<Radio.Group value={this.state.contactType} onChange={(e) => {
  238. this.setState({ contactType: e.target.value })
  239. }}>
  240. <Radio value={0}>外出</Radio>
  241. <Radio value={1}>电话</Radio>
  242. <Radio value={2}>QQ</Radio>
  243. <Radio value={3}>微信</Radio>
  244. <Radio value={4}>邮箱</Radio>
  245. </Radio.Group>:
  246. <span>{getContactType(this.state.contactType)}</span>
  247. }
  248. </FormItem>
  249. <div className="clearfix">
  250. {!followData.readOnly&&<FormItem className="half-item"
  251. {...formItemLayout}
  252. label="当前联系人"
  253. >
  254. <span>{this.state.contacts}</span>
  255. </FormItem>}
  256. <FormItem className="half-item"
  257. {...formItemLayout}
  258. label="跟进时间"
  259. >
  260. <span>{this.state.followTime}</span>
  261. </FormItem>
  262. {!followData.readOnly&&<FormItem className="half-item"
  263. {...formItemLayout}
  264. label="联系电话"
  265. >
  266. <span>{this.state.contactMobile}</span>
  267. </FormItem>}
  268. </div>
  269. <div className="clearfix">
  270. <FormItem
  271. labelCol={{ span: 4 }}
  272. wrapperCol={{ span: 16 }}
  273. label="跟进备注" >
  274. {!followData.readOnly?<Input type="textarea" rows={4} value={this.state.result}
  275. onChange={(e)=>{this.setState({result:e.target.value})}}/>:
  276. <span>{this.state.result}</span>
  277. }
  278. </FormItem>
  279. </div>
  280. <div className="clearfix">
  281. <div style={{fontSize:'18px',marginLeft:'100px',marginTop:'15px',marginBottom:'10px'}}>业务意向</div>
  282. <div className="clearfix">
  283. <Spin spinning={this.state.loading}>
  284. <Table
  285. rowKey={record => record.id}
  286. pagination={false}
  287. columns={this.state.intentionList}
  288. dataSource={this.state.dataBus}
  289. />
  290. </Spin>
  291. </div>
  292. </div>
  293. </div>
  294. {!followData.readOnly&& <FormItem wrapperCol={{ span: 12, offset: 6 }}>
  295. <Button type="primary" size="large" htmlType="submit" style={{marginRight:'150px',marginTop:'20px'}}>保存</Button>
  296. <Button size="large" onClick={this.visitCancel}>取消</Button>
  297. </FormItem>}
  298. </Spin>
  299. </Form>
  300. </Modal>
  301. </div>
  302. )
  303. }
  304. })
  305. export default VisitDetail;