queryCutomer.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. import React from 'react';
  2. import { Button,Cascader,Input, Select, Spin, Table,Tabs, message, Form ,Tooltip} from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import {ShowModal} from '../../../../tools.js'
  6. import { citySelect, provinceList } from '@/NewDicProvinceList';
  7. import ShowModalDiv from "@/showModal.jsx";
  8. import ZhuanjiaoDetail from "@/zhuanjiaoDetail.jsx";
  9. import Detaile from './detail.jsx';
  10. import {ChooseList} from "../../../order/orderNew/chooseList";
  11. import EnterpriseNameChange from "../../../../common/enterpriseNameChange";
  12. const {TabPane} =Tabs
  13. const QueryCustomer = React.createClass({
  14. loadData(pageNo, apiUrl) {
  15. this.setState({
  16. visitModul: false,
  17. loading: true,
  18. ispage: pageNo,
  19. modalVisible: false,
  20. });
  21. let api = apiUrl ? apiUrl : this.props.ApiUrl;
  22. $.ajax({
  23. method: "post",
  24. dataType: "json",
  25. crossDomain: false,
  26. url: globalConfig.context + api,
  27. data: {
  28. pageNo: pageNo || 1,
  29. pageSize: this.state.pagination.pageSize,
  30. name: this.state.nameSearch,
  31. departmentId: this.state.departmenttSearch,
  32. aid: this.state.theTypes,
  33. },
  34. success: function (data) {
  35. ShowModal(this);
  36. let theArr = [];
  37. if (data.error.length || data.data.list == "") {
  38. if (data.error && data.error.length) {
  39. message.warning(data.error[0].message);
  40. }
  41. } else {
  42. for (let i = 0; i < data.data.list.length; i++) {
  43. let thisdata = data.data.list[i];
  44. let diqu =
  45. (thisdata.province == null ? "" : thisdata.province) +
  46. (thisdata.city == null ? "" : "-" + thisdata.city) +
  47. (thisdata.area == null ? "" : "-" + thisdata.area);
  48. thisdata.key = i;
  49. thisdata.id = thisdata.uid;
  50. thisdata.createTime = thisdata.createTime && thisdata.createTime.split(" ")[0];
  51. thisdata.locationProvince = diqu;
  52. theArr.push(thisdata);
  53. }
  54. this.state.pagination.current = data.data.pageNo;
  55. this.state.pagination.total = data.data.totalCount;
  56. }
  57. if (data.data && data.data.list && !data.data.list.length) {
  58. this.state.pagination.current = 0;
  59. this.state.pagination.total = 0;
  60. }
  61. this.setState({
  62. dataSource: theArr,
  63. pagination: this.state.pagination,
  64. selectedRowKeys: [],
  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: 150,
  144. render: (text, record, index) => {
  145. return (
  146. <span>
  147. {record.channel=== 1 ? <div style={{
  148. background:'#ef7207',
  149. color:'#FFF',
  150. padding: '1px 7px',
  151. borderRadius:'5px',
  152. fontSize:'12px',
  153. display: 'inline-block',
  154. marginRight:'10px'
  155. }}>
  156. 渠道
  157. </div> : null}
  158. <Tooltip title={text}>
  159. <div style={{
  160. maxWidth:'120px',
  161. overflow:'hidden',
  162. textOverflow: "ellipsis",
  163. whiteSpace:'nowrap',
  164. }}>{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. },
  193. {
  194. title: "客户所属人",
  195. dataIndex: "adminName",
  196. key: "adminName",
  197. },
  198. {
  199. title: "资料所属人",
  200. dataIndex: "informationMaintainer",
  201. key: "informationMaintainer",
  202. },
  203. {
  204. title: "操作",
  205. dataIndex: "abc",
  206. key: "abc",
  207. render: (text, record, index) => {
  208. return (
  209. <div>
  210. <Button
  211. disabled={record.signBills === 0}
  212. onClick={(e) => {
  213. e.stopPropagation(), this.seeDetail(record);
  214. }}
  215. type="primary"
  216. style={{ marginRight: 10 }}
  217. >
  218. {record.signBills === 0 ? '暂未签单' : '查看签单详情'}
  219. </Button>
  220. <Button
  221. onClick={(e) => {
  222. e.stopPropagation(), this.zhuanjiaoLog(record);
  223. }}
  224. type="primary"
  225. >
  226. 查看转交记录
  227. </Button>
  228. <EnterpriseNameChange
  229. type='journal'
  230. style={{ marginLeft: 10 }}
  231. enterpriseId={record.uid}/>
  232. </div>
  233. );
  234. },
  235. },
  236. ],
  237. };
  238. },
  239. zhuanjiaoDetailCancel() {
  240. this.setState({
  241. zhuanjiaoVisible: false,
  242. });
  243. },
  244. zhuanjiaoLog(record) {
  245. this.setState({
  246. zhuanjiaoVisible: true,
  247. zhuanjiaoId: record.id,
  248. });
  249. },
  250. seeDetail(record) {
  251. this.setState({
  252. data: record,
  253. visitModul: true,
  254. });
  255. },
  256. closeDesc(e) {
  257. this.state.visitModul = e;
  258. },
  259. search() {
  260. this.loadData();
  261. },
  262. reset() {
  263. this.state.nameSearch = "";
  264. this.state.departmenttSearch = undefined;
  265. this.state.theTypes = "";
  266. this.state.auto = "";
  267. this.state.provinceSearch = undefined;
  268. this.state.addressSearch = [];
  269. this.loadData();
  270. },
  271. componentWillReceiveProps(nextProps) {
  272. if (nextProps.ApiUrl != this.props.ApiUrl) {
  273. this.state.nameSearch = "";
  274. this.state.provinceSearch = undefined;
  275. this.state.addressSearch = [];
  276. this.loadData(null, nextProps.ApiUrl);
  277. }
  278. },
  279. componentWillMount() {
  280. this.departmentList();
  281. //城市
  282. let Province = [];
  283. provinceList.map(function (item) {
  284. var id = String(item.id);
  285. Province.push(
  286. <Select.Option value={id} key={item.name}>
  287. {item.name}
  288. </Select.Option>
  289. );
  290. });
  291. this.state.Provinces = Province;
  292. this.loadData();
  293. },
  294. //指定转交人自动补全
  295. supervisor(e) {
  296. $.ajax({
  297. method: "get",
  298. dataType: "json",
  299. crossDomain: false,
  300. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  301. data: {
  302. adminName: e,
  303. },
  304. success: function (data) {
  305. let thedata = data.data;
  306. if (!thedata) {
  307. if (data.error && data.error.length) {
  308. message.warning(data.error[0].message);
  309. }
  310. thedata = {};
  311. }
  312. this.setState({
  313. customerArr: thedata,
  314. });
  315. }.bind(this),
  316. }).always(
  317. function () {
  318. this.setState({
  319. loading: false,
  320. });
  321. }.bind(this)
  322. );
  323. },
  324. //输入转交人输入框失去焦点是判断客户是否存在
  325. selectAuto(value, options) {
  326. this.setState({
  327. auto: value,
  328. });
  329. },
  330. blurChange(e) {
  331. let theType = "";
  332. let contactLists = this.state.customerArr || [];
  333. if (e) {
  334. contactLists.map(function (item) {
  335. if (item.name == e.toString()) {
  336. theType = item.id;
  337. }
  338. });
  339. }
  340. this.setState({
  341. theTypes: theType,
  342. });
  343. },
  344. //值改变时请求客户名称
  345. httpChange(e) {
  346. if (e.length >= 1) {
  347. this.supervisor(e);
  348. }
  349. this.setState({
  350. auto: e,
  351. });
  352. },
  353. changeList(arr) {
  354. const newArr = [];
  355. this.state.columns.forEach(item => {
  356. arr.forEach(val => {
  357. if (val === item.title) {
  358. newArr.push(item);
  359. }
  360. });
  361. });
  362. this.setState({
  363. changeList: newArr
  364. });
  365. },
  366. render() {
  367. let departmentArr = this.state.departmentArr || [];
  368. const intentionState = this.props.intentionState;
  369. const FormItem = Form.Item;
  370. const rowSelection = {
  371. selectedRowKeys: this.state.selectedRowKeys,
  372. onChange: (selectedRowKeys, selectedRows) => {
  373. this.setState({
  374. modalVisible: false,
  375. selectedRows: selectedRows.slice(-1),
  376. selectedRowKeys: selectedRowKeys.slice(-1),
  377. });
  378. },
  379. onSelect: (recordt, selected, selectedRows) => {
  380. this.setState({
  381. modalVisible: false,
  382. recordt: recordt.id,
  383. });
  384. },
  385. };
  386. const dataSources = this.state.customerArr || [];
  387. const options = dataSources.map((group) => (
  388. <Select.Option key={group.id} value={group.name}>
  389. {group.name}
  390. </Select.Option>
  391. ));
  392. const hasSelected = this.state.selectedRowKeys.length > 0;
  393. return (
  394. <div className="user-content">
  395. <ShowModalDiv ShowModal={this.state.showModal} />
  396. <div className="content-title">
  397. <span>{!intentionState ? "单位客户查询" : "个人客户查询"}</span>
  398. </div>
  399. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  400. <TabPane tab="搜索" key="1">
  401. <div className="user-search">
  402. <Input
  403. placeholder="请输入精确客户全称"
  404. value={this.state.nameSearch}
  405. onChange={(e) => {
  406. this.setState({ nameSearch: e.target.value });
  407. }}
  408. />
  409. {/* <Select placeholder="选择部门"
  410. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  411. value={this.state.departmenttSearch}
  412. onChange={(e) => { this.setState({ departmenttSearch: e }) }}>
  413. {
  414. departmentArr.map(function (item) {
  415. return <Select.Option key={item.id} >{item.name}</Select.Option>
  416. })
  417. }
  418. </Select> */}
  419. {/* <AutoComplete
  420. className="certain-category-search"
  421. dropdownClassName="certain-category-search-dropdown"
  422. dropdownMatchSelectWidth={false}
  423. dropdownStyle={{ width: 120 }}
  424. style={{ width: '120px'}}
  425. dataSource={options}
  426. placeholder="客户所有人姓名"
  427. value={this.state.auto}
  428. onChange={this.httpChange}
  429. filterOption={true}
  430. onBlur={this.blurChange}
  431. onSelect={this.selectAuto}
  432. >
  433. <Input />
  434. </AutoComplete> */}
  435. <Button type="primary" onClick={this.search}>
  436. 搜索
  437. </Button>
  438. <Button onClick={this.reset}>重置</Button>
  439. </div>
  440. </TabPane>
  441. <TabPane tab="更改表格显示数据" key="2">
  442. <div style={{ marginLeft: 10 }}>
  443. <ChooseList
  444. columns={this.state.columns}
  445. changeFn={this.changeList}
  446. changeList={this.state.changeList}
  447. top={55}
  448. margin={11}
  449. />
  450. </div>
  451. </TabPane>
  452. </Tabs>
  453. <div className="patent-table">
  454. <Spin spinning={this.state.loading}>
  455. <Table
  456. size="middle"
  457. columns={
  458. this.state.changeList
  459. ? this.state.changeList
  460. : this.state.columns
  461. }
  462. dataSource={this.state.dataSource}
  463. rowSelection={rowSelection}
  464. pagination={this.state.pagination}
  465. />
  466. </Spin>
  467. </div>
  468. <Detaile
  469. visitModul={this.state.visitModul}
  470. data={this.state.data}
  471. detailApi={this.props.detailApi}
  472. closeDesc={this.closeDesc}
  473. />
  474. {this.state.zhuanjiaoVisible ? (
  475. <ZhuanjiaoDetail
  476. cancel={this.zhuanjiaoDetailCancel}
  477. visible={this.state.zhuanjiaoVisible}
  478. id={this.state.zhuanjiaoId}
  479. />
  480. ) : (
  481. ""
  482. )}
  483. </div>
  484. );
  485. },
  486. });
  487. export default QueryCustomer;