myClient.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. import React from 'react';
  2. import { Radio, Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal, Upload } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import moment from 'moment';
  6. import './myClient.less';
  7. import TechAchievementDesc from './myClientDesc.jsx';
  8. import { achievementCategoryList, techAuditStatusList,cityArr,customerStatus } from '../../dataDic.js';
  9. import { beforeUploadFile, companySearch, getAchievementCategory, getSearchUrl, getTechAuditStatus,getcustomerTyp,getcityArr,getcustomerStatue,getCompanyIntention,getfllowSituation} from '../../tools.js';
  10. import BatchImport from './batchImport';
  11. const AchievementList = React.createClass({
  12. loadData(pageNo, apiUrl) {
  13. this.state.data = [];
  14. this.setState({
  15. loading: true
  16. });
  17. $.ajax({
  18. method: "get",
  19. dataType: "json",
  20. crossDomain: false,
  21. url:globalConfig.context + '/api/admin/customer/searchCustomerList',
  22. data: {
  23. pageNo: pageNo || 1,
  24. pageSize: this.state.pagination.pageSize,
  25. companyName: this.state.companyName, //名称
  26. customerTyp: this.state.customerTyp, //客户类型
  27. province:this.state.province,//地区
  28. customerStatue:this.state.customerStatue,//客户状态
  29. customerName:this.state.customerName,//联系人姓名
  30. adminName:this.state.adminName,//跟单人
  31. //releaseDateStartDate: this.state.releaseDate[0],
  32. //releaseDateEndDate: this.state.releaseDate[1],
  33. },
  34. success: function (data) {
  35. console.log(data)
  36. let theArr = [];
  37. if (!data.data || !data.data.list) {
  38. if (data.error && data.error.length) {
  39. message.warning(data.error[0].message);
  40. };
  41. } else {
  42. for (let i = 0; i < data.data.list.length; i++) {
  43. let thisdata = data.data.list[i];
  44. theArr.push({
  45. key: i,
  46. id: thisdata.id,
  47. companyName:thisdata.companyName,
  48. customerTyp:thisdata.customerTyp,
  49. province:thisdata.province,
  50. customerName:thisdata.customerName,
  51. telNum:thisdata.telNum,
  52. customerStatue:thisdata.customerStatue,
  53. companyIntention:thisdata.companyIntention,
  54. fllowSituation:thisdata.fllowSituation,
  55. adminName:thisdata.adminName
  56. });
  57. };
  58. this.state.pagination.current = data.data.pageNo;
  59. this.state.pagination.total = data.data.totalCount;
  60. };
  61. this.setState({
  62. dataSource: theArr,
  63. pagination: this.state.pagination
  64. });
  65. }.bind(this),
  66. }).always(function () {
  67. this.setState({
  68. loading: false
  69. });
  70. }.bind(this));
  71. },
  72. // showModal(){
  73. // this.setState({
  74. // visible: true,
  75. // });
  76. // },
  77. // handleOk(e){
  78. // this.setState({
  79. // visible: false,
  80. // });
  81. // },
  82. // handleCancel(e){
  83. // this.setState({
  84. // visible: false,
  85. // });
  86. // },
  87. getInitialState() {
  88. return {
  89. //visible: false ,
  90. searchMore: true,
  91. searchType: 0,
  92. validityPeriodDate: [],
  93. releaseDate: [],
  94. selectedRowKeys: [],
  95. selectedRows: [],
  96. loading: false,
  97. pagination: {
  98. defaultCurrent: 1,
  99. defaultPageSize: 10,
  100. showQuickJumper: true,
  101. pageSize: 10,
  102. onChange: function (page) {
  103. this.loadData(page);
  104. }.bind(this),
  105. showTotal: function (total) {
  106. return '共' + total + '条数据';
  107. }
  108. },
  109. columns: [
  110. {
  111. title: '公司名称',
  112. dataIndex: 'companyName',
  113. key: 'companyName',
  114. }, {
  115. title: '客户类型',
  116. dataIndex: 'customerTyp',
  117. key: 'customerTyp',
  118. render: text => { return getcustomerTyp(text); }
  119. }, {
  120. title: '地区',
  121. dataIndex: 'province',
  122. key: 'province',
  123. render: text => { return getcityArr(text); }
  124. }, {
  125. title: '联系人姓名',
  126. dataIndex: 'customerName',
  127. key: 'customerName',
  128. },
  129. {
  130. title: '手机号',
  131. dataIndex: 'telNum',
  132. key:'telNum',
  133. },
  134. {
  135. title: '客户状态',
  136. dataIndex: 'customerStatue',
  137. key: 'customerStatue',
  138. render: text => { return getcustomerStatue(text) }
  139. },
  140. {
  141. title: '意向服务',
  142. dataIndex: 'companyIntention',
  143. key: 'companyIntention',
  144. render: text => { return getCompanyIntention(text) }
  145. },
  146. {
  147. title: '最新跟进',
  148. dataIndex: 'fllowSituation',
  149. key: 'fllowSituation',
  150. render: text => { return getfllowSituation(text) }
  151. // render: text => {
  152. // return
  153. // <div>
  154. // <Button type="primary" onClick={this.showModal}>{getfllowSituation(text)}<Icon type="plus" /></Button>
  155. // <Modal
  156. // title="修改"
  157. // visible={this.state.visible}
  158. // onOk={this.handleOk}
  159. // onCancel={this.handleCancel}
  160. // >
  161. // <p>Some contents...</p>
  162. // <p>Some contents...</p>
  163. // <p>Some contents...</p>
  164. // </Modal>
  165. // </div>
  166. // }
  167. },
  168. {
  169. title: '跟单人',
  170. dataIndex: 'adminName',
  171. key: 'adminName',
  172. }
  173. ],
  174. dataSource: [],
  175. searchTime: [,]
  176. };
  177. },
  178. componentWillMount() {
  179. let theArr = [];
  180. customerStatus.map(function (item) {
  181. theArr.push(
  182. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  183. )
  184. });
  185. let auditArr = [];
  186. cityArr.map(function (item) {
  187. auditArr.push(
  188. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  189. )
  190. });
  191. this.state.customerStatuarr = theArr;
  192. this.state.auditStatusOption = auditArr;
  193. if (window.location.search) {
  194. let theObj = getSearchUrl(window.location.search);
  195. if (theObj.rid) {
  196. theObj.id = theObj.rid;
  197. if (theObj.rid != 'null') {
  198. this.tableRowClick(theObj);
  199. };
  200. };
  201. };
  202. this.loadData();
  203. },
  204. tableRowClick(record, index) {
  205. this.state.RowData = record;
  206. this.setState({
  207. showDesc: true
  208. });
  209. },
  210. delectRow() {
  211. let deletedIds;
  212. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  213. let rowItem = this.state.selectedRows[idx];
  214. if (rowItem.id) {
  215. deletedIds=rowItem.id
  216. };
  217. };
  218. this.setState({
  219. selectedRowKeys: [],
  220. loading: deletedIds.length > 0
  221. });
  222. $.ajax({
  223. method: "GET",
  224. dataType: "json",
  225. crossDomain: false,
  226. url: globalConfig.context + "/api/admin/customer/deleteCustomer",
  227. data: {
  228. id: deletedIds
  229. }
  230. }).done(function (data) {
  231. if (!data.data.error.length) {
  232. message.success('删除成功!');
  233. this.setState({
  234. loading: false,
  235. });
  236. } else {
  237. message.warning(data.error[0].message);
  238. };
  239. this.loadData();
  240. }.bind(this));
  241. },
  242. addClick() {
  243. this.state.RowData = {};
  244. this.setState({
  245. showDesc: true
  246. });
  247. },
  248. closeDesc(e, s) {
  249. this.state.showDesc = e;
  250. if (s) {
  251. this.loadData();
  252. };
  253. },
  254. search() {
  255. this.loadData();
  256. },
  257. reset() {
  258. this.state.id = undefined;
  259. this.state.companyName = undefined;
  260. this.state.customerTyp = undefined;
  261. this.state.province = undefined;
  262. this.state.ownerType = undefined;
  263. this.state.customerStatue = undefined;
  264. this.state.auditStatus = undefined;
  265. this.state.adminName = undefined;
  266. this.state.customerName = undefined;
  267. this.state.releaseDate = [];
  268. this.loadData();
  269. },
  270. searchSwitch() {
  271. this.setState({
  272. searchMore: !this.state.searchMore
  273. });
  274. },
  275. render() {
  276. const rowSelection = {
  277. selectedRowKeys: this.state.selectedRowKeys,
  278. onChange: (selectedRowKeys, selectedRows) => {
  279. this.setState({
  280. selectedRows: selectedRows.slice(-1),
  281. selectedRowKeys: selectedRowKeys.slice(-1)
  282. });
  283. }
  284. };
  285. const hasSelected = this.state.selectedRowKeys.length > 0;
  286. const { RangePicker } = DatePicker;
  287. return (
  288. <div className="user-content" >
  289. <div className="content-title">
  290. <span>客户管理</span>
  291. <div className="patent-addNew clearfix">
  292. <Upload
  293. action={globalConfig.context + "/api/admin/achievement/uploadTemplate"}
  294. data={{ 'sign': 'achievement_template' }}
  295. beforeUpload={beforeUploadFile}
  296. showUploadList={false}
  297. onChange={(info) => {
  298. if (info.file.status !== 'uploading') {
  299. console.log(info.file, info.fileList);
  300. }
  301. if (info.file.status === 'done') {
  302. if (!info.file.response.error.length) {
  303. message.success(`${info.file.name} 文件上传成功!`);
  304. } else {
  305. message.warning(info.file.response.error[0].message);
  306. return;
  307. };
  308. } else if (info.file.status === 'error') {
  309. message.error(`${info.file.name} 文件上传失败。`);
  310. };
  311. }} >
  312. <Button>上传批量导入模板</Button>
  313. </Upload>
  314. <Button onClick={() => { window.open(globalConfig.context + '/api/admin/achievement/downloadTemplate?sign=achievement_template') }}>下载批量导入模板</Button>
  315. <Button type="primary" className="addButton" onClick={this.addClick}>新建客户<Icon type="plus" /></Button>
  316. <BatchImport closeDesc={this.closeDesc} />
  317. </div>
  318. </div>
  319. <div className="user-search">
  320. <Input placeholder="公司名称"
  321. value={this.state.companyName}
  322. onChange={(e) => { this.setState({ companyName: e.target.value }); }} />
  323. <Select placeholder="客户类型" style={{ width: 120 }}
  324. value={this.state.customerTyp }
  325. onChange={(e) => { this.setState({ customerTyp : e }) }}>
  326. <Select.Option value="0" >个人客户</Select.Option>
  327. <Select.Option value="1" >公司客户</Select.Option>
  328. </Select>
  329. <Select placeholder="地区"
  330. style={{ width: 160 }}
  331. value={this.state.province}
  332. onChange={(e) => { this.setState({ province: e }) }}>
  333. {this.state.auditStatusOption}
  334. </Select>
  335. <Select placeholder="客户状态" style={{ width: 120 }}
  336. value={this.state.customerStatue}
  337. onChange={(e) => { this.setState({ customerStatue: e }) }}>
  338. {this.state.customerStatuarr}
  339. </Select>
  340. <Button type="primary" onClick={this.search}>搜索</Button>
  341. <Button onClick={this.reset}>重置</Button>
  342. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  343. disabled={!hasSelected}
  344. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  345. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  346. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  347. <Input placeholder="跟单人" style={{width:'140px',marginRight:'10px'}}
  348. value={this.state.adminName}
  349. onChange={(e) => { this.setState({ adminName: e.target.value }); }} />
  350. <Input placeholder="联系人姓名" style={{width:'140px',marginRight:'10px'}}
  351. value={this.state.customerName}
  352. onChange={(e) => { this.setState({ customerName: e.target.value }); }} />
  353. <span>发布时间 :</span>
  354. <RangePicker
  355. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  356. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  357. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  358. </div>
  359. </div>
  360. <div className="patent-table">
  361. <Spin spinning={this.state.loading}>
  362. <Table columns={this.state.columns}
  363. dataSource={this.state.dataSource}
  364. rowSelection={rowSelection}
  365. pagination={this.state.pagination}
  366. onRowClick={this.tableRowClick} />
  367. </Spin>
  368. </div>
  369. <TechAchievementDesc
  370. data={this.state.RowData}
  371. detailApiUrl={this.props['data-detailApiUrl']}
  372. achievementCategoryOption={this.state.achievementCategoryOption}
  373. showDesc={this.state.showDesc}
  374. closeDesc={this.closeDesc} />
  375. </div >
  376. );
  377. }
  378. });
  379. export default AchievementList;