2
0
Эх сурвалжийг харах

factors 改为可选参数

visuddhinanda 2 жил өмнө
parent
commit
97063ae936

+ 11 - 6
dashboard/src/components/template/Wbw/WbwDetailFm.tsx

@@ -85,16 +85,16 @@ const WbwFactorMeaningItem = ({ pali, meaning, onChange }: IWFMI) => {
 };
 };
 
 
 interface IWidget {
 interface IWidget {
-  factors: string[];
+  factors?: string[];
   initValue?: string[];
   initValue?: string[];
   onChange?: Function;
   onChange?: Function;
-  onOk?: Function;
+  onJoin?: Function;
 }
 }
 const WbwDetailFmWidget = ({
 const WbwDetailFmWidget = ({
-  factors,
+  factors = [],
   initValue = [],
   initValue = [],
   onChange,
   onChange,
-  onOk,
+  onJoin,
 }: IWidget) => {
 }: IWidget) => {
   const [factorInputEnable, setFactorInputEnable] = useState(false);
   const [factorInputEnable, setFactorInputEnable] = useState(false);
   const [factorMeaning, setFactorMeaning] = useState<string[]>(initValue);
   const [factorMeaning, setFactorMeaning] = useState<string[]>(initValue);
@@ -116,6 +116,7 @@ const WbwDetailFmWidget = ({
   }, []);
   }, []);
 
 
   useEffect(() => {
   useEffect(() => {
+    console.log("factors", factors);
     setFactorMeaning(resizeArray(factorMeaning));
     setFactorMeaning(resizeArray(factorMeaning));
   }, [factors]);
   }, [factors]);
 
 
@@ -181,8 +182,12 @@ const WbwDetailFmWidget = ({
                       type="text"
                       type="text"
                       icon={<CheckOutlined />}
                       icon={<CheckOutlined />}
                       onClick={() => {
                       onClick={() => {
-                        if (typeof onOk !== "undefined") {
-                          onOk(factorMeaning.join(""));
+                        if (typeof onJoin !== "undefined") {
+                          onJoin(
+                            factorMeaning
+                              .filter((value) => !value.includes("["))
+                              .join(" ")
+                          );
                         }
                         }
                       }}
                       }}
                     />
                     />