diff --git a/src/api/index1.js b/src/api/index1.js index 9d1ab747..77df3b43 100644 --- a/src/api/index1.js +++ b/src/api/index1.js @@ -2,7 +2,7 @@ * @Author: lixg lixg@dongwu-inc.com * @Date: 2022-11-04 22:45:31 * @LastEditors: lixg lixg@dongwu-inc.com - * @LastEditTime: 2023-02-04 19:59:55 + * @LastEditTime: 2023-02-06 15:11:40 * @FilePath: /fe-manage/src/api/index1.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -208,4 +208,5 @@ export const getStageList = (obj) => http.get('/admin/project/getStageList', { p export const getTaskList = (obj) => http.get('/admin/project/getTaskList', { params: obj }) //查看证书学员列表 export const stuCertList = (obj) => http.get('/admin/certificate/stuCertList', { params: obj }) - +//更新学员证书 +export const updateStuCert = (obj) => http.post('/admin/certificate/updateStuCert', obj) diff --git a/src/components/drawers/project/AddCertificate.vue b/src/components/drawers/project/AddCertificate.vue index 06a261df..8bfab55c 100644 --- a/src/components/drawers/project/AddCertificate.vue +++ b/src/components/drawers/project/AddCertificate.vue @@ -9,7 +9,9 @@ >
-
{{ edit ? "编辑" : "添加" }}证书
+
+ {{ ACertificateEditId ? "编辑" : "添加" }}证书 +
{ + 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), diff --git a/src/components/student/TableCertificateStudent.vue b/src/components/student/TableCertificateStudent.vue index 13729c88..7fda64af 100644 --- a/src/components/student/TableCertificateStudent.vue +++ b/src/components/student/TableCertificateStudent.vue @@ -2,6 +2,7 @@
培训证书 +