signCustomer.jsx 15 KB

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