index.jsx 20 KB

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