myClient.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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 => {
  151. return
  152. <div>
  153. <Button type="primary" onClick={this.showModal}>{getfllowSituation(text)}<Icon type="plus" /></Button>
  154. <Modal
  155. title="修改"
  156. visible={this.state.visible}
  157. onOk={this.handleOk}
  158. onCancel={this.handleCancel}
  159. >
  160. <p>Some contents...</p>
  161. <p>Some contents...</p>
  162. <p>Some contents...</p>
  163. </Modal>
  164. </div>
  165. }
  166. },
  167. {
  168. title: '跟单人',
  169. dataIndex: 'adminName',
  170. key: 'adminName',
  171. }
  172. ],
  173. dataSource: [],
  174. searchTime: [,]
  175. };
  176. },
  177. componentWillMount() {
  178. let theArr = [];
  179. customerStatus.map(function (item) {
  180. theArr.push(
  181. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  182. )
  183. });
  184. let auditArr = [];
  185. cityArr.map(function (item) {
  186. auditArr.push(
  187. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  188. )
  189. });
  190. this.state.customerStatuarr = theArr;
  191. this.state.auditStatusOption = auditArr;
  192. if (window.location.search) {
  193. let theObj = getSearchUrl(window.location.search);
  194. if (theObj.rid) {
  195. theObj.id = theObj.rid;
  196. if (theObj.rid != 'null') {
  197. this.tableRowClick(theObj);
  198. };
  199. };
  200. };
  201. this.loadData();
  202. },
  203. tableRowClick(record, index) {
  204. this.state.RowData = record;
  205. this.setState({
  206. showDesc: true
  207. });
  208. },
  209. delectRow() {
  210. let deletedIds;
  211. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  212. let rowItem = this.state.selectedRows[idx];
  213. if (rowItem.id) {
  214. deletedIds=rowItem.id
  215. };
  216. };
  217. this.setState({
  218. selectedRowKeys: [],
  219. loading: deletedIds.length > 0
  220. });
  221. $.ajax({
  222. method: "GET",
  223. dataType: "json",
  224. crossDomain: false,
  225. url: globalConfig.context + "/api/admin/customer/deleteCustomer",
  226. data: {
  227. id: deletedIds
  228. }
  229. }).done(function (data) {
  230. if (!data.data.error.length) {
  231. message.success('删除成功!');
  232. this.setState({
  233. loading: false,
  234. });
  235. } else {
  236. message.warning(data.error[0].message);
  237. };
  238. this.loadData();
  239. }.bind(this));
  240. },
  241. addClick() {
  242. this.state.RowData = {};
  243. this.setState({
  244. showDesc: true
  245. });
  246. },
  247. closeDesc(e, s) {
  248. this.state.showDesc = e;
  249. if (s) {
  250. this.loadData();
  251. };
  252. },
  253. search() {
  254. this.loadData();
  255. },
  256. reset() {
  257. this.state.id = undefined;
  258. this.state.companyName = undefined;
  259. this.state.customerTyp = undefined;
  260. this.state.province = undefined;
  261. this.state.ownerType = undefined;
  262. this.state.customerStatue = undefined;
  263. this.state.auditStatus = undefined;
  264. this.state.adminName = undefined;
  265. this.state.customerName = undefined;
  266. this.state.releaseDate = [];
  267. this.loadData();
  268. },
  269. searchSwitch() {
  270. this.setState({
  271. searchMore: !this.state.searchMore
  272. });
  273. },
  274. render() {
  275. const rowSelection = {
  276. selectedRowKeys: this.state.selectedRowKeys,
  277. onChange: (selectedRowKeys, selectedRows) => {
  278. this.setState({
  279. selectedRows: selectedRows.slice(-1),
  280. selectedRowKeys: selectedRowKeys.slice(-1)
  281. });
  282. }
  283. };
  284. const hasSelected = this.state.selectedRowKeys.length > 0;
  285. const { RangePicker } = DatePicker;
  286. return (
  287. <div className="user-content" >
  288. <div className="content-title">
  289. <span>客户管理</span>
  290. <div className="patent-addNew clearfix">
  291. <Upload
  292. action={globalConfig.context + "/api/admin/achievement/uploadTemplate"}
  293. data={{ 'sign': 'achievement_template' }}
  294. beforeUpload={beforeUploadFile}
  295. showUploadList={false}
  296. onChange={(info) => {
  297. if (info.file.status !== 'uploading') {
  298. console.log(info.file, info.fileList);
  299. }
  300. if (info.file.status === 'done') {
  301. if (!info.file.response.error.length) {
  302. message.success(`${info.file.name} 文件上传成功!`);
  303. } else {
  304. message.warning(info.file.response.error[0].message);
  305. return;
  306. };
  307. } else if (info.file.status === 'error') {
  308. message.error(`${info.file.name} 文件上传失败。`);
  309. };
  310. }} >
  311. <Button>上传批量导入模板</Button>
  312. </Upload>
  313. <Button onClick={() => { window.open(globalConfig.context + '/api/admin/achievement/downloadTemplate?sign=achievement_template') }}>下载批量导入模板</Button>
  314. <Button type="primary" className="addButton" onClick={this.addClick}>新建客户<Icon type="plus" /></Button>
  315. <BatchImport closeDesc={this.closeDesc} />
  316. </div>
  317. </div>
  318. <div className="user-search">
  319. <Input placeholder="公司名称"
  320. value={this.state.companyName}
  321. onChange={(e) => { this.setState({ companyName: e.target.value }); }} />
  322. <Select placeholder="客户类型" style={{ width: 120 }}
  323. value={this.state.customerTyp }
  324. onChange={(e) => { this.setState({ customerTyp : e }) }}>
  325. <Select.Option value="0" >个人客户</Select.Option>
  326. <Select.Option value="1" >公司客户</Select.Option>
  327. </Select>
  328. <Select placeholder="地区"
  329. style={{ width: 160 }}
  330. value={this.state.province}
  331. onChange={(e) => { this.setState({ province: e }) }}>
  332. {this.state.auditStatusOption}
  333. </Select>
  334. <Select placeholder="客户状态" style={{ width: 120 }}
  335. value={this.state.customerStatue}
  336. onChange={(e) => { this.setState({ customerStatue: e }) }}>
  337. {this.state.customerStatuarr}
  338. </Select>
  339. <Button type="primary" onClick={this.search}>搜索</Button>
  340. <Button onClick={this.reset}>重置</Button>
  341. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  342. disabled={!hasSelected}
  343. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  344. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  345. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  346. <Input placeholder="跟单人" style={{width:'140px',marginRight:'10px'}}
  347. value={this.state.adminName}
  348. onChange={(e) => { this.setState({ adminName: e.target.value }); }} />
  349. <Input placeholder="联系人姓名" style={{width:'140px',marginRight:'10px'}}
  350. value={this.state.customerName}
  351. onChange={(e) => { this.setState({ customerName: e.target.value }); }} />
  352. <span>发布时间 :</span>
  353. <RangePicker
  354. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  355. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  356. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  357. </div>
  358. </div>
  359. <div className="patent-table">
  360. <Spin spinning={this.state.loading}>
  361. <Table columns={this.state.columns}
  362. dataSource={this.state.dataSource}
  363. rowSelection={rowSelection}
  364. pagination={this.state.pagination}
  365. onRowClick={this.tableRowClick} />
  366. </Spin>
  367. </div>
  368. <TechAchievementDesc
  369. data={this.state.RowData}
  370. detailApiUrl={this.props['data-detailApiUrl']}
  371. achievementCategoryOption={this.state.achievementCategoryOption}
  372. showDesc={this.state.showDesc}
  373. closeDesc={this.closeDesc} />
  374. </div >
  375. );
  376. }
  377. });
  378. export default AchievementList;