index.jsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. import React,{Component} from 'react';
  2. import {
  3. AutoComplete,
  4. Button,
  5. Cascader,
  6. DatePicker,
  7. Icon,
  8. Input,
  9. message,
  10. Modal,
  11. Select,
  12. Spin,
  13. Table,
  14. Tabs,
  15. Tag, Tooltip
  16. } from "antd";
  17. import { citySelect, provinceList } from '@/NewDicProvinceList';
  18. import {getSocialAttribute, ShowModal} from "@/tools.js";
  19. import ShowModalDiv from "@/showModal.jsx";
  20. import moment from "moment";
  21. import $ from "jquery/src/ajax";
  22. import IntentionDetail from "../../NEW/intentionCustomer/intentionDetail/intentionDetail";
  23. import {ChooseList} from "../../../order/orderNew/chooseList";
  24. const {TabPane} = Tabs;
  25. const { RangePicker } = DatePicker;
  26. class CustomerFollow extends Component{
  27. constructor(props) {
  28. super(props);
  29. this.state={
  30. nameSearch: '',
  31. provinceSearch: undefined,
  32. addressSearch: '',
  33. level: undefined,
  34. releaseDate: [],
  35. selectedRowKeys: [],
  36. sortType: 0,
  37. filteredInfo: null,
  38. sortedInfo: null,
  39. columns : [
  40. {
  41. title: "客户名称",
  42. dataIndex: "name",
  43. key: "name",
  44. width:150,
  45. render: text => {
  46. return (
  47. <Tooltip title={text}>
  48. <div style={{
  49. maxWidth:'150px',
  50. overflow:'hidden',
  51. textOverflow: "ellipsis",
  52. whiteSpace:'nowrap',
  53. }}>{text}</div>
  54. </Tooltip>
  55. )
  56. }
  57. },
  58. {
  59. title: "地区",
  60. dataIndex: "locationProvince",
  61. key: "locationProvince",
  62. },
  63. {
  64. title: "联系人",
  65. dataIndex: "contacts",
  66. key: "contacts",
  67. },
  68. {
  69. title: "联系电话",
  70. dataIndex: "contactMobile",
  71. key: "contactMobile",
  72. },
  73. {
  74. title: "社会性质",
  75. dataIndex: "societyTag",
  76. key: "societyTag",
  77. render: (text) => {
  78. return getSocialAttribute(text);
  79. },
  80. },
  81. {
  82. title: "客户初始时间",
  83. dataIndex: "transferTime",
  84. key: "transferTime",
  85. },
  86. {
  87. title: "剩余私有天数",
  88. dataIndex: "surplusFollowTime",
  89. key: "surplusFollowTime",
  90. },
  91. {
  92. title: "剩余签单天数",
  93. dataIndex: "surplusSignTime",
  94. key: "surplusSignTime",
  95. },
  96. {
  97. title: "最新跟进时间",
  98. dataIndex: "lastFollowTime",
  99. key: "lastFollowTime",
  100. //0无 1转换倒序 2转换正序
  101. sorter: true,
  102. sortOrder: (this.sortedInfo || {}).columnKey === 'lastFollowTime' && (this.sortedInfo || {}).order,
  103. filteredValue: (this.filteredInfo || {}).lastFollowTime || null,
  104. },
  105. {
  106. title: "客户等级",
  107. dataIndex: "level",
  108. key: "level",
  109. render: (text) => {
  110. if(text === 0) {
  111. return <Tag color="#87d068">一般客户</Tag>;
  112. }else if(text === 1) {
  113. return <Tag color="#D2691E">意向客户</Tag>;
  114. }else if(text === 2) {
  115. return <Tag color="#FF0000">重点客户</Tag>;
  116. }else {
  117. return "";
  118. }
  119. },
  120. },
  121. {
  122. title: "跟进人",
  123. dataIndex: "aName",
  124. key: "aName",
  125. },
  126. {
  127. title: "跟进操作",
  128. dataIndex: "abc",
  129. key: "abc",
  130. render: (text, record, index) => {
  131. return (
  132. <div>
  133. <Button
  134. onClick={(e) => {
  135. e.stopPropagation();
  136. this.setState({
  137. tabsKey:"4",
  138. },()=>{
  139. this.tableRowClick(record)
  140. })
  141. }}
  142. type="primary"
  143. >
  144. {this.props.isEditGuidanceLv ? '指导' : '查看指导'}
  145. </Button>
  146. </div>
  147. );
  148. },
  149. },
  150. ],
  151. provinces: [],
  152. dataSource: [],
  153. categoryArr: [],
  154. modalName: '',
  155. modalVisible: false,
  156. basicState: false,
  157. contactState: false,
  158. rowData: {},
  159. pagination: {
  160. defaultCurrent: 1,
  161. defaultPageSize: 10,
  162. showQuickJumper: true,
  163. pageSize: 10,
  164. onChange: function (page) {
  165. this.loadData(page);
  166. }.bind(this),
  167. showTotal: function (total) {
  168. return "共" + total + "条数据";
  169. },
  170. },
  171. loading: false,
  172. ispage: 1,
  173. guidance: '',
  174. tabsKey:'',
  175. };
  176. this.callback = this.callback.bind(this);
  177. this.loadData = this.loadData.bind(this);
  178. this.reset = this.reset.bind(this);
  179. this.tableRowClick = this.tableRowClick.bind(this);
  180. this.closeDesc = this.closeDesc.bind(this);
  181. this.releaseGuidance = this.releaseGuidance.bind(this);
  182. this.changeList = this.changeList.bind(this);
  183. }
  184. componentDidMount() {
  185. this.loadData();
  186. this.category();
  187. //城市
  188. let Province = [];
  189. provinceList.map(function (item) {
  190. let id = String(item.id);
  191. Province.push(
  192. <Select.Option value={id} key={item.name}>
  193. {item.name}
  194. </Select.Option>
  195. );
  196. });
  197. this.setState({
  198. provinces: Province
  199. })
  200. }
  201. callback(){
  202. }
  203. loadData(pageNo) {
  204. this.setState({
  205. loading: true,
  206. });
  207. let api = '/api/admin/customer/listFollowManagement';
  208. $.ajax({
  209. method: "get",
  210. dataType: "json",
  211. crossDomain: false,
  212. url: globalConfig.context + api,
  213. data: {
  214. pageNo: pageNo || 1,
  215. pageSize: this.state.pagination.pageSize,
  216. level: this.state.level ? this.state.level : undefined,
  217. name: this.state.nameSearch,
  218. province: !this.state.addressSearch.length
  219. ? this.state.provinceSearch
  220. : this.state.addressSearch[0],
  221. city: !this.state.addressSearch.length
  222. ? ""
  223. : this.state.addressSearch[1],
  224. startDate: this.state.releaseDate[0],
  225. endDate: this.state.releaseDate[1],
  226. sortType:this.state.sortType,
  227. },
  228. success: function (data) {
  229. ShowModal(this);
  230. let theArr = [];
  231. if (data.error.length !== 0) {
  232. if (data.error && data.error.length) {
  233. message.warning(data.error[0].message);
  234. }
  235. } else {
  236. for (let i = 0; i < data.data.list.length; i++) {
  237. let thisdata = data.data.list[i];
  238. let diqu =
  239. (thisdata.province == null ? "" : thisdata.province) +
  240. (thisdata.city == null ? "" : "-" + thisdata.city) +
  241. (thisdata.area == null ? "" : "-" + thisdata.area);
  242. thisdata.key = i;
  243. thisdata.id = thisdata.uid;
  244. thisdata.lastFollowTime = thisdata.lastFollowTime && thisdata.lastFollowTime.split(" ")[0];
  245. thisdata.transferTime= thisdata.transferTime && thisdata.transferTime.split(" ")[0];
  246. thisdata.surplusFollowTime= thisdata.surplusFollowTime && thisdata.surplusFollowTime.split(" ")[0];
  247. thisdata.surplusSignTime= thisdata.surplusSignTime && thisdata.surplusSignTime.split(" ")[0];
  248. thisdata.locationProvince= diqu;
  249. theArr.push(thisdata);
  250. }
  251. this.state.pagination.current = data.data.pageNo;
  252. this.state.pagination.total = data.data.totalCount;
  253. if (data.data && data.data.list && !data.data.list.length) {
  254. this.state.pagination.current = 0;
  255. this.state.pagination.total = 0;
  256. }
  257. this.setState({
  258. ispage: data.data.pageNo,
  259. dataSource: theArr,
  260. pagination: this.state.pagination,
  261. });
  262. }
  263. }.bind(this),
  264. }).always(
  265. function () {
  266. this.setState({
  267. loading: false,
  268. });
  269. }.bind(this)
  270. );
  271. };
  272. reset(){
  273. this.setState({
  274. nameSearch: '',
  275. provinceSearch: undefined,
  276. addressSearch: '',
  277. level: undefined,
  278. releaseDate: [],
  279. selectedRowKeys: [],
  280. sortType: 0,
  281. filteredInfo: null,
  282. sortedInfo: null,
  283. },()=>{
  284. this.loadData();
  285. });
  286. };
  287. //品类数据获取
  288. category() {
  289. $.ajax({
  290. method: "get",
  291. dataType: "json",
  292. crossDomain: false,
  293. url: globalConfig.context + "/api/admin/Varieties/getSuperList",
  294. data: {},
  295. success: function (data) {
  296. let thedata = data.data;
  297. let theArr = [];
  298. if (!thedata) {
  299. if (data.error && data.error.length) {
  300. message.warning(data.error[0].message);
  301. }
  302. } else {
  303. thedata.map(function (item, index) {
  304. theArr.push({
  305. value: item.id,
  306. key: item.cname,
  307. });
  308. });
  309. }
  310. this.setState({
  311. categoryArr: theArr,
  312. });
  313. }.bind(this),
  314. });
  315. }
  316. tableRowClick(record){ //key 控制弹窗初始显示第几级
  317. this.setState({
  318. selectedRowKeys: [],
  319. modalVisible: true,
  320. basicState: true,
  321. contactState: true,
  322. modalName: record.name,
  323. rowData: record,
  324. });
  325. };
  326. closeDesc(e, s) {
  327. this.setState({
  328. basicState: e,
  329. visitModul: e,
  330. modalVisible: e,
  331. showDesc: e,
  332. tabsKey: '',
  333. })
  334. if (s) {
  335. this.loadData(this.state.ispage);
  336. }
  337. }
  338. //发布指导意见
  339. releaseGuidance(){
  340. if(!this.state.guidance){
  341. message.info('指导意见不能为空')
  342. return;
  343. }
  344. this.setState({
  345. loading: true,
  346. });
  347. let _this = this;
  348. $.ajax({
  349. method: "get",
  350. dataType: "json",
  351. crossDomain: false,
  352. url: globalConfig.context + "/api/admin/customer/pushReleaseUser",
  353. data: {
  354. guidance: this.state.guidance,
  355. },
  356. success: function (data) {
  357. let thedata = data.data;
  358. if (!thedata) {
  359. if (data.error && data.error.length) {
  360. message.warning(data.error[0].message);
  361. }
  362. }else {
  363. message.success("发布成功");
  364. _this.loadData(this.state.ispage);
  365. }
  366. }.bind(this),
  367. }).always(
  368. function () {
  369. this.setState({
  370. loading: false,
  371. });
  372. }.bind(this)
  373. );
  374. }
  375. changeList(arr) {
  376. const newArr = [];
  377. this.state.columns.forEach(item => {
  378. arr.forEach(val => {
  379. if (val === item.title) {
  380. newArr.push(item);
  381. }
  382. });
  383. });
  384. this.setState({
  385. changeList: newArr
  386. });
  387. }
  388. render() {
  389. let { sortedInfo, filteredInfo,columns } = this.state;
  390. return(
  391. <div className="user-content">
  392. <ShowModalDiv ShowModal={this.state.showModal} />
  393. <div className="content-title">
  394. <span>指导意见</span>
  395. </div>
  396. <Tabs defaultActiveKey="1" className="test">
  397. <TabPane tab="搜索" key="1">
  398. <div className="user-search">
  399. <Input
  400. placeholder="客户名称"
  401. value={this.state.nameSearch}
  402. style={{ width: 150, marginRight: 10, marginLeft: 10 }}
  403. onChange={(e) => {
  404. this.setState({ nameSearch: e.target.value });
  405. }}
  406. />
  407. <Select
  408. placeholder="选择地区"
  409. style={{ width: 80 }}
  410. value={this.state.provinceSearch}
  411. onChange={(e) => {
  412. this.setState({ provinceSearch: e });
  413. }}
  414. >
  415. {this.state.provinces}
  416. </Select>
  417. <span style={{ marginRight: "10px" }}>
  418. <Cascader
  419. options={citySelect()}
  420. value={this.state.addressSearch}
  421. placeholder="选择城市"
  422. onChange={(e, pre) => {
  423. this.setState({ addressSearch: e });
  424. }}
  425. />
  426. </span>
  427. <Select
  428. style={{ width: 120 }}
  429. value={this.state.level}
  430. onChange={(e) => {
  431. this.setState({ level: e });
  432. }}
  433. placeholder="选择客户等级"
  434. >
  435. <Select.Option value="0">一般客户</Select.Option>
  436. <Select.Option value="1">意向客户</Select.Option>
  437. <Select.Option value="2">重点客户</Select.Option>
  438. </Select>
  439. <RangePicker
  440. value={[
  441. this.state.releaseDate[0]
  442. ? moment(this.state.releaseDate[0])
  443. : null,
  444. this.state.releaseDate[1]
  445. ? moment(this.state.releaseDate[1])
  446. : null,
  447. ]}
  448. onChange={(data, dataString) => {
  449. this.setState({ releaseDate: dataString });
  450. }}
  451. />
  452. <Button
  453. type="primary"
  454. style={{ marginLeft: "10px", marginRight: 10 }}
  455. onClick={()=>{
  456. this.loadData();
  457. }}
  458. >
  459. 搜索
  460. </Button>
  461. <Button onClick={this.reset}>重置</Button>
  462. </div>
  463. </TabPane>
  464. <TabPane tab="更改表格显示数据" key="2">
  465. <div style={{ marginLeft: 10 }}>
  466. <ChooseList
  467. columns={columns}
  468. changeFn={this.changeList}
  469. changeList={this.state.changeList}
  470. top={55}
  471. margin={11}
  472. />
  473. </div>
  474. </TabPane>
  475. </Tabs>
  476. <div className="patent-table">
  477. <Spin spinning={this.state.loading}>
  478. <Table
  479. columns={
  480. this.state.changeList
  481. ? this.state.changeList
  482. : columns
  483. }
  484. dataSource={this.state.dataSource}
  485. pagination={this.state.pagination}
  486. onRowClick={this.tableRowClick}
  487. style={{
  488. cursor: 'pointer',
  489. }}
  490. onChange={(pagination, filters, sorter)=>{
  491. //0 正序 1倒序
  492. if(sorter.order === 'ascend'){ //倒序
  493. this.setState({
  494. sortType: 1
  495. },()=>{
  496. this.loadData(pagination.current)
  497. });
  498. }else if (sorter.order === 'descend'){ //正序
  499. this.setState({
  500. sortType: 0
  501. },()=>{
  502. this.loadData(pagination.current)
  503. });
  504. }else if (typeof sorter.order === 'undefined'){ //正常
  505. this.setState({
  506. sortType: 0
  507. },()=>{
  508. this.loadData(pagination.current)
  509. });
  510. }
  511. this.setState({
  512. filteredInfo: filters,
  513. sortedInfo: sorter,
  514. });
  515. }
  516. }
  517. />
  518. </Spin>
  519. </div>
  520. <IntentionDetail
  521. isGuidanceLv={this.props.isGuidanceLv}
  522. isEditGuidanceLv={this.props.isEditGuidanceLv}
  523. categoryArr={this.state.categoryArr}
  524. detailApi={this.props.detailApi}
  525. IntentionData={this.state.rowData}
  526. modalVisible={this.state.modalVisible}
  527. tabsKey={this.state.tabsKey}
  528. name={this.state.modalName}
  529. closeDesc={this.closeDesc}
  530. basicState={this.state.basicState}
  531. contactState={this.state.contactState}
  532. />
  533. <Modal
  534. maskClosable={false}
  535. className="customeDetails"
  536. title="指导意见"
  537. width='500px'
  538. visible={this.state.guidanceVisible}
  539. onOk={()=>{
  540. this.setState({
  541. guidanceVisible: false,
  542. guidance: '',
  543. },()=>{
  544. this.loadData(this.state.ispage);
  545. })
  546. }}
  547. onCancel={()=>{
  548. this.setState({
  549. guidanceVisible: false,
  550. guidance: '',
  551. },()=>{
  552. this.loadData(this.state.ispage);
  553. })
  554. }}
  555. footer=''
  556. >
  557. <Spin spinning={this.state.loading}>
  558. <div style={{
  559. display:'flex',
  560. flexFlow:'column',
  561. }}>
  562. <Input
  563. style={{ width: '400px',height:'50px' }}
  564. placeholder="请输入指导意见"
  565. type={'textarea'}
  566. onChange={(e)=>{
  567. this.setState({
  568. guidance: e.target.value,
  569. })
  570. }}
  571. />
  572. <Button
  573. type="primary"
  574. style={{ marginTop: "10px", marginBottom: '10px' }}
  575. onClick={()=>{
  576. this.releaseGuidance();
  577. }}
  578. >
  579. 确定
  580. </Button>
  581. </div>
  582. </Spin>
  583. </Modal>
  584. </div>
  585. )
  586. }
  587. }
  588. export default CustomerFollow;