Kaynağa Gözat

Merge branch 'master' of http://face3d.4dage.com:7005/chenzimin2/ZGZQBWG

任一存 1 yıl önce
ebeveyn
işleme
8d86e96b95

+ 42 - 11
houtai/src/pages/A1Rule/TopicSetting/index.tsx

@@ -23,9 +23,12 @@ import {
 } from "@/store/action/A1Rule";
 import { QuestionTableType } from "@/types";
 import { MessageFu } from "@/utils/message";
+import { v4 } from "uuid";
 import encodeStr from "@/utils/pass";
+// import decodeStr from "@/utils/pass";
+
 import { Base64 } from "js-base64";
-import { v4 } from "uuid";
+
 type Props = {
   closeFu: () => void;
 };
@@ -69,9 +72,8 @@ function TopicSetting({ closeFu }: Props) {
   const [curEdit, setCurEdit] = useState<any>();
   const onFinish = useCallback(
     async (values: any) => {
+      console.log("修改");
       let newList = editShowData;
-      // console.log(curEdit, newList[curEdit.index + (Number(pageNumRef) * Number(pagePageRef))], values.numberVal);
-      // console.log(curEdit, editShowData);
       if (curEdit && values.numberVal !== "") {
         switch (curEdit.project) {
           case "题目描述":
@@ -94,7 +96,7 @@ function TopicSetting({ closeFu }: Props) {
                     Number(pageNumRef.current - 1) * Number(pagePageRef.current)
                 ].answer.answer.push({
                   name: values.numberVal,
-                  val: encodeStr(Base64.encode("A")),
+                  val: "A",
                 });
             break;
           case "选项2":
@@ -121,7 +123,7 @@ function TopicSetting({ closeFu }: Props) {
                         Number(pagePageRef.current)
                   ].answer.answer.push({
                     name: values.numberVal,
-                    val: encodeStr(Base64.encode("B")),
+                    val: "B",
                   });
             }
             break;
@@ -149,7 +151,7 @@ function TopicSetting({ closeFu }: Props) {
                         Number(pagePageRef.current)
                   ].answer.answer.push({
                     name: values.numberVal,
-                    val: encodeStr(Base64.encode("C")),
+                    val: "C",
                   });
             }
             break;
@@ -177,7 +179,8 @@ function TopicSetting({ closeFu }: Props) {
                         Number(pagePageRef.current)
                   ].answer.answer.push({
                     name: values.numberVal,
-                    val: encodeStr(Base64.encode("D")),
+                    // val: encodeStr(Base64.encode("D")),
+                    val: "D",
                   });
             }
             break;
@@ -211,17 +214,38 @@ function TopicSetting({ closeFu }: Props) {
       });
     });
     setEditShowData(newList);
-    // setTableShowData(newList.splice(0, pagePageRef.current));
   }, []);
 
+  const decodeStr = (str: string) => {
+    const NUM = 2;
+    const str1 = str.substring(8);
+    const str2 = str1.substring(0, str1.length - 8);
+    const front = str2.slice(-NUM);
+    const end = str2.substring(0, str2.length - 8 - NUM);
+    return front + end;
+  };
+
   const handleCorrectChange = useCallback(
     (value: string, index: number) => {
       let newList = editShowData;
       newList[
         index + Number(pageNumRef.current - 1) * Number(pagePageRef.current)
-      ].answer.correct = value;
+      ].answer.correct = encodeStr(Base64.encode(value));
+      // console.log(
+      //   "切换正确答案",
+      //   Base64.decode(
+      //     decodeStr(
+      //       newList[
+      //         index +
+      //           Number(pageNumRef.current - 1) * Number(pagePageRef.current)
+      //       ].answer.correct
+      //     )
+      //   ),
+      //   value,
+      //   encodeStr(Base64.encode(value))
+      // );
+
       setEditShowData([...newList]);
-      // console.log(editShowData);
     },
     [editShowData]
   );
@@ -411,7 +435,11 @@ function TopicSetting({ closeFu }: Props) {
           return (
             <Select
               style={{ width: 120 }}
-              defaultValue={item.answer.correct ? item.answer.correct : ""}
+              defaultValue={
+                item.answer.correct
+                  ? Base64.decode(decodeStr(item.answer.correct))
+                  : ""
+              }
               onChange={(value: any) => {
                 handleCorrectChange(value, index);
               }}
@@ -510,7 +538,10 @@ function TopicSetting({ closeFu }: Props) {
         await deleteQuestionAPI(item);
       });
     }
+
+    console.log("查看题目编辑的数据是什么样", editShowData);
     // 执行数据提交   新增不用传id  编辑要传id
