queryCutomer.jsx 12 KB

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