queryCutomer.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. import React from 'react';
  2. import { Button,Modal,Input, Select, Spin, Table,Tabs, message, Form ,Tooltip} from 'antd';
  3. import $ from 'jquery/src/ajax';
  4. import {ShowModal} from '../../../../tools.js'
  5. import {provinceList } from '@/NewDicProvinceList';
  6. import ShowModalDiv from "@/showModal.jsx";
  7. import ZhuanjiaoDetail from "@/zhuanjiaoDetail.jsx";
  8. import Detaile from './detail.jsx';
  9. import {ChooseList} from "../../../order/orderNew/chooseList";
  10. import EnterpriseNameChange from "../../../../common/enterpriseNameChange";
  11. const confirm = Modal.confirm;
  12. const {TabPane} =Tabs
  13. const QueryCustomer = React.createClass({
  14. loadData(pageNo, apiUrl) {
  15. this.setState({
  16. visitModul: false,
  17. loading: true,
  18. modalVisible: false,
  19. });
  20. let api = apiUrl ? apiUrl : this.props.ApiUrl;
  21. $.ajax({
  22. method: "post",
  23. dataType: "json",
  24. crossDomain: false,
  25. url: globalConfig.context + api,
  26. data: {
  27. pageNo: pageNo || 1,
  28. pageSize: this.state.pagination.pageSize,
  29. name: this.state.nameSearch,
  30. departmentId: this.state.departmenttSearch,
  31. aid: this.state.theTypes,
  32. },
  33. success: function (data) {
  34. ShowModal(this);
  35. let theArr = [];
  36. if (data.error.length || data.data.list == "") {
  37. if (data.error && data.error.length) {
  38. message.warning(data.error[0].message);
  39. }
  40. } else {
  41. for (let i = 0; i < data.data.list.length; i++) {
  42. let thisdata = data.data.list[i];
  43. let diqu =
  44. (thisdata.province == null ? "" : thisdata.province) +
  45. (thisdata.city == null ? "" : "-" + thisdata.city) +
  46. (thisdata.area == null ? "" : "-" + thisdata.area);
  47. thisdata.key = i;
  48. thisdata.id = thisdata.uid;
  49. thisdata.createTime = thisdata.createTime && thisdata.createTime.split(" ")[0];
  50. thisdata.locationProvince = diqu;
  51. theArr.push(thisdata);
  52. }
  53. this.state.pagination.current = data.data.pageNo;
  54. this.state.pagination.total = data.data.totalCount;
  55. }
  56. if (data.data && data.data.list && !data.data.list.length) {
  57. this.state.pagination.current = 0;
  58. this.state.pagination.total = 0;
  59. }
  60. this.setState({
  61. dataSource: theArr,
  62. pagination: this.state.pagination,
  63. selectedRowKeys: [],
  64. ispage: data.data.pageNo,
  65. });
  66. }.bind(this),
  67. }).always(
  68. function () {
  69. this.setState({
  70. loading: false,
  71. });
  72. }.bind(this)
  73. );
  74. },
  75. //部门
  76. departmentList() {
  77. this.setState({
  78. loading: true,
  79. });
  80. $.ajax({
  81. method: "get",
  82. dataType: "json",
  83. crossDomain: false,
  84. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  85. data: {},
  86. success: function (data) {
  87. let thedata = data.data;
  88. let theArr = [];
  89. if (!thedata) {
  90. if (data.error && data.error.length) {
  91. message.warning(data.error[0].message);
  92. }
  93. thedata = {};
  94. } else {
  95. thedata.map(function (item, index) {
  96. theArr.push({
  97. key: index,
  98. name: item.name,
  99. id: item.id,
  100. });
  101. });
  102. }
  103. this.setState({
  104. departmentArr: theArr,
  105. });
  106. }.bind(this),
  107. }).always(
  108. function () {
  109. this.setState({
  110. loading: false,
  111. });
  112. }.bind(this)
  113. );
  114. },
  115. getInitialState() {
  116. return {
  117. addressSearch: [],
  118. dataSource: [],
  119. zhuanjiaoVisible: false,
  120. zhuanjiaoData: [],
  121. loading: false,
  122. departmentArr: [],
  123. selectedRowKeys: [],
  124. selectedRowKey: [],
  125. selectedRows: [],
  126. pagination: {
  127. defaultCurrent: 1,
  128. defaultPageSize: 10,
  129. showQuickJumper: true,
  130. pageSize: 10,
  131. onChange: function (page) {
  132. this.loadData(page);
  133. }.bind(this),
  134. showTotal: function (total) {
  135. return "共" + total + "条数据";
  136. },
  137. },
  138. columns: [
  139. {
  140. title: "客户名称",
  141. dataIndex: "name",
  142. key: "name",
  143. width: 350,
  144. render: (text, record) => {
  145. return (
  146. <span style={{display:'flex',alignItems: 'flex-start'}}>
  147. {record.channel=== 1 ? <div style={{
  148. whiteSpace:'nowrap',
  149. background:'#ef7207',
  150. color:'#FFF',
  151. padding: '1px 7px',
  152. borderRadius:'5px',
  153. fontSize:'12px',
  154. display: 'inline-block',
  155. marginRight:'10px'
  156. }}>
  157. 渠道
  158. </div> : null}
  159. <Tooltip title={text}>
  160. <div>{text}</div>
  161. </Tooltip>
  162. </span>
  163. )
  164. }
  165. },
  166. {
  167. title: "共享类型",
  168. dataIndex: "shareType",
  169. key: "shareType",
  170. //0-私有 1-公共 2 签单
  171. render: (text) => {
  172. return (
  173. text === '0' ? '私有':
  174. text === '1' ? '公共':
  175. text === '2' ? '签单': ''
  176. )
  177. }
  178. },
  179. {
  180. title: "地区",
  181. dataIndex: "locationProvince",
  182. key: "locationProvince",
  183. },
  184. {
  185. title: "创建时间",
  186. dataIndex: "createTime",
  187. key: "createTime",
  188. },
  189. {
  190. title: "客户所属人",
  191. dataIndex: "adminName",
  192. key: "adminName",
  193. },
  194. {
  195. title: "资料所属人",
  196. dataIndex: "informationMaintainer",
  197. key: "informationMaintainer",
  198. },
  199. {
  200. title: "操作",
  201. dataIndex: "abc",
  202. key: "abc",
  203. render: (text, record) => {
  204. return (
  205. <div>
  206. <Button
  207. disabled={record.signBills === 0}
  208. onClick={(e) => {
  209. e.stopPropagation(), this.seeDetail(record);
  210. }}
  211. type="primary"
  212. style={{ marginRight: 10 }}
  213. >
  214. {record.signBills === 0 ? '暂未签单' : '查看签单详情'}
  215. </Button>
  216. <Button
  217. onClick={(e) => {
  218. e.stopPropagation(), this.zhuanjiaoLog(record);
  219. }}
  220. type="primary"
  221. >
  222. 查看转交记录
  223. </Button>
  224. <EnterpriseNameChange
  225. type='journal'
  226. style={{ marginLeft: 10 }}
  227. enterpriseId={record.uid}/>
  228. {record.shareType === '1' &&
  229. <Button style={{ marginLeft: 10 }} onClick={(e) =>{
  230. e.stopPropagation();
  231. let _this = this;
  232. confirm({
  233. title: '提醒!',
  234. content: '确定要领取此客户吗?',
  235. onOk() {
  236. _this.receive(record);
  237. },
  238. onCancel() {},
  239. });
  240. }} type="primary">领取</Button>
  241. }
  242. </div>
  243. );
  244. },
  245. },
  246. ],
  247. };
  248. },
  249. receive(e) {
  250. this.setState({
  251. loading: true,
  252. });
  253. $.ajax({
  254. method: "get",
  255. dataType: "json",
  256. crossDomain: false,
  257. url: globalConfig.context + "/api/admin/customer/receiveCustomer",
  258. data: {
  259. uid: e.id,
  260. }
  261. }).done(function(data) {
  262. this.setState({
  263. loading: false,
  264. });
  265. if(data.error.length === 0) {
  266. message.success('领取成功!');
  267. this.loadData(this.state.ispage);
  268. } else {
  269. message.warning(data.error[0].message);
  270. };
  271. }.bind(this));
  272. },
  273. zhuanjiaoDetailCancel() {
  274. this.setState({
  275. zhuanjiaoVisible: false,
  276. });
  277. },
  278. zhuanjiaoLog(record) {
  279. this.setState({
  280. zhuanjiaoVisible: true,
  281. zhuanjiaoId: record.id,
  282. });
  283. },
  284. seeDetail(record) {
  285. this.setState({
  286. data: record,
  287. visitModul: true,
  288. });
  289. },
  290. closeDesc(e) {
  291. this.state.visitModul = e;
  292. },
  293. search() {
  294. this.loadData();
  295. },
  296. reset() {
  297. this.state.nameSearch = "";
  298. this.state.departmenttSearch = undefined;
  299. this.state.theTypes = "";
  300. this.state.auto = "";
  301. this.state.provinceSearch = undefined;
  302. this.state.addressSearch = [];
  303. this.loadData();
  304. },
  305. componentWillReceiveProps(nextProps) {
  306. if (nextProps.ApiUrl != this.props.ApiUrl) {
  307. this.state.nameSearch = "";
  308. this.state.provinceSearch = undefined;
  309. this.state.addressSearch = [];
  310. this.loadData(null, nextProps.ApiUrl);
  311. }
  312. },
  313. componentWillMount() {
  314. this.departmentList();
  315. //城市
  316. let Province = [];
  317. provinceList.map(function (item) {
  318. var id = String(item.id);
  319. Province.push(
  320. <Select.Option value={id} key={item.name}>
  321. {item.name}
  322. </Select.Option>
  323. );
  324. });
  325. this.state.Provinces = Province;
  326. this.loadData();
  327. },
  328. //指定转交人自动补全
  329. supervisor(e) {
  330. $.ajax({
  331. method: "get",
  332. dataType: "json",
  333. crossDomain: false,
  334. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  335. data: {
  336. adminName: e,
  337. },
  338. success: function (data) {
  339. let thedata = data.data;
  340. if (!thedata) {
  341. if (data.error && data.error.length) {
  342. message.warning(data.error[0].message);
  343. }
  344. thedata = {};
  345. }
  346. this.setState({
  347. customerArr: thedata,
  348. });
  349. }.bind(this),
  350. }).always(
  351. function () {
  352. this.setState({
  353. loading: false,
  354. });
  355. }.bind(this)
  356. );
  357. },
  358. //输入转交人输入框失去焦点是判断客户是否存在
  359. selectAuto(value, options) {
  360. this.setState({
  361. auto: value,
  362. });
  363. },
  364. blurChange(e) {
  365. let theType = "";
  366. let contactLists = this.state.customerArr || [];
  367. if (e) {
  368. contactLists.map(function (item) {
  369. if (item.name == e.toString()) {
  370. theType = item.id;
  371. }
  372. });
  373. }
  374. this.setState({
  375. theTypes: theType,
  376. });
  377. },
  378. //值改变时请求客户名称
  379. httpChange(e) {
  380. if (e.length >= 1) {
  381. this.supervisor(e);
  382. }
  383. this.setState({
  384. auto: e,
  385. });
  386. },
  387. changeList(arr) {
  388. const newArr = [];
  389. this.state.columns.forEach(item => {
  390. arr.forEach(val => {
  391. if (val === item.title) {
  392. newArr.push(item);
  393. }
  394. });
  395. });
  396. this.setState({
  397. changeList: newArr
  398. });
  399. },
  400. render() {
  401. let departmentArr = this.state.departmentArr || [];
  402. const intentionState = this.props.intentionState;
  403. const FormItem = Form.Item;
  404. const rowSelection = {
  405. selectedRowKeys: this.state.selectedRowKeys,
  406. onChange: (selectedRowKeys, selectedRows) => {
  407. this.setState({
  408. modalVisible: false,
  409. selectedRows: selectedRows.slice(-1),
  410. selectedRowKeys: selectedRowKeys.slice(-1),
  411. });
  412. },
  413. onSelect: (recordt, selected, selectedRows) => {
  414. this.setState({
  415. modalVisible: false,
  416. recordt: recordt.id,
  417. });
  418. },
  419. };
  420. const dataSources = this.state.customerArr || [];
  421. const options = dataSources.map((group) => (
  422. <Select.Option key={group.id} value={group.name}>
  423. {group.name}
  424. </Select.Option>
  425. ));
  426. const hasSelected = this.state.selectedRowKeys.length > 0;
  427. return (
  428. <div className="user-content">
  429. <ShowModalDiv ShowModal={this.state.showModal} />
  430. <div className="content-title">
  431. <span>{!intentionState ? "单位客户查询" : "个人客户查询"}</span>
  432. </div>
  433. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  434. <TabPane tab="搜索" key="1">
  435. <div className="user-search">
  436. <Input
  437. placeholder="请输入精确客户全称"
  438. value={this.state.nameSearch}
  439. onChange={(e) => {
  440. this.setState({ nameSearch: e.target.value });
  441. }}
  442. />
  443. {/* <Select placeholder="选择部门"
  444. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  445. value={this.state.departmenttSearch}
  446. onChange={(e) => { this.setState({ departmenttSearch: e }) }}>
  447. {
  448. departmentArr.map(function (item) {
  449. return <Select.Option key={item.id} >{item.name}</Select.Option>
  450. })
  451. }
  452. </Select> */}
  453. {/* <AutoComplete
  454. className="certain-category-search"
  455. dropdownClassName="certain-category-search-dropdown"
  456. dropdownMatchSelectWidth={false}
  457. dropdownStyle={{ width: 120 }}
  458. style={{ width: '120px'}}
  459. dataSource={options}
  460. placeholder="客户所有人姓名"
  461. value={this.state.auto}
  462. onChange={this.httpChange}
  463. filterOption={true}
  464. onBlur={this.blurChange}
  465. onSelect={this.selectAuto}
  466. >
  467. <Input />
  468. </AutoComplete> */}
  469. <Button type="primary" onClick={this.search}>
  470. 搜索
  471. </Button>
  472. <Button onClick={this.reset}>重置</Button>
  473. </div>
  474. </TabPane>
  475. <TabPane tab="更改表格显示数据" key="2">
  476. <div style={{ marginLeft: 10 }}>
  477. <ChooseList
  478. columns={this.state.columns}
  479. changeFn={this.changeList}
  480. changeList={this.state.changeList}
  481. top={55}
  482. margin={11}
  483. />
  484. </div>
  485. </TabPane>
  486. </Tabs>
  487. <div className="patent-table">
  488. <Spin spinning={this.state.loading}>
  489. <Table
  490. size="middle"
  491. columns={
  492. this.state.changeList
  493. ? this.state.changeList
  494. : this.state.columns
  495. }
  496. dataSource={this.state.dataSource}
  497. rowSelection={rowSelection}
  498. pagination={this.state.pagination}
  499. />
  500. </Spin>
  501. </div>
  502. <Detaile
  503. visitModul={this.state.visitModul}
  504. data={this.state.data}
  505. detailApi={this.props.detailApi}
  506. closeDesc={this.closeDesc}
  507. />
  508. {this.state.zhuanjiaoVisible ? (
  509. <ZhuanjiaoDetail
  510. cancel={this.zhuanjiaoDetailCancel}
  511. visible={this.state.zhuanjiaoVisible}
  512. id={this.state.zhuanjiaoId}
  513. />
  514. ) : (
  515. ""
  516. )}
  517. </div>
  518. );
  519. },
  520. });
  521. export default QueryCustomer;