index.jsx 20 KB

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