signCustomer.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. import React from 'react';
  2. import { Radio, Icon, Button, AutoComplete,Cascader,Input, Select, Spin, Popconfirm, Table, Switch, message, DatePicker, Upload, Form } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import moment from 'moment';
  6. import { citySelect, provinceList } from '@/NewDicProvinceList';
  7. import { socialAttribute, industry, auditStatusL, lvl, currentMember } from '@/dataDic.js';
  8. import { getSocialAttribute, beforeUploadFile } from '@/tools.js';
  9. import FollowDetail from './followDetail.jsx'
  10. import IntentionDetail from './intentionDetail/intentionDetail.jsx'
  11. import './customer.less';
  12. const IntentionCustomer = Form.create()(React.createClass({
  13. loadData(pageNo, apiUrl) {
  14. this.setState({
  15. visitModul:false,
  16. loading: true,
  17. ispage:pageNo,
  18. modalVisible:false
  19. });
  20. let api=apiUrl?apiUrl:this.props.ApiUrl;
  21. $.ajax({
  22. method: "post",
  23. dataType: "json",
  24. crossDomain: false,
  25. url: globalConfig.context + api,
  26. data: {
  27. pageNo: pageNo || 1,
  28. pageSize: this.state.pagination.pageSize,
  29. name: this.state.nameSearch,
  30. province: !(this.state.addressSearch).length ? this.state.provinceSearch : this.state.addressSearch[0],
  31. city: !(this.state.addressSearch).length ? '' : this.state.addressSearch[1],
  32. startDate: this.state.releaseDate[0],
  33. endDate: this.state.releaseDate[1],
  34. },
  35. success: function(data) {
  36. let theArr = [];
  37. if(data.error.length || data.data.list == "") {
  38. if(data.error && data.error.length) {
  39. message.warning(data.error[0].message);
  40. };
  41. } else {
  42. for(let i = 0; i < data.data.list.length; i++) {
  43. let thisdata = data.data.list[i];
  44. let diqu=(thisdata.province==null?"":thisdata.province)+(thisdata.city==null?"":"-"+thisdata.city)+(thisdata.area==null?"":"-"+thisdata.area);
  45. theArr.push({
  46. key: i,
  47. id: thisdata.uid,
  48. type: thisdata.type,
  49. name: thisdata.name,
  50. shareType:thisdata.shareType,
  51. contacts:thisdata.contacts,
  52. contactMobile:thisdata.contactMobile,
  53. societyTag:thisdata.societyTag,
  54. transferTime:thisdata.transferTime&&thisdata.transferTime.split(' ')[0],
  55. lastSignTime:thisdata.lastSignTime&&thisdata.lastSignTime.split(' ')[0],
  56. lastFollowTime:thisdata.lastFollowTime&&thisdata.lastFollowTime.split(' ')[0],
  57. locationProvince: diqu,
  58. });
  59. };
  60. this.state.pagination.current = data.data.pageNo;
  61. this.state.pagination.total = data.data.totalCount;
  62. };
  63. if(data.data&&data.data.list&&!data.data.list.length){
  64. this.state.pagination.current=0
  65. this.state.pagination.total=0
  66. };
  67. this.setState({
  68. dataSource: theArr,
  69. pagination: this.state.pagination,
  70. selectedRowKeys:[]
  71. });
  72. }.bind(this),
  73. }).always(function() {
  74. this.setState({
  75. loading: false
  76. });
  77. }.bind(this));
  78. },
  79. getInitialState() {
  80. return {
  81. addressSearch: [],
  82. orgCodeUrl: [],
  83. companyLogoUrl: [],
  84. visible: false,
  85. searchMore: true,
  86. releaseDate: [],
  87. visitModul:false,
  88. keys:false,
  89. detailApi:'',
  90. followData:{},
  91. selectedRowKeys: [],
  92. selectedRowKey: [],
  93. selectedRows: [],
  94. loading: false,
  95. modalVisible:false,
  96. pagination: {
  97. defaultCurrent: 1,
  98. defaultPageSize: 10,
  99. showQuickJumper: true,
  100. pageSize: 10,
  101. onChange: function(page) {
  102. this.loadData(page);
  103. }.bind(this),
  104. showTotal: function(total) {
  105. return '共' + total + '条数据';
  106. }
  107. },
  108. columns: [{
  109. title: '客户名称',
  110. dataIndex: 'name',
  111. key: 'name',
  112. },{
  113. title: '地区',
  114. dataIndex: 'locationProvince',
  115. key: 'locationProvince',
  116. },
  117. {
  118. title: '最新签单日期',
  119. dataIndex: 'lastSignTime',
  120. key: 'lastSignTime',
  121. },{
  122. title: '最新跟进日期',
  123. dataIndex: 'lastFollowTime',
  124. key: 'lastFollowTime',
  125. },
  126. {
  127. title: '联系人',
  128. dataIndex: 'contacts',
  129. key: 'contacts',
  130. },
  131. {
  132. title: '联系电话',
  133. dataIndex: 'contactMobile',
  134. key: 'contactMobile',
  135. },
  136. {
  137. title: '社会属性',
  138. dataIndex: 'societyTag',
  139. key: 'societyTag',
  140. render:text=>{return getSocialAttribute(text) }
  141. },
  142. {
  143. title: '操作',
  144. dataIndex: 'abc',
  145. key: 'abc',
  146. render: (text, record, index) => {
  147. return <div>
  148. <Button onClick={(e) =>{ e.stopPropagation(), this.visit(record)}} type="primary">客户跟进</Button>
  149. </div>
  150. }
  151. }
  152. ],
  153. data: [],
  154. dataSource: [],
  155. };
  156. },
  157. //进入新增拜访记录
  158. visit(e) {
  159. this.setState({
  160. followData:e,
  161. visitModul:true,
  162. modalVisible:false
  163. })
  164. },
  165. //列表删除功能
  166. delectRow() {
  167. let deletedIds;
  168. for(let idx = 0; idx < this.state.selectedRows.length; idx++) {
  169. let rowItem = this.state.selectedRows[idx];
  170. if(rowItem.id) {
  171. deletedIds = rowItem.id;
  172. };
  173. };
  174. this.setState({
  175. loading: true,
  176. selectedRowKeys: [],
  177. });
  178. $.ajax({
  179. method: "get",
  180. dataType: "json",
  181. crossDomain: false,
  182. url: globalConfig.context + "/api/admin/customer/deleteCustomer",
  183. data: {
  184. uid: deletedIds, //删除的ID
  185. }
  186. }).done(function(data) {
  187. if(!data.error.length) {
  188. message.success('删除成功!');
  189. this.setState({
  190. loading: false,
  191. });
  192. } else {
  193. message.warning(data.error[0].message);
  194. };
  195. this.loadData(this.state.ispage);
  196. }.bind(this));
  197. },
  198. componentWillMount() {
  199. //城市
  200. let Province = [];
  201. provinceList.map(function(item) {
  202. var id = String(item.id)
  203. Province.push(
  204. <Select.Option value={id} key={item.name}>{item.name}</Select.Option>
  205. )
  206. });
  207. //行业
  208. let intentionalArr = [];
  209. industry.map(function(item) {
  210. intentionalArr.push(
  211. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  212. )
  213. });
  214. this.state.Provinces = Province;
  215. this.state.intentionalOption = intentionalArr;
  216. this.loadData();
  217. },
  218. closeDesc(e, s) {
  219. this.state.basicState=e
  220. this.state.visitModul=e;
  221. this.state.modalVisible=e;
  222. this.state.showDesc = e;
  223. if(s) {
  224. this.loadData(this.state.ispage);
  225. };
  226. },
  227. search() {
  228. this.loadData();
  229. },
  230. reset() {
  231. this.state.nameSearch = '';
  232. this.state.addressSearch = [];
  233. this.state.provinceSearch = undefined;
  234. this.state.citySearch = undefined;
  235. this.state.releaseDate[0] = undefined;
  236. this.state.releaseDate[1] = undefined;
  237. this.loadData();
  238. },
  239. searchSwitch() {
  240. this.setState({
  241. visitModul:false,
  242. searchMore: !this.state.searchMore
  243. });
  244. },
  245. //整行点击
  246. tableRowClick(record, index) {
  247. this.state.visitModul=false;
  248. this.state.RowData = record;
  249. this.setState({
  250. selectedRowKeys: [],
  251. modalVisible:true,
  252. basicState:true,
  253. contactState:true,
  254. })
  255. },
  256. //指定转交人自动补全
  257. supervisor(e){
  258. $.ajax({
  259. method: "get",
  260. dataType: "json",
  261. crossDomain: false,
  262. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  263. data:{
  264. adminName:e
  265. },
  266. success: function (data) {
  267. let thedata=data.data;
  268. if (!thedata) {
  269. if (data.error && data.error.length) {
  270. message.warning(data.error[0].message);
  271. };
  272. thedata = {};
  273. };
  274. this.setState({
  275. customerArr:thedata,
  276. });
  277. }.bind(this),
  278. }).always(function () {
  279. this.setState({
  280. loading: false
  281. });
  282. }.bind(this));
  283. },
  284. componentWillReceiveProps(nextProps) {
  285. if(nextProps.ApiUrl!=this.props.ApiUrl) {
  286. if(!this.state.searchMore){
  287. this.state.searchMore=true
  288. }
  289. this.state.nameSearch = '';
  290. this.state.addressSearch = [];
  291. this.state.provinceSearch = undefined;
  292. this.state.citySearch = undefined;
  293. this.state.releaseDate[0] = undefined;
  294. this.state.releaseDate[1] = undefined;
  295. this.loadData(null,nextProps.ApiUrl);
  296. };
  297. },
  298. render() {
  299. const FormItem = Form.Item;
  300. const rowSelection = {
  301. selectedRowKeys: this.state.selectedRowKeys,
  302. onChange: (selectedRowKeys, selectedRows) => {
  303. this.setState({
  304. modalVisible:false,
  305. selectedRows: selectedRows.slice(-1),
  306. selectedRowKeys: selectedRowKeys.slice(-1)
  307. });
  308. },
  309. onSelect: (recordt, selected, selectedRows) => {
  310. this.setState({
  311. modalVisible:false,
  312. recordt: recordt.id
  313. })
  314. },
  315. };
  316. const hasSelected = this.state.selectedRowKeys.length > 0;
  317. const { RangePicker } = DatePicker;
  318. const dataSources=this.state.customerArr || [];
  319. const options = dataSources.map((group) =>
  320. <Select.Option key={group.id} value={group.name}>{group.name}</Select.Option>
  321. )
  322. const intentionState = this.props.intentionState ||'';
  323. return(
  324. <div className="user-content" >
  325. <div className="content-title">
  326. <span>{!intentionState?'我的单位签单客户':'我的个人签单客户'}</span>
  327. </div>
  328. <div className="user-search">
  329. <Input placeholder="客户名称"
  330. value={this.state.nameSearch}
  331. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  332. <Select placeholder="省"
  333. style={{ width: 80 }}
  334. value={this.state.provinceSearch}
  335. onChange={(e) => {this.setState({ provinceSearch: e});}}>
  336. {this.state.Provinces}
  337. </Select>
  338. <span style={{marginRight:'10px'}}>
  339. <Cascader options={citySelect()} value={this.state.addressSearch} placeholder="选择城市"
  340. onChange={(e,pre) => { this.setState({ addressSearch: e }) }} />
  341. </span>
  342. <Button type="primary" onClick={this.search}>搜索</Button>
  343. <Button onClick={this.reset}>重置</Button>
  344. {adminData.isSuperAdmin?<Popconfirm title="是否删除?" onConfirm={this.delectRow} okText="是" cancelText="否">
  345. <Button type="danger" style={{marginLeft:'10px'}}
  346. disabled={!hasSelected}
  347. >删除<Icon type="minus" />
  348. </Button>
  349. </Popconfirm>:''
  350. }
  351. <span style={{marginLeft:'10px',marginRight:'20px'}}>更多搜索<Switch checked={!this.state.searchMore} onChange={this.searchSwitch} /></span>
  352. <div className='clearfix' style={{marginTop:'5px'}}>
  353. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  354. <RangePicker
  355. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  356. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  357. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  358. </div>
  359. </div>
  360. </div>
  361. <div className="patent-table">
  362. <Spin spinning={this.state.loading}>
  363. <Table columns={this.state.columns}
  364. dataSource={this.state.dataSource}
  365. rowSelection={rowSelection}
  366. pagination={this.state.pagination}
  367. onRowClick={this.tableRowClick}
  368. />
  369. </Spin>
  370. </div>
  371. <FollowDetail
  372. followData={this.state.followData}
  373. visitModul={this.state.visitModul}
  374. closeDesc={this.closeDesc}
  375. />
  376. <IntentionDetail
  377. detailApi={this.props.detailApi}
  378. IntentionData={this.state.RowData}
  379. modalVisible={this.state.modalVisible}
  380. closeDesc={this.closeDesc}
  381. basicState={this.state.basicState}
  382. contactState={this.state.contactState}
  383. />
  384. </div >
  385. );
  386. }
  387. }));
  388. export default IntentionCustomer;