queryCutomer.jsx 16 KB

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