lisenzhou 2 years ago
parent
commit
d55edcf7ca

+ 4
- 13
src/components/Wangeditor/index.jsx View File

@@ -7,16 +7,12 @@ import { Editor, Toolbar } from "@wangeditor/editor-for-react";
7 7
 
8 8
 function MyEditor(props) {
9 9
   const {
10
-    value,
10
+    value = "",
11 11
     onChange = (e) => {
12 12
       setHtml(e);
13 13
     },
14 14
     toolbarConfig = {
15
-      excludeKeys: [
16
-
17
-        "group-image",
18
-        "group-video",
19
-      ],
15
+      excludeKeys: ["group-image", "group-video"],
20 16
     },
21 17
     editorConfig = {
22 18
       placeholder: "请输入内容...",
@@ -25,15 +21,10 @@ function MyEditor(props) {
25 21
   } = props;
26 22
   const [editor, setEditor] = useState(null); // 存储 editor 实例
27 23
   const [html, setHtml] = useState("");
28
-  console.log(props, "MyEditor");
24
+ 
29 25
   // 模拟 ajax 请求,异步设置 html
30 26
   useEffect(() => {
31
-    if(editor){
32
-      console.log(editor,editor.getConfig(),editor.getAllMenuKeys(),editor.getMenuConfig('image')) ;
33
-    }
34
-   
35
-
36
-    setHtml(value);
27
+    setHtml(value || "");
37 28
   }, [value]);
38 29
 
39 30
   // 及时销毁 editor

+ 51
- 0
src/pages/rotationChart/detail/index.jsx View File

@@ -0,0 +1,51 @@
1
+import { savePosts, getPostsDetail, updatePosts } from "@/services/posts";
2
+import {
3
+  addBanner,
4
+  getBannerdById,
5
+  updataBanner,
6
+} from "@/services/rotationChart";
7
+import { useNavigate, useSearchParams } from "react-router-dom";
8
+import { Card, Typography, message, Row, Button, Space } from "antd";
9
+import { useEffect, useRef, useState } from "react";
10
+
11
+const { Title } = Typography;
12
+export default (props) => {
13
+  const [searchParams] = useSearchParams();
14
+  const id = searchParams.get("id");
15
+  const [data, setData] = useState({});
16
+  // const [url, setUrl] = useState("");
17
+  const navigate = useNavigate();
18
+
19
+  const formRef = useRef();
20
+
21
+  useEffect(() => {
22
+    if (id) {
23
+      getBannerdById(id).then((res) => {
24
+        setData(res);
25
+        // setUrl(res.filesList[0]?.fileAddr);
26
+      });
27
+    }
28
+  }, [id]);
29
+
30
+  return (
31
+    <Card title={<Button onClick={() => navigate(-1)}> 返回</Button>}>
32
+      <div dangerouslySetInnerHTML={{ __html: data?.desc }}></div>
33
+      {data?.type === "1" && data?.image && (
34
+        <img src={data?.image} alt=""></img>
35
+      )}
36
+      {data?.type === "2" && data?.video && (
37
+        <video src={data?.video} autoPlay={false} controls="controls"></video>
38
+      )}
39
+      {/* {url && (
40
+        <div style={{marginTop:"2em"}}>
41
+          <a
42
+            href={`${url}`}
43
+            download
44
+          >
45
+            {url?.substring(url?.lastIndexOf("/") + 1)}
46
+          </a>
47
+        </div>
48
+      )} */}
49
+    </Card>
50
+  );
51
+};

+ 48
- 27
src/pages/rotationChart/edit/index.jsx View File

@@ -1,7 +1,10 @@
1
-import UploadImage from '@/components/UploadImage';
2
-import UploadVideo from '@/components/UploadVideo';
3
-import UploadFile from '@/components/UploadFile';
4
-import { addBanner, getBannerdById, updataBanner } from '@/services/rotationChart';
1
+
2
+import UploadFile from "@/components/UploadFile";
3
+import {
4
+  addBanner,
5
+  getBannerdById,
6
+  updataBanner,
7
+} from "@/services/rotationChart";
5 8
 import {
6 9
   PageContainer,
7 10
   ProForm,
@@ -9,16 +12,17 @@ import {
9 12
   ProFormRadio,
10 13
   ProFormSelect,
11 14
   ProFormTextArea,
12
-} from '@ant-design/pro-components';
13
-import { useNavigate, useSearchParams } from 'react-router-dom';
14
-import { Card, Col, message, Row, Space, Image } from 'antd';
15
-import { useEffect, useRef, useState } from 'react';
15
+} from "@ant-design/pro-components";
16
+import { useNavigate, useSearchParams } from "react-router-dom";
17
+import { Card, Col, message, Row, Space, Image } from "antd";
18
+import { useEffect, useRef, useState } from "react";
19
+import Wangeditor from "@/components/Wangeditor";
16 20
 
17 21
 export default (props) => {
18 22
   const [searchParams, setSearchParams] = useSearchParams();
19
-  const id = searchParams.get('id');
23
+  const id = searchParams.get("id");
20 24
   const [data, setData] = useState({});
21
-  const [imgLabel, setImgLabel] = useState('图片');
25
+  const [imgLabel, setImgLabel] = useState("图片");
22 26
   const formRef = useRef();
23 27
   const navigate = useNavigate();
24 28
 
@@ -36,13 +40,13 @@ export default (props) => {
36 40
     if (id) {
37 41
       // 修改
38 42
       updataBanner(id, { ...values }).then((res) => {
39
-        message.success('修改成功');
43
+        message.success("修改成功");
40 44
         navigate(-1);
41 45
       });
42 46
     } else {
43 47
       // 新增
44 48
       addBanner({ ...values }).then((res) => {
45
-        message.success('添加成功');
49
+        message.success("添加成功");
46 50
         navigate(-1);
47 51
       });
48 52
     }
@@ -55,14 +59,14 @@ export default (props) => {
55 59
       <Card>
56 60
         <ProForm
57 61
           formRef={formRef}
58
-          layout={'horizontal'}
62
+          layout={"horizontal"}
59 63
           labelCol={{ span: 8 }}
60 64
           wrapperCol={{ span: 16 }}
61 65
           onFinish={onFinish}
62
-          initialValues={{ type: '1', state: '1' }}
66
+          initialValues={{ type: "1", state: "1" }}
63 67
           submitter={{
64 68
             searchConfig: {
65
-              resetText: '返回',
69
+              resetText: "返回",
66 70
             },
67 71
             onReset: () => navigate(-1),
68 72
             render: (props, doms) => {
@@ -81,12 +85,14 @@ export default (props) => {
81 85
             width="md"
82 86
             label="轮播图类型"
83 87
             valueEnum={{
84
-              1: '图片',
85
-              2: '视频',
88
+              1: "图片",
89
+              2: "视频",
86 90
             }}
87 91
             placeholder="轮播图类型"
88
-            rules={[{ required: true, message: 'Please select your country!' }]}
89
-            onChange={({ value }) =>  setImgLabel(value === '1' ? '图片' : '封面')}
92
+            rules={[{ required: true, message: "Please select your country!" }]}
93
+            onChange={({ value }) =>
94
+              setImgLabel(value === "1" ? "图片" : "封面")
95
+            }
90 96
           />
91 97
           <ProForm.Item
92 98
             width="md"
@@ -97,12 +103,16 @@ export default (props) => {
97 103
           >
98 104
             <UploadFile
99 105
               accept="image/*"
100
-              preview={src => <div style={{ marginTop: '2em' }}><Image width={200} src={src} /></div>}
106
+              preview={(src) => (
107
+                <div style={{ marginTop: "2em" }}>
108
+                  <Image width={200} src={src} />
109
+                </div>
110
+              )}
101 111
             />
102 112
           </ProForm.Item>
103 113
           <ProForm.Item noStyle shouldUpdate>
104 114
             {(form) => {
105
-              return form.getFieldValue('type') == '1' ? null : (
115
+              return form.getFieldValue("type") == "1" ? null : (
106 116
                 <ProForm.Item
107 117
                   width="md"
108 118
                   name="video"
@@ -112,7 +122,11 @@ export default (props) => {
112 122
                 >
113 123
                   <UploadFile
114 124
                     accept="video/*"
115
-                    preview={src => <div style={{ marginTop: '6px' }}><video height={360} width={480} src={src} controls /></div>}
125
+                    preview={(src) => (
126
+                      <div style={{ marginTop: "6px" }}>
127
+                        <video height={360} width={480} src={src} controls />
128
+                      </div>
129
+                    )}
116 130
                   />
117 131
                 </ProForm.Item>
118 132
               );
@@ -124,17 +138,24 @@ export default (props) => {
124 138
             radioType="button"
125 139
             options={[
126 140
               {
127
-                label: '上架',
128
-                value: '1',
141
+                label: "上架",
142
+                value: "1",
129 143
               },
130 144
               {
131
-                label: '下架',
132
-                value: '2',
145
+                label: "下架",
146
+                value: "2",
133 147
               },
134 148
             ]}
135 149
           />
136 150
           <ProFormDigit name="qz" label="权重" width="md" />
137
-          <ProFormTextArea width="md" name="desc" label="描述" placeholder="请输入描述" />
151
+          <ProForm.Item
152
+            name="desc"
153
+            label="详情"
154
+            placeholder="请输入详情"
155
+            // rules={[{ required: true, message: "请输入详情" }]}
156
+          >
157
+            <Wangeditor></Wangeditor>
158
+          </ProForm.Item>
138 159
         </ProForm>
139 160
       </Card>
140 161
     </PageContainer>

+ 12
- 1
src/pages/rotationChart/list/index.jsx View File

@@ -92,12 +92,23 @@ const RotationChartList = (props) => {
92 92
         >
93 93
           {record.state === '1' ? '下架' : '上架'}
94 94
         </Button>,
95
+         <Button
96
+         key={4}
97
+         style={{ padding: 0 }}
98
+         type="link"
99
+         onClick={() => {
100
+      
101
+           navigate(`/cms/rotationChart/detail?id=${record.id}`);
102
+         }}
103
+       >
104
+         详情
105
+       </Button>,
95 106
         <Button
96 107
           key={2}
97 108
           style={{ padding: 0 }}
98 109
           type="link"
99 110
           onClick={() => {
100
-            console.log(record, ']]');
111
+            
101 112
             navigate(`/cms/rotationChart/add?id=${record.id}`);
102 113
           }}
103 114
         >

+ 34
- 25
src/pages/sample/home/index.jsx View File

@@ -3,7 +3,7 @@ import React, { useState, useRef, useEffect, useMemo } from "react";
3 3
 import { getBannerList } from "@/services/rotationChart";
4 4
 
5 5
 import VideoPlay from "./components/VideoPlay";
6
-
6
+import { useNavigate } from "react-router-dom";
7 7
 const height = "100%";
8 8
 const contentStyle = {
9 9
   height,
@@ -12,7 +12,8 @@ const contentStyle = {
12 12
 };
13 13
 
14 14
 export default (props) => {
15
-  const [height, setHeight] = useState('100%');
15
+  const navigate = useNavigate();
16
+  const [height, setHeight] = useState("100%");
16 17
   const [current, setCurrent] = useState(0);
17 18
   const [mouse, setMouse] = useState(false);
18 19
   const [mediaList, setMediaList] = useState([]);
@@ -23,12 +24,15 @@ export default (props) => {
23 24
   const isVideoRef = useRef(false);
24 25
   const isVideoPlayRef = useRef(false);
25 26
 
26
-  const itemStyle = useMemo(() => ({
27
-    height,
28
-    overflow: 'hidden',
29
-    width: '100%',
30
-    objectFit: 'contain',
31
-  }), [height]);
27
+  const itemStyle = useMemo(
28
+    () => ({
29
+      height,
30
+      overflow: "hidden",
31
+      width: "100%",
32
+      objectFit: "contain",
33
+    }),
34
+    [height]
35
+  );
32 36
 
33 37
   useEffect(() => {
34 38
     getBannerList().then((res) => {
@@ -53,7 +57,7 @@ export default (props) => {
53 57
     handNext();
54 58
 
55 59
     const boxHeight = boxRef.current.offsetHeight;
56
-    setHeight(boxHeight ? `${boxHeight}px` : '100%');
60
+    setHeight(boxHeight ? `${boxHeight}px` : "100%");
57 61
   }, []);
58 62
 
59 63
   const handNext = () => {
@@ -66,18 +70,23 @@ export default (props) => {
66 70
   };
67 71
 
68 72
   const onMouseEnter = () => {
69
-   
70 73
     mouseRef.current = true;
71 74
   };
72 75
   const onMouseLeave = () => {
73 76
     mouseRef.current = false;
74 77
   };
75 78
 
79
+  const onClick = (row) => {
80
+    if (row.id) {
81
+      navigate(`/cms/rotationChart/detail?id=${row.id}`);
82
+    }
83
+  };
84
+
76 85
   return (
77 86
     <div
78 87
       onMouseEnter={onMouseEnter}
79 88
       onMouseLeave={onMouseLeave}
80
-      style={{ height, overflow: "hidden", background: '#081A48' }}
89
+      style={{ height, overflow: "hidden", background: "#081A48" }}
81 90
       ref={boxRef}
82 91
     >
83 92
       <Carousel
@@ -86,20 +95,20 @@ export default (props) => {
86 95
           setCurrent(cur);
87 96
         }}
88 97
       >
89
-          {mediaList?.map((x, index) => (
90
-            <div key={index}>
91
-              { x.type === "image" && <img src={x.url} style={itemStyle}></img> }
92
-              { x.type === "video" && (
93
-                <VideoPlay
94
-                  url={x.url}
95
-                  isVideoPlayRef={isVideoPlayRef}
96
-                  index={index}
97
-                  current={current}
98
-                  style={itemStyle}
99
-                />
100
-              )}
101
-            </div>
102
-          ))}
98
+        {mediaList?.map((x, index) => (
99
+          <div key={index} onClick={()=>onClick(x)}>
100
+            {x.type === "image" && <img src={x.url} style={itemStyle}></img>}
101
+            {x.type === "video" && (
102
+              <VideoPlay
103
+                url={x.url}
104
+                isVideoPlayRef={isVideoPlayRef}
105
+                index={index}
106
+                current={current}
107
+                style={itemStyle}
108
+              />
109
+            )}
110
+          </div>
111
+        ))}
103 112
       </Carousel>
104 113
     </div>
105 114
   );

+ 51
- 42
src/routes/routes.jsx View File

@@ -6,38 +6,39 @@ import {
6 6
   MenuFoldOutlined,
7 7
   MenuUnfoldOutlined,
8 8
   PieChartOutlined,
9
-} from '@ant-design/icons';
10
-import { Navigate } from 'react-router-dom';
11
-import AuthLayout from '@/layouts/AuthLayout';
12
-import Container from '@/layouts/Container';
13
-import Login from '@/pages/login';
14
-import Page404 from '@/pages/404';
15
-import Home from '@/pages/sample/home';
16
-import BasicForm from '@/pages/sample/form';
17
-import BasicTable from '@/pages/sample/table';
18
-import GuaranteeTaskList from '@/pages/guaranteeTask';
19
-import GuaranteeTaskEdit from '@/pages/guaranteeTask/Edit';
20
-import GuaranteeTaskPrint from '@/pages/guaranteeTask/print';
9
+} from "@ant-design/icons";
10
+import { Navigate } from "react-router-dom";
11
+import AuthLayout from "@/layouts/AuthLayout";
12
+import Container from "@/layouts/Container";
13
+import Login from "@/pages/login";
14
+import Page404 from "@/pages/404";
15
+import Home from "@/pages/sample/home";
16
+import BasicForm from "@/pages/sample/form";
17
+import BasicTable from "@/pages/sample/table";
18
+import GuaranteeTaskList from "@/pages/guaranteeTask";
19
+import GuaranteeTaskEdit from "@/pages/guaranteeTask/Edit";
20
+import GuaranteeTaskPrint from "@/pages/guaranteeTask/print";
21 21
 import GuaranteeTaskEvaluate from "@/pages/evaluate";
22 22
 import GuaranteeTaskEvaluateList from "@/pages/evaluate/evaluateList";
23
-import DishList from '@/pages/dish/list';
24
-import DishEdit from '@/pages/dish/edit';
25
-import PackageList from '@/pages/package';
26
-import StockList from '@/pages/stock/list';
27
-import StockEdit from '@/pages/stock/edit';
28
-import StockInOut from '@/pages/stock/outAndIn';
29
-import StockLog from '@/pages/stock/stockLog';
30
-import StockClassificationList from '@/pages/stockClassification/list';
31
-import StockClassificationEdit from '@/pages/stockClassification/edit';
32
-import RotationChartList from '@/pages/rotationChart/list';
33
-import RotationChartEdit from '@/pages/rotationChart/edit';
34
-import RotationChartIntroduction from '@/pages/rotationChart/introduction';
35
-import RotationChartIntroductionEdit from '@/pages/rotationChart/introduction/edit';
36
-import Roles from '@/pages/roles/index';
37
-import RegulationList from '@/regulation';
38
-import RegulationEdit from '@/regulation/edit';
39
-import UserList from '@/pages/user';
40
-import UserEdit from '@/pages/user/Edit';
23
+import DishList from "@/pages/dish/list";
24
+import DishEdit from "@/pages/dish/edit";
25
+import PackageList from "@/pages/package";
26
+import StockList from "@/pages/stock/list";
27
+import StockEdit from "@/pages/stock/edit";
28
+import StockInOut from "@/pages/stock/outAndIn";
29
+import StockLog from "@/pages/stock/stockLog";
30
+import StockClassificationList from "@/pages/stockClassification/list";
31
+import StockClassificationEdit from "@/pages/stockClassification/edit";
32
+import RotationChartList from "@/pages/rotationChart/list";
33
+import RotationChartEdit from "@/pages/rotationChart/edit";
34
+import RotationChartIntroduction from "@/pages/rotationChart/introduction";
35
+import RotationChartIntroductionEdit from "@/pages/rotationChart/introduction/edit";
36
+import RotationChartDetail from "@/pages/rotationChart/detail";
37
+import Roles from "@/pages/roles/index";
38
+import RegulationList from "@/regulation";
39
+import RegulationEdit from "@/regulation/edit";
40
+import UserList from "@/pages/user";
41
+import UserEdit from "@/pages/user/Edit";
41 42
 import PurchasePlanList from "@/pages/purchase/plan/list";
42 43
 import PurchasePlanEdit from "@/pages/purchase/plan/edit";
43 44
 import PurchaseBillEdit from "@/pages/purchase/bill/edit";
@@ -46,9 +47,9 @@ import EmergencyPlanList from "@/pages/cms/emergencyPlan/list";
46 47
 import EmergencyPlanEdit from "@/pages/cms/emergencyPlan/edit";
47 48
 import EmergencyPlanDetail from "@/pages/cms/emergencyPlan/detail";
48 49
 import FilesList from "@/pages/cms/files/list";
49
-import MessageList from '@/pages/message';
50
-import MessageDetail from '@/pages/message/detail';
51
-import StatisCharts from '@/pages/statis/charts';
50
+import MessageList from "@/pages/message";
51
+import MessageDetail from "@/pages/message/detail";
52
+import StatisCharts from "@/pages/statis/charts";
52 53
 
53 54
 /**
54 55
  * meta 用来扩展自定义数据数据
@@ -57,7 +58,7 @@ import StatisCharts from '@/pages/statis/charts';
57 58
  *    hideInMenu: 布尔值, 如果为 false, 菜单不会显示
58 59
  *    noLayout: 布尔值, 如果为 true, 将不会使用默认布局
59 60
  *    noSiderBar: 布尔值, 如果为 true, 将没有左侧菜单栏
60
- *    noFooter: 布尔值, 如果为 true, 将没有底部 footer 
61
+ *    noFooter: 布尔值, 如果为 true, 将没有底部 footer
61 62
  *    target: 字符串, 如果为 _blank, 将在新窗口打开
62 63
  * }
63 64
  */
@@ -197,6 +198,14 @@ export const authRoutes = [
197 198
           hideInMenu: true,
198 199
         },
199 200
       },
201
+      {
202
+        path: "rotationChart/detail",
203
+        element: <RotationChartDetail />,
204
+        meta: {
205
+          title: "公告详情",
206
+          hideInMenu: true,
207
+        },
208
+      },
200 209
       {
201 210
         path: "rotationChart/introduction",
202 211
         element: <RotationChartIntroduction />,
@@ -213,18 +222,18 @@ export const authRoutes = [
213 222
         },
214 223
       },
215 224
       {
216
-        path: 'regulation',
225
+        path: "regulation",
217 226
         element: <RegulationList />,
218 227
         meta: {
219 228
           title: "规章制度",
220 229
         },
221 230
       },
222 231
       {
223
-        path: 'regulation/add',
232
+        path: "regulation/add",
224 233
         element: <RegulationEdit />,
225 234
         meta: {
226 235
           hideInMenu: true,
227
-          title: '规章制度维护',
236
+          title: "规章制度维护",
228 237
         },
229 238
       },
230 239
       {
@@ -261,10 +270,10 @@ export const authRoutes = [
261 270
     ],
262 271
   },
263 272
   {
264
-    path: 'static',
273
+    path: "static",
265 274
     element: <StatisCharts />,
266 275
     meta: {
267
-      title: '数据分析',
276
+      title: "数据分析",
268 277
       noSiderBar: true,
269 278
       noFooter: true,
270 279
     },
@@ -417,7 +426,7 @@ export const authRoutes = [
417 426
         meta: {
418 427
           title: "操作手册",
419 428
         },
420
-      }
429
+      },
421 430
     ],
422 431
   },
423 432
 ];
@@ -457,7 +466,7 @@ export const defaultRoutes = [
457 466
   },
458 467
 ];
459 468
 
460
-export function mergeAuthRoutes (r1, r2) {
469
+export function mergeAuthRoutes(r1, r2) {
461 470
   const r = r1.slice();
462 471
   const children = r1[0].children.slice();
463 472
   r[0].children = children.concat(r2);
@@ -466,7 +475,7 @@ export function mergeAuthRoutes (r1, r2) {
466 475
 
467 476
 // 全部路由
468 477
 export const routes = mergeAuthRoutes(defaultRoutes, authRoutes);
469
-function getPath (parent = "/", current = "") {
478
+function getPath(parent = "/", current = "") {
470 479
   if (current.indexOf("/") === 0 || current.indexOf("http") === 0)
471 480
     return current;
472 481
   return `${parent}/${current}`.replace(/\/\//g, "/");