mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-12 12:26:47 +08:00
feat:在作业和考试drawer中新增编辑·查询.删除功能
fix: 时间栏显示bug
This commit is contained in:
@@ -8,7 +8,10 @@ export const createExamination = (obj) => http.post('/examination/createExaminat
|
||||
// 根据Id删除考试信息
|
||||
export const deleteExaminationById = (obj) => http.post('/examination/deleteExaminationById',obj);
|
||||
// 根据ID获取考试信息详情
|
||||
export const queryExaminationDetailById = (obj) => http.post('/examination/queryExaminationDetailById',obj);
|
||||
export const queryExaminationDetailById = (obj) => http.post('/examination/queryExaminationDetailById',obj,{headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
}
|
||||
});
|
||||
// 创建考试信息接口
|
||||
export const updateExamination = (obj) => http.post('/examination/updateExamination',obj);
|
||||
|
||||
|
||||
@@ -8,7 +8,11 @@ export const createWorkTask = (obj) => http.post('/work/createWorkTask',obj,{
|
||||
// 删除作业信息接口
|
||||
export const deleteWorkTask = (obj) => http.post('/work/deleteWorkTask',obj);
|
||||
// 根据ID获取作业信息详情
|
||||
export const queryWorkDetailById = (obj) => http.post('/work/queryWorkDetailById',obj);
|
||||
export const queryWorkDetailById = (obj) => http.post('/work/queryWorkDetailById',obj,{
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
}
|
||||
});
|
||||
// 修改作业信息接口
|
||||
export const updateWorkTaskUsing = (obj) => http.post('/work/updateWorkTask',obj);
|
||||
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
:visible="addhomeworkVisible"
|
||||
class="drawerStyle addhomeworkDrawer"
|
||||
width="80%"
|
||||
title="添加作业"
|
||||
placement="right"
|
||||
@after-visible-change="afterVisibleChange"
|
||||
>
|
||||
<div class="drawerMain">
|
||||
<div class="header">
|
||||
<div class="headerTitle">添加作业</div>
|
||||
<div class="headerTitle">{{workId ? '编辑':'添加' }}作业</div>
|
||||
<img
|
||||
style="width: 29px; height: 29px; cursor: pointer"
|
||||
src="../../assets/images/basicinfo/close.png"
|
||||
@@ -17,7 +16,6 @@
|
||||
/>
|
||||
</div>
|
||||
<a-form
|
||||
|
||||
ref="formRef"
|
||||
name="custom-validation"
|
||||
:model="formState"
|
||||
@@ -59,6 +57,7 @@
|
||||
<a-range-picker
|
||||
style="width: 424px;margin-left: 35px;"
|
||||
v-model:value="formState.choosedTime"
|
||||
format="YYYY-MM-DD"
|
||||
:placeholder="[' 开始时间', ' 结束时间']"
|
||||
/>
|
||||
</a-form-item>
|
||||
@@ -81,7 +80,7 @@
|
||||
action="/api/file/upload"
|
||||
@change="handleChange"
|
||||
>
|
||||
<button class="xkbtn">上传附件</button>
|
||||
<button class="xkbtn" type="button">上传附件</button>
|
||||
</a-upload>
|
||||
</div>
|
||||
</div>
|
||||
@@ -106,7 +105,7 @@
|
||||
<script>
|
||||
import { reactive, ref } from "vue";
|
||||
import {message} from"ant-design-vue";
|
||||
import {createWorkTask} from "@/api/indexWork"
|
||||
import { createWorkTask, queryWorkDetailById, updateWorkTaskUsing} from "@/api/indexWork";
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const rowSelection = ref({
|
||||
@@ -134,6 +133,10 @@ export default {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
workId: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
}
|
||||
},
|
||||
setup(props, ctx) {
|
||||
const formState = reactive({
|
||||
@@ -142,23 +145,22 @@ export default {
|
||||
choosedTime: '',
|
||||
});
|
||||
const formRef = ref();
|
||||
|
||||
|
||||
let checkWorkName = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入作业名称");
|
||||
return Promise.reject('请输入作业名称');
|
||||
}
|
||||
};
|
||||
|
||||
let checkWorkRequirement = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入作业要求");
|
||||
return Promise.reject('请输入作业要求');
|
||||
}
|
||||
};
|
||||
|
||||
let checkTime = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请选择时间");
|
||||
if (!value.length) {
|
||||
return Promise.reject('请选择时间');
|
||||
}
|
||||
};
|
||||
@@ -190,7 +192,7 @@ export default {
|
||||
// };
|
||||
const handleFinish = values => {
|
||||
console.log(values);
|
||||
addHomework()
|
||||
updateWork(props.workId)
|
||||
};
|
||||
|
||||
const handleFinishFailed = errors => {
|
||||
@@ -220,13 +222,29 @@ export default {
|
||||
const fileList = ref([]);
|
||||
const closeDrawer = () => {
|
||||
resetForm();
|
||||
fileList.value = [];
|
||||
formState.choosedTime = '';
|
||||
ctx.emit("update:addhomeworkVisible", false);
|
||||
};
|
||||
const afterVisibleChange = (bool) => {
|
||||
if(props.addhomeworkVisible && props.workId){
|
||||
queryWork({workId: props.workId})
|
||||
}
|
||||
console.log("state", bool);
|
||||
};
|
||||
const addHomework = () => {
|
||||
createWorkTask({
|
||||
const queryWork = (data) => {
|
||||
queryWorkDetailById(data).then((res) => {
|
||||
console.log(dayjs(res.data.data.submitStartTime).format("YYYY-MM-DD"));
|
||||
formState.workName = res.data.data.workName;
|
||||
formState.workRequirement = res.data.data.workRequirement;
|
||||
formState.choosedTime=[dayjs(res.data.data.submitStartTime,"YYYY-MM-DD"),dayjs(res.data.data.submitEndTime,"YYYY-MM-DD")]
|
||||
console.log(res);
|
||||
}).catch(() => {
|
||||
message.error(`查询失败`)
|
||||
})
|
||||
};
|
||||
const updateWork = (id) => {
|
||||
let obj = {
|
||||
"createTime": "",
|
||||
"createUser": 0,
|
||||
"submitEndTime": dayjs(formState.choosedTime[1]).format("YYYY-MM-DD"),
|
||||
@@ -235,22 +253,32 @@ export default {
|
||||
"updateUser": 0,
|
||||
"workEnclosureAddress": "",
|
||||
"workFlag": "",
|
||||
"workId": 0,
|
||||
"workId": id || 0,
|
||||
"workName": formState.workName,
|
||||
"workRequirement": formState.workRequirement,
|
||||
"workTag": ""
|
||||
}).then((res)=>{
|
||||
}
|
||||
if(id) {
|
||||
updateWorkTaskUsing(obj).then((res) => {
|
||||
console.log(res);
|
||||
message.success(`编辑成功`)
|
||||
closeDrawer();
|
||||
}).catch((err) => {
|
||||
message.error(`编辑失败${err}`)
|
||||
})
|
||||
} else {
|
||||
createWorkTask(obj).then((res)=>{
|
||||
message.success(`添加成功${res}`)
|
||||
closeDrawer();
|
||||
}).catch((err)=>{
|
||||
message.error(`添加失败${err}`)
|
||||
})
|
||||
}
|
||||
};
|
||||
return {
|
||||
afterVisibleChange,
|
||||
closeDrawer,
|
||||
rowSelection,
|
||||
addHomework,
|
||||
handleChange,
|
||||
fileList,
|
||||
formState,
|
||||
@@ -261,6 +289,8 @@ export default {
|
||||
formRef,
|
||||
// layout,
|
||||
rules,
|
||||
queryWork,
|
||||
updateWork,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
:visible="addtestVisible"
|
||||
class="drawerStyle addtestDrawer"
|
||||
width="80%"
|
||||
title="添加作业"
|
||||
placement="right"
|
||||
@after-visible-change="afterVisibleChange"
|
||||
>
|
||||
<div class="drawerMain">
|
||||
<div class="header">
|
||||
<div class="headerTitle">添加考试</div>
|
||||
<div class="headerTitle">{{examinationId ? "编辑" : "添加" }}考试</div>
|
||||
<img
|
||||
style="width: 29px; height: 29px; cursor: pointer"
|
||||
src="../../assets/images/basicinfo/close.png"
|
||||
@@ -73,6 +72,7 @@
|
||||
|
||||
<a-range-picker
|
||||
v-model:value="formState.choosedTime"
|
||||
format="YYYY-MM-DD"
|
||||
style="width: 424px;margin-left: 35px;"
|
||||
:placeholder="[' 开始时间', ' 结束时间']"
|
||||
/>
|
||||
@@ -88,8 +88,9 @@
|
||||
style="width: 388px; height: 32px;
|
||||
margin-left: 35px;"
|
||||
/>
|
||||
<span style="margin-left: 5px">分钟</span>
|
||||
|
||||
</a-form-item>
|
||||
<span style="transform: translateY(-50%)">分钟</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main_item">
|
||||
@@ -115,7 +116,7 @@
|
||||
<div class="btnbox">
|
||||
<a-form-item has-feedback label="显示答案" name="showAnswers">
|
||||
|
||||
<a-radio-group style="margin-left: 35px;" v-model:value="formState.showAnswers">
|
||||
<a-radio-group style="margin-left: 35px;margin-right: 12px;" v-model:value="formState.showAnswers">
|
||||
<a-radio v-model:checked="checked" :value="1" @click="cloradio1">允许查看</a-radio>
|
||||
<a-radio v-model:checked="checked" :value="2" @click="cloradio1"
|
||||
>不允许查看</a-radio
|
||||
@@ -129,7 +130,7 @@
|
||||
<div class="btnbox">
|
||||
<a-form-item has-feedback label="显示解析" name="showAnalysis">
|
||||
|
||||
<a-radio-group style="margin-left: 35px;" v-model:value="formState.showAnalysis">
|
||||
<a-radio-group style="margin-left: 35px;margin-right: 12px;" v-model:value="formState.showAnalysis">
|
||||
<a-radio v-model:checked="checked" :value="1" @click="cloradio2">允许查看</a-radio>
|
||||
<a-radio v-model:checked="checked" :value="2" @click="cloradio2"
|
||||
>不允许查看</a-radio
|
||||
@@ -143,7 +144,7 @@
|
||||
<div class="btnbox">
|
||||
<a-form-item has-feedback label="评分模式" name="scoringModel">
|
||||
|
||||
<a-radio-group style="margin-left: 35px;" v-model:value="formState.scoringModel">
|
||||
<a-radio-group style="margin-left: 35px;margin-right: 12px;" v-model:value="formState.scoringModel">
|
||||
<a-radio v-model:checked="checked" :value="1" @click="cloradio3"
|
||||
>最高一次</a-radio
|
||||
>
|
||||
@@ -171,7 +172,9 @@
|
||||
<div class="btnbox">
|
||||
<a-form-item has-feedback label="作业要求" name="questionArrangement">
|
||||
|
||||
<a-radio-group v-model:value="formState.questionArrangement">
|
||||
<a-radio-group
|
||||
style="margin-right:12px;"
|
||||
v-model:value="formState.questionArrangement">
|
||||
<a-radio v-model:checked="checked" :value="1" @click="cloradio4">试题乱序</a-radio>
|
||||
<a-radio v-model:checked="checked" :value="2" @click="cloradio4">试题排序</a-radio>
|
||||
<a-radio v-model:checked="checked" :value="3" @click="cloradio4">全部乱序</a-radio>
|
||||
@@ -193,7 +196,7 @@
|
||||
<script>
|
||||
import { reactive, ref } from "vue";
|
||||
import {message} from"ant-design-vue";
|
||||
import {createExamination} from "@/api/indexExam"
|
||||
import {createExamination,queryExaminationDetailById,updateExamination} from "@/api/indexExam"
|
||||
import dayjs from 'dayjs';
|
||||
const rowSelection = ref({
|
||||
checkStrictly: false,
|
||||
@@ -220,6 +223,10 @@ export default {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
examinationId: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
}
|
||||
},
|
||||
setup(props, ctx) {
|
||||
const formState = reactive({
|
||||
@@ -233,71 +240,61 @@ export default {
|
||||
scoringModel:2,
|
||||
showAnalysis:2,
|
||||
showAnswers:2,
|
||||
choosedTime:'',
|
||||
});
|
||||
const formRef = ref();
|
||||
let checkExaminationName = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入考试名称");
|
||||
return Promise.reject('请输入考试名称');
|
||||
}
|
||||
};
|
||||
let checkExaminationExplain = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入考试说明");
|
||||
return Promise.reject('请输入考试说明');
|
||||
}
|
||||
};
|
||||
let checkChoosedTest = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请选择考试");
|
||||
return Promise.reject('请选择考试');
|
||||
}
|
||||
};
|
||||
let checkChoosedTime = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请选择时间");
|
||||
if (!value.length) {
|
||||
return Promise.reject('请选择时间');
|
||||
}
|
||||
};
|
||||
let checkExaminationDuration = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入考试时长");
|
||||
return Promise.reject('请输入考试时长');
|
||||
}
|
||||
};
|
||||
let checkLimit = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入考试限制");
|
||||
return Promise.reject('请输入考试限制');
|
||||
}
|
||||
};
|
||||
let checkShowAnswers = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入作业名称");
|
||||
return Promise.reject('请输入作业名称');
|
||||
}
|
||||
};
|
||||
let checkShowAnalysis = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入作业名称");
|
||||
return Promise.reject('请输入作业名称');
|
||||
}
|
||||
};
|
||||
let checkScoringModel = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入作业名称");
|
||||
return Promise.reject('请输入作业名称');
|
||||
}
|
||||
};
|
||||
let checkPassLine = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入及格线");
|
||||
return Promise.reject('请输入及格线');
|
||||
}
|
||||
};
|
||||
let checkQuestionArrangement = async (_rule, value) => {
|
||||
if (!value) {
|
||||
message.warning("请输入作业名称");
|
||||
return Promise.reject('请输入作业名称');
|
||||
}
|
||||
};
|
||||
@@ -366,7 +363,7 @@ export default {
|
||||
])
|
||||
const handleFinish = values => {
|
||||
console.log(values);
|
||||
addTest()
|
||||
updateTest(props.examinationId)
|
||||
};
|
||||
|
||||
const handleFinishFailed = errors => {
|
||||
@@ -383,17 +380,38 @@ export default {
|
||||
};
|
||||
const closeDrawer = () => {
|
||||
resetForm();
|
||||
formState.choosedTime = '';
|
||||
ctx.emit("update:addtestVisible", false);
|
||||
};
|
||||
const addTest = () => {
|
||||
createExamination({
|
||||
const queryTest = (data) => {
|
||||
queryExaminationDetailById(data).then((res) => {
|
||||
formState.examinationName = res.data.data.examinationName;
|
||||
formState.workRequirement = res.data.data.workRequirement;
|
||||
formState.examinationDuration = res.data.data.examinationDuration;
|
||||
formState.examinationLimit = res.data.data.examinationLimit || -1;
|
||||
formState.passLine = res.data.data.passLine;
|
||||
formState.examinationExplain = res.data.data.examinationExplain;
|
||||
formState.questionArrangement = res.data.data.questionArrangement || 1;
|
||||
formState.scoringModel = res.data.data.scoringModel || 1;
|
||||
formState.showAnalysis = res.data.data.showAnalysis || 1;
|
||||
formState.showAnswers = res.data.data.showAnswers || 1;
|
||||
if(res.data.data.examinationEndTime && res.data.data.examinationStartTime){
|
||||
formState.choosedTime= [dayjs(res.data.data.examinationStartTime,"YYYY-MM-DD"),dayjs(res.data.data.examinationEndTime,"YYYY-MM-DD")]
|
||||
} else { formState.choosedTime=[] }
|
||||
console.log(res);
|
||||
}).catch(() => {
|
||||
message.error(`查询失败`)
|
||||
})
|
||||
}
|
||||
const updateTest = (id) => {
|
||||
let obj = {
|
||||
"createTime": "",
|
||||
"createUser": 0,
|
||||
"examinationDuration": formState.examinationDuration,
|
||||
"examinationEndTime": dayjs(formState.choosedTime[1]).format("YYYY-MM-DD"),
|
||||
"examinationExplain": formState.examinationExplain,
|
||||
"examinationFlag": "",
|
||||
"examinationId": 0,
|
||||
"examinationId": id || 0,
|
||||
"examinationLimit": formState.examinationLimit,
|
||||
"examinationName": formState.examinationName,
|
||||
"examinationPaperId": 0,
|
||||
@@ -407,16 +425,31 @@ export default {
|
||||
"showAnswers": formState.showAnswers,
|
||||
"updateTime": "",
|
||||
"updateUser": 0
|
||||
}).then((res)=>{
|
||||
}
|
||||
if(id) {
|
||||
updateExamination(obj).then((res)=>{
|
||||
console.log(res);
|
||||
message.success(`编辑成功`)
|
||||
closeDrawer();
|
||||
}).catch(()=>{
|
||||
message.error(`编辑失败`)
|
||||
})
|
||||
} else {
|
||||
createExamination(obj).then((res)=>{
|
||||
message.success(`添加成功${res}`)
|
||||
closeDrawer();
|
||||
}).catch((err)=>{
|
||||
message.error(`添加失败${err}`)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
const afterVisibleChange = (bool) => {
|
||||
console.log("formState", bool);
|
||||
if(props.addtestVisible && props.examinationId){
|
||||
queryTest({examinationId: props.examinationId})
|
||||
}
|
||||
};
|
||||
const cloradio1 = (value) => {
|
||||
if (value != "") {
|
||||
@@ -447,7 +480,6 @@ export default {
|
||||
cloradio2,
|
||||
cloradio3,
|
||||
cloradio4,
|
||||
addTest,
|
||||
options1,
|
||||
handleFinish,
|
||||
handleFinishFailed,
|
||||
@@ -456,6 +488,8 @@ export default {
|
||||
formRef,
|
||||
// layout,
|
||||
rules,
|
||||
updateTest,
|
||||
queryTest,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user