+    // console.log(editShowData)
     let data = editShowData.map((item: any) => {
       return item.type && item.type === "add"
         ? {

+ 1 - 0
houtai/src/pages/A1Rule/index.tsx

@@ -72,6 +72,7 @@ function A1Rule() {
   );
 
   const getList = useCallback(async () => {
+    // @ts-ignore
     dispatch(getRuleAPI("game"));
     const onlineRes = await getOnlineRuleAPI("online");
     if (onlineRes.code === 0) {

+ 1 - 0
houtai/src/pages/A2Integral/index.tsx

@@ -77,6 +77,7 @@ function A2Integral() {
   useEffect(() => {
     pageNumRef.current = tableSelect.pageNum;
     pagePageRef.current = tableSelect.pageSize;
+    // @ts-ignore
     dispatch(getIntegralListAPI(tableSelect));
   }, [dispatch, tableSelect]);
 

+ 1 - 0
houtai/src/pages/A3User/index.tsx

@@ -51,6 +51,7 @@ function A3User() {
       ...tableSelect,
       pageNum: pageNumRef.current,
     };
+    // @ts-ignore
     dispatch(getUserListAPI(data));
   }, [dispatch, tableSelect]);
 

+ 1 - 0
houtai/src/pages/A4Prize/index.tsx

@@ -93,6 +93,7 @@ function A4Prize() {
   );
 
   const getList = useCallback(async () => {
+    // @ts-ignore
     dispatch(getPrizeListAPI(tableSelect));
   }, [dispatch, tableSelect]);
 

+ 2 - 0
houtai/src/pages/A5Exchange/index.tsx

@@ -146,6 +146,7 @@ function A5Exchange() {
     const res: any = await handleCorrectChangeAPI(data);
     if (res.code === 0) {
       MessageFu.success("更新成功!");
+      // @ts-ignore
       dispatch(getExchangeListAPI(tableSelect));
     }
   };
@@ -153,6 +154,7 @@ function A5Exchange() {
   useEffect(() => {
     pageNumRef.current = tableSelect.pageNum;
     pagePageRef.current = tableSelect.pageSize;
+    // @ts-ignore
     dispatch(getExchangeListAPI(tableSelect));
   }, [dispatch, tableSelect]);
 

+ 1 - 0
houtai/src/pages/A6IDUser/IntegralEdit/index.tsx

@@ -126,6 +126,7 @@ function IntegralEdit({ currentItem, closeFu }: Props) {
             resultss
           );
           getInfoById();
+          // @ts-ignore
           dispatch(getIDUserListAPI(tableSelect));
           // setCurrentItemShow({
           //   ...currentItem,

+ 3 - 0
houtai/src/pages/A6IDUser/index.tsx

@@ -74,6 +74,7 @@ function A6IDUser() {
   useEffect(() => {
     pageNumRef.current = tableSelect.pageNum;
     pagePageRef.current = tableSelect.pageSize;
+    // @ts-ignore
     dispatch(getIDUserListAPI(tableSelect));
   }, [dispatch, tableSelect]);
 
@@ -109,6 +110,7 @@ function A6IDUser() {
         MessageFu.success(`成功${num === 0 ? "设为" : "取消"}黑名单`);
         pageNumRef.current = tableSelect.pageNum;
         pagePageRef.current = tableSelect.pageSize;
+        // @ts-ignore
         dispatch(getIDUserListAPI(tableSelect));
       } else {
         MessageFu.success(`操作失败`);
@@ -125,6 +127,7 @@ function A6IDUser() {
         MessageFu.success("删除成功!");
         pageNumRef.current = tableSelect.pageNum;
         pagePageRef.current = tableSelect.pageSize;
+        // @ts-ignore
         dispatch(getIDUserListAPI(tableSelect));
       }
     },

+ 1 - 0
houtai/src/pages/A8Scene/index.tsx

@@ -21,6 +21,7 @@ function A8Scene() {
     endTime: "",
   });
   const getList = useCallback(() => {
+    // @ts-ignore
     dispatch(getSceneListAPI(tableSelect));
   }, [dispatch, tableSelect]);
 

+ 1 - 0
houtai/src/pages/C7Log/index.tsx

@@ -44,6 +44,7 @@ function C2Log() {
   useEffect(() => {
     pageNumRef.current = tableSelect.pageNum;
     pagePageRef.current = tableSelect.pageSize;
+    // @ts-ignore
     dispatch(getLogListAPI(tableSelect));
   }, [dispatch, tableSelect]);
 

+ 1 - 0
houtai/src/pages/Login/index.tsx

@@ -12,6 +12,7 @@ import store from "@/store";
 import history from "@/utils/history";
 import encodeStr from "@/utils/pass";
 
+
 import LoginIMG from "@/assets/img/logo.png";
 import centerIMG from "@/assets/img/center.png";
 

+ 2 - 0
houtai/src/utils/pass.ts

@@ -97,4 +97,6 @@ const encodeStr = (str: string, strv = "") => {
   return front + str2 + middle + str1 + end;
 };
 
+
+
 export default encodeStr;