signCustomer.jsx 14 KB

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