queryCutomer.jsx 16 KB

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