index.jsx 23 KB

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