page.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import React from 'react';
  2. import { Col, Row, Button } from 'antd';
  3. import './index.less';
  4. import Page from '@src/containers/Page';
  5. import Block from '@src/components/Block';
  6. import EditTableCell from '@src/components/EditTableCell';
  7. import TableLayout from '@src/layouts/TableLayout';
  8. import { asyncSMessage } from '@src/services/AsyncTools';
  9. import { System } from '../../../stores/system';
  10. const locations = [
  11. { page: '4-1/3模考-千行CAT/加入第二套', location: '显示第一次模考成绩', value: '4-1/3-show' },
  12. { page: '4-3-1 做题结束-练习报告', location: '建议用时', value: '4-3-1-suggest' },
  13. { page: '4-3.2模考-数学机经-最新列表页', location: '邮箱订阅', value: '4-3.2-update' },
  14. { page: '4-4 模考-休息', location: 'Optional Break', value: '4-4-optional' },
  15. { page: '4-2-3 模考-数学机经-购买', location: '填写邮箱', value: '4-2-3-email' },
  16. { page: '5-1/3主页/弹框', location: '备注6', value: '5-1/3-note' },
  17. { page: '5-7/1 数据-练习', location: '平均用时', value: '5-7/1-data' },
  18. { page: '5-1 显示答案', location: '解释30%', value: '4-2-2-answer' },
  19. { page: '5-6 数据', location: '平均用时+?号', value: '5-6-data' },
  20. { page: '5-9 显示答案', location: '课程开发票', value: '5-9-invoice' },
  21. ];
  22. export default class extends Page {
  23. constructor(props) {
  24. super(props);
  25. this.columns = [{
  26. title: '页面',
  27. dataIndex: 'page',
  28. }, {
  29. title: '位置',
  30. dataIndex: 'location',
  31. }, {
  32. title: '内容',
  33. dataIndex: 'value',
  34. render: (text, record) => {
  35. const { data } = this.state;
  36. return <EditTableCell value={data[record.value]} onChange={(v) => {
  37. this.changeData(record.value, v);
  38. }} />;
  39. },
  40. }];
  41. }
  42. initData() {
  43. System.getTips().then(result => {
  44. this.setState({ load: true, data: result });
  45. });
  46. }
  47. changeData(key, value) {
  48. const { data } = this.state;
  49. data[key] = value;
  50. this.setState({ data });
  51. }
  52. submit() {
  53. const { data } = this.state;
  54. System.setTips(data)
  55. .then(() => {
  56. this.setState(data);
  57. asyncSMessage('保存成功');
  58. });
  59. }
  60. renderView() {
  61. return <Block flex >
  62. <TableLayout
  63. columns={this.tableSort(this.columns)}
  64. list={locations}
  65. pagination={false}
  66. loading={this.props.core.loading}
  67. />
  68. <Row type="flex" justify="center">
  69. <Col>
  70. <Button type="primary" onClick={() => {
  71. this.submit();
  72. }}>保存</Button>
  73. </Col>
  74. </Row>
  75. </Block>;
  76. }
  77. }