signCustomer.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. import React from 'react';
  2. import {
  3. Radio,
  4. Icon,
  5. Button,
  6. AutoComplete,
  7. Cascader,
  8. Input,
  9. Select,
  10. Tabs,
  11. Spin,
  12. Popconfirm,
  13. Table,
  14. Switch,
  15. message,
  16. DatePicker,
  17. Upload,
  18. Form,
  19. Modal
  20. } from 'antd';
  21. import ajax from 'jquery/src/ajax/xhr.js';
  22. import $ from 'jquery/src/ajax';
  23. import moment from 'moment';
  24. import { citySelect, provinceList } from '@/NewDicProvinceList';
  25. import { socialAttribute, industry, auditStatusL, lvl, currentMember } from '@/dataDic.js';
  26. import { getSocialAttribute, beforeUploadFile, ShowModal } from "@/tools.js";
  27. import FollowDetail from './followDetail.jsx'
  28. import ShowModalDiv from "@/showModal.jsx";
  29. import ZhuanjiaoDetail from "@/zhuanjiaoDetail.jsx";
  30. import IntentionDetail from './intentionDetail/intentionDetail.jsx'
  31. import './customer.less';
  32. import {ChooseList} from "../../../order/orderNew/chooseList";
  33. const {TabPane} = Tabs
  34. const IntentionCustomer = Form.create()(React.createClass({
  35. loadData(pageNo, apiUrl) {
  36. this.setState({
  37. visitModul:false,
  38. loading: true,
  39. ispage:pageNo,
  40. modalVisible:false
  41. });
  42. let api=apiUrl?apiUrl:this.props.ApiUrl;
  43. $.ajax({
  44. method: "post",
  45. dataType: "json",
  46. crossDomain: false,
  47. url: globalConfig.context + api,
  48. data: {
  49. pageNo: pageNo || 1,
  50. pageSize: this.state.pagination.pageSize,
  51. name: this.state.nameSearch,
  52. channel: this.state.channelSearch,
  53. province: !(this.state.addressSearch).length ? this.state.provinceSearch : this.state.addressSearch[0],
  54. city: !(this.state.addressSearch).length ? '' : this.state.addressSearch[1],
  55. startDate: this.state.releaseDate[0],
  56. endDate: this.state.releaseDate[1],
  57. },
  58. success: function(data) {
  59. ShowModal(this);
  60. let theArr = [];
  61. if(data.error.length || data.data.list == "") {
  62. if(data.error && data.error.length) {
  63. message.warning(data.error[0].message);
  64. };
  65. } else {
  66. for(let i = 0; i < data.data.list.length; i++) {
  67. let thisdata = data.data.list[i];
  68. let diqu=(thisdata.province==null?"":thisdata.province)+(thisdata.city==null?"":"-"+thisdata.city)+(thisdata.area==null?"":"-"+thisdata.area);
  69. thisdata.key = i;
  70. thisdata.id = thisdata.uid;
  71. thisdata.transferTime = thisdata.transferTime && thisdata.transferTime.split(" ")[0];
  72. thisdata.lastSignTime = thisdata.lastSignTime && thisdata.lastSignTime.split(" ")[0];
  73. thisdata.lastFollowTime = thisdata.lastFollowTime && thisdata.lastFollowTime.split(" ")[0];
  74. thisdata.locationProvince = diqu
  75. theArr.push(thisdata);
  76. };
  77. this.state.pagination.current = data.data.pageNo;
  78. this.state.pagination.total = data.data.totalCount;
  79. };
  80. if(data.data&&data.data.list&&!data.data.list.length){
  81. this.state.pagination.current=0
  82. this.state.pagination.total=0
  83. };
  84. this.setState({
  85. dataSource: theArr,
  86. pagination: this.state.pagination,
  87. selectedRowKeys:[]
  88. });
  89. }.bind(this),
  90. }).always(function() {
  91. this.setState({
  92. loading: false
  93. });
  94. }.bind(this));
  95. },
  96. getInitialState() {
  97. return {
  98. addressSearch: [],
  99. orgCodeUrl: [],
  100. companyLogoUrl: [],
  101. visible: false,
  102. searchMore: true,
  103. releaseDate: [],
  104. visitModul: false,
  105. keys: false,
  106. detailApi: "",
  107. followData: {},
  108. selectedRowKeys: [],
  109. selectedRowKey: [],
  110. selectedRows: [],
  111. loading: false,
  112. defaultActiveKey: '',
  113. modalVisible: false,
  114. pagination: {
  115. defaultCurrent: 1,
  116. defaultPageSize: 10,
  117. showQuickJumper: true,
  118. pageSize: 10,
  119. onChange: function (page) {
  120. this.loadData(page);
  121. }.bind(this),
  122. showTotal: function (total) {
  123. return "共" + total + "条数据";
  124. },
  125. },
  126. columns: [
  127. {
  128. title: "客户名称",
  129. dataIndex: "name",
  130. key: "name",
  131. render: (text,record) => {
  132. return (
  133. <span>
  134. {record.channel === 1 ? <div style={{
  135. background:'#ef7207',
  136. color:'#FFF',
  137. padding: '1px 7px',
  138. borderRadius:'5px',
  139. fontSize:'12px',
  140. display: 'inline-block',
  141. marginRight:'10px'
  142. }}>
  143. 渠道
  144. </div> : null}
  145. {text}
  146. </span>
  147. )
  148. },
  149. },
  150. {
  151. title: "地区",
  152. dataIndex: "locationProvince",
  153. key: "locationProvince",
  154. },
  155. {
  156. title: "最新签单日期",
  157. dataIndex: "transferTime",
  158. key: "transferTime",
  159. },
  160. // {
  161. // title: "最新跟进日期",
  162. // dataIndex: "lastFollowTime",
  163. // key: "lastFollowTime",
  164. // },
  165. // {
  166. // title: "剩余私有天数",
  167. // dataIndex: "surplusFollowTime",
  168. // key: "surplusFollowTime",
  169. // },
  170. // {
  171. // title: "剩余签单天数",
  172. // dataIndex: "surplusSignTime",
  173. // key: "surplusSignTime",
  174. // },
  175. // {
  176. // title: "联系人",
  177. // dataIndex: "contacts",
  178. // key: "contacts",
  179. // },
  180. // {
  181. // title: "联系电话",
  182. // dataIndex: "contactMobile",
  183. // key: "contactMobile",
  184. // },
  185. {
  186. title: "社会属性",
  187. dataIndex: "societyTag",
  188. key: "societyTag",
  189. render: (text) => {
  190. return getSocialAttribute(text);
  191. },
  192. },
  193. {
  194. title: "操作",
  195. dataIndex: "abc",
  196. key: "abc",
  197. render: (text, record, index) => {
  198. return (
  199. <div>
  200. <Button
  201. onClick={(e) => {
  202. e.stopPropagation(), this.visit(record);
  203. }}
  204. type="primary"
  205. >
  206. 客户跟进
  207. </Button>
  208. <Button
  209. style={{ marginLeft: 10 }}
  210. onClick={(e) => {
  211. e.stopPropagation(), this.zhuanjiaoDetail(record);
  212. }}
  213. type="primary"
  214. >
  215. 转交记录
  216. </Button>
  217. <Button
  218. style={{ marginLeft: 10 }}
  219. type="primary"
  220. onClick={(e)=>{
  221. e.stopPropagation();
  222. this.setState({
  223. defaultActiveKey: '6'
  224. },()=>{
  225. this.tableRowClick(record);
  226. })
  227. }}
  228. >
  229. 转交业务
  230. </Button>
  231. </div>
  232. );
  233. },
  234. },
  235. ],
  236. data: [],
  237. dataSource: [],
  238. };
  239. },
  240. zhuanjiaoDetail(record) {
  241. this.setState({
  242. zhuanjiaoVisible: true,
  243. zhuanjiaoId: record.id
  244. })
  245. },
  246. zhuanjiaoDetailCancel() {
  247. this.setState({
  248. zhuanjiaoVisible: false
  249. })
  250. },
  251. //进入新增拜访记录
  252. visit(e) {
  253. this.setState({
  254. followData:e,
  255. visitModul:true,
  256. modalVisible:false
  257. })
  258. },
  259. //列表删除功能
  260. delectRow() {
  261. let deletedIds;
  262. for(let idx = 0; idx < this.state.selectedRows.length; idx++) {
  263. let rowItem = this.state.selectedRows[idx];
  264. if(rowItem.id) {
  265. deletedIds = rowItem.id;
  266. };
  267. };
  268. this.setState({
  269. loading: true,
  270. selectedRowKeys: [],
  271. });
  272. $.ajax({
  273. method: "get",
  274. dataType: "json",
  275. crossDomain: false,
  276. url: globalConfig.context + "/api/admin/customer/deleteCustomer",
  277. data: {
  278. uid: deletedIds, //删除的ID
  279. }
  280. }).done(function(data) {
  281. if(!data.error.length) {
  282. message.success('删除成功!');
  283. this.setState({
  284. loading: false,
  285. });
  286. } else {
  287. message.warning(data.error[0].message);
  288. };
  289. this.loadData(this.state.ispage);
  290. }.bind(this));
  291. },
  292. componentWillMount() {
  293. //城市
  294. let Province = [];
  295. provinceList.map(function(item) {
  296. var id = String(item.id)
  297. Province.push(
  298. <Select.Option value={id} key={item.name}>{item.name}</Select.Option>
  299. )
  300. });
  301. //行业
  302. let intentionalArr = [];
  303. industry.map(function(item) {
  304. intentionalArr.push(
  305. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  306. )
  307. });
  308. this.state.Provinces = Province;
  309. this.state.intentionalOption = intentionalArr;
  310. this.loadData();
  311. },
  312. closeDesc(e, s) {
  313. this.state.basicState=e
  314. this.state.visitModul=e;
  315. this.state.modalVisible=e;
  316. this.state.showDesc = e;
  317. this.setState({
  318. defaultActiveKey:''
  319. })
  320. if(s) {
  321. this.loadData(this.state.ispage);
  322. };
  323. },
  324. search() {
  325. this.loadData();
  326. },
  327. reset() {
  328. this.state.nameSearch = '';
  329. this.state.addressSearch = [];
  330. this.state.provinceSearch = undefined;
  331. this.state.channelSearch = undefined;
  332. this.state.citySearch = undefined;
  333. this.state.releaseDate[0] = undefined;
  334. this.state.releaseDate[1] = undefined;
  335. this.loadData();
  336. },
  337. searchSwitch() {
  338. this.setState({
  339. visitModul:false,
  340. searchMore: !this.state.searchMore
  341. });
  342. },
  343. //整行点击
  344. tableRowClick(record) {
  345. this.state.visitModul=false;
  346. this.state.RowData = record;
  347. this.setState({
  348. // selectedRowKeys: [],
  349. modalVisible:true,
  350. basicState:true,
  351. contactState:true,
  352. modalName: record.name
  353. })
  354. },
  355. //指定转交人自动补全
  356. supervisor(e){
  357. $.ajax({
  358. method: "get",
  359. dataType: "json",
  360. crossDomain: false,
  361. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  362. data:{
  363. adminName:e
  364. },
  365. success: function (data) {
  366. let thedata=data.data;
  367. if (!thedata) {
  368. if (data.error && data.error.length) {
  369. message.warning(data.error[0].message);
  370. };
  371. thedata = {};
  372. };
  373. this.setState({
  374. customerArr:thedata,
  375. });
  376. }.bind(this),
  377. }).always(function () {
  378. this.setState({
  379. loading: false
  380. });
  381. }.bind(this));
  382. },
  383. componentWillReceiveProps(nextProps) {
  384. if(nextProps.ApiUrl!=this.props.ApiUrl) {
  385. if(!this.state.searchMore){
  386. this.state.searchMore=true
  387. }
  388. this.state.nameSearch = '';
  389. this.state.addressSearch = [];
  390. this.state.provinceSearch = undefined;
  391. this.state.channelSearch = undefined
  392. this.state.citySearch = undefined;
  393. this.state.releaseDate[0] = undefined;
  394. this.state.releaseDate[1] = undefined;
  395. this.loadData(null,nextProps.ApiUrl);
  396. };
  397. },
  398. changeList(arr) {
  399. const newArr = [];
  400. this.state.columns.forEach(item => {
  401. arr.forEach(val => {
  402. if (val === item.title) {
  403. newArr.push(item);
  404. }
  405. });
  406. });
  407. this.setState({
  408. changeList: newArr
  409. });
  410. },
  411. //上级主管输入框失去焦点是判断客户是否存在
  412. selectAuto(value, options) {
  413. this.setState({
  414. auto: value,
  415. });
  416. },
  417. //值改变时请求客户名称
  418. httpChange(e) {
  419. if (e.length >= 1) {
  420. this.supervisor(e);
  421. }
  422. this.setState({
  423. auto: e,
  424. });
  425. },
  426. showConfirm(fn, record) {
  427. if(this.state.confirmLoading){
  428. return false;
  429. }
  430. Modal.confirm({
  431. title: "提示",
  432. content: (
  433. <span style={{ color: "red" }}>
  434. 确定要转交以下客户吗?
  435. {
  436. this.state.selectedRows.map((value,index)=>(
  437. <div key={index} style={{marginTop:'5px',color: "#000"}}>
  438. {value.name}
  439. </div>
  440. ))
  441. }
  442. </span>
  443. ),
  444. onOk() {
  445. fn(record);
  446. },
  447. onCancel() {},
  448. });
  449. },
  450. //转交
  451. changeAssigner() {
  452. if (this.state.theTypes) {
  453. this.setState({
  454. confirmLoading: true
  455. })
  456. const hide = message.loading('转交中...', 0);
  457. let changeIds = '';
  458. let oldAid = '';
  459. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  460. let rowItem = this.state.selectedRows[idx];
  461. if (rowItem.id) {
  462. oldAid = rowItem.aid;
  463. changeIds = this.state.selectedRows.length-1 === idx ? changeIds +rowItem.id : changeIds + rowItem.id + ',' ;
  464. }
  465. }
  466. $.ajax({
  467. method: "get",
  468. dataType: "json",
  469. crossDomain: false,
  470. url: globalConfig.context + "/api/admin/customer/transferToOther",
  471. data: {
  472. uid: changeIds, //这一行数据的ID
  473. aid: this.state.theTypes, //指定转交人的ID
  474. oldAid: window.adminData.uid,
  475. operatorType:4
  476. },
  477. }).done(
  478. function (data) {
  479. if (!data.error.length) {
  480. message.success("转交成功!");
  481. this.setState({
  482. auto: "",
  483. loading: false,
  484. selectedRowKeys: [],
  485. });
  486. } else {
  487. message.warning(data.error[0].message);
  488. }
  489. this.loadData(
  490. Math.min(
  491. this.state.ispage == undefined ? 1 : this.state.ispage,
  492. Math.ceil((this.state.pagination.total - 1) / 10)
  493. )
  494. );
  495. hide();
  496. this.setState({
  497. confirmLoading: false
  498. })
  499. }.bind(this)
  500. );
  501. } else {
  502. message.warning("请输入转交人姓名");
  503. }
  504. },
  505. blurChange(e) {
  506. let theType = "";
  507. let contactLists = this.state.customerArr || [];
  508. if (e) {
  509. contactLists.map(function (item) {
  510. if (item.name == e.toString()) {
  511. theType = item.id;
  512. }
  513. });
  514. }
  515. this.setState({
  516. theTypes: theType,
  517. });
  518. },
  519. render() {
  520. const rowSelection = {
  521. selectedRowKeys: this.state.selectedRowKeys,
  522. onChange: (selectedRowKeys, selectedRows) => {
  523. this.setState({
  524. modalVisible:false,
  525. selectedRows: selectedRows,
  526. selectedRowKeys: selectedRowKeys
  527. });
  528. },
  529. onSelect: (recordt, selected, selectedRows) => {
  530. this.setState({
  531. modalVisible:false,
  532. recordt: recordt.id
  533. })
  534. },
  535. };
  536. const hasSelected = this.state.selectedRowKeys.length > 0;
  537. const { RangePicker } = DatePicker;
  538. const dataSources=this.state.customerArr || [];
  539. const options = dataSources.map((group) =>
  540. <Select.Option key={group.id} value={group.name}>{group.name}</Select.Option>
  541. )
  542. const intentionState = this.props.intentionState ||'';
  543. return (
  544. <div className="user-content">
  545. <ShowModalDiv ShowModal={this.state.showModal} />
  546. {this.state.zhuanjiaoVisible ? (
  547. <ZhuanjiaoDetail
  548. cancel={this.zhuanjiaoDetailCancel}
  549. visible={this.state.zhuanjiaoVisible}
  550. type={1}
  551. id={this.state.zhuanjiaoId}
  552. />
  553. ) : (
  554. ""
  555. )}
  556. <div className="content-title">
  557. <span>{!intentionState ? "签单客户" : "签单客户"}</span>
  558. </div>
  559. <Tabs defaultActiveKey="1" className="test">
  560. <TabPane tab="搜索" key="1">
  561. <div className="user-search">
  562. <Input
  563. placeholder="客户名称"
  564. value={this.state.nameSearch}
  565. onChange={(e) => {
  566. this.setState({ nameSearch: e.target.value });
  567. }}
  568. />
  569. <Select
  570. placeholder="是否为渠道"
  571. style={{ width: 110 }}
  572. value={this.state.channelSearch}
  573. onChange={(e) => {
  574. this.setState({ channelSearch: e });
  575. }}
  576. >
  577. <Select.Option value={0}>
  578. 非渠道
  579. </Select.Option>
  580. <Select.Option value={1}>
  581. 渠道
  582. </Select.Option>
  583. </Select>
  584. <Select
  585. placeholder="省"
  586. style={{ width: 80 }}
  587. value={this.state.provinceSearch}
  588. onChange={(e) => {
  589. this.setState({ provinceSearch: e });
  590. }}
  591. >
  592. {this.state.Provinces}
  593. </Select>
  594. <span style={{ marginRight: "10px" }}>
  595. <Cascader
  596. options={citySelect()}
  597. value={this.state.addressSearch}
  598. placeholder="选择城市"
  599. onChange={(e, pre) => {
  600. this.setState({ addressSearch: e });
  601. }}
  602. />
  603. </span>
  604. {/* <div className="clearfix" style={{ marginTop: "5px" }}>
  605. <div
  606. className="search-more"
  607. style={this.state.searchMore ? { display: "none" } : {}}
  608. > */}
  609. <span>签单时间:</span>
  610. <RangePicker
  611. value={[
  612. this.state.releaseDate[0]
  613. ? moment(this.state.releaseDate[0])
  614. : null,
  615. this.state.releaseDate[1]
  616. ? moment(this.state.releaseDate[1])
  617. : null,
  618. ]}
  619. onChange={(data, dataString) => {
  620. this.setState({ releaseDate: dataString });
  621. }}
  622. />
  623. {/* </div>
  624. </div> */}
  625. <Button
  626. type="primary"
  627. onClick={this.search}
  628. style={{ marginLeft: 10 }}
  629. >
  630. 搜索
  631. </Button>
  632. <Button onClick={this.reset}>重置</Button>
  633. {/* {adminData.isSuperAdmin?<Popconfirm title="是否删除?" onConfirm={this.delectRow} okText="是" cancelText="否">
  634. <Button type="danger" style={{marginLeft:'10px'}}
  635. disabled={!hasSelected}
  636. >删除<Icon type="minus" />
  637. </Button>
  638. </Popconfirm>:''
  639. }*/}
  640. {/* <span style={{ marginLeft: "10px", marginRight: "20px" }}>
  641. 更多搜索
  642. <Switch
  643. checked={!this.state.searchMore}
  644. onChange={this.searchSwitch}
  645. />
  646. </span> */}
  647. </div>
  648. </TabPane>
  649. <TabPane tab="操作" key="2">
  650. <div className="user-search">
  651. <AutoComplete
  652. className="certain-category-search"
  653. dropdownClassName="certain-category-search-dropdown"
  654. dropdownMatchSelectWidth={false}
  655. dropdownStyle={{ width: 120 }}
  656. style={{ width: "120px" }}
  657. dataSource={options}
  658. placeholder="输入转交人姓名"
  659. value={this.state.auto}
  660. onChange={this.httpChange}
  661. filterOption={true}
  662. onBlur={this.blurChange}
  663. onSelect={this.selectAuto}
  664. disabled={!hasSelected}
  665. >
  666. <Input />
  667. </AutoComplete>
  668. <Button
  669. type="primary"
  670. onClick={(e) => {
  671. e.stopPropagation();
  672. this.showConfirm(this.changeAssigner);
  673. }}
  674. disabled={!hasSelected}
  675. style={{ marginRight: 10 }}
  676. >
  677. 转交客户
  678. </Button>
  679. </div>
  680. </TabPane>
  681. <TabPane tab="更改表格显示数据" key="3">
  682. <div style={{ marginLeft: 10 }}>
  683. <ChooseList
  684. columns={this.state.columns}
  685. changeFn={this.changeList}
  686. changeList={this.state.changeList}
  687. top={55}
  688. margin={11}
  689. />
  690. </div>
  691. </TabPane>
  692. </Tabs>
  693. <div className="patent-table">
  694. <Spin spinning={this.state.loading}>
  695. <Table
  696. size="middle"
  697. columns={
  698. this.state.changeList
  699. ? this.state.changeList
  700. : this.state.columns
  701. }
  702. dataSource={this.state.dataSource}
  703. rowSelection={rowSelection}
  704. pagination={this.state.pagination}
  705. onRowClick={this.tableRowClick}
  706. />
  707. </Spin>
  708. </div>
  709. <FollowDetail
  710. followData={this.state.followData}
  711. visitModul={this.state.visitModul}
  712. closeDesc={this.closeDesc}
  713. loadData={this.loadData}
  714. />
  715. <IntentionDetail
  716. detailApi={this.props.detailApi}
  717. IntentionData={this.state.RowData}
  718. loadData={this.loadData}
  719. modalVisible={this.state.modalVisible}
  720. defaultActiveKey={this.state.defaultActiveKey}
  721. name={this.state.modalName}
  722. closeDesc={this.closeDesc}
  723. basicState={this.state.basicState}
  724. contactState={this.state.contactState}
  725. />
  726. </div>
  727. );
  728. }
  729. }));
  730. export default IntentionCustomer;