queryCutomer.jsx 15 KB

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