queryCutomer.jsx 15 KB

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