queryCutomer.jsx 13 KB

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