queryCutomer.jsx 14 KB

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