customers.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  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. render: r => {
  134. return(
  135. getCompanyName(r)
  136. )
  137. }
  138. },
  139. {
  140. title: "回复备注",
  141. dataIndex: "remark",
  142. key: "remark"
  143. },
  144. {
  145. title: "操作",
  146. dataIndex: "aab",
  147. key: "aab",
  148. render: (text, record) => {
  149. return (
  150. <div>
  151. <Button
  152. type="primary"
  153. onClick={(e) => {
  154. this.addRemarks(record);
  155. }}
  156. >
  157. 添加备注
  158. </Button>
  159. <Popconfirm
  160. placement="top"
  161. title={"是否确认删除?"}
  162. onConfirm={e => {
  163. this.delete(record);
  164. }}
  165. okText="确认"
  166. cancelText="取消"
  167. >
  168. <Button
  169. type="primary"
  170. style={{ marginLeft: 10 }}
  171. >
  172. 删除
  173. </Button>
  174. </Popconfirm>
  175. </div>
  176. );
  177. }
  178. }
  179. ],
  180. //数据列表
  181. dataSource: []
  182. };
  183. },
  184. componentWillMount() {
  185. this.loadData();
  186. },
  187. stopPropagation(e) {
  188. e.stopPropagation();
  189. e.nativeEvent.stopImmediatePropagation();
  190. },
  191. addRemarks(record) {
  192. let status = record.status + ""
  193. this.setState({
  194. visible: true,
  195. id: record.id,
  196. status,
  197. remark: record.remark
  198. })
  199. },
  200. cancel() {
  201. this.setState({
  202. visible: false,
  203. remarks: undefined,
  204. status: []
  205. })
  206. },
  207. delete(record) {
  208. this.setState({
  209. loading: true
  210. });
  211. $.ajax({
  212. method: "post",
  213. dataType: "json",
  214. crossDomain: false,
  215. url:
  216. globalConfig.context +
  217. "/api/admin/visitingCustomers/updateVisitingCustomers",
  218. data: {
  219. id: record.id,
  220. status: 2,
  221. remark: record.remark
  222. },
  223. success: function(data) {
  224. let theArr = [];
  225. if (data.error && data.error.length) {
  226. message.warning(data.error[0].message);
  227. } else {
  228. message.success("删除成功!");
  229. this.loadData();
  230. }
  231. }.bind(this)
  232. }).always(
  233. function() {
  234. this.setState({
  235. loading: false
  236. });
  237. }.bind(this)
  238. );
  239. },
  240. tijiao() {
  241. this.setState({
  242. loading: true
  243. })
  244. $.ajax({
  245. method: "post",
  246. dataType: "json",
  247. crossDomain: false,
  248. url:
  249. globalConfig.context +
  250. "/api/admin/visitingCustomers/updateVisitingCustomers",
  251. data: {
  252. id: this.state.id,
  253. status: this.state.status,
  254. remark: this.state.remark
  255. },
  256. success: function(data) {
  257. let theArr = [];
  258. if (data.error && data.error.length) {
  259. message.warning(data.error[0].message);
  260. }else {
  261. this.loadData()
  262. this.cancel()
  263. message.success("提交成功!");
  264. }
  265. }.bind(this)
  266. }).always(
  267. function() {
  268. this.setState({
  269. loading: false
  270. });
  271. }.bind(this)
  272. );
  273. },
  274. reset() {
  275. this.setState({
  276. locationSearch: [],
  277. time: [],
  278. name: undefined,
  279. },()=>{
  280. this.loadData()
  281. })
  282. },
  283. render() {
  284. const FormItem = Form.Item;
  285. return (
  286. <div className="user-content">
  287. <div className="content-title">
  288. <span>客户访问列表</span>
  289. <div className="user-search">
  290. <Input
  291. placeholder="请输入客户名称"
  292. style={{
  293. width: "150px",
  294. marginRight: "20px",
  295. marginBottom: "10px"
  296. }}
  297. value={this.state.name}
  298. onChange={e => {
  299. this.setState({ name: e.target.value });
  300. }}
  301. />
  302. <span style={{ fontSize: 14 }} >提交日期:</span>
  303. <RangePicker
  304. value={[
  305. this.state.time[0] ? moment(this.state.time[0]) : null,
  306. this.state.time[1] ? moment(this.state.time[1]) : null
  307. ]}
  308. onChange={(data, dataString) => {
  309. this.setState({ time: dataString });
  310. }}
  311. />
  312. <Select
  313. placeholder="请选择公司"
  314. style={{ width: 150,marginLeft: "20px", }}
  315. value={this.state.locationSearch}
  316. onChange={e => {
  317. this.setState({
  318. locationSearch: e
  319. });
  320. }}
  321. >
  322. {
  323. companyList.map((v)=>(
  324. <Select.Option key={v.value} value={v.value}>{v.label}</Select.Option>
  325. ))
  326. }
  327. </Select>
  328. <Button
  329. type="primary"
  330. onClick={()=>{this.loadData()}}
  331. style={{ marginRight: "10px",marginLeft: 10 }}
  332. >
  333. 搜索
  334. </Button>
  335. <Button onClick={this.reset} style={{ marginRight: "10px" }}>
  336. 重置
  337. </Button>
  338. </div>
  339. <div className="patent-table">
  340. <SpinContainer spinning={this.state.loading}>
  341. <Table
  342. columns={this.state.columns}
  343. dataSource={this.state.dataSource}
  344. pagination={this.state.pagination}
  345. onRowClick={this.tableRowClick}
  346. size="small"
  347. bordered
  348. />
  349. </SpinContainer>
  350. </div>
  351. </div>
  352. <div className="patent-desc">
  353. <Modal
  354. className="customeDetails"
  355. title={"备注信息"}
  356. width="350"
  357. visible={this.state.visible}
  358. onOk={this.tijiao}
  359. okText={"保存"}
  360. onCancel={this.cancel}
  361. >
  362. <SpinContainer spinning={this.state.loading}>
  363. <div className="clearfix">
  364. <FormItem
  365. labelCol={{ span: 6 }}
  366. wrapperCol={{ span: 14 }}
  367. label="客户备注"
  368. >
  369. <TextArea
  370. placeholder="请输入备注"
  371. value={this.state.remark}
  372. onChange={e => {
  373. this.setState({
  374. remark: e.target.value
  375. });
  376. }}
  377. />
  378. </FormItem>
  379. <FormItem
  380. labelCol={{ span: 6 }}
  381. wrapperCol={{ span: 14 }}
  382. label="是否已读"
  383. >
  384. <Select
  385. defaultValue="0"
  386. style={{ width: 120 }}
  387. value={this.state.status}
  388. placeholder="是否阅读"
  389. onChange={e => {
  390. this.setState({
  391. status: e
  392. });
  393. }}
  394. >
  395. <Option value="0">未读</Option>
  396. <Option value="1">已读</Option>
  397. </Select>
  398. </FormItem>
  399. </div>
  400. </SpinContainer>
  401. </Modal>
  402. </div>
  403. </div>
  404. );
  405. }
  406. })
  407. );
  408. export default Form.create()(Customers);