signCustomer.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. import React from 'react';
  2. import { Radio, Icon, Button, AutoComplete,Cascader,Input, Select,Tabs, Spin, Popconfirm, Table, Switch, message, DatePicker, Upload, Form } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import moment from 'moment';
  6. import { citySelect, provinceList } from '@/NewDicProvinceList';
  7. import { socialAttribute, industry, auditStatusL, lvl, currentMember } from '@/dataDic.js';
  8. import { getSocialAttribute, beforeUploadFile, ShowModal } from "@/tools.js";
  9. import FollowDetail from './followDetail.jsx'
  10. import ShowModalDiv from "@/showModal.jsx";
  11. import ZhuanjiaoDetail from "@/zhuanjiaoDetail.jsx";
  12. import IntentionDetail from './intentionDetail/intentionDetail.jsx'
  13. import './customer.less';
  14. import {ChooseList} from "../../../order/orderNew/chooseList";
  15. const {TabPane} = Tabs
  16. const IntentionCustomer = Form.create()(React.createClass({
  17. loadData(pageNo, apiUrl) {
  18. this.setState({
  19. visitModul:false,
  20. loading: true,
  21. ispage:pageNo,
  22. modalVisible:false
  23. });
  24. let api=apiUrl?apiUrl:this.props.ApiUrl;
  25. $.ajax({
  26. method: "post",
  27. dataType: "json",
  28. crossDomain: false,
  29. url: globalConfig.context + api,
  30. data: {
  31. pageNo: pageNo || 1,
  32. pageSize: this.state.pagination.pageSize,
  33. name: this.state.nameSearch,
  34. province: !(this.state.addressSearch).length ? this.state.provinceSearch : this.state.addressSearch[0],
  35. city: !(this.state.addressSearch).length ? '' : this.state.addressSearch[1],
  36. startDate: this.state.releaseDate[0],
  37. endDate: this.state.releaseDate[1],
  38. },
  39. success: function(data) {
  40. ShowModal(this);
  41. let theArr = [];
  42. if(data.error.length || data.data.list == "") {
  43. if(data.error && data.error.length) {
  44. message.warning(data.error[0].message);
  45. };
  46. } else {
  47. for(let i = 0; i < data.data.list.length; i++) {
  48. let thisdata = data.data.list[i];
  49. let diqu=(thisdata.province==null?"":thisdata.province)+(thisdata.city==null?"":"-"+thisdata.city)+(thisdata.area==null?"":"-"+thisdata.area);
  50. theArr.push({
  51. key: i,
  52. id: thisdata.uid,
  53. type: thisdata.type,
  54. name: thisdata.name,
  55. shareType: thisdata.shareType,
  56. contacts: thisdata.contacts,
  57. contactMobile: thisdata.contactMobile,
  58. societyTag: thisdata.societyTag,
  59. surplusFollowTime: thisdata.surplusFollowTime,
  60. surplusSignTime: thisdata.surplusSignTime,
  61. transferTime:
  62. thisdata.transferTime && thisdata.transferTime.split(" ")[0],
  63. lastSignTime:
  64. thisdata.lastSignTime && thisdata.lastSignTime.split(" ")[0],
  65. lastFollowTime:
  66. thisdata.lastFollowTime &&
  67. thisdata.lastFollowTime.split(" ")[0],
  68. locationProvince: diqu,
  69. });
  70. };
  71. this.state.pagination.current = data.data.pageNo;
  72. this.state.pagination.total = data.data.totalCount;
  73. };
  74. if(data.data&&data.data.list&&!data.data.list.length){
  75. this.state.pagination.current=0
  76. this.state.pagination.total=0
  77. };
  78. this.setState({
  79. dataSource: theArr,
  80. pagination: this.state.pagination,
  81. selectedRowKeys:[]
  82. });
  83. }.bind(this),
  84. }).always(function() {
  85. this.setState({
  86. loading: false
  87. });
  88. }.bind(this));
  89. },
  90. getInitialState() {
  91. return {
  92. addressSearch: [],
  93. orgCodeUrl: [],
  94. companyLogoUrl: [],
  95. visible: false,
  96. searchMore: true,
  97. releaseDate: [],
  98. visitModul: false,
  99. keys: false,
  100. detailApi: "",
  101. followData: {},
  102. selectedRowKeys: [],
  103. selectedRowKey: [],
  104. selectedRows: [],
  105. loading: false,
  106. modalVisible: false,
  107. pagination: {
  108. defaultCurrent: 1,
  109. defaultPageSize: 10,
  110. showQuickJumper: true,
  111. pageSize: 10,
  112. onChange: function (page) {
  113. this.loadData(page);
  114. }.bind(this),
  115. showTotal: function (total) {
  116. return "共" + total + "条数据";
  117. },
  118. },
  119. columns: [
  120. {
  121. title: "客户名称",
  122. dataIndex: "name",
  123. key: "name",
  124. },
  125. {
  126. title: "地区",
  127. dataIndex: "locationProvince",
  128. key: "locationProvince",
  129. },
  130. {
  131. title: "最新签单日期",
  132. dataIndex: "transferTime",
  133. key: "transferTime",
  134. },
  135. // {
  136. // title: "最新跟进日期",
  137. // dataIndex: "lastFollowTime",
  138. // key: "lastFollowTime",
  139. // },
  140. // {
  141. // title: "剩余私有天数",
  142. // dataIndex: "surplusFollowTime",
  143. // key: "surplusFollowTime",
  144. // },
  145. // {
  146. // title: "剩余签单天数",
  147. // dataIndex: "surplusSignTime",
  148. // key: "surplusSignTime",
  149. // },
  150. // {
  151. // title: "联系人",
  152. // dataIndex: "contacts",
  153. // key: "contacts",
  154. // },
  155. // {
  156. // title: "联系电话",
  157. // dataIndex: "contactMobile",
  158. // key: "contactMobile",
  159. // },
  160. {
  161. title: "社会属性",
  162. dataIndex: "societyTag",
  163. key: "societyTag",
  164. render: (text) => {
  165. return getSocialAttribute(text);
  166. },
  167. },
  168. {
  169. title: "操作",
  170. dataIndex: "abc",
  171. key: "abc",
  172. render: (text, record, index) => {
  173. return (
  174. <div>
  175. <Button
  176. onClick={(e) => {
  177. e.stopPropagation(), this.visit(record);
  178. }}
  179. type="primary"
  180. >
  181. 客户跟进
  182. </Button>
  183. <Button
  184. style={{ marginLeft: 10 }}
  185. onClick={(e) => {
  186. e.stopPropagation(), this.zhuanjiaoDetail(record);
  187. }}
  188. type="primary"
  189. >
  190. 转交记录
  191. </Button>
  192. </div>
  193. );
  194. },
  195. },
  196. ],
  197. data: [],
  198. dataSource: [],
  199. };
  200. },
  201. zhuanjiaoDetail(record) {
  202. this.setState({
  203. zhuanjiaoVisible: true,
  204. zhuanjiaoId: record.id
  205. })
  206. },
  207. zhuanjiaoDetailCancel() {
  208. this.setState({
  209. zhuanjiaoVisible: false
  210. })
  211. },
  212. //进入新增拜访记录
  213. visit(e) {
  214. this.setState({
  215. followData:e,
  216. visitModul:true,
  217. modalVisible:false
  218. })
  219. },
  220. //列表删除功能
  221. delectRow() {
  222. let deletedIds;
  223. for(let idx = 0; idx < this.state.selectedRows.length; idx++) {
  224. let rowItem = this.state.selectedRows[idx];
  225. if(rowItem.id) {
  226. deletedIds = rowItem.id;
  227. };
  228. };
  229. this.setState({
  230. loading: true,
  231. selectedRowKeys: [],
  232. });
  233. $.ajax({
  234. method: "get",
  235. dataType: "json",
  236. crossDomain: false,
  237. url: globalConfig.context + "/api/admin/customer/deleteCustomer",
  238. data: {
  239. uid: deletedIds, //删除的ID
  240. }
  241. }).done(function(data) {
  242. if(!data.error.length) {
  243. message.success('删除成功!');
  244. this.setState({
  245. loading: false,
  246. });
  247. } else {
  248. message.warning(data.error[0].message);
  249. };
  250. this.loadData(this.state.ispage);
  251. }.bind(this));
  252. },
  253. componentWillMount() {
  254. //城市
  255. let Province = [];
  256. provinceList.map(function(item) {
  257. var id = String(item.id)
  258. Province.push(
  259. <Select.Option value={id} key={item.name}>{item.name}</Select.Option>
  260. )
  261. });
  262. //行业
  263. let intentionalArr = [];
  264. industry.map(function(item) {
  265. intentionalArr.push(
  266. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  267. )
  268. });
  269. this.state.Provinces = Province;
  270. this.state.intentionalOption = intentionalArr;
  271. this.loadData();
  272. },
  273. closeDesc(e, s) {
  274. this.state.basicState=e
  275. this.state.visitModul=e;
  276. this.state.modalVisible=e;
  277. this.state.showDesc = e;
  278. if(s) {
  279. this.loadData(this.state.ispage);
  280. };
  281. },
  282. search() {
  283. this.loadData();
  284. },
  285. reset() {
  286. this.state.nameSearch = '';
  287. this.state.addressSearch = [];
  288. this.state.provinceSearch = undefined;
  289. this.state.citySearch = undefined;
  290. this.state.releaseDate[0] = undefined;
  291. this.state.releaseDate[1] = undefined;
  292. this.loadData();
  293. },
  294. searchSwitch() {
  295. this.setState({
  296. visitModul:false,
  297. searchMore: !this.state.searchMore
  298. });
  299. },
  300. //整行点击
  301. tableRowClick(record, index) {
  302. this.state.visitModul=false;
  303. this.state.RowData = record;
  304. this.setState({
  305. selectedRowKeys: [],
  306. modalVisible:true,
  307. basicState:true,
  308. contactState:true,
  309. modalName: record.name
  310. })
  311. },
  312. //指定转交人自动补全
  313. supervisor(e){
  314. $.ajax({
  315. method: "get",
  316. dataType: "json",
  317. crossDomain: false,
  318. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  319. data:{
  320. adminName:e
  321. },
  322. success: function (data) {
  323. let thedata=data.data;
  324. if (!thedata) {
  325. if (data.error && data.error.length) {
  326. message.warning(data.error[0].message);
  327. };
  328. thedata = {};
  329. };
  330. this.setState({
  331. customerArr:thedata,
  332. });
  333. }.bind(this),
  334. }).always(function () {
  335. this.setState({
  336. loading: false
  337. });
  338. }.bind(this));
  339. },
  340. componentWillReceiveProps(nextProps) {
  341. if(nextProps.ApiUrl!=this.props.ApiUrl) {
  342. if(!this.state.searchMore){
  343. this.state.searchMore=true
  344. }
  345. this.state.nameSearch = '';
  346. this.state.addressSearch = [];
  347. this.state.provinceSearch = undefined;
  348. this.state.citySearch = undefined;
  349. this.state.releaseDate[0] = undefined;
  350. this.state.releaseDate[1] = undefined;
  351. this.loadData(null,nextProps.ApiUrl);
  352. };
  353. },
  354. changeList(arr) {
  355. const newArr = [];
  356. this.state.columns.forEach(item => {
  357. arr.forEach(val => {
  358. if (val === item.title) {
  359. newArr.push(item);
  360. }
  361. });
  362. });
  363. this.setState({
  364. changeList: newArr
  365. });
  366. },
  367. render() {
  368. const FormItem = Form.Item;
  369. const rowSelection = {
  370. selectedRowKeys: this.state.selectedRowKeys,
  371. onChange: (selectedRowKeys, selectedRows) => {
  372. this.setState({
  373. modalVisible:false,
  374. selectedRows: selectedRows.slice(-1),
  375. selectedRowKeys: selectedRowKeys.slice(-1)
  376. });
  377. },
  378. onSelect: (recordt, selected, selectedRows) => {
  379. this.setState({
  380. modalVisible:false,
  381. recordt: recordt.id
  382. })
  383. },
  384. };
  385. const hasSelected = this.state.selectedRowKeys.length > 0;
  386. const { RangePicker } = DatePicker;
  387. const dataSources=this.state.customerArr || [];
  388. const options = dataSources.map((group) =>
  389. <Select.Option key={group.id} value={group.name}>{group.name}</Select.Option>
  390. )
  391. const intentionState = this.props.intentionState ||'';
  392. return (
  393. <div className="user-content">
  394. <ShowModalDiv ShowModal={this.state.showModal} />
  395. {this.state.zhuanjiaoVisible ? (
  396. <ZhuanjiaoDetail
  397. cancel={this.zhuanjiaoDetailCancel}
  398. visible={this.state.zhuanjiaoVisible}
  399. type={1}
  400. id={this.state.zhuanjiaoId}
  401. />
  402. ) : (
  403. ""
  404. )}
  405. <div className="content-title">
  406. <span>{!intentionState ? "签单客户" : "签单客户"}</span>
  407. </div>
  408. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  409. <TabPane tab="搜索" key="1">
  410. <div className="user-search">
  411. <Input
  412. placeholder="客户名称"
  413. value={this.state.nameSearch}
  414. onChange={(e) => {
  415. this.setState({ nameSearch: e.target.value });
  416. }}
  417. />
  418. <Select
  419. placeholder="省"
  420. style={{ width: 80 }}
  421. value={this.state.provinceSearch}
  422. onChange={(e) => {
  423. this.setState({ provinceSearch: e });
  424. }}
  425. >
  426. {this.state.Provinces}
  427. </Select>
  428. <span style={{ marginRight: "10px" }}>
  429. <Cascader
  430. options={citySelect()}
  431. value={this.state.addressSearch}
  432. placeholder="选择城市"
  433. onChange={(e, pre) => {
  434. this.setState({ addressSearch: e });
  435. }}
  436. />
  437. </span>
  438. {/* <div className="clearfix" style={{ marginTop: "5px" }}>
  439. <div
  440. className="search-more"
  441. style={this.state.searchMore ? { display: "none" } : {}}
  442. > */}
  443. <span>签单时间:</span>
  444. <RangePicker
  445. value={[
  446. this.state.releaseDate[0]
  447. ? moment(this.state.releaseDate[0])
  448. : null,
  449. this.state.releaseDate[1]
  450. ? moment(this.state.releaseDate[1])
  451. : null,
  452. ]}
  453. onChange={(data, dataString) => {
  454. this.setState({ releaseDate: dataString });
  455. }}
  456. />
  457. {/* </div>
  458. </div> */}
  459. <Button
  460. type="primary"
  461. onClick={this.search}
  462. style={{ marginLeft: 10 }}
  463. >
  464. 搜索
  465. </Button>
  466. <Button onClick={this.reset}>重置</Button>
  467. {/* {adminData.isSuperAdmin?<Popconfirm title="是否删除?" onConfirm={this.delectRow} okText="是" cancelText="否">
  468. <Button type="danger" style={{marginLeft:'10px'}}
  469. disabled={!hasSelected}
  470. >删除<Icon type="minus" />
  471. </Button>
  472. </Popconfirm>:''
  473. }*/}
  474. {/* <span style={{ marginLeft: "10px", marginRight: "20px" }}>
  475. 更多搜索
  476. <Switch
  477. checked={!this.state.searchMore}
  478. onChange={this.searchSwitch}
  479. />
  480. </span> */}
  481. </div>
  482. </TabPane>
  483. <TabPane tab="更改表格显示数据" key="2">
  484. <div style={{ marginLeft: 10 }}>
  485. <ChooseList
  486. columns={this.state.columns}
  487. changeFn={this.changeList}
  488. changeList={this.state.changeList}
  489. top={55}
  490. margin={11}
  491. />
  492. </div>
  493. </TabPane>
  494. </Tabs>
  495. <div className="patent-table">
  496. <Spin spinning={this.state.loading}>
  497. <Table
  498. size="middle"
  499. columns={
  500. this.state.changeList
  501. ? this.state.changeList
  502. : this.state.columns
  503. }
  504. dataSource={this.state.dataSource}
  505. rowSelection={rowSelection}
  506. pagination={this.state.pagination}
  507. onRowClick={this.tableRowClick}
  508. />
  509. </Spin>
  510. </div>
  511. <FollowDetail
  512. followData={this.state.followData}
  513. visitModul={this.state.visitModul}
  514. closeDesc={this.closeDesc}
  515. loadData={this.loadData}
  516. />
  517. <IntentionDetail
  518. detailApi={this.props.detailApi}
  519. IntentionData={this.state.RowData}
  520. loadData={this.loadData}
  521. modalVisible={this.state.modalVisible}
  522. name={this.state.modalName}
  523. closeDesc={this.closeDesc}
  524. basicState={this.state.basicState}
  525. contactState={this.state.contactState}
  526. />
  527. </div>
  528. );
  529. }
  530. }));
  531. export default IntentionCustomer;