Преглед изворни кода

factors 改为可选参数

visuddhinanda пре 2 година
родитељ
комит
97063ae936
1 измењених фајлова са 11 додато и 6 уклоњено
  1. 11 6
      dashboard/src/components/template/Wbw/WbwDetailFm.tsx

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

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