二次弹窗提示修改

main
hujunpeng 3 months ago
parent a8cf3d81ac
commit 7ff893b479
  1. 11
      packages/examination/src/views/exam-online/compoents/ExamEditPage.tsx
  2. 8
      packages/examination/src/views/exam-online/compoents/ExamListPage.tsx
  3. 16
      packages/examination/src/views/examPaper/examPaperAdd.tsx
  4. 8
      packages/examination/src/views/examPaper/examPaperList.tsx
  5. 12
      packages/examination/src/views/question/questionAdd.tsx
  6. 9
      packages/examination/src/views/question/questionEdit.tsx
  7. 8
      packages/examination/src/views/question/questionList.tsx

@ -1,6 +1,6 @@
import React, { useRef, useEffect, useState } from 'react'; import React, { useRef, useEffect, useState } from 'react';
// @ts-ignore // @ts-ignore
import { Form, Input, Select, DatePicker, Space, ColProps, Button, Cascader, DefaultOptionType, Rule } from 'antd'; import {Form, Input, Select, DatePicker, Space, ColProps, Button, Cascader, DefaultOptionType, Rule, Modal} from 'antd';
import type { FormProps, FormInstance } from 'antd'; import type { FormProps, FormInstance } from 'antd';
import ESBreadcrumbComponent from './ESBreadcrumbComponent'; // 引入面包屑组件 import ESBreadcrumbComponent from './ESBreadcrumbComponent'; // 引入面包屑组件
import { withRouter, RouteComponentProps } from 'react-router-dom'; // 引入 withRouter 和 RouteComponentProps import { withRouter, RouteComponentProps } from 'react-router-dom'; // 引入 withRouter 和 RouteComponentProps
@ -136,7 +136,16 @@ const ExamBasicInfoForm: React.FC<PropsWithRouter> = (props) => {
const handleSubmit = () => { const handleSubmit = () => {
if (formRef.current) { if (formRef.current) {
formRef.current.validateFields().then((values) => { formRef.current.validateFields().then((values) => {
const text = isEdit ? '修改' : '新增';
Modal.confirm({
title: `确认${text}`,
content: `是否${text}考试?`,
onOk: () => {
onFinish(values); onFinish(values);
},
onCancel: () => {
},
});
}).catch((errorInfo) => { }).catch((errorInfo) => {
console.log('表单验证失败:', errorInfo); console.log('表单验证失败:', errorInfo);
}); });

@ -241,18 +241,10 @@ const ExamListPage = ({ history }: { history: any }) => {
// 编辑 // 编辑
const handleEdit = (examId: number) => { const handleEdit = (examId: number) => {
Modal.confirm({
title: `确认修改`,
content: `是否修改试卷?`,
onOk: () => {
history.push({ history.push({
pathname: '/exam-edit', pathname: '/exam-edit',
state: { examId }, state: { examId },
}); });
},
onCancel: () => {
},
});
}; };
const handleDetail = (examId: number) => { const handleDetail = (examId: number) => {

@ -332,6 +332,10 @@ class ExamPaperAdd extends Component<any, States> {
questionIds questionIds
}; };
if (isEdit === 'true') { if (isEdit === 'true') {
Modal.confirm({
title: `确认修改`,
content: `是否修改试卷?`,
onOk: async () => {
const res = await editExamPaper(data); const res = await editExamPaper(data);
const success = res["success"]; const success = res["success"];
if (success) { if (success) {
@ -340,7 +344,15 @@ class ExamPaperAdd extends Component<any, States> {
} else { } else {
message.error('试卷更新失败'); message.error('试卷更新失败');
} }
},
onCancel: () => {
},
});
} else { } else {
Modal.confirm({
title: `确认保存`,
content: `是否保存试卷?`,
onOk: async () => {
const res = await addExamPaper(data); const res = await addExamPaper(data);
const success = res["success"]; const success = res["success"];
if (success) { if (success) {
@ -349,6 +361,10 @@ class ExamPaperAdd extends Component<any, States> {
} else { } else {
message.error('试卷保存失败'); message.error('试卷保存失败');
} }
},
onCancel: () => {
},
});
} }
} catch (error) { } catch (error) {
} }

@ -323,10 +323,6 @@ 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={() => {
Modal.confirm({
title: `确认修改`,
content: `是否修改试卷?`,
onOk: () => {
this.props.history.push({ this.props.history.push({
pathname: '/examPaperAdd', pathname: '/examPaperAdd',
state: { state: {
@ -334,10 +330,6 @@ class ExamPaperList extends Component<any, States> {
isEdit: "true" isEdit: "true"
} }
}); });
},
onCancel: () => {
},
});
}}></span>, }}></span>,
<span className='mr10 link' onClick={() => { <span className='mr10 link' onClick={() => {
this.props.history.push({ this.props.history.push({

@ -1,9 +1,10 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { Form, Input, Button, Radio, Checkbox, Select, message } from "antd"; import {Form, Input, Button, Radio, Checkbox, Select, message, Modal} from "antd";
import { dictionary } from "api/dict/index"; import { dictionary } from "api/dict/index";
import { addQuestion, findIndustry } from "api/question"; import { addQuestion, findIndustry } from "api/question";
import { CloseCircleOutlined } from '@ant-design/icons'; import { CloseCircleOutlined } from '@ant-design/icons';
import * as XLSX from "xlsx"; import * as XLSX from "xlsx";
import {addExamPaper} from "../../api/examPaper";
const { Option } = Select; const { Option } = Select;
@ -136,7 +137,10 @@ class QuestionAdd extends Component<any, States> {
this.formRef.current.validateFields().then((values: any) => { this.formRef.current.validateFields().then((values: any) => {
const questions: any = []; const questions: any = [];
const { formIds } = this.state; const { formIds } = this.state;
Modal.confirm({
title: `确认保存`,
content: `是否保存试题?`,
onOk: async () => {
formIds.forEach((formId) => { formIds.forEach((formId) => {
let answer = values[`answer_${formId}`]; let answer = values[`answer_${formId}`];
if (Array.isArray(answer)) { if (Array.isArray(answer)) {
@ -168,6 +172,10 @@ class QuestionAdd extends Component<any, States> {
}).catch(() => { }).catch(() => {
message.error("新增试题时发生错误,请检查"); message.error("新增试题时发生错误,请检查");
}); });
},
onCancel: () => {
},
});
}); });
}; };

@ -1,5 +1,5 @@
import React, { Component } from'react'; import React, { Component } from'react';
import { Form, Input, Button, Radio, Checkbox, Select, message } from 'antd'; import { Form, Input, Button, Radio, Checkbox, Select, message, Modal } from 'antd';
import { dictionary } from "api/dict/index"; import { dictionary } from "api/dict/index";
import { findIndustry, getQuestionDetail, editQuestion } from 'api/question'; import { findIndustry, getQuestionDetail, editQuestion } from 'api/question';
import TextArea from "antd/es/input/TextArea"; import TextArea from "antd/es/input/TextArea";
@ -91,6 +91,10 @@ class QuestionEdit extends Component<any, States> {
values.answer.sort(); values.answer.sort();
values.answer = values.answer.join(','); values.answer = values.answer.join(',');
} }
Modal.confirm({
title: `确认修改`,
content: `是否修改试题?`,
onOk: () => {
editQuestion(values).then((res) => { editQuestion(values).then((res) => {
const success = res['success']; const success = res['success'];
if (success) { if (success) {
@ -102,6 +106,9 @@ class QuestionEdit extends Component<any, States> {
}).catch(() => { }).catch(() => {
message.error('修改时发生错误,请检查'); message.error('修改时发生错误,请检查');
}); });
},
onCancel: () => {},
});
}); });
}; };

@ -266,18 +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={() => {
Modal.confirm({
title: `确认修改`,
content: `是否修改试题?`,
onOk: () => {
this.props.history.push({ this.props.history.push({
pathname: '/questionEdit', pathname: '/questionEdit',
state: { id: record.id } state: { id: record.id }
}); });
},
onCancel: () => {
},
});
}}></span> }}></span>
] ]
}, },

Loading…
Cancel
Save