queryCutomer.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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. const {TabPane} =Tabs
  11. const QueryCustomer = React.createClass({
  12. loadData(pageNo, apiUrl) {
  13. this.setState({
  14. visitModul: false,
  15. loading: true,
  16. ispage: pageNo,
  17. modalVisible: false,
  18. });
  19. let api = apiUrl ? apiUrl : this.props.ApiUrl;
  20. $.ajax({
  21. method: "post",
  22. dataType: "json",
  23. crossDomain: false,
  24. url: globalConfig.context + api,
  25. data: {
  26. pageNo: pageNo || 1,
  27. pageSize: this.state.pagination.pageSize,
  28. name: this.state.nameSearch,
  29. departmentId: this.state.departmenttSearch,
  30. aid: this.state.theTypes,
  31. },
  32. success: function (data) {
  33. ShowModal(this);
  34. let theArr = [];
  35. if (data.error.length || data.data.list == "") {
  36. if (data.error && data.error.length) {
  37. message.warning(data.error[0].message);
  38. }
  39. } else {
  40. for (let i = 0; i < data.data.list.length; i++) {
  41. let thisdata = data.data.list[i];
  42. let diqu =
  43. (thisdata.province == null ? "" : thisdata.province) +
  44. (thisdata.city == null ? "" : "-" + thisdata.city) +
  45. (thisdata.area == null ? "" : "-" + thisdata.area);
  46. theArr.push({
  47. key: i,
  48. id: thisdata.uid,
  49. name: thisdata.name,
  50. adminName: thisdata.adminName,
  51. informationMaintainer: thisdata.informationMaintainer,
  52. createTime:
  53. thisdata.createTime && thisdata.createTime.split(" ")[0],
  54. locationProvince: diqu,
  55. });
  56. }
  57. this.state.pagination.current = data.data.pageNo;
  58. this.state.pagination.total = data.data.totalCount;
  59. }
  60. if (data.data && data.data.list && !data.data.list.length) {
  61. this.state.pagination.current = 0;
  62. this.state.pagination.total = 0;
  63. }
  64. this.setState({
  65. dataSource: theArr,
  66. pagination: this.state.pagination,
  67. selectedRowKeys: [],
  68. });
  69. }.bind(this),
  70. }).always(
  71. function () {
  72. this.setState({
  73. loading: false,
  74. });
  75. }.bind(this)
  76. );
  77. },
  78. //部门
  79. departmentList() {
  80. this.setState({
  81. loading: true,
  82. });
  83. $.ajax({
  84. method: "get",
  85. dataType: "json",
  86. crossDomain: false,
  87. url: globalConfig.context + "/api/admin/organization/selectSuperId",
  88. data: {},
  89. success: function (data) {
  90. let thedata = data.data;
  91. let theArr = [];
  92. if (!thedata) {
  93. if (data.error && data.error.length) {
  94. message.warning(data.error[0].message);
  95. }
  96. thedata = {};
  97. } else {
  98. thedata.map(function (item, index) {
  99. theArr.push({
  100. key: index,
  101. name: item.name,
  102. id: item.id,
  103. });
  104. });
  105. }
  106. this.setState({
  107. departmentArr: theArr,
  108. });
  109. }.bind(this),
  110. }).always(
  111. function () {
  112. this.setState({
  113. loading: false,
  114. });
  115. }.bind(this)
  116. );
  117. },
  118. getInitialState() {
  119. return {
  120. addressSearch: [],
  121. dataSource: [],
  122. zhuanjiaoVisible: false,
  123. zhuanjiaoData: [],
  124. loading: false,
  125. departmentArr: [],
  126. selectedRowKeys: [],
  127. selectedRowKey: [],
  128. selectedRows: [],
  129. pagination: {
  130. defaultCurrent: 1,
  131. defaultPageSize: 10,
  132. showQuickJumper: true,
  133. pageSize: 10,
  134. onChange: function (page) {
  135. this.loadData(page);
  136. }.bind(this),
  137. showTotal: function (total) {
  138. return "共" + total + "条数据";
  139. },
  140. },
  141. columns: [
  142. {
  143. title: "客户名称",
  144. dataIndex: "name",
  145. key: "name",
  146. },
  147. {
  148. title: "地区",
  149. dataIndex: "locationProvince",
  150. key: "locationProvince",
  151. },
  152. {
  153. title: "创建时间",
  154. dataIndex: "createTime",
  155. key: "createTime",
  156. },
  157. {
  158. title: "客户所属人",
  159. dataIndex: "adminName",
  160. key: "adminName",
  161. },
  162. {
  163. title: "资料所属人",
  164. dataIndex: "informationMaintainer",
  165. key: "informationMaintainer",
  166. },
  167. {
  168. title: "操作",
  169. dataIndex: "abc",
  170. key: "abc",
  171. render: (text, record, index) => {
  172. return (
  173. <div>
  174. <Button
  175. onClick={(e) => {
  176. e.stopPropagation(), this.seeDetail(record);
  177. }}
  178. type="primary"
  179. style={{ marginRight: 10 }}
  180. >
  181. 查看详情
  182. </Button>
  183. <Button
  184. onClick={(e) => {
  185. e.stopPropagation(), this.zhuanjiaoLog(record);
  186. }}
  187. type="primary"
  188. >
  189. 查看转交记录
  190. </Button>
  191. </div>
  192. );
  193. },
  194. },
  195. ],
  196. };
  197. },
  198. zhuanjiaoDetailCancel() {
  199. this.setState({
  200. zhuanjiaoVisible: false,
  201. });
  202. },
  203. zhuanjiaoLog(record) {
  204. this.setState({
  205. zhuanjiaoVisible: true,
  206. zhuanjiaoId: record.id,
  207. });
  208. },
  209. seeDetail(record) {
  210. this.setState({
  211. data: record,
  212. visitModul: true,
  213. });
  214. },
  215. closeDesc(e) {
  216. this.state.visitModul = e;
  217. },
  218. search() {
  219. this.loadData();
  220. },
  221. reset() {
  222. this.state.nameSearch = "";
  223. this.state.departmenttSearch = undefined;
  224. this.state.theTypes = "";
  225. this.state.auto = "";
  226. this.state.provinceSearch = undefined;
  227. this.state.addressSearch = [];
  228. this.loadData();
  229. },
  230. componentWillReceiveProps(nextProps) {
  231. if (nextProps.ApiUrl != this.props.ApiUrl) {
  232. this.state.nameSearch = "";
  233. this.state.provinceSearch = undefined;
  234. this.state.addressSearch = [];
  235. this.loadData(null, nextProps.ApiUrl);
  236. }
  237. },
  238. componentWillMount() {
  239. this.departmentList();
  240. //城市
  241. let Province = [];
  242. provinceList.map(function (item) {
  243. var id = String(item.id);
  244. Province.push(
  245. <Select.Option value={id} key={item.name}>
  246. {item.name}
  247. </Select.Option>
  248. );
  249. });
  250. this.state.Provinces = Province;
  251. this.loadData();
  252. },
  253. //指定转交人自动补全
  254. supervisor(e) {
  255. $.ajax({
  256. method: "get",
  257. dataType: "json",
  258. crossDomain: false,
  259. url: globalConfig.context + "/api/admin/customer/listAdminByName",
  260. data: {
  261. adminName: e,
  262. },
  263. success: function (data) {
  264. let thedata = data.data;
  265. if (!thedata) {
  266. if (data.error && data.error.length) {
  267. message.warning(data.error[0].message);
  268. }
  269. thedata = {};
  270. }
  271. this.setState({
  272. customerArr: thedata,
  273. });
  274. }.bind(this),
  275. }).always(
  276. function () {
  277. this.setState({
  278. loading: false,
  279. });
  280. }.bind(this)
  281. );
  282. },
  283. //输入转交人输入框失去焦点是判断客户是否存在
  284. selectAuto(value, options) {
  285. this.setState({
  286. auto: value,
  287. });
  288. },
  289. blurChange(e) {
  290. let theType = "";
  291. let contactLists = this.state.customerArr || [];
  292. if (e) {
  293. contactLists.map(function (item) {
  294. if (item.name == e.toString()) {
  295. theType = item.id;
  296. }
  297. });
  298. }
  299. this.setState({
  300. theTypes: theType,
  301. });
  302. },
  303. //值改变时请求客户名称
  304. httpChange(e) {
  305. if (e.length >= 1) {
  306. this.supervisor(e);
  307. }
  308. this.setState({
  309. auto: e,
  310. });
  311. },
  312. render() {
  313. let departmentArr = this.state.departmentArr || [];
  314. const intentionState = this.props.intentionState;
  315. const FormItem = Form.Item;
  316. const rowSelection = {
  317. selectedRowKeys: this.state.selectedRowKeys,
  318. onChange: (selectedRowKeys, selectedRows) => {
  319. this.setState({
  320. modalVisible: false,
  321. selectedRows: selectedRows.slice(-1),
  322. selectedRowKeys: selectedRowKeys.slice(-1),
  323. });
  324. },
  325. onSelect: (recordt, selected, selectedRows) => {
  326. this.setState({
  327. modalVisible: false,
  328. recordt: recordt.id,
  329. });
  330. },
  331. };
  332. const dataSources = this.state.customerArr || [];
  333. const options = dataSources.map((group) => (
  334. <Select.Option key={group.id} value={group.name}>
  335. {group.name}
  336. </Select.Option>
  337. ));
  338. const hasSelected = this.state.selectedRowKeys.length > 0;
  339. return (
  340. <div className="user-content">
  341. <ShowModalDiv ShowModal={this.state.showModal} />
  342. <div className="content-title">
  343. <span>{!intentionState ? "单位客户查询" : "个人客户查询"}</span>
  344. </div>
  345. <Tabs defaultActiveKey="1" onChange={this.callback} className="test">
  346. <TabPane tab="搜索" key="1">
  347. <div className="user-search">
  348. <Input
  349. placeholder="请输入精确客户全称"
  350. value={this.state.nameSearch}
  351. onChange={(e) => {
  352. this.setState({ nameSearch: e.target.value });
  353. }}
  354. />
  355. {/* <Select placeholder="选择部门"
  356. style={{ width: 150 ,marginRight:'10px',marginLeft:'10px'}}
  357. value={this.state.departmenttSearch}
  358. onChange={(e) => { this.setState({ departmenttSearch: e }) }}>
  359. {
  360. departmentArr.map(function (item) {
  361. return <Select.Option key={item.id} >{item.name}</Select.Option>
  362. })
  363. }
  364. </Select> */}
  365. {/* <AutoComplete
  366. className="certain-category-search"
  367. dropdownClassName="certain-category-search-dropdown"
  368. dropdownMatchSelectWidth={false}
  369. dropdownStyle={{ width: 120 }}
  370. style={{ width: '120px'}}
  371. dataSource={options}
  372. placeholder="客户所有人姓名"
  373. value={this.state.auto}
  374. onChange={this.httpChange}
  375. filterOption={true}
  376. onBlur={this.blurChange}
  377. onSelect={this.selectAuto}
  378. >
  379. <Input />
  380. </AutoComplete> */}
  381. <Button type="primary" onClick={this.search}>
  382. 搜索
  383. </Button>
  384. <Button onClick={this.reset}>重置</Button>
  385. </div>
  386. </TabPane>
  387. </Tabs>
  388. <div className="patent-table">
  389. <Spin spinning={this.state.loading}>
  390. <Table
  391. columns={this.state.columns}
  392. dataSource={this.state.dataSource}
  393. rowSelection={rowSelection}
  394. pagination={this.state.pagination}
  395. />
  396. </Spin>
  397. </div>
  398. <Detaile
  399. visitModul={this.state.visitModul}
  400. data={this.state.data}
  401. detailApi={this.props.detailApi}
  402. closeDesc={this.closeDesc}
  403. />
  404. {this.state.zhuanjiaoVisible ? (
  405. <ZhuanjiaoDetail
  406. cancel={this.zhuanjiaoDetailCancel}
  407. visible={this.state.zhuanjiaoVisible}
  408. id={this.state.zhuanjiaoId}
  409. />
  410. ) : (
  411. ""
  412. )}
  413. </div>
  414. );
  415. },
  416. });
  417. export default QueryCustomer;