Your Name 2 years ago
parent
commit
95afa5a7c7
3 changed files with 33 additions and 19 deletions
  1. 13
    10
      src/components/Wangeditor/index.jsx
  2. 12
    1
      src/pages/evaluate/index.jsx
  3. 8
    8
      src/routes/routes.jsx

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

@@ -31,23 +31,19 @@ function MyEditor(props) {
31 31
   const [editor, setEditor] = useState(null); // 存储 editor 实例
32 32
   const [html, setHtml] = useState("");
33 33
  
34
-  // // 模拟 ajax 请求,异步设置 html
35
-  // useEffect(() => {
36
-  //   setHtml(value || "");
37
-  // }, [value]);
34
+  // 模拟 ajax 请求,异步设置 html
35
+  useEffect(() => {
36
+    setHtml(value || "");
37
+  }, [value]);
38 38
 
39 39
   // 及时销毁 editor
40 40
   useEffect(() => {
41
-    if (editor) {
42
-      setHtml(value || "");
43
-    }
44
-
45 41
     return () => {
46 42
       if (editor == null) return;
47 43
       editor.destroy();
48 44
       setEditor(null);
49 45
     };
50
-  }, [editor, value]);
46
+  }, [editor]);
51 47
 
52 48
   function insertText() {
53 49
     if (editor == null) return;
@@ -59,6 +55,13 @@ function MyEditor(props) {
59 55
     console.log(editor.getHtml());
60 56
   }
61 57
 
58
+  const handleChange = (editor) => {
59
+    const raw = editor.getHtml();
60
+    if (raw !== '<p><br></p>') {
61
+      onChange(raw)
62
+    }
63
+  }
64
+
62 65
   return !readonly ? (
63 66
     <div className={props.className} style={style}>
64 67
       <Toolbar
@@ -71,7 +74,7 @@ function MyEditor(props) {
71 74
         defaultConfig={editorConfig}
72 75
         value={html}
73 76
         onCreated={setEditor}
74
-        onChange={(editor) => onChange(editor.getHtml())}
77
+        onChange={handleChange}
75 78
         mode="default"
76 79
         style={{ height: "500px" }}
77 80
       />

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

@@ -9,6 +9,7 @@ import { Link, useNavigate } from "react-router-dom";
9 9
 import { Button, message, Popconfirm } from "antd";
10 10
 import moment from "moment";
11 11
 import { useRef, useState } from "react";
12
+import AddeValuate from "./evaluateList/addeValuate";
12 13
 
13 14
 const GuaranteeTaskList = (props) => {
14 15
   const navigate = useNavigate();
@@ -77,6 +78,16 @@ const GuaranteeTaskList = (props) => {
77 78
       valueType: "option",
78 79
       width: 200,
79 80
       render: (_, record) => [
81
+        <Button
82
+          key={1}
83
+          style={{ padding: 0 }}
84
+          type="link"
85
+          onClick={() => {
86
+            navigate(`/task/evaluate/list?id=${record.id}`);
87
+          }}
88
+        >
89
+          评价列表
90
+        </Button>,
80 91
         <Button
81 92
           key={2}
82 93
           style={{ padding: 0 }}
@@ -85,7 +96,7 @@ const GuaranteeTaskList = (props) => {
85 96
             navigate(`/task/evaluate/list?id=${record.id}`);
86 97
           }}
87 98
         >
88
-          评价
99
+          新增评价
89 100
         </Button>,
90 101
       ],
91 102
     },

+ 8
- 8
src/routes/routes.jsx View File

@@ -92,14 +92,6 @@ export const authRoutes = [
92 92
         index: true,
93 93
         element: <Navigate to="guaranteeTask" replace />,
94 94
       },
95
-      {
96
-        path: "guaranteeTask",
97
-        element: <GuaranteeTaskList />,
98
-        meta: {
99
-          title: "军供通报",
100
-          permission: 'guaranteeTask',
101
-        },
102
-      },
103 95
       {
104 96
         path: "guaranteeTask/edit",
105 97
         element: <GuaranteeTaskEdit />,
@@ -108,6 +100,14 @@ export const authRoutes = [
108 100
           permission: 'guaranteeTask.edit',
109 101
         },
110 102
       },
103
+      {
104
+        path: "guaranteeTask",
105
+        element: <GuaranteeTaskList />,
106
+        meta: {
107
+          title: "军供通报",
108
+          permission: 'guaranteeTask',
109
+        },
110
+      },
111 111
       {
112 112
         path: "guaranteeTask/print",
113 113
         element: <GuaranteeTaskPrint />,