signCustomer.jsx 16 KB

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