feat:关卡列表数据接入

This commit is contained in:
王熙东
2022-11-03 16:41:15 +08:00
parent bfe5790553
commit d45007605d
4 changed files with 215 additions and 154 deletions

14
src/api/indexTask.js Normal file
View File

@@ -0,0 +1,14 @@
import http from "./config";
// 获取路径图详情-包含关卡及任务列表
export const GetRouterDetail = (routerId) => http.get(`/admin/router/detail?routerId=${routerId}`)
// 新建或编辑阶段任务
export const ProjectEditTask = (obj) => http.post('/admin/project/editTask',obj)
// 新建或编辑关卡任务
export const RouterEditTask = (obj) => http.post('/admin/router/editTask',obj)
// 删除关卡任务
export const RouterDeleteTask = (obj) => http.post('/admin/router/deleteTask',obj);
// 删除项目任务
export const ProjectDeleteTask = (obj) => http.delete('/admin/project/deleteTask',obj);

View File

@@ -106,6 +106,7 @@
import { reactive, ref } from "vue";
import {message} from"ant-design-vue";
import { createWorkTask, queryWorkDetailById, updateWorkTaskUsing} from "@/api/indexWork";
import { ProjectEditTask,RouterEditTask } from "@/api/indexTask"
import dayjs from 'dayjs';
const rowSelection = ref({
@@ -133,7 +134,15 @@ export default {
type: Boolean,
default: false,
},
workId: {
flag: {
type: Number,
default: 0,
},
projectTaskId: {
type: Number,
default: 0,
},
routerTaskId: {
type: Number,
default: 0,
}
@@ -261,19 +270,60 @@ export default {
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();
console.log(res);
}).catch((err)=>{
message.error(`添加失败${err}`)
})
}
if(props.flag == 1) {
let editObj = {
"courseId": 0,
"duration": 0,
"flag": true,
"name": formState.workName,
"projectId": 0,
"projectTaskId": props.workId || '',
"stageId": 0,
"type": 4
}
// 新增编辑或新增项目任务
ProjectEditTask(editObj).then(res => {
console.log(` 编辑项目成功的打印 ${res}`);
message.success(`${props.workId? '编辑' : '新增'}阶段任务成功`)
closeDrawer();
}).catch(err => {
message.error(`${props.workId? '编辑' : '新增'}阶段任务失败`)
console.log(` 编辑项目失败的打印 ${err}`);
})
} else {
let editObj1 = {
"chapterId":36,
"courseId": 0,
"duration": 0,
"flag": true,
"name": formState.workName,
"routerId": 92,
"routerTaskId": 0,
"type": 4
}
// 新增编辑或新增关卡任务
RouterEditTask(editObj1).then(res => {
console.log(` 编辑关卡成功的打印 ${res}`);
message.success(`${props.workId? '编辑' : '新增'}关卡任务成功`)
closeDrawer();
}).catch(err => {
message.error(`${props.workId? '编辑' : '新增'}关卡任务失败`)
console.log(` 编辑关卡失败的打印 ${err}`);
})
}
};
return {
afterVisibleChange,

View File

@@ -85,6 +85,7 @@
<a-input
v-model:value="formState.examinationDuration"
type="number"
style="width: 388px; height: 32px;
margin-left: 35px;"
/>
@@ -100,6 +101,7 @@
<a-input-number
:min="-1" :precision="0"
type="number"
v-model:value="formState.examinationLimit"
style="width: 88px; height: 32px;
border-radius: 8px;overflow: hidden;"
@@ -161,6 +163,7 @@
<a-input
v-model:value="formState.passLine"
type="number"
style="width: 88px; height: 32px;margin-left: 35px;"
/>
</a-form-item>
@@ -197,6 +200,8 @@
import { reactive, ref } from "vue";
import {message} from"ant-design-vue";
import {createExamination,queryExaminationDetailById,updateExamination} from "@/api/indexExam"
import { ProjectEditTask } from "@/api/indexTask"
import dayjs from 'dayjs';
const rowSelection = ref({
checkStrictly: false,
@@ -225,7 +230,7 @@ export default {
},
examinationId: {
type: Number,
default: 0,
default: -1,
}
},
setup(props, ctx) {
@@ -429,21 +434,38 @@ export default {
if(id) {
updateExamination(obj).then((res)=>{
console.log(res);
message.success(`编辑成功`)
closeDrawer();
}).catch(()=>{
message.error(`编辑失败`)
})
} else {
createExamination(obj).then((res)=>{
message.success(`添加成功${res}`)
closeDrawer();
createExamination(obj).then(()=>{
}).catch((err)=>{
message.error(`添加失败${err}`)
})
}
let editObj = {
"courseId": 0,
"duration": 0,
"flag": true,
"name": "",
"projectId": 0,
"projectTaskId": props.examinationId || '',
"stageId": 0,
"type": 5
}
// 新增编辑或新增项目
ProjectEditTask(editObj).then(res => {
console.log(` 编辑项目成功的打印 ${res}`);
message.success(`${props.examinationId? '编辑' : '新增'}阶段任务成功`)
closeDrawer();
}).catch(err => {
message.error(`${props.examinationId? '编辑' : '新增'}阶段任务失败`)
console.log(` 编辑项目失败的打印 ${err}`);
})
}
const afterVisibleChange = (bool) => {
console.log("formState", bool);

View File

@@ -17,10 +17,10 @@
> -->
<div
class="items"
:class="isactive == index && isActive == true ? 'active' : ''"
:class="isactive == index ? 'active' : ''"
@click="changebgc(index)"
v-for="(item, index) in level"
:key="item.id"
:key="item.chapterId"
>
<div class="items1">
<div class="boxs_left">
@@ -37,7 +37,7 @@
<div class="nname">{{ item.name }}</div>
</div>
<!-- <div class="itemle">
<div class="tit">{{ item.tit }}</div>
<div class="tit">{{ item.remark }}</div>
<div class="name">{{ item.name }}</div>
</div> -->
</div>
@@ -60,7 +60,7 @@
<div class="main">
<div class="inma">
<div class="name">
<div class="d" style="margin-top: 2px; margin-right: 2px">
<div class="d" style="margin-top: 2px;margin-right:2px">
<img
style="width: 10px; height: 10px"
src="../../assets/images/basicinfo/asterisk.png"
@@ -78,15 +78,8 @@
<div class="co">{{ value1.length }}/20</div>
</div>
<div class="name">
<div
class="d"
style="
width: 10px;
height: 10px;
margin-top: 2px;
margin-right: 2px;
"
></div>
<div class="d" style="width: 10px;height: 10px;margin-top: 2px;margin-right:2px">
</div>
<div class="fir">关卡说明</div>
<div class="input">
<a-textarea
@@ -166,20 +159,30 @@
</div>
<div class="item">
<div class="itcon">
<div class="img">
<div class="img" @click="showDrawerAddHomework">
<img src="../../assets/images/leveladd/zuo.png" />
</div>
<div class="text">作业</div>
</div>
<!-- 添加作业侧弹窗 -->
<div>
<add-homework
flag=0 routerTaskId=ListChoosedId
v-model:addhomeworkVisible="addhomeworkvisible" />
</div>
<div class="lin"></div>
</div>
<div class="item">
<div class="itcon">
<div class="img">
<div class="img" @click="showDrawerAddTest">
<img src="../../assets/images/leveladd/kao.png" />
</div>
<div class="text">考试</div>
</div>
<!-- 添加考试侧弹窗 -->
<div>
<add-test v-model:addtestVisible="addtestvisible" />
</div>
<div class="lin"></div>
</div>
<div class="item">
@@ -519,67 +522,27 @@
import { reactive, toRefs, onMounted, onUnmounted } from "vue";
import AddStu from "../../components/drawers/AddLevelAddStu";
import ImpStu from "../../components/drawers/AddLevelImportStu";
import AddHomework from "../../components/drawers/AddHomework.vue";
import AddTest from "../../components/drawers/AddTest.vue";
import * as api from "../../api/indexLevel";
import { GetRouterDetail, RouterDeleteTask } from "../../api/indexTask";
import { message } from "ant-design-vue";
export default {
name: "LevelAddDetail",
components: {
AddStu,
ImpStu,
AddHomework,
AddTest
},
setup() {
const state = reactive({
level: [
{
id: "1",
tit: "关卡1关卡1关卡1关卡1关卡1关卡1",
name: "初级产品经理fewfewfwefwefe",
},
{
id: "2",
tit: "关卡2",
name: "中级产品经理",
},
{
id: "2",
tit: "关卡2",
name: "中级产品经理",
},
{
id: "2",
tit: "关卡2",
name: "中级产品经理",
},
{
id: "2",
tit: "关卡2",
name: "中级产品经理",
},
{
id: "2",
tit: "关卡2",
name: "中级产品经理",
},
{
id: "2",
tit: "关卡2",
name: "中级产品经理",
},
{
id: "2",
tit: "关卡2",
name: "中级产品经理",
},
{
id: "2",
tit: "关卡2",
name: "中级产品经理",
},
{
id: "2",
tit: "关卡2",
name: "中级产品经理",
},
chapterId: "1",
remark: "关卡说明",
name: "默认关卡",
}
],
tableData: [
{
@@ -593,50 +556,6 @@ export default {
checked1: false,
checkedd: false,
},
{
key: 2,
lei: "面授",
// state: "草稿",
creater: "管理者面授",
// pubtime: "2022-07-20 14:00:03",
cretime: "20分钟",
haspub: true,
checked1: false,
checkedd: false,
},
{
key: 3,
lei: "作业",
// state: "已停用",
creater: "管理者作业",
// pubtime: "2022-07-20 14:00:03",
cretime: "60分钟",
haspub: false,
checked1: false,
checkedd: false,
},
{
key: 4,
lei: "考试",
// state: "草稿",
creater: "管理者考试",
// pubtime: "2022-07-20 14:00:03",
cretime: "20分钟",
haspub: true,
checked1: false,
checkedd: false,
},
{
key: 5,
lei: "案例",
// state: "草稿",
creater: "腾飞班1案例",
// pubtime: "2022-07-20 14:00:03",
cretime: "-",
haspub: true,
checked1: true,
checkedd: false,
},
],
tableData2: [
{
@@ -821,15 +740,18 @@ export default {
value2: "",
selectedRowKeys: [],
gqxy_hs: true,
isactive: -1,
isActive: false,
isactive: 0,
projectChecked: null, //项目单选框
addhomeworkvisible: false,
addtestvisible:false,
updateChapterID: null, //修改关卡id
// 表示当前触发列表的id,用来发送编辑和删除
ListChoosedId:0
});
//新建关卡
const editChapter = () => {
if (!state.value1) return message.warning("请输入关卡名称");
if(!state.value1) return message.warning("请输入关卡名称");
let obj = {
name: state.value1,
remark: state.value2,
@@ -852,29 +774,70 @@ export default {
.catch((err) => {
console.log("创建失败", err);
});
};
}
//编辑关卡
const updateChapter = () => {
let obj = {
chapterId: state.updateChapterID,
name: "",
remark: "",
routerId: 0,
};
api
.updateChapter(obj)
.then((res) => {
console.log("修改成功", res);
message.success("修改成功");
})
.catch((err) => {
console.log("修改失败", err);
});
};
// const updateChapter = () => {
// let obj = {
// chapterId: state.updateChapterID,
// name: "",
// remark:"",
// routerId: 0,
// };
// api
// .updateChapter(obj)
// .then((res) => {
// console.log("修改成功",res);
// message.success("修改成功");
// })
// .catch((err) => {
// console.log("修改失败",err);
// })
// };
const showDrawer = () => {
state.visible = true;
};
// 作业和考试的抽屉
const showDrawerAddHomework = () => {
state.addhomeworkvisible = true;
state.ListChoosedId = 0
};
const showDrawerAddTest = () => {
state.addtestvisible = true;
state.ListChoosedId = 0
};
// tableData数据赋值方法
const dataAssignment = () => {
console.log((state.level));
state.level[0].taskList.forEach((element,index) => {
state.tableData[index] = {
key:element.routerTaskId,
lei:checkType(element.type),
creater:element.name,
cretime:element.duration,
checked1:element.flag
}
});
}
const getDetail = (index) => {
GetRouterDetail(92).then((res) => {
state.level = res.data.data.chapterList
console.log(state.level);
if(index == 0) {
// state.tableData[1] = {
// key: 2,
// lei: "在线",
// creater: "管理者课程",
// cretime: "60",
// checked1: true,
// }
dataAssignment(0)
}
}).catch((err) => {
message.error(err)
})
}
const closeDrawer = () => {
state.visible = false;
};
@@ -1000,14 +963,9 @@ export default {
<span style="color:#4EA6FF;margin-right:25px;cursor:pointer">
编辑
</span>
<span
style="color:#4EA6FF;cursor:pointer"
onClick={() => {
updateChapter();
}}
>
删除
</span>
<span style="color:#4EA6FF;cursor:pointer" onClick={() => {
deleteLevelTask()
}}>删除</span>
</div>
</div>
);
@@ -1016,6 +974,10 @@ export default {
];
return columns;
};
const checkType = (index) => {
let typeRules = ["","在线","面授","案例","作业","考试","直播","外链","讨论","测评","评估","投票"];
return typeRules[index];
}
const tableDataFunc2 = () => {
const columns = [
{
@@ -1200,6 +1162,7 @@ export default {
document.getElementsByTagName("main")[0].style.background =
"rgb(245, 247, 250,1)";
document.getElementsByTagName("main")[0].style.boxShadow = "none";
getDetail(0)
});
onUnmounted(() => {
document.getElementsByTagName("main")[0].style.background = "#ffffff";
@@ -1208,7 +1171,7 @@ export default {
});
const changebgc = (index) => {
state.isactive = index;
state.isActive = !state.isActive;
dataAssignment(index);
};
const gqxy_hShow = () => {
state.gqxy_hs = !state.gqxy_hs;
@@ -1219,6 +1182,15 @@ export default {
const delete_exit = () => {
state.deleteAll = false;
};
const deleteLevelTask = () => {
RouterDeleteTask(state.listChoosedId).then((res) => {
console.log(`删除成功${res}`);
message.success('删除成功')
}).catch((err) => {
console.log(`删除失败${err}`);
})
}
return {
...toRefs(state),
tableDataFunc,
@@ -1238,7 +1210,10 @@ export default {
delete_exit,
drawertableColumns,
editChapter,
updateChapter,
// updateChapter,
showDrawerAddHomework,
showDrawerAddTest,
deleteLevelTask,
};
},
};
@@ -1364,9 +1339,9 @@ export default {
width: 100px;
height: 40px;
border-radius: 4px;
border: 1px solid #409eff;
border: 1px solid #409EFF;
font-size: 14px;
color: #409eff;
color: #409EFF;
cursor: pointer;
background: #ffffff;
margin-right: 20px;
@@ -1379,7 +1354,7 @@ export default {
color: #fff;
cursor: pointer;
border: 0;
background: #409eff;
background: #409EFF;
}
}
}
@@ -1401,7 +1376,7 @@ export default {
.drawerMain {
min-width: 600px;
margin: 0px 32px 0px 32px;
overflow-x: auto;
overflow-x: scroll;
display: flex;
flex-direction: column;
.header {