queryCutomer.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  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: "orgCode",
  173. key: "orgCode",
  174. },
  175. {
  176. title: "共享类型",
  177. dataIndex: "shareType",
  178. key: "shareType",
  179. //0-私有 1-公共 2 签单
  180. render: (text, record) => {
  181. return (
  182. <span>
  183. {
  184. text === '0' ? '私有' :
  185. text === '1' ? '公共' :
  186. text === '2' ? '签单' : ''
  187. }
  188. {
  189. record.newChannel == "1"
  190. ? "渠道" : ""
  191. }
  192. </span>
  193. )
  194. }
  195. },
  196. {
  197. title: "地区",
  198. dataIndex: "locationProvince",
  199. key: "locationProvince",
  200. },
  201. {
  202. title: "创建时间",
  203. dataIndex: "createTime",
  204. key: "createTime",
  205. width: 80,
  206. },
  207. {
  208. title: "客户所属人",
  209. dataIndex: "adminName",
  210. key: "adminName",
  211. },
  212. {
  213. title: "资料所属人",
  214. dataIndex: "informationMaintainer",
  215. key: "informationMaintainer",
  216. },
  217. {
  218. title: "操作",
  219. dataIndex: "abc",
  220. key: "abc",
  221. render: (text, record) => {
  222. return (
  223. <div>
  224. <Button
  225. disabled={record.signBills === 0}
  226. onClick={(e) => {
  227. e.stopPropagation(), this.seeDetail(record);
  228. }}
  229. // type="primary"
  230. style={{ marginRight: 10, color: "#fff", background: record.signBills === 0 ? "#58A3FF" : "green" }}
  231. >
  232. {record.signBills === 0 ? '暂未签单' : '已签,查看详细'}
  233. </Button>
  234. <Button
  235. onClick={(e) => {
  236. e.stopPropagation(), this.zhuanjiaoLog(record);
  237. }}
  238. type="primary"
  239. >
  240. 查看转交记录
  241. </Button>
  242. <EnterpriseNameChange
  243. type='journal'
  244. style={{ marginLeft: 10 }}
  245. enterpriseId={record.uid} />
  246. {record.shareType === '1' &&
  247. <Button style={{ marginLeft: 10 }} onClick={(e) => {
  248. e.stopPropagation();
  249. let _this = this;
  250. confirm({
  251. title: '提醒!',
  252. content: '确定要领取此客户吗?',
  253. onOk() {
  254. _this.receive(record);
  255. },
  256. onCancel() { },
  257. });
  258. }} type="primary">领取</Button>
  259. }
  260. </div>
  261. );
  262. },
  263. },
  264. ],
  265. };
  266. },
  267. //
  268. receive(e) {
  269. this.setState({
  270. loading: true,
  271. });
  272. $.ajax({
  273. method: "get",
  274. dataType: "json",
  275. crossDomain: false,
  276. url: globalConfig.context + "/api/admin/customer/receiveCustomer",
  277. data: {
  278. uid: e.id,
  279. }
  280. }).done(function (data) {
  281. this.setState({
  282. loading: false,
  283. });
  284. if (data.error.length === 0) {
  285. message.success('领取成功!');
  286. this.loadData(this.state.ispage);
  287. } else {
  288. message.warning(data.error[0].message);
  289. };
  290. }.bind(this));
  291. },
  292. //
  293. zhuanjiaoDetailCancel() {
  294. this.setState({
  295. zhuanjiaoVisible: false,
  296. });
  297. },
  298. //
  299. zhuanjiaoLog(record) {
  300. this.setState({
  301. zhuanjiaoVisible: true,
  302. zhuanjiaoId: record.id,
  303. });
  304. },
  305. //
  306. seeDetail(record) {
  307. this.setState({
  308. data: record,
  309. visitModul: true,
  310. });
  311. },
  312. //
  313. closeDesc(e) {
  314. this.state.visitModul = e;
  315. },
  316. //
  317. search() {
  318. this.loadData();
  319. },
  320. //
  321. reset() {
  322. this.setState({
  323. nameSearch: undefined,
  324. departmenttSearch: undefined,
  325. theTypes: undefined,
  326. auto: undefined,
  327. provinceSearch: undefined,
  328. addressSearch: [],
  329. dataSource: []
  330. })
  331. // this.loadData();
  332. },
  333. componentWillReceiveProps(nextProps) {
  334. if (nextProps.ApiUrl != this.props.ApiUrl) {
  335. this.state.nameSearch = "";
  336. this.state.provinceSearch = undefined;
  337. this.state.addressSearch = [];
  338. this.loadData(null, nextProps.ApiUrl);
  339. }
  340. },
  341. componentWillMount() {
  342. // this.departmentList();
  343. //城市
  344. let Province = [];
  345. provinceList.map(function (item) {
  346. var id = String(item.id);
  347. Province.push(
  348. <Select.Option value={id} key={item.name}>
  349. {item.name}
  350. </Select.Option>
  351. );
  352. });
  353. this.state.Provinces = Province;
  354. this.loadData();
  355. },
  356. //指定转交人自动补全
  357. supervisor(e) {
  358. $.ajax({
  359. method: "get",
  360. dataType: "json",
  361. crossDomain: false,
  362. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  363. data: {
  364. adminName: e,
  365. },
  366. success: function (data) {
  367. let thedata = data.data;
  368. if (!thedata) {
  369. if (data.error && data.error.length) {
  370. message.warning(data.error[0].message);
  371. }
  372. thedata = {};
  373. }
  374. this.setState({
  375. customerArr: thedata,
  376. });
  377. }.bind(this),
  378. }).always(
  379. function () {
  380. this.setState({
  381. loading: false,
  382. });
  383. }.bind(this)
  384. );
  385. },
  386. //输入转交人输入框失去焦点是判断客户是否存在
  387. selectAuto(value, options) {
  388. this.setState({
  389. auto: value,
  390. });
  391. },
  392. blurChange(e) {
  393. let theType = "";
  394. let contactLists = this.state.customerArr || [];
  395. if (e) {
  396. contactLists.map(function (item) {
  397. if (item.name == e.toString()) {
  398. theType = item.id;
  399. }
  400. });
  401. }
  402. this.setState({
  403. theTypes: theType,
  404. });
  405. },
  406. //值改变时请求客户名称
  407. httpChange(e) {
  408. if (e.length >= 1) {
  409. this.supervisor(e);
  410. }
  411. this.setState({
  412. auto: e,
  413. });
  414. },
  415. changeList(arr) {
  416. const newArr = [];
  417. this.state.columns.forEach(item => {
  418. arr.forEach(val => {
  419. if (val === item.title) {
  420. newArr.push(item);
  421. }
  422. });
  423. });
  424. this.setState({
  425. changeList: newArr
  426. });
  427. },
  428. render() {
  429. let departmentArr = this.state.departmentArr || [];
  430. const intentionState = this.props.intentionState;
  431. const FormItem = Form.Item;
  432. const rowSelection = {
  433. selectedRowKeys: this.state.selectedRowKeys,
  434. onChange: (selectedRowKeys, selectedRows) => {
  435. this.setState({
  436. modalVisible: false,
  437. selectedRows: selectedRows.slice(-1),
  438. selectedRowKeys: selectedRowKeys.slice(-1),
  439. });
  440. },
  441. onSelect: (recordt, selected, selectedRows) => {
  442. this.setState({
  443. modalVisible: false,
  444. recordt: recordt.id,
  445. });
  446. },
  447. };
  448. const dataSources = this.state.customerArr || [];
  449. const options = dataSources.map((group) => (
  450. <Select.Option key={group.id} value={group.name}>
  451. {group.name}
  452. </Select.Option>
  453. ));
  454. const hasSelected = this.state.selectedRowKeys.length > 0;
  455. return (
  456. <div className="user-content">
  457. <ShowModalDiv ShowModal={this.state.showModal} />
  458. <div className="content-title" style={{ marginBottom: 10 }}>
  459. <span style={{ fontWeight: 900, fontSize: 16 }}>{!intentionState ? "单位客户查询" : "个人客户查询"}</span>
  460. </div>
  461. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  462. <TabPane tab="搜索" key="1">
  463. <div className="user-search">
  464. <Input
  465. style={{ width: 240 }}
  466. placeholder="请输入精确客户全称或统一社会信用代码"
  467. value={this.state.nameSearch}
  468. onChange={(e) => {
  469. this.setState({ nameSearch: e.target.value });
  470. }}
  471. />
  472. {/* <Select placeholder="选择部门"
  473. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  474. value={this.state.departmenttSearch}
  475. onChange={(e) => { this.setState({ departmenttSearch: e }) }}>
  476. {
  477. departmentArr.map(function (item) {
  478. return <Select.Option key={item.id} >{item.name}</Select.Option>
  479. })
  480. }
  481. </Select> */}
  482. {/* <AutoComplete
  483. className="certain-category-search"
  484. dropdownClassName="certain-category-search-dropdown"
  485. dropdownMatchSelectWidth={false}
  486. dropdownStyle={{ width: 120 }}
  487. style={{ width: '120px'}}
  488. dataSource={options}
  489. placeholder="客户所有人姓名"
  490. value={this.state.auto}
  491. onChange={this.httpChange}
  492. filterOption={true}
  493. onBlur={this.blurChange}
  494. onSelect={this.selectAuto}
  495. >
  496. <Input />
  497. </AutoComplete> */}
  498. <Button type="primary" onClick={this.search}>
  499. 搜索
  500. </Button>
  501. <Button onClick={this.reset}>重置</Button>
  502. </div>
  503. </TabPane>
  504. <TabPane tab="更改表格显示数据" key="2">
  505. <div style={{ marginLeft: 10 }}>
  506. <ChooseList
  507. columns={this.state.columns}
  508. changeFn={this.changeList}
  509. changeList={this.state.changeList}
  510. top={55}
  511. margin={11}
  512. />
  513. </div>
  514. </TabPane>
  515. </Tabs>
  516. <div className="patent-table">
  517. <Spin spinning={this.state.loading}>
  518. <Table
  519. size="middle"
  520. columns={
  521. this.state.changeList
  522. ? this.state.changeList
  523. : this.state.columns
  524. }
  525. dataSource={this.state.dataSource}
  526. rowSelection={rowSelection}
  527. pagination={this.state.pagination}
  528. />
  529. </Spin>
  530. </div>
  531. <Detaile
  532. visitModul={this.state.visitModul}
  533. data={this.state.data}
  534. detailApi={this.props.detailApi}
  535. closeDesc={this.closeDesc}
  536. />
  537. {this.state.zhuanjiaoVisible ? (
  538. <ZhuanjiaoDetail
  539. cancel={this.zhuanjiaoDetailCancel}
  540. visible={this.state.zhuanjiaoVisible}
  541. id={this.state.zhuanjiaoId}
  542. />
  543. ) : (
  544. ""
  545. )}
  546. </div>
  547. );
  548. },
  549. });
  550. export default QueryCustomer;