feat:增加证书学员分页获取

This commit is contained in:
lixg
2023-02-06 18:57:34 +08:00
parent 3e3859872d
commit c0a2d9d027
4 changed files with 187 additions and 54 deletions

View File

@@ -9,7 +9,9 @@
>
<div class="drawerMain">
<div class="header">
<div class="headerTitle">{{ edit ? "编辑" : "添加" }}证书</div>
<div class="headerTitle">
{{ ACertificateEditId ? "编辑" : "添加" }}证书
</div>
<img
style="width: 29px; height: 29px; cursor: pointer"
src="../../../assets/images/basicinfo/close.png"
@@ -432,6 +434,7 @@ export default {
state.CCertificate = false;
state.stageList = [];
state.taskList = [];
state.examList = [];
state.selectStageName = null;
state.selectStageId = null;
state.selectTaskName = null;
@@ -454,6 +457,7 @@ export default {
if (bool) {
getStageList();
getTaskList();
getTaskExam();
}
};
//获取阶段
@@ -474,16 +478,22 @@ export default {
});
};
//获取任务
const getTaskList = () => {
const getTaskList = (exam) => {
let obj = {
projectId: props.projectId,
type: exam ? 5 : 0,
};
api
.getTaskList(obj)
.then((res) => {
console.log("获取任务列表", res);
if (res.data.code === 200) {
state.taskList = res.data.data;
if (exam) {
state.examList = res.data.data;
} else {
state.taskList = res.data.data;
}
}
})
.catch((err) => {
@@ -491,7 +501,9 @@ export default {
});
};
//获取考试
const getTaskExam = () => {
getTaskList(true);
};
//选择阶段
const selectStage = (e, k) => {
console.log("选择阶段", e, k);
@@ -520,7 +532,7 @@ export default {
state.selectTaskName = null;
state.selectTaskId = null;
state.selectExamName = e;
state.selectExamId = e.examId;
state.selectExamId = k.projectTaskId;
};
//选择的获得条件
const selectCondition = (e) => {
@@ -573,8 +585,48 @@ export default {
.certificatedetail(obj)
.then((res) => {
console.log("获取证书详情", res);
// if (res.data.code === 200) {
// }
if (res.data.code === 200) {
let info = res.data.data;
state.certificateName = info.name; //证书名称
state.imageUrl = process.env.VUE_APP_FILE_PATH + info.url; //证书封面
state.certificateRemark = info.remark; //证书说明
state.condition = info.finishType; //选择条件
state.large = info.finishType == 1 ? info.finishValue : null; //选择项目里的全部任务或必修任务
state.selectStageId =
info.finishType == 2 ? info.finishValue : null;
state.selectTaskId = info.finishType == 3 ? info.finishValue : null;
state.selectExamId = info.finishType == 4 ? info.finishValue : null;
state.score = info.finishType == 5 ? info.finishValue : null; //积分
let timer = setInterval(() => {
if (
state.stageList.length !== 0 &&
state.taskList.length !== 0 &&
state.examList.length !== 0
) {
if (info.finishType == 2) {
let stageItem = state.stageList.filter((item) => {
return item.stageId == info.finishValue;
});
state.selectStageName = stageItem ? stageItem[0].name : null;
}
if (info.finishType == 3) {
let taskItem = state.taskList.filter((item) => {
return item.projectTaskId == info.finishValue;
});
state.selectTaskName = taskItem ? taskItem[0].name : null;
}
if (info.finishType == 4) {
let taskItem = state.examList.filter((item) => {
return item.projectTaskId == info.finishValue;
});
console.log("taskItem", taskItem);
state.selectExamName = taskItem ? taskItem[0].name : null;
}
clearInterval(timer);
}
}, 1000);
}
})
.catch((err) => {
console.log("获取证书详情失败", err);
@@ -583,7 +635,7 @@ export default {
//添加证书
const saveupdatecertificate = () => {
if (!state.certificateName) return message.warning("请输入证书名称");
if (!state.imageName) return message.warning("请上传证书封面");
if (!state.imageUrl) return message.warning("请上传证书封面");
if (!state.condition) return message.warning("请设置获得条件");
if (state.condition == 1 && !state.large)
return message.warning("请选择完成项目类型");
@@ -595,45 +647,46 @@ export default {
return message.warning("请选择考试");
if (state.condition == 5 && !state.score)
return message.warning("请输入积分");
let obj = {
pid: props.projectId,
name: state.certificateName,
url: state.imageName,
remark: state.certificateRemark,
finishType: state.condition,
finishValue:
state.condition == 1
? state.large
: state.condition == 2
? state.selectStageId
: state.condition == 3
? state.selectTaskId
: state.condition == 4
? state.selectExamId
: state.condition == 5
? state.score
: "",
type: 1,
};
if (props.ACertificateEdit) {
console.log("更新证书");
} else {
console.log("新增证书");
let obj = {
pid: props.projectId,
name: state.certificateName,
url: state.imageName,
finishType: state.condition,
finishValue:
state.condition == 1
? state.large
: state.condition == 2
? state.selectStageId
: state.condition == 3
? state.selectTaskId
: state.condition == 4
? state.selectExamId
: state.condition == 5
? state.score
: "",
type: 1,
};
reset();
api
.saveupdatecertificate(obj)
.then((res) => {
console.log("新增证书", res);
if (res.data.code === 200) {
message.success("证书添加成功");
props.getCertificate && props.getCertificate();
}
})
.catch((err) => {
console.log("新增证书失败", err);
});
obj.id = props.ACertificateEditId;
}
reset();
api
.saveupdatecertificate(obj)
.then((res) => {
console.log("新增/编辑成功证书", res);
if (res.data.code === 200) {
message.success(
props.ACertificateEdit ? "证书修改成功" : "证书添加成功"
);
props.getCertificate && props.getCertificate();
}
})
.catch((err) => {
console.log("新增/编辑证书失败", err);
});
};
return {
...toRefs(state),