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

@@ -2,7 +2,7 @@
* @Author: lixg lixg@dongwu-inc.com * @Author: lixg lixg@dongwu-inc.com
* @Date: 2022-11-04 22:45:31 * @Date: 2022-11-04 22:45:31
* @LastEditors: lixg lixg@dongwu-inc.com * @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 * @FilePath: /fe-manage/src/api/index1.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @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 getTaskList = (obj) => http.get('/admin/project/getTaskList', { params: obj })
//查看证书学员列表 //查看证书学员列表
export const stuCertList = (obj) => http.get('/admin/certificate/stuCertList', { params: obj }) export const stuCertList = (obj) => http.get('/admin/certificate/stuCertList', { params: obj })
//更新学员证书
export const updateStuCert = (obj) => http.post('/admin/certificate/updateStuCert', obj)

View File

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

View File

@@ -2,6 +2,7 @@
<div class="TableCertificateStudent"> <div class="TableCertificateStudent">
<div class="certificatetitle"> <div class="certificatetitle">
<span style="margin-left: 32px">培训证书</span> <span style="margin-left: 32px">培训证书</span>
<button class="returnBtn" @click="returnClick">返回</button>
</div> </div>
<div class="search"> <div class="search">
<div class="selectBox"> <div class="selectBox">
@@ -25,11 +26,10 @@
<div>选择时间</div> <div>选择时间</div>
<div class="select in"> <div class="select in">
<a-range-picker <a-range-picker
style="width: 320px; height: 40px; border-radius: 8px" v-model:value="selectTime"
:disabled-date="disabledDate" style="width: 320px"
:disabled-time="disabledRangeTime" format="YYYY-MM-DD"
format="YYYY/MM/DD HH:mm" separator="至"
v-model:value="chooseTime"
:placeholder="[' 开始时间', ' 结束时间']" :placeholder="[' 开始时间', ' 结束时间']"
/> />
</div> </div>
@@ -92,6 +92,7 @@
import { reactive, toRefs } from "vue"; import { reactive, toRefs } from "vue";
import * as api from "@/api/index1"; import * as api from "@/api/index1";
import OrgClass from "@/components/project/OrgClass"; import OrgClass from "@/components/project/OrgClass";
import { message } from "ant-design-vue";
export default { export default {
name: "TableCertificateStudent", name: "TableCertificateStudent",
components: { components: {
@@ -107,12 +108,17 @@ export default {
type: Number, type: Number,
default: null, default: null,
}, },
ischeckCertificate: {
type: Boolean,
default: false,
}, },
setup(props) { },
setup(props, ctx) {
const state = reactive({ const state = reactive({
studentName: null, studentName: null,
tstudentDepartId: null, tstudentDepartId: null,
studentDepartName: null, studentDepartName: null,
selectTime: null,
tablecolumns: [ tablecolumns: [
{ {
title: "工号", title: "工号",
@@ -195,19 +201,28 @@ export default {
], ],
pageSize: 10, pageSize: 10,
currentPage: 1, currentPage: 1,
tableDataTotal: 1, tableDataTotal: -1,
selectedRowKeys: [], selectedRowKeys: [],
}); });
//获取证书学员 //获取证书学员
const stuCertList = () => { const stuCertList = () => {
let obj = { let obj = {
name: state.studentName,
orgName: state.studentDepartName,
id: props.ACertificateCheckId, id: props.ACertificateCheckId,
pid: props.projectId, pid: props.projectId,
size: state.pageSize,
}; };
state.tableDataTotal = -1;
api api
.stuCertList(obj) .stuCertList(obj)
.then((res) => { .then((res) => {
console.log("获取证书学员", res); console.log("获取证书学员", res);
if (res.data.code === 200) {
state.stuList = res.data.data.record;
state.tableDataTotal = res.data.data.total;
}
}) })
.catch((err) => { .catch((err) => {
console.log("获取证书学员失败", err); console.log("获取证书学员失败", err);
@@ -215,18 +230,63 @@ export default {
}; };
stuCertList(); stuCertList();
//搜索
const search = () => {
state.currentPage = 1;
stuCertList();
};
//重置
const reset = () => {
state.currentPage = 1;
state.studentName = null;
state.tstudentDepartId = null;
state.studentDepartName = null;
state.selectTime = null;
};
//取消授权 //取消授权
const updateStuCert = (text) => { const updateStuCert = (text) => {
console.log("text", text); console.log("text", text);
let obj = {
id: text.record.id,
status: -1,
};
api
.updateStuCert(obj)
.then((res) => {
console.log("取消证书成功", res);
if (res.data.code === 200) {
message.success("取消证书成功");
stuCertList();
}
})
.catch((err) => {
console.log("取消证书失败", err);
});
}; };
const onSelectChange = (selectedRowKeys, e) => { const onSelectChange = (selectedRowKeys, e) => {
console.log("selectedRowKeys changed: ", selectedRowKeys, e); console.log("selectedRowKeys changed: ", selectedRowKeys, e);
state.selectedRowKeys = selectedRowKeys; state.selectedRowKeys = selectedRowKeys;
}; };
//分页
const changePaginationStu = (page) => {
state.currentPage = page;
stuCertList();
};
//返回
const returnClick = () => {
ctx.emit("update:ischeckCertificate", false);
console.log("点击返回");
};
return { return {
...toRefs(state), ...toRefs(state),
stuCertList, stuCertList,
search,
reset,
onSelectChange, onSelectChange,
changePaginationStu,
returnClick,
}; };
}, },
}; };
@@ -240,12 +300,26 @@ export default {
.certificatetitle { .certificatetitle {
width: 100%; width: 100%;
height: 74px; height: 74px;
padding-top: 40px; padding-top: 29px;
border-bottom: 1px solid rgba(232, 232, 232, 1); border-bottom: 1px solid rgba(232, 232, 232, 1);
font-size: 18px; font-size: 18px;
font-weight: 500; font-weight: 500;
color: #333333; color: #333333;
line-height: 25px; line-height: 25px;
display: flex;
justify-content: space-between;
.returnBtn {
cursor: pointer;
width: 100px;
height: 40px;
background: #4ea6ff;
border-radius: 8px;
border: 0;
margin-left: 15px;
color: #fff;
margin-right: 20px;
font-size: 14px;
}
} }
.search { .search {
display: flex; display: flex;

View File

@@ -1091,6 +1091,7 @@
:projectId="projectId" :projectId="projectId"
:ACertificateCheckId="ACertificateCheckId" :ACertificateCheckId="ACertificateCheckId"
v-if="ischeckCertificate" v-if="ischeckCertificate"
v-model:ischeckCertificate="ischeckCertificate"
> >
</TableCertificateStudent> </TableCertificateStudent>
</a-tab-pane> </a-tab-pane>
@@ -3592,6 +3593,10 @@ export default {
rankReset(); rankReset();
state.tabFlag = false; state.tabFlag = false;
} }
if(e!=7){
state.ischeckCertificate=false
}
console.log("切换了", state.tabFlag); console.log("切换了", state.tabFlag);
}; };