queryCutomer.jsx 13 KB

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