Yansen 2 years ago
parent
commit
8ba43eea7c
4 changed files with 128 additions and 21 deletions
  1. 17
    2
      src/components/Page/index.jsx
  2. 74
    0
      src/pages/checkStand/index.jsx
  3. 11
    19
      src/routes/routes.jsx
  4. 26
    0
      src/service/tacheckstand.js

+ 17
- 2
src/components/Page/index.jsx View File

7
   margin: '24px',
7
   margin: '24px',
8
   minHeight: 'calc(100% - 48px)',
8
   minHeight: 'calc(100% - 48px)',
9
 }
9
 }
10
-const { Title } = Typography;
10
+const titleStyle = {
11
+  display: 'flex',
12
+  justifyContent: 'space-between',
13
+  alignItems: 'center',
14
+  paddingBottom: '12px',
15
+}
16
+
17
+const Title = (props) => {
18
+
19
+  return (
20
+    <div style={titleStyle}>
21
+      <Typography.Title level={3} style={{fontWeight: 400, flex: 'none'}}>{props.children}</Typography.Title>
22
+      <div style={{flex: 'none'}}>{props.extra}</div>
23
+    </div>
24
+  )
25
+}
11
 
26
 
12
 export default (props) => {
27
 export default (props) => {
13
   const { meta = {} } = useRoute() || {};
28
   const { meta = {} } = useRoute() || {};
16
 
31
 
17
   return (
32
   return (
18
     <div style={style}>
33
     <div style={style}>
19
-      { title && !meta.noLayout && <Title level={4} style={{ paddingBottom: '12px' }}>{ title }</Title> }
34
+      { title && !meta.noLayout && <Title extra={props.extra}>{ title }</Title> }
20
       {props.children}
35
       {props.children}
21
     </div>
36
     </div>
22
   )
37
   )

+ 74
- 0
src/pages/checkStand/index.jsx View File

1
+import React from 'react';
2
+import { Button, Card } from 'antd';
3
+import Page from '@/components/Page';
4
+import Wangeditor from '@/components/Wangeditor';
5
+import { getTaCheckStandById, putTaCheckStand } from '@/service/tacheckstand';
6
+
7
+export default (props) => {
8
+
9
+  const [loading, setLoading] = React.useState(false);
10
+  const [editable, setEditAble] = React.useState(false);
11
+  const [detail, setDetail] = React.useState(false);
12
+
13
+  const onChange = (e) => {
14
+    setDetail({
15
+      ...detail || {},
16
+      content: e,
17
+    })
18
+  }
19
+
20
+  const onSubmit = (e) => {
21
+    setLoading(true);
22
+    putTaCheckStand(1, detail).then(() => {
23
+      setLoading(false);
24
+      setEditAble(false);
25
+    }).catch(() => {
26
+      setLoading(false);
27
+    })
28
+  }
29
+
30
+  React.useEffect(() => {
31
+    setLoading(true);
32
+    getTaCheckStandById(1).then((res) => {
33
+      setDetail(res);
34
+      setLoading(false);
35
+    }).catch(() => {
36
+      setLoading(false);
37
+    })
38
+  }, []);
39
+
40
+  return (
41
+    <Page>
42
+      <Card loading={loading} extra={(
43
+        editable ? <Button type="primary" onClick={onSubmit}>提交</Button>
44
+          : <Button type="primary" onClick={() => setEditAble(true)}>编辑</Button>
45
+      )}>
46
+      {
47
+        editable ? (
48
+          <Wangeditor
49
+            value={detail?.content}
50
+            toolbarConfig={{
51
+              toolbarKeys: [
52
+                'headerSelect',
53
+                'blockquote',
54
+                '|',
55
+                'bold',
56
+                'underline',
57
+                'italic',
58
+                'color',
59
+                'fontSize',
60
+                '|',
61
+                'bulletedList',
62
+                'numberedList',
63
+              ]
64
+            }}
65
+            onChange={onChange}
66
+          />
67
+        ) : (
68
+          <div dangerouslySetInnerHTML={{__html: detail?.content}}></div>
69
+        )
70
+      }
71
+      </Card>
72
+    </Page>
73
+  )
74
+}

+ 11
- 19
src/routes/routes.jsx View File

10
   BranchesOutlined,
10
   BranchesOutlined,
11
   NodeIndexOutlined,
11
   NodeIndexOutlined,
12
   NotificationOutlined,
12
   NotificationOutlined,
13
+  ScheduleOutlined
13
 } from '@ant-design/icons';
14
 } from '@ant-design/icons';
14
 import { Outlet } from 'react-router-dom';
15
 import { Outlet } from 'react-router-dom';
15
 import AuthLayout from "@/layouts/AuthLayout";
16
 import AuthLayout from "@/layouts/AuthLayout";
34
 import QuestionList from "@/pages/question/list";
35
 import QuestionList from "@/pages/question/list";
35
 import IssueList from '@/pages/issue';
36
 import IssueList from '@/pages/issue';
36
 import Notice from '@/pages/notice';
37
 import Notice from '@/pages/notice';
38
+import CheckStand from '@/pages/checkStand';
37
 
39
 
38
 /**
40
 /**
39
  * meta 用来扩展自定义数据数据
41
  * meta 用来扩展自定义数据数据
152
           // permission: 'form',
154
           // permission: 'form',
153
         },
155
         },
154
       },
156
       },
157
+      {
158
+        path: "checkStand",
159
+        element: <CheckStand />,
160
+        meta: {
161
+          title: '测评标准',
162
+          icon: <ScheduleOutlined />,
163
+          // permission: 'form',
164
+        },
165
+      },
155
     ]
166
     ]
156
   },
167
   },
157
   {
168
   {
222
       },
233
       },
223
     ]
234
     ]
224
   },
235
   },
225
-
226
-  // {
227
-  //   path: "form",
228
-  //   element: <BasicForm />,
229
-  //   meta: {
230
-  //     title: '表单',
231
-  //     icon: <AppstoreOutlined />,
232
-  //     permission: 'form',
233
-  //   },
234
-  // },
235
-  // {
236
-  //   path: "table",
237
-  //   element: <BasicTable />,
238
-  //   meta: {
239
-  //     title: '表格',
240
-  //     icon: <ContainerOutlined />,
241
-  //     permission: 'table',
242
-  //   },
243
-  // },
244
 ];
236
 ];
245
 
237
 
246
 export const defaultRoutes = [
238
 export const defaultRoutes = [

+ 26
- 0
src/service/tacheckstand.js View File

1
+import request from '@/utils/request';
2
+
3
+/*
4
+ * 分页查询
5
+ */
6
+export const getTaCheckStand = (params) => request('/api/taCheckStand', { params });
7
+
8
+/*
9
+ * 新增数据
10
+ */
11
+export const postTaCheckStand = (data) => request('/api/taCheckStand', { data, method: 'post' });
12
+
13
+/*
14
+ * 通过ID查询单条数据
15
+ */
16
+export const getTaCheckStandById = (id) => request(`/api/taCheckStand/${id}`);
17
+
18
+/*
19
+ * 更新数据
20
+ */
21
+export const putTaCheckStand = (id, data) => request(`/api/taCheckStand/${id}`, { data, method: 'put' });
22
+
23
+/*
24
+ * 通过主键删除数据
25
+ */
26
+export const deleteTaCheckStand = (id) => request(`/api/taCheckStand/${id}`, { method: 'delete' });