queryCutomer.jsx 15 KB

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