sessionStorage删除

main
hujunpeng 3 months ago
parent 0056237bb5
commit 476dcaac80
  1. 6
      packages/examination/src/views/examPaper/examPaperAdd.tsx
  2. 25
      packages/examination/src/views/examPaper/examPaperList.tsx
  3. 6
      packages/examination/src/views/examPaper/examPaperView.tsx
  4. 4
      packages/examination/src/views/question/questionEdit.tsx
  5. 13
      packages/examination/src/views/question/questionList.tsx

@ -69,11 +69,9 @@ class ExamPaperAdd extends Component<any, States> {
componentDidMount() { componentDidMount() {
this.handleFindDict(); this.handleFindDict();
const id = sessionStorage.getItem('id'); const { state } = this.props.location;
const isEdit= sessionStorage.getItem('isEdit'); const { id, isEdit } = state;
this.setState({ id: id ,isEdit: isEdit}); this.setState({ id: id ,isEdit: isEdit});
sessionStorage.removeItem('id');
sessionStorage.removeItem('isEdit');
if(isEdit === 'true'){ if(isEdit === 'true'){
this.handleGetDetail(id); this.handleGetDetail(id);
} }

@ -34,11 +34,6 @@ class ExamPaperList extends Component<any, States> {
componentDidMount() { componentDidMount() {
this.handleFindIndustry(); this.handleFindIndustry();
const savedFormValues = sessionStorage.getItem('examPaperListFormValues');
if (savedFormValues) {
const values = JSON.parse(savedFormValues);
this.formRef.current.setFieldsValue(values);
}
this.handlegetList('def'); this.handlegetList('def');
} }
@ -62,7 +57,6 @@ class ExamPaperList extends Component<any, States> {
page : stat && stat === 'init' ? 1 : page page : stat && stat === 'init' ? 1 : page
}; };
this.setState({ page: data.page, num: data.num }); this.setState({ page: data.page, num: data.num });
sessionStorage.setItem('examPaperListFormValues', JSON.stringify(values));
getList(data).then((res) => { getList(data).then((res) => {
this.setState({ this.setState({
list: res.data.data, list: res.data.data,
@ -80,7 +74,6 @@ class ExamPaperList extends Component<any, States> {
// 重置 // 重置
handleReset = () => { handleReset = () => {
sessionStorage.removeItem('examPaperListFormValues');
this.formRef.current.resetFields(); this.formRef.current.resetFields();
}; };
@ -330,13 +323,21 @@ class ExamPaperList extends Component<any, States> {
width: 200, width: 200,
render: (record: any) => [ render: (record: any) => [
<span className='mr10 link' onClick={() => { <span className='mr10 link' onClick={() => {
sessionStorage.setItem('id', String(record.id)); this.props.history.push({
sessionStorage.setItem('isEdit', "true"); pathname: '/examPaperAdd',
this.props.history.push(`/examPaperAdd`); state: {
id: String(record.id),
isEdit: "true"
}
});
}}></span>, }}></span>,
<span className='mr10 link' onClick={() => { <span className='mr10 link' onClick={() => {
sessionStorage.setItem('id', String(record.id)); this.props.history.push({
this.props.history.push(`/examPaperView`); pathname: '/examPaperView',
state: {
id: String(record.id)
}
});
}}></span>, }}></span>,
<span className='mr10 link' onClick={() => { <span className='mr10 link' onClick={() => {
this.handleUpdatePaperStatus(record.id, record.paperStatus); this.handleUpdatePaperStatus(record.id, record.paperStatus);

@ -52,8 +52,8 @@ class ExamPaperView extends Component<any, States> {
componentDidMount() { componentDidMount() {
this.handleFindIndustry(); this.handleFindIndustry();
const id = sessionStorage.getItem('id'); const { state } = this.props.location;
sessionStorage.removeItem('id'); const { id } = state;
this.handleGetDetail(id); this.handleGetDetail(id);
} }
@ -67,7 +67,7 @@ class ExamPaperView extends Component<any, States> {
} }
// 试卷详情 // 试卷详情
handleGetDetail = (id: string | null) => { handleGetDetail = (id: string) => {
getExamPaperDetail(id).then((res: any) => { getExamPaperDetail(id).then((res: any) => {
if (res.data) { if (res.data) {
const newQuestions: QuestionState[] = res.data.data.map((questionData: any) => { const newQuestions: QuestionState[] = res.data.data.map((questionData: any) => {

@ -48,8 +48,8 @@ class QuestionEdit extends Component<any, States> {
// 试题详情 // 试题详情
handleGetQuestionDetail = () => { handleGetQuestionDetail = () => {
const id = sessionStorage.getItem('id'); const { state } = this.props.location;
sessionStorage.removeItem('id'); const { id } = state;
getQuestionDetail(id).then((res: any) => { getQuestionDetail(id).then((res: any) => {
if (res.data) { if (res.data) {
this.setState({ questionTypes: String(res.data.questionTypes) }); this.setState({ questionTypes: String(res.data.questionTypes) });

@ -36,11 +36,6 @@ class QuestionList extends Component<any, States> {
componentDidMount() { componentDidMount() {
this.handleFindDict(); this.handleFindDict();
const savedFormValues = sessionStorage.getItem('questionListFormValues');
if (savedFormValues) {
const values = JSON.parse(savedFormValues);
this.formRef.current.setFieldsValue(values);
}
this.handlegetList('def'); this.handlegetList('def');
} }
@ -81,7 +76,6 @@ class QuestionList extends Component<any, States> {
page : stat && stat === 'init' ? 1 : page page : stat && stat === 'init' ? 1 : page
}; };
this.setState({ page: data.page, num: data.num }); this.setState({ page: data.page, num: data.num });
sessionStorage.setItem('questionListFormValues', JSON.stringify(values));
getList(data) getList(data)
.then((res) => { .then((res) => {
this.setState({ this.setState({
@ -100,7 +94,6 @@ class QuestionList extends Component<any, States> {
// 重置 // 重置
handleReset = () => { handleReset = () => {
sessionStorage.removeItem('questionListFormValues');
this.formRef.current.resetFields(); this.formRef.current.resetFields();
}; };
@ -273,8 +266,10 @@ class QuestionList extends Component<any, States> {
this.handleDeleteQuestion(record.id); this.handleDeleteQuestion(record.id);
}}></span>, }}></span>,
<span className="mr10 link" onClick={() => { <span className="mr10 link" onClick={() => {
sessionStorage.setItem('id', String(record.id)); this.props.history.push({
this.props.history.push(`/questionEdit`); pathname: '/questionEdit',
state: { id: record.id }
});
}}></span> }}></span>
] ]
}, },

Loading…
Cancel
Save