customers.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. import React from "react";
  2. import $ from "jquery/src/ajax";
  3. import "react-quill/dist/quill.bubble.css";
  4. import moment from "moment";
  5. import {
  6. Form,
  7. Icon,
  8. Button,
  9. Input,
  10. Table,
  11. message,
  12. Modal,
  13. Select,
  14. DatePicker,
  15. Popconfirm, Tooltip,
  16. } from "antd";
  17. import SpinContainer from '../../SpinContainer';
  18. import {companyList, getCompanyName} from "../../common/configure";
  19. const { Option } = Select;
  20. const { TextArea } = Input;
  21. const { RangePicker } = DatePicker;
  22. //主体
  23. const Customers = Form.create()(
  24. React.createClass({
  25. loadData(pageNo = 1) {
  26. this.state.data = [];
  27. this.setState({
  28. loading: true,
  29. });
  30. $.ajax({
  31. method: "get",
  32. dataType: "json",
  33. crossDomain: false,
  34. url:
  35. globalConfig.context +
  36. "/api/admin/visitingCustomers/listVisitingCustomers",
  37. data: {
  38. pageNo: pageNo,
  39. pageSize: this.state.pagination.pageSize,
  40. name: this.state.name,
  41. startTime: this.state.time[0],
  42. endTime: this.state.time[1],
  43. location:this.state.locationSearch,
  44. },
  45. success: function(data) {
  46. let theArr = [];
  47. if (!data.data || !data.data.list) {
  48. if (data.error && data.error.length) {
  49. message.warning(data.error[0].message);
  50. }
  51. } else {
  52. for (let i = 0; i < data.data.list.length; i++) {
  53. let thisdata = data.data.list[i];
  54. thisdata.key = i + 1;
  55. theArr.push(thisdata);
  56. }
  57. this.state.pagination.current = data.data.pageNo;
  58. this.state.pagination.total = data.data.totalCount;
  59. }
  60. this.setState({
  61. dataSource: theArr,
  62. pagination: this.state.pagination,
  63. page: data.data.pageNo
  64. });
  65. }.bind(this)
  66. }).always(
  67. function() {
  68. this.setState({
  69. loading: false
  70. });
  71. }.bind(this)
  72. );
  73. },
  74. getInitialState() {
  75. return {
  76. //数据类型
  77. loading: false,
  78. visible: false,
  79. time: [],
  80. locationSearch:[],
  81. pagination: {
  82. defaultCurrent: 1,
  83. defaultPageSize: 10,
  84. showQuickJumper: true,
  85. pageSize: 10,
  86. onChange: function(page) {
  87. this.loadData(page);
  88. this.setState({
  89. selectedRowKeys: []
  90. });
  91. }.bind(this),
  92. showTotal: function(total) {
  93. return "共" + total + "条数据";
  94. }
  95. },
  96. columns: [
  97. {
  98. title: "序号",
  99. dataIndex: "id",
  100. key: "id"
  101. },
  102. {
  103. title: "姓名",
  104. dataIndex: "name",
  105. key: "name"
  106. },
  107. {
  108. title: "联系方式",
  109. dataIndex: "mobile",
  110. key: "mobile"
  111. },
  112. {
  113. title: "提交时间",
  114. dataIndex: "createTimes",
  115. key: "createTimes"
  116. },
  117. {
  118. title: "是否查看",
  119. dataIndex: "status",
  120. key: "status",
  121. render: text => {
  122. if (text == 0) {
  123. return "未读";
  124. } else if (text == 1) {
  125. return "已读";
  126. }
  127. }
  128. },
  129. {
  130. title: "公司",
  131. dataIndex: "location",
  132. key: "location",
  133. width:150,
  134. render: r => {
  135. return(
  136. getCompanyName(r)
  137. )
  138. }
  139. },
  140. {
  141. title: "回复备注",
  142. dataIndex: "remark",
  143. key: "remark"
  144. },
  145. {
  146. title: "操作",
  147. dataIndex: "aab",
  148. key: "aab",
  149. render: (text, record) => {
  150. return (
  151. <div>
  152. <Button
  153. type="primary"
  154. onClick={(e) => {
  155. this.addRemarks(record);
  156. }}
  157. >
  158. 添加备注
  159. </Button>
  160. <Popconfirm
  161. placement="top"
  162. title={"是否确认删除?"}
  163. onConfirm={e => {
  164. this.delete(record);
  165. }}
  166. okText="确认"
  167. cancelText="取消"
  168. >
  169. <Button
  170. type="primary"
  171. style={{ marginLeft: 10 }}
  172. >
  173. 删除
  174. </Button>
  175. </Popconfirm>
  176. </div>
  177. );
  178. }
  179. }
  180. ],
  181. //数据列表
  182. dataSource: []
  183. };
  184. },
  185. componentWillMount() {
  186. this.loadData();
  187. },
  188. stopPropagation(e) {
  189. e.stopPropagation();
  190. e.nativeEvent.stopImmediatePropagation();
  191. },
  192. addRemarks(record) {
  193. let status = record.status + ""
  194. this.setState({
  195. visible: true,
  196. id: record.id,
  197. status,
  198. remark: record.remark
  199. })
  200. },
  201. cancel() {
  202. this.setState({
  203. visible: false,
  204. remarks: undefined,
  205. status: []
  206. })
  207. },
  208. delete(record) {
  209. this.setState({
  210. loading: true
  211. });
  212. $.ajax({
  213. method: "post",
  214. dataType: "json",
  215. crossDomain: false,
  216. url:
  217. globalConfig.context +
  218. "/api/admin/visitingCustomers/updateVisitingCustomers",
  219. data: {
  220. id: record.id,
  221. status: 2,
  222. remark: record.remark
  223. },
  224. success: function(data) {
  225. let theArr = [];
  226. if (data.error && data.error.length) {
  227. message.warning(data.error[0].message);
  228. } else {
  229. message.success("删除成功!");
  230. this.loadData();
  231. }
  232. }.bind(this)
  233. }).always(
  234. function() {
  235. this.setState({
  236. loading: false
  237. });
  238. }.bind(this)
  239. );
  240. },
  241. tijiao() {
  242. this.setState({
  243. loading: true
  244. })
  245. $.ajax({
  246. method: "post",
  247. dataType: "json",
  248. crossDomain: false,
  249. url:
  250. globalConfig.context +
  251. "/api/admin/visitingCustomers/updateVisitingCustomers",
  252. data: {
  253. id: this.state.id,
  254. status: this.state.status,
  255. remark: this.state.remark
  256. },
  257. success: function(data) {
  258. let theArr = [];
  259. if (data.error && data.error.length) {
  260. message.warning(data.error[0].message);
  261. }else {
  262. this.loadData()
  263. this.cancel()
  264. message.success("提交成功!");
  265. }
  266. }.bind(this)
  267. }).always(
  268. function() {
  269. this.setState({
  270. loading: false
  271. });
  272. }.bind(this)
  273. );
  274. },
  275. reset() {
  276. this.setState({
  277. locationSearch: [],
  278. time: [],
  279. name: undefined,
  280. },()=>{
  281. this.loadData()
  282. })
  283. },
  284. render() {
  285. const FormItem = Form.Item;
  286. return (
  287. <div className="user-content">
  288. <div className="content-title">
  289. <span>客户访问列表</span>
  290. <div className="user-search">
  291. <Input
  292. placeholder="请输入客户名称"
  293. style={{
  294. width: "150px",
  295. marginRight: "20px",
  296. marginBottom: "10px"
  297. }}
  298. value={this.state.name}
  299. onChange={e => {
  300. this.setState({ name: e.target.value });
  301. }}
  302. />
  303. <span style={{ fontSize: 14 }} >提交日期:</span>
  304. <RangePicker
  305. value={[
  306. this.state.time[0] ? moment(this.state.time[0]) : null,
  307. this.state.time[1] ? moment(this.state.time[1]) : null
  308. ]}
  309. onChange={(data, dataString) => {
  310. this.setState({ time: dataString });
  311. }}
  312. />
  313. <Select
  314. placeholder="请选择公司"
  315. style={{ width: 150,marginLeft: "20px", }}
  316. value={this.state.locationSearch}
  317. onChange={e => {
  318. this.setState({
  319. locationSearch: e
  320. });
  321. }}
  322. >
  323. {
  324. companyList.map((v)=>(
  325. <Select.Option key={v.value} value={v.value}>{v.label}</Select.Option>
  326. ))
  327. }
  328. </Select>
  329. <Button
  330. type="primary"
  331. onClick={()=>{this.loadData()}}
  332. style={{ marginRight: "10px",marginLeft: 10 }}
  333. >
  334. 搜索
  335. </Button>
  336. <Button onClick={this.reset} style={{ marginRight: "10px" }}>
  337. 重置
  338. </Button>
  339. </div>
  340. <div className="patent-table">
  341. <SpinContainer spinning={this.state.loading}>
  342. <Table
  343. columns={this.state.columns}
  344. dataSource={this.state.dataSource}
  345. pagination={this.state.pagination}
  346. onRowClick={this.tableRowClick}
  347. size="small"
  348. bordered
  349. />
  350. </SpinContainer>
  351. </div>
  352. </div>
  353. <div className="patent-desc">
  354. <Modal
  355. className="customeDetails"
  356. title={"备注信息"}
  357. width="350"
  358. visible={this.state.visible}
  359. onOk={this.tijiao}
  360. okText={"保存"}
  361. onCancel={this.cancel}
  362. >
  363. <SpinContainer spinning={this.state.loading}>
  364. <div className="clearfix">
  365. <FormItem
  366. labelCol={{ span: 6 }}
  367. wrapperCol={{ span: 14 }}
  368. label="客户备注"
  369. >
  370. <TextArea
  371. placeholder="请输入备注"
  372. value={this.state.remark}
  373. onChange={e => {
  374. this.setState({
  375. remark: e.target.value
  376. });
  377. }}
  378. />
  379. </FormItem>
  380. <FormItem
  381. labelCol={{ span: 6 }}
  382. wrapperCol={{ span: 14 }}
  383. label="是否已读"
  384. >
  385. <Select
  386. defaultValue="0"
  387. style={{ width: 120 }}
  388. value={this.state.status}
  389. placeholder="是否阅读"
  390. onChange={e => {
  391. this.setState({
  392. status: e
  393. });
  394. }}
  395. >
  396. <Option value="0">未读</Option>
  397. <Option value="1">已读</Option>
  398. </Select>
  399. </FormItem>
  400. </div>
  401. </SpinContainer>
  402. </Modal>
  403. </div>
  404. </div>
  405. );
  406. }
  407. })
  408. );
  409. export default Form.create()(Customers);