feat:增加内部考试,外部考试编辑

This commit is contained in:
wyx
2023-02-10 17:55:42 +08:00
parent 962f55dee5
commit 1b4bb2b5ee
4 changed files with 121 additions and 68 deletions

View File

@@ -17,21 +17,44 @@
</div>
<!-- 2022-11-30注释 后面放开 修改div的padding-topL:32 -->
<div style="display: flex; flex-direction: row; padding-top: 0px; margin-top: 20px; margin-left: 32px;">
<button
style="width: 100px; cursor: pointer;"
@click="changeOuter(1)"
:class="[isOuter == 1 ? 'outer' : 'notOuter']"
>
系统考试
</button>
<button
style="width: 100px; cursor: pointer;"
@click="changeOuter(2)"
:class="[isOuter == 2 ? 'outer' : 'notOuter']"
>
外部考试
</button>
<div v-if="edit">
<button
v-if="isOuter == 1"
style="width: 100px; cursor: pointer;"
@click="changeOuter(1)"
:class="[isOuter == 1 ? 'outer' : 'notOuter']"
>
系统考试
</button>
<button
v-else
style="width: 100px; cursor: pointer;"
@click="changeOuter(2)"
:class="[isOuter == 2 ? 'outer' : 'notOuter']"
>
外部考试
</button>
</div>
<div v-else>
<button
style="width: 100px; cursor: pointer;"
@click="changeOuter(1)"
:class="[isOuter == 1 ? 'outer' : 'notOuter']"
>
系统考试
</button>
<button
style="width: 100px; cursor: pointer;"
@click="changeOuter(2)"
:class="[isOuter == 2 ? 'outer' : 'notOuter']"
>
外部考试
</button>
</div>
</div>
<div v-if="isOuter==1" class="contentMain">
@@ -366,6 +389,8 @@ import {message} from "ant-design-vue";
import {
createExamination,
queryExaminationDetailById,
updateExamination,
updateExternalExam
} from "@/api/indexExam";
// updateExamination,
import STest from "./SelectTest.vue";
@@ -496,6 +521,12 @@ export default {
scoringModel: 2,
questionArrangement: 4,
};
state.test1 = {
externalName: '',
source: '',
externalExplain: null
}
};
const closeDrawer = () => {
@@ -522,7 +553,7 @@ export default {
console.log("props", props);
if (props.addtestVisible && props.EditTestId && props.EditTestId >0) {
// 该页面显示同时 edit为true 时,发送查询请求,
// queryTest();
queryTest();
}
if (bool) {
state.test.showAnswers = 1;
@@ -541,22 +572,36 @@ export default {
const queryTest = () => {
queryExaminationDetailById({examinationId: props.EditTestId})
.then((res) => {
state.test = res.data.data;
state.test.showAnswers = Number(state.test.showAnswers);
state.test.showAnalysis = Number(state.test.showAnalysis);
state.test.scoringModel = Number(state.test.scoringModel);
state.test.questionArrangement = Number(
state.test.questionArrangement
);
state.test.chooseTime = [
dayjs(res.data.data.examinationStartTime, "YYYY-MM-DD HH:mm"),
dayjs(res.data.data.examinationEndTime, "YYYY-MM-DD HH:mm"),
];
state.paperName = state.test.examinationTestName;
// state.paperId=dayjs
state.paperId = state.test.examinationTestId;
console.log(res)
// 判断获取的考试
if(res.data.data.examType==2){
state.isOuter = 2;
// 外部考试
state.test1 = {
externalName: res.data.data.examinationName,
source: res.data.data.source,
externalExplain: res.data.data.examinationExplain
}
}else{
// 系统考试
state.isOuter = 1;
state.test = res.data.data;
state.test.showAnswers = Number(state.test.showAnswers);
state.test.showAnalysis = Number(state.test.showAnalysis);
state.test.scoringModel = Number(state.test.scoringModel);
state.test.questionArrangement = Number(
state.test.questionArrangement
);
state.test.chooseTime = [
dayjs(res.data.data.examinationStartTime, "YYYY-MM-DD HH:mm"),
dayjs(res.data.data.examinationEndTime, "YYYY-MM-DD HH:mm"),
];
state.paperName = state.test.examinationTestName;
// state.paperId=dayjs
state.paperId = state.test.examinationTestId;
console.log("querytest", state.test);
console.log("querytest", state.test);
}
})
.catch(() => {
//message.error(`查询失败`);
@@ -630,18 +675,18 @@ export default {
// if (props.EditTestId > 0) {
// // 编辑任务
// updateExamination(state.test)
// .then(async (res) => {
// await updateTask(res);
// // closeDrawer();
// })
// .catch(() => {
// message.destroy();
// message.error(`编辑失败`);
// });
// } else {
if (props.EditTestId > 0) {
// 编辑任务
updateExamination(state.test)
.then(async (res) => {
await updateTask(res);
// closeDrawer();
})
.catch(() => {
message.destroy();
message.error(`编辑失败`);
});
} else {
// 创建任务
createExamination(state.test)
.then(async (res) => {
@@ -652,7 +697,7 @@ export default {
message.destroy();
message.error(`创建失败`);
});
// }
}
}else{
// 创建外部考试
console.log('我是点了外部考试')
@@ -687,14 +732,34 @@ export default {
}
}
// 新建外部考试
CreateExternalExam(state.test1).then( async res=>{
console.log('新建外部考试返回的参数',res)
// 添加更新到任务
await updateTask1(res);
}).catch(err=>{
console.log(err)
})
if (props.EditTestId > 0) {
console.log('我要开始编辑外部考试任务了 啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊')
let obj = {
examinationId:props.EditTestId,
examinationName:state.test1.externalName,
examinationExplain:state.test1.externalExplain,
source:state.test1.source
}
updateExternalExam(obj)
.then(async (res) => {
await updateTask1(res);
// closeDrawer();
})
.catch(() => {
message.destroy();
message.error(`编辑失败`);
});
}else{
// 新建外部考试
CreateExternalExam(state.test1).then( async res=>{
console.log('新建外部考试返回的参数',res)
// 添加更新到任务
await updateTask1(res);
}).catch(err=>{
console.log(err)
})
}
}
};
// 系统考试