queryCutomer.jsx 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import React from 'react';
  2. import { Button,Cascader,Input, Select, Spin, Table, message, Form } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import { citySelect, provinceList } from '@/NewDicProvinceList';
  6. import Detaile from './detail.jsx';
  7. const QueryCustomer = React.createClass({
  8. loadData(pageNo, apiUrl) {
  9. this.setState({
  10. visitModul:false,
  11. loading: true,
  12. ispage:pageNo,
  13. modalVisible:false
  14. });
  15. let api=apiUrl?apiUrl:this.props.ApiUrl;
  16. $.ajax({
  17. method: "post",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + api,
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. name: this.state.nameSearch,
  25. province: !(this.state.addressSearch).length ? this.state.provinceSearch : this.state.addressSearch[0],
  26. city: !(this.state.addressSearch).length ? '' : this.state.addressSearch[1],
  27. },
  28. success: function(data) {
  29. let theArr = [];
  30. if(data.error.length || data.data.list == "") {
  31. if(data.error && data.error.length) {
  32. message.warning(data.error[0].message);
  33. };
  34. } else {
  35. for(let i = 0; i < data.data.list.length; i++) {
  36. let thisdata = data.data.list[i];
  37. theArr.push({
  38. key: i,
  39. id: thisdata.uid,
  40. name: thisdata.name,
  41. adminName: thisdata.adminName,
  42. informationMaintainer:thisdata.informationMaintainer,
  43. createTime: thisdata.createTime&&thisdata.createTime.split(' ')[0],
  44. locationProvince: thisdata.province ? thisdata.province + '-' + thisdata.city + '-' + thisdata.area : '--'
  45. });
  46. };
  47. this.state.pagination.current = data.data.pageNo;
  48. this.state.pagination.total = data.data.totalCount;
  49. };
  50. if(data.data&&data.data.list&&!data.data.list.length){
  51. this.state.pagination.current=0
  52. this.state.pagination.total=0
  53. }
  54. this.setState({
  55. dataSource: theArr,
  56. pagination: this.state.pagination,
  57. selectedRowKeys:[]
  58. });
  59. }.bind(this),
  60. }).always(function() {
  61. this.setState({
  62. loading: false
  63. });
  64. }.bind(this));
  65. },
  66. getInitialState(){
  67. return {
  68. addressSearch: [],
  69. dataSource:[],
  70. loading:false,
  71. selectedRowKeys: [],
  72. selectedRowKey: [],
  73. selectedRows: [],
  74. pagination: {
  75. defaultCurrent: 1,
  76. defaultPageSize: 10,
  77. showQuickJumper: true,
  78. pageSize: 10,
  79. onChange: function(page) {
  80. this.loadData(page);
  81. }.bind(this),
  82. showTotal: function(total) {
  83. return '共' + total + '条数据';
  84. }
  85. },
  86. columns: [{
  87. title: '客户名称',
  88. dataIndex: 'name',
  89. key: 'name',
  90. }, {
  91. title: '地区',
  92. dataIndex: 'locationProvince',
  93. key: 'locationProvince',
  94. },{
  95. title: '创建时间',
  96. dataIndex: 'createTime',
  97. key: 'createTime',
  98. },
  99. {
  100. title: '客户所属人',
  101. dataIndex: 'adminName',
  102. key: 'adminName',
  103. },
  104. {
  105. title: '资料所属人',
  106. dataIndex: 'informationMaintainer',
  107. key: 'informationMaintainer',
  108. },
  109. {
  110. title: '操作',
  111. dataIndex: 'abc',
  112. key: 'abc',
  113. render: (text, record, index) => {
  114. return <div>
  115. <Button onClick={(e) =>{ e.stopPropagation(), this.seeDetail(record)}} type="primary">查看详情</Button>
  116. </div>
  117. }
  118. }
  119. ],
  120. }
  121. },
  122. seeDetail(record){
  123. this.setState({
  124. data:record,
  125. visitModul:true
  126. })
  127. },
  128. closeDesc(e) {
  129. this.state.visitModul = e;
  130. },
  131. search() {
  132. this.loadData();
  133. },
  134. reset() {
  135. this.state.nameSearch='';
  136. this.state.provinceSearch=undefined;
  137. this.state.addressSearch=[];
  138. this.loadData()
  139. },
  140. componentWillReceiveProps(nextProps) {
  141. if(nextProps.ApiUrl!=this.props.ApiUrl) {
  142. this.state.nameSearch='';
  143. this.state.provinceSearch=undefined;
  144. this.state.addressSearch=[];
  145. this.loadData(null,nextProps.ApiUrl);
  146. };
  147. },
  148. componentWillMount() {
  149. //城市
  150. let Province = [];
  151. provinceList.map(function(item) {
  152. var id = String(item.id)
  153. Province.push(
  154. <Select.Option value={id} key={item.name}>{item.name}</Select.Option>
  155. )
  156. });
  157. this.state.Provinces = Province;
  158. this.loadData();
  159. },
  160. render(){
  161. const intentionState=this.props.intentionState;
  162. const FormItem = Form.Item;
  163. const rowSelection = {
  164. selectedRowKeys: this.state.selectedRowKeys,
  165. onChange: (selectedRowKeys, selectedRows) => {
  166. this.setState({
  167. modalVisible:false,
  168. selectedRows: selectedRows.slice(-1),
  169. selectedRowKeys: selectedRowKeys.slice(-1)
  170. });
  171. },
  172. onSelect: (recordt, selected, selectedRows) => {
  173. this.setState({
  174. modalVisible:false,
  175. recordt: recordt.id
  176. })
  177. },
  178. };
  179. const hasSelected = this.state.selectedRowKeys.length > 0;
  180. return(
  181. <div className="user-content" >
  182. <div className="content-title">
  183. <span>{!intentionState?'单位客户查询':'个人客户查询'}</span>
  184. </div>
  185. <div className="user-search">
  186. <Input placeholder="客户名称"
  187. value={this.state.nameSearch}
  188. onChange={(e) => { this.setState({ nameSearch: e.target.value }); }} />
  189. <Select placeholder="省"
  190. style={{ width: 80 }}
  191. value={this.state.provinceSearch}
  192. onChange={(e) => {this.setState({ provinceSearch: e});}}>
  193. {this.state.Provinces}
  194. </Select>
  195. <span style={{marginRight:'10px'}}>
  196. <Cascader options={citySelect()} value={this.state.addressSearch} placeholder="选择城市"
  197. onChange={(e,pre) => { this.setState({ addressSearch: e }) }} />
  198. </span>
  199. <Button type="primary" onClick={this.search}>搜索</Button>
  200. <Button onClick={this.reset}>重置</Button>
  201. </div>
  202. <div className="patent-table">
  203. <Spin spinning={this.state.loading}>
  204. <Table columns={this.state.columns}
  205. dataSource={this.state.dataSource}
  206. rowSelection={rowSelection}
  207. pagination={this.state.pagination}
  208. />
  209. </Spin>
  210. </div>
  211. <Detaile
  212. visitModul={this.state.visitModul}
  213. data={this.state.data}
  214. detailApi={this.props.detailApi}
  215. closeDesc={this.closeDesc}
  216. />
  217. </div>
  218. )
  219. }
  220. })
  221. export default QueryCustomer;