diff --git a/packages/examination/src/views/examPaper/examPaperAdd.tsx b/packages/examination/src/views/examPaper/examPaperAdd.tsx index fe2ca7e..9f91e23 100644 --- a/packages/examination/src/views/examPaper/examPaperAdd.tsx +++ b/packages/examination/src/views/examPaper/examPaperAdd.tsx @@ -69,11 +69,9 @@ class ExamPaperAdd extends Component { componentDidMount() { this.handleFindDict(); - const id = sessionStorage.getItem('id'); - const isEdit= sessionStorage.getItem('isEdit'); + const { state } = this.props.location; + const { id, isEdit } = state; this.setState({ id: id ,isEdit: isEdit}); - sessionStorage.removeItem('id'); - sessionStorage.removeItem('isEdit'); if(isEdit === 'true'){ this.handleGetDetail(id); } diff --git a/packages/examination/src/views/examPaper/examPaperList.tsx b/packages/examination/src/views/examPaper/examPaperList.tsx index 4825e56..4a3c0db 100644 --- a/packages/examination/src/views/examPaper/examPaperList.tsx +++ b/packages/examination/src/views/examPaper/examPaperList.tsx @@ -34,11 +34,6 @@ class ExamPaperList extends Component { componentDidMount() { this.handleFindIndustry(); - const savedFormValues = sessionStorage.getItem('examPaperListFormValues'); - if (savedFormValues) { - const values = JSON.parse(savedFormValues); - this.formRef.current.setFieldsValue(values); - } this.handlegetList('def'); } @@ -62,7 +57,6 @@ class ExamPaperList extends Component { page : stat && stat === 'init' ? 1 : page }; this.setState({ page: data.page, num: data.num }); - sessionStorage.setItem('examPaperListFormValues', JSON.stringify(values)); getList(data).then((res) => { this.setState({ list: res.data.data, @@ -80,7 +74,6 @@ class ExamPaperList extends Component { // 重置 handleReset = () => { - sessionStorage.removeItem('examPaperListFormValues'); this.formRef.current.resetFields(); }; @@ -330,13 +323,21 @@ class ExamPaperList extends Component { width: 200, render: (record: any) => [ { - sessionStorage.setItem('id', String(record.id)); - sessionStorage.setItem('isEdit', "true"); - this.props.history.push(`/examPaperAdd`); + this.props.history.push({ + pathname: '/examPaperAdd', + state: { + id: String(record.id), + isEdit: "true" + } + }); }}>编辑, { - sessionStorage.setItem('id', String(record.id)); - this.props.history.push(`/examPaperView`); + this.props.history.push({ + pathname: '/examPaperView', + state: { + id: String(record.id) + } + }); }}>预览, { this.handleUpdatePaperStatus(record.id, record.paperStatus); diff --git a/packages/examination/src/views/examPaper/examPaperView.tsx b/packages/examination/src/views/examPaper/examPaperView.tsx index 87a2339..f296bff 100644 --- a/packages/examination/src/views/examPaper/examPaperView.tsx +++ b/packages/examination/src/views/examPaper/examPaperView.tsx @@ -52,8 +52,8 @@ class ExamPaperView extends Component { componentDidMount() { this.handleFindIndustry(); - const id = sessionStorage.getItem('id'); - sessionStorage.removeItem('id'); + const { state } = this.props.location; + const { id } = state; this.handleGetDetail(id); } @@ -67,7 +67,7 @@ class ExamPaperView extends Component { } // 试卷详情 - handleGetDetail = (id: string | null) => { + handleGetDetail = (id: string) => { getExamPaperDetail(id).then((res: any) => { if (res.data) { const newQuestions: QuestionState[] = res.data.data.map((questionData: any) => { diff --git a/packages/examination/src/views/question/questionEdit.tsx b/packages/examination/src/views/question/questionEdit.tsx index 2885d77..d62c230 100644 --- a/packages/examination/src/views/question/questionEdit.tsx +++ b/packages/examination/src/views/question/questionEdit.tsx @@ -48,8 +48,8 @@ class QuestionEdit extends Component { // 试题详情 handleGetQuestionDetail = () => { - const id = sessionStorage.getItem('id'); - sessionStorage.removeItem('id'); + const { state } = this.props.location; + const { id } = state; getQuestionDetail(id).then((res: any) => { if (res.data) { this.setState({ questionTypes: String(res.data.questionTypes) }); diff --git a/packages/examination/src/views/question/questionList.tsx b/packages/examination/src/views/question/questionList.tsx index 8b28b0a..517f4b4 100644 --- a/packages/examination/src/views/question/questionList.tsx +++ b/packages/examination/src/views/question/questionList.tsx @@ -36,11 +36,6 @@ class QuestionList extends Component { componentDidMount() { this.handleFindDict(); - const savedFormValues = sessionStorage.getItem('questionListFormValues'); - if (savedFormValues) { - const values = JSON.parse(savedFormValues); - this.formRef.current.setFieldsValue(values); - } this.handlegetList('def'); } @@ -81,7 +76,6 @@ class QuestionList extends Component { page : stat && stat === 'init' ? 1 : page }; this.setState({ page: data.page, num: data.num }); - sessionStorage.setItem('questionListFormValues', JSON.stringify(values)); getList(data) .then((res) => { this.setState({ @@ -100,7 +94,6 @@ class QuestionList extends Component { // 重置 handleReset = () => { - sessionStorage.removeItem('questionListFormValues'); this.formRef.current.resetFields(); }; @@ -273,8 +266,10 @@ class QuestionList extends Component { this.handleDeleteQuestion(record.id); }}>删除, { - sessionStorage.setItem('id', String(record.id)); - this.props.history.push(`/questionEdit`); + this.props.history.push({ + pathname: '/questionEdit', + state: { id: record.id } + }); }}>修正 ] },