customers.jsx 11 KB

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