Files
student-h5/src/views/growth/growthPath.vue
Pengxiansen 84553505ff 提交
2025-02-27 01:45:47 +08:00

1058 lines
28 KiB
Vue

<template>
<div class="growth-details">
<div class="navbar">
<div class="nav-left" @click="returnclick">
<el-icon color="#fff" size="20"><ArrowLeft /></el-icon>
</div>
<div class="nav-title">{{ data.growthName }}</div>
</div>
<!-- <template v-if="data.electiveTaskNum !== 0"> -->
<div class="tabs">
<div
class="tabs-item"
:class="queryParams.type == 1 ? 'active' : ''"
@click="tabClick(1)"
>
<div class="tabs-text">必修</div>
<div class="tabs-line"></div>
</div>
<div
class="tabs-item"
:class="queryParams.type == 2 ? 'active' : ''"
@click="tabClick(2)"
>
<div class="tabs-text">选修</div>
<div class="tabs-line"></div>
</div>
</div>
<!-- </template> -->
<div class="search">
<div class="search-input">
<el-input
v-model="queryParams.taskName"
:input-style="{
width: '100%',
height: '40px',
color: '#fff',
}"
@change="getList"
placeholder="搜索关键字"
>
<template #prefix>
<el-icon color="#fff" class="el-input__icon"><search /></el-icon>
</template>
</el-input>
</div>
<el-dropdown>
<img class="icon" src="@/assets/image/growth/qiehuan.png" />
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="tabClick(null, '4')"
>全部</el-dropdown-item
>
<el-dropdown-item @click="tabClick(null, '0')"
>未开始</el-dropdown-item
>
<el-dropdown-item @click="tabClick(null, '1')"
>已完成</el-dropdown-item
>
<el-dropdown-item @click="tabClick(null, '2')"
>进行中</el-dropdown-item
>
</el-dropdown-menu>
</template>
</el-dropdown>
<!-- <img class="icon" src="@/assets/image/growth/list.png" /> -->
<img class="icon" @click="toPath" src="@/assets/image/growth/list.png" />
</div>
<template v-if="stageProcessList && stageProcessList.length">
<div class="container" v-loading="loading">
<!-- :style="{
top: data.electiveTaskNum !== 0 ? '165px' : '103px',
}" -->
<div :style="{ transform: 'scale(' + transformSize + ')' }">
<template v-if="growthInfo.template == 2">
<div class="path-container">
<div
:class="
item.position + 1 < 3 ||
item.position + 1 == 4 ||
item.position + 1 == 6
? 'path-item-left'
: 'path-item-right'
"
@click.native="toFinish(item)"
:style="point[item.position]"
v-for="(item, index) of stageProcessList"
>
<template
v-if="
item.position + 1 < 3 ||
item.position + 1 == 4 ||
item.position + 1 == 6
"
>
<div>
<div class="item-name">
<div
style="
display: inline-block;
border-radius: 50%;
line-height: 16px;
text-align: center;
margin-right: 6px;
width: 16px;
height: 16px;
font-size: 12px;
font-weight: 700;
background-color: #fff;
color: #0077ec;
"
>
{{ stageProcessList.length - index }}
</div>
<div style="display: inline">{{ item.taskName }}</div>
</div>
<div class="triangle"></div>
</div>
<div class="f-a-c">
<div class="f-a-c">
<div class="item-progress">
<el-progress
:percentage="parseInt(item.progress)"
:show-text="false"
:stroke-width="6"
:color="stateData(item).progressColor"
/>
</div>
<div
class="item-state"
:style="{
color: stateData(item).color,
background: stateData(item).bgColor,
}"
>
{{ stateData(item).text }}
</div>
</div>
<div class="item-link">
<div
:style="{
width: widthConfig(item.position).width,
marginLeft: widthConfig(item.position).margin,
}"
class="line"
></div>
<div class="circle"></div>
</div>
</div>
</template>
<template v-else>
<div class="item-link">
<div class="circle"></div>
<div
:style="{
width: widthConfig(item.position).width,
marginRight: widthConfig(item.position).margin,
}"
class="line"
></div>
</div>
<div>
<div>
<div class="item-name">
<div
style="
display: inline-block;
border-radius: 50%;
line-height: 16px;
text-align: center;
margin-right: 6px;
width: 16px;
height: 16px;
font-size: 12px;
font-weight: 700;
background-color: #fff;
color: #0077ec;
"
>
{{ stageProcessList.length - index }}
</div>
<div style="display: inline">{{ item.taskName }}</div>
</div>
<div class="triangle"></div>
</div>
<div class="f-a-c" style="justify-content: flex-end">
<div class="item-progress">
<el-progress
:percentage="parseInt(item.progress)"
:show-text="false"
:stroke-width="6"
:color="stateData(item).progressColor"
/>
</div>
<div
class="item-state"
:style="{
color: stateData(item).color,
background: stateData(item).bgColor,
}"
>
{{ stateData(item).text }}
</div>
</div>
</div>
</template>
</div>
</div>
</template>
<template v-else>
<GrowthPath2
@toFinish="toFinish"
:stageProcessList="stageProcessList"
></GrowthPath2>
</template>
</div>
</div>
</template>
<template v-else>
<div class="container" style="background-image: none">
<el-empty description="暂无数据" />
</div>
</template>
<!-- 开课列表弹框 -->
<el-dialog
top="120px"
title="开课列表"
v-model="openCourseVisible"
style="min-height: 320px; padding: 0; border-radius: 4px"
width="80%"
>
<div style="width: 100%; min-height: 210px; margin-top: 12px">
<div
v-for="(item, key) in openCourseList"
style="
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
background: rgb(247, 251, 253);
height: 40px;
padding: 5px;
border-radius: 5px;
"
>
<div
style="
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
width: 200px;
"
>
{{ item }}
</div>
<div
@click="toOffcoursePlanPage(openCourseIdList[key])"
style="
width: 60px;
height: 30px;
text-align: center;
line-height: 30px;
background: #0078fc;
border-radius: 5px;
color: #fff;
cursor: pointer;
"
>
去上课
</div>
</div>
</div>
</el-dialog>
</div>
</template>
<script setup>
import { computed, reactive, ref, watch, onMounted } from "vue";
import { ElLoading } from "element-plus";
import { useRequest, request } from "@/api/request";
import { growthRequest } from "@/api/growthRequest";
import GrowthPath2 from "./components/gowthPath2.vue";
import {
EvaluationToLearn,
QueryEvaluationTaskStatusOne,
STUDY_RECORD,
SubmitExternalExam,
PROFESSIONAL_STUDENT_TASKLIST,
PROFESSIONAL_STUDENT_LEARN,
} from "@/api/api";
import { useRoute, useRouter } from "vue-router";
import store from "@/store";
import { ElMessage } from "element-plus";
import ReturnHead from "@/components/ReturnHead.vue";
import { GROWTH, TASK_TYPES } from "@/api/CONST";
import dayjs from "dayjs";
import { useStore } from "vuex";
import { changeTime } from "@/api/method";
const {
query: { routerId, type },
} = useRoute();
const router = useRouter();
const { commit, dispatch, state } = useStore();
// 专业力必修详情
const data = computed(() => state.growthInfo);
// 查询条件
const queryParams = reactive({
type: 1,
});
const tabClick = (type, status) => {
// 选修/必修
if (type) {
queryParams.type = type;
}
// 任务状态
if (status) {
queryParams.completionStatus = status;
}
if (status == 4) {
queryParams.completionStatus = "";
}
getList();
};
watch(data, () => {
if (data.value.code === 6) {
router.push({
path: "/notpath",
});
}
});
// 学习任务列表
const stageProcessList = ref([]);
// 锚点跳转的次数
const anchorNum = ref(0);
onMounted(() => {
updateWindowWidth(); // 初始化宽度
window.addEventListener("resize", updateWindowWidth);
dispatch("getGrowthInfo", { routerId, type });
if (type) {
queryParams.type = type;
}
getList();
});
// 储存屏幕宽
const windowWidth = ref(0);
const transformSize = ref(1);
const updateWindowWidth = () => {
windowWidth.value = window.innerWidth;
transformSize.value = windowWidth.value / 414;
};
// 是否加载数据中
const loading = ref(false);
const getList = () => {
loading.value = true;
growthRequest(PROFESSIONAL_STUDENT_TASKLIST, {
growthId: routerId,
...queryParams,
}).then((res) => {
if (growthInfo.value.template == 1) {
stageProcessList.value = res.data.reverse();
} else {
let newData = res.data.slice(0, 15).reverse();
// 默认第一个在第一点位
let num = 15 / newData.length;
stageProcessList.value = newData.map((item, index) => {
// 默认第一个在第一点位
if (index === 0) {
item.position = 0;
}
item.position = Number((index * num).toFixed());
return item;
});
}
if (anchorNum.value === 0) {
let find = stageProcessList.value.find((item) => item.lastStudy);
if (find) {
// var aLink = document.createElement("a");
// aLink.href = `#${find.id}`; // 设置链接地址
// aLink.click();
// document.body.removeChild(aLink);
}
}
loading.value = false;
});
};
const openCourseVisible = ref(false);
const openCourseList = ref([]);
const openCourseIdList = ref([]);
const userInfo = computed(() => store.state.userInfo);
const growthInfo = computed(() => store.state.growthInfo);
const point = [
{
top: "-15px",
right: "57px",
},
{
top: "51px",
right: "106px",
},
{
top: "132px",
right: "-26px",
},
{
top: "124px",
right: "146px",
},
{
top: "207px",
right: "10px",
},
{
top: "204px",
right: "181px",
},
{
top: "288px",
left: "109px",
},
{
top: "356px",
left: "91px",
},
{
top: "435px",
left: "76px",
},
{
top: "503px",
left: "66px",
},
{
top: "580px",
left: "57px",
},
{
top: "649px",
left: "51px",
},
{
top: "720px",
left: "51px",
},
{
top: "790px",
left: "45px",
},
{
top: "860px",
left: "45px",
},
];
// 基础配置项
const widthConfig = computed(() => {
return (index) => {
if (index === 0) {
return {
width: "60px",
margin: "19px",
};
} else if (index === 1) {
return {
width: "60px",
margin: "19px",
};
} else if (index === 2) {
return {
width: "25px",
margin: "0",
};
} else if (index === 3) {
return {
width: "30px",
margin: "0px",
};
} else if (index === 4) {
return {
width: "25px",
margin: "0",
};
} else if (index === 5) {
return {
width: "10px",
margin: "0",
};
} else if (index === 6) {
return {
width: "50px",
margin: "0",
};
} else if (index === 7) {
return {
width: "60px",
margin: "0px",
};
} else {
return {
width: "70px",
margin: "0px",
};
}
};
});
// 基础配置项
const stateData = computed(() => {
return (item) => {
if (item.completionStatus === "10") {
return {
text: "未解锁",
color: "#666666",
bgColor: "rgba(102, 102, 102, 0.2)",
progressColor: "#AEB3B8",
};
} else if (item.completionStatus === "0") {
return {
text: "未开始",
color: "#666666",
bgColor: "rgba(102, 102, 102, 0.2)",
progressColor: "#AEB3B8",
};
} else if (item.completionStatus === "1") {
return {
text: "已完成",
color: "#0077EC",
bgColor: "rgba(0, 119, 236, 0.2)",
progressColor: "#0077EC",
};
} else if (item.completionStatus === "2") {
return {
text: "进行中",
color: "#F2903D",
bgColor: "rgba(242, 144, 61, 0.2)",
progressColor: "#F2903D",
};
} else if (item.completionStatus === "3") {
return {
text: "已结束",
color: "#666666",
bgColor: "rgba(102, 102, 102, 0.2)",
progressColor: "#AEB3B8",
};
}
};
});
async function toFinish(d) {
if (!d.canLearn) {
ElMessage.warning(`学习任务暂未开始`);
return;
}
if (d.completionStatus == 3) {
ElMessage.warning(`学习任务已结束无法学习`);
return;
}
if (d.completionStatus == 10) {
ElMessage.warning(`请先完成“${d.superTaskName}”的学习任务`);
return;
}
//更新学员当前任务
await growthRequest(PROFESSIONAL_STUDENT_LEARN, {
growthId: routerId,
taskId: d.taskId,
});
if (d.courseType === "2") {
if (!d.targetId) {
return ElMessage.error("还未添加开课,请联系管理员!");
}
if (d.targetId.split(",").length > 1) {
openCourseList.value = d.targetName?.split(",");
openCourseIdList.value = d.targetId?.split(",");
openCourseVisible.value = true;
return;
}
}
// 作业过期判断
if (d.courseType == 4) {
let date1 = new Date(d.info.submitEndTime).getTime();
let date2 = new Date().getTime();
if (date1 < date2) {
dialogVisibleTip.value = "当前作业已结束";
dialogVisible.value = true;
//return
}
}
// 直播结束时间
if (d.courseType == 6) {
let date1 = new Date(d.info.liveEndTime).getTime();
let date2 = new Date().getTime();
if (date1 < date2) {
dialogVisibleTip.value = "当前直播已结束";
dialogVisible.value = true;
//return
}
}
// 考试 停用
if (d.courseType == 5) {
// 此处判断外部考试跳转
if (d.info.examType == 2) {
// 点击即更新状态 进行中
request(SubmitExternalExam, {
chapterId: 0,
externalId: d.courseId,
externalName: d.taskName,
targetId: data.value.id,
studentNo: userInfo.value.userNo,
})
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});
router.push({
path: "/externalexam",
query: {
courseId: d.courseId ? d.courseId : d.info.id,
type: GROWTH,
},
});
return;
}
}
// 其他活动 结束时间
if (d.courseType == 9) {
let date1 = new Date(d.info.activityEndTime).getTime();
let date2 = new Date().getTime();
if (date1 < date2) {
dialogVisibleTip.value = "当前活动已结束";
dialogVisible.value = true;
//return
}
}
// 测评模块 请求接口跳转新的页面 - 新增 暂时未调试 目前无测评数据 2023-02-04
if (d.courseType == 10) {
if (d.completionStatus != 1) {
// 肯定没有完成测评
// 调用接口 跳转页面
request(EvaluationToLearn, {
businessType: "project",
chapterId: 0,
courseId: d.courseId,
quizKid: d.info.evaluationTypeId,
routerOrProjectId: routerId,
studentId: userInfo.value.id,
studentName: userInfo.value.realName,
})
.then((res) => {
console.log(res);
if (res.code == 200) {
let jumpUrl = res.data.quizUrl;
// 此处写跳转url
window.open(jumpUrl, "_top");
}
})
.catch((err) => {
console.log(err);
});
return;
} else {
// 进行中 或者 已完成
// 调用接口 判断当前测评状态 跳转页面
console.log("我是查询测评跳转链接所传递得参数", {
quizTaskId: d.quizTaskId,
});
request(QueryEvaluationTaskStatusOne, {
quizTaskId: d.quizTaskId,
})
.then((res) => {
console.log(res);
if (res.code == 200) {
if (res.data.complete_status == 2) {
ElMessage.error("您已完成测评");
return;
} else {
// 重新查询跳转
// 调用接口 跳转页面
console.log("我是查询测评跳转链接所传递得参数", {
businessType: "project",
chapterId: 0,
courseId: d.courseId,
quizKid: d.info.evaluationTypeId,
routerOrProjectId: routerId,
studentId: userInfo.value.id,
studentName: userInfo.value.realName,
});
request(EvaluationToLearn, {
businessType: "project",
chapterId: 0,
courseId: d.courseId ? d.courseId : d.info.id,
quizKid: d.info.evaluationTypeId,
routerOrProjectId: routerId,
studentId: userInfo.value.id,
studentName: userInfo.value.realName,
})
.then((res) => {
console.log(res);
if (res.code == 200) {
let jumpUrl = res.data.quizUrl;
// 此处写跳转url
window.open(jumpUrl, "_top");
}
})
.catch((err) => {
console.log(err);
});
return;
}
}
})
.catch((err) => {
console.log(err);
});
return;
}
}
if (!TASK_TYPES.path[d.courseType]) {
ElMessage.error("暂时未开放");
return;
}
if (
d.courseType == 3 ||
d.courseType == 7 ||
(d.courseType == 5 && d.examType == 2)
) {
console.log(d, data.value);
await request(STUDY_RECORD, {
studentId: userInfo.value.id,
targetId: data.value.id,
logo: GROWTH,
type: GROWTH,
stageOrChapterId: 0,
taskId: d.id,
taskType: d.courseType,
});
}
if (typeof TASK_TYPES.path[d.courseType] === "string") {
TASK_TYPES.path[d.courseType] &&
TASK_TYPES.path[d.courseType].startsWith("http") &&
window.open(TASK_TYPES.path[d.type] + d.targetId, "_top");
TASK_TYPES.path[d.courseType] &&
TASK_TYPES.path[d.courseType].startsWith("/") &&
router.push({
path: TASK_TYPES.path[d.courseType],
query: {
id: d.id,
type: d.courseType === "11" ? "5" : GROWTH,
projectId: d.courseId,
infoId: d.courseType === "11" ? d.taskId : data.value.id,
courseId: d.courseId ? d.courseId : d.info.id,
pName: data.value.growthName,
sName: d.taskName,
chapterOrStageId: 0,
// id: d.id,
// type: PROJECT,
// infoId: data.value.projectId,
// courseId: d.courseId,
// pName: data.value.name,
// sName,
// chapterOrStageId: chapterOrStageId,
// studentId: userInfo.value.id,
// status: d.status,
// targetId: d.targetId,
// evaType: d.evaType,
// btype: 1,
// quizTaskId: d.quizTaskId,
},
});
} else if (typeof TASK_TYPES.path[d.courseType] === "function") {
if (d.courseType == 5) {
let params = {
examType: d.info.examType,
};
window.open(
TASK_TYPES.path[d.courseType](params) + d.info.examinationPaperId,
"_top"
);
} else {
let params = {
courseId: d.courseId ? d.courseId : d.info.id,
targetId: d.targetId ? d.targetId : "",
};
TASK_TYPES.path[d.courseType](params);
}
}
}
function toOffcoursePlanPage(id) {
window.open(
`${location.protocol}//${location.host}${
import.meta.env.VITE_BASE_API
}/stu/project/redirectDetail?courseId=${id}`,
"_top"
);
}
const returnclick = () => {
window.open(
window.location.protocol + import.meta.env.VITE_BOE_GROWTH,
"_top"
);
};
const toPath = () => {
router.push({
path: "/growthDetails",
query: {
routerId,
type: queryParams.type,
},
});
};
</script>
<style lang="scss" scoped>
.f-a-c {
display: flex;
align-items: center;
}
.growth-details {
background-image: url(@/assets/image/growth/bg.png);
background-size: 100%;
background-repeat: no-repeat;
height: 100vh;
box-sizing: border-box;
background-color: #ffffff;
position: relative;
:deep(input::placeholder) {
color: #ffffff;
}
:deep(.el-progress-bar__outer) {
background-color: #aeb3b8;
}
.container {
position: absolute;
background-color: #ffffff;
background-image: url(@/assets/image/growth/path-bg.png);
background-size: 100% 100%;
top: 165px;
left: 0;
right: 0;
border-radius: 15px 15px 0 0;
.path-container {
position: relative;
height: 935px;
margin: 53px 45px 31px 63px;
box-sizing: border-box;
background-image: url(@/assets/image/growth/path-arrow.png);
background-size: 100%;
.path-item-left {
position: absolute;
// width: 125px;
z-index: 9999;
.item-link {
display: flex;
align-items: center;
.line {
height: 2px;
background: linear-gradient(-90deg, #ffffff 0%, #0077ec 65%);
border-image: linear-gradient(-90deg, #ffffff, #0077ec) 10 10;
}
.circle {
width: 10px;
height: 10px;
background: #ffffff;
border-radius: 50%;
border: 2px solid #0077ec;
}
}
.item-progress {
width: 71px;
}
.item-state {
width: 48px;
height: 16px;
border-radius: 3px;
text-align: center;
line-height: 16px;
margin-left: 4px;
font-size: 12px;
}
.item-name {
max-width: 125px;
min-width: 40px;
display: inline-block;
background: linear-gradient(268deg, #3c65f5 0%, #4395f9 100%);
border-radius: 4px;
font-size: 12px;
color: #ffffff;
padding: 8px 5px 9px 10px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.triangle {
width: 0px;
height: 0px;
border: 5px solid transparent;
border-top-color: #4391f8;
margin-left: 22px;
}
}
.path-item-right {
position: absolute;
// width: 125px;
display: flex;
z-index: 9999;
.item-link {
height: 28px;
display: flex;
align-items: center;
.line {
height: 2px;
background: linear-gradient(90deg, #ffffff 0%, #0077ec 65%);
border-image: linear-gradient(0deg, #ffffff, #0077ec) 10 10;
}
.circle {
width: 10px;
height: 10px;
background: #ffffff;
border-radius: 50%;
border: 2px solid #0077ec;
}
}
.item-progress {
width: 71px;
}
.item-state {
width: 48px;
height: 16px;
border-radius: 3px;
text-align: center;
line-height: 16px;
margin-left: 4px;
font-size: 12px;
}
.item-name {
max-width: 125px;
min-width: 40px;
display: inline-block;
background: linear-gradient(268deg, #3c65f5 0%, #4395f9 100%);
border-radius: 4px;
font-size: 12px;
color: #ffffff;
padding: 8px 5px 9px 10px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.triangle {
width: 0px;
height: 0px;
border: 5px solid transparent;
border-top-color: #4391f8;
margin-left: 22px;
}
}
}
}
.search {
display: flex;
align-items: center;
padding: 0 15px;
.search-input {
flex: 1;
}
.icon {
width: 18px;
height: 18px;
margin-left: 8px;
}
:deep(.el-input__wrapper) {
box-shadow: none;
padding-left: 18px;
background-color: rgba(255, 255, 255, 0.1);
border-radius: 20px;
}
:deep(.el-input__inner) {
background-color: rgba(255, 255, 255, 0);
padding-left: 0;
}
}
.navbar {
position: relative;
display: flex;
justify-content: center;
align-items: center;
height: 44px;
.nav-title {
width: 300px;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: 500;
font-size: 18px;
color: #ffffff;
}
.nav-left {
position: absolute;
left: 10px;
top: calc(50% - 10px);
}
}
.el-dialog__body {
width: 80%;
}
:deep(.el-dialog__body) {
padding-top: 0px;
}
.el-dialog__header {
display: none;
}
.tabs {
padding: 12px 0 14px 0;
display: flex;
justify-content: center;
align-items: center;
.tabs-item {
color: #ffffff;
margin: 0 33px;
display: flex;
align-items: center;
flex-direction: column;
font-size: 15px;
opacity: 0.7;
font-weight: 700;
}
.tabs-line {
width: 39px;
height: 3px;
margin-top: 6px;
}
.active {
font-size: 17px;
font-weight: 700;
opacity: 1;
.tabs-line {
background: #ffffff;
border-radius: 2px;
}
}
}
}
</style>