|
|
@@ -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"
|
|
|
? {
|