This commit is contained in:
kclf
2022-11-25 20:48:21 +08:00
58 changed files with 4125 additions and 1677 deletions

View File

@@ -51,6 +51,15 @@
<button class="checkEval" @click="showEvalDrawer">
选择测评
</button>
<span style="margin-left: 10px">
<a-tag
class="tag-style"
v-if="evaluationTypeName != ''"
:closable="true"
@close="delTag"
>{{ evaluationTypeName }}</a-tag
>
</span>
</div>
</div>
<div class="main_item">
@@ -83,7 +92,7 @@
</div>
<div class="main_btns">
<button class="btn1" @click="closeDrawer">取消</button>
<button class="btn2" @click="createEvalText">确定</button>
<button class="btn2" @click="creoredit">确定</button>
</div>
</div>
<EvList
@@ -107,6 +116,7 @@ import * as apitaskadd from "../../api/indexTaskadd";
import { message } from "ant-design-vue";
import { RouterEditTask } from "@/api/indexTask";
import dayjs from "dayjs";
import { addTempTask } from "../../api/indexTaskadd";
// const router = useRouter();
export default {
name: "AddEval",
@@ -144,11 +154,6 @@ export default {
type: Number,
default: null,
},
projectTaskId: {
// 要编辑的projectId
type: Number,
default: null,
},
routerId: {
type: Number,
default: null,
@@ -171,47 +176,58 @@ export default {
EvalListVisible: false,
// addLoading:false,
});
const checkFinish = (EvListDate)=> {
state.evaluationTypeId = EvListDate.Id
state.evaluationTypeName = EvListDate.Name
}
const checkFinish = (value) => {
state.evaluationTypeId = value.quiz_kid;
state.evaluationTypeName = value.title;
};
const closeDrawer = () => {
ctx.emit("update:addevalVisible", false);
ctx.emit("update:edit", false);
state.inputV1 = "";
state.inputV2 = "";
localStorage.setItem("stageId", props.chooseStageId);
state.time = undefined;
state.description = "";
(state.evaluationTypeId = 0),
(state.evaluationTypeName = ""),
localStorage.setItem("stageId", props.chooseStageId);
localStorage.setItem("chapterId", props.isactive);
};
const afterVisibleChange = (bool) => {
if (props.edit && bool) {
queryEval();
queryInvistById();
}
};
const showEvalDrawer = () => {
state.EvalListVisible = true;
};
const queryEval = () => {
api
.queryEvaluationDetailById({ evaluationId: props.evaluationId })
.then((res) => {
state.inputV1 = res.data.data.evaluationName;
state.time = [
dayjs(res.data.data.evaluationStartTime, "YYYY-MM-DD"),
dayjs(res.data.data.evaluationEndTime, "YYYY-MM-DD"),
];
state.evaluationTypeId = res.data.data.evaluationTypeId;
state.evaluationTypeName = res.data.data.evaluationTypeName;
})
.catch(() => {
});
//删除标签要清除子组件传过来的参数
const delTag = () => {
state.evaluationTypeId = 0;
state.evaluationTypeName = "";
};
const updateTask = (res) => {
//向关卡或阶段渲染
const updateTask = (value) => {
if (props.isLevel == 1) {
RouterEditTask({
chapterId: props.isactive,
courseId: Number(value.evaluationId),
name: value.evaluationName,
routerId: props.routerId,
routerTaskId: props.routerTaskId || 0,
type: 10,
})
.then(() => {
message.success(
`${props.EditTestId ? "编辑" : "新增"}关卡任务成功`
);
})
.catch(() => {
message.error(`${props.EditTestId ? "编辑" : "新增"}关卡任务失败`);
});
} else if (props.isLevel == 2) {
apitaskadd
.addTask({
courseId: res.data.data.evaluationId,
name: res.data.data.evaluationName,
// courseId: res.data.data.evaluationId,
// name: res.data.data.evaluationName,
projectId: props.projectId,
projectTaskId: props.projectTaskId || 0,
stageId: props.chooseStageId,
@@ -219,34 +235,96 @@ export default {
evaluationTypeName: state.evaluationTypeName,
type: 10,
})
.then(( ) => {
message.success(`${props.edit ? "编辑" : "新增"}关卡任务成功`);
.then(() => {
message.success(`${props.edit ? "编辑" : "新增"}阶段任务成功`);
})
.catch(( ) => {
message.error(`${props.edit ? "编辑" : "新增"}关卡任务失败`);
});
} else if (props.isLevel == 2) {
RouterEditTask({
chapterId: props.isactive,
courseId: res.data.data.evaluationId,
name: res.data.data.evaluationName,
routerId: props.routerId,
routerTaskId: props.routerTaskId || 0,
evaluationTypeId: state.evaluationTypeId,
evaluationTypeName: state.evaluationTypeName,
type: 10,
})
.then(( ) => {
message.success(`${props.EditTestId ? "编辑" : "新增"}阶段任务成功`);
})
.catch(( ) => {
message.error(`${props.EditTestId ? "编辑" : "新增"}阶段任务失败`);
.catch(() => {
message.error(`${props.edit ? "编辑" : "新增"}阶段任务失败`);
});
} else if (props.isLevel == 3) {
console.log("");
addTempTask({
duration: 0,
flag: true,
courseId: Number(value.evaluationId),
name: value.evaluationName,
projectId: props.projectId,
projectTaskId: props.projectTaskId || 0,
stageId: props.chooseStageId,
type: 10,
})
.then(() => {
message.success(`${props.edit ? "编辑" : "新增"}阶段任务成功`);
})
.catch(() => {
message.error(`${props.edit ? "编辑" : "新增"}阶段任务失败`);
});
}
};
//创建或编辑测评信息
//根据id获取测评信息
const queryInvistById = () => {
let objqi = {
evaluationId: props.EditEvalId,
};
api
.queryEvaluationDetailById(objqi)
.then((res) => {
message.destroy();
message.success("获取测评信息成功");
state.inputV1 = res.data.data.evaluationName;
state.evaluationTypeName = res.data.data.evaluationTypeName;
state.evaluationTypeId = res.data.data.evaluationTypeId;
state.time = [
dayjs(res.data.data.evaluationStartTime, "YYYY-MM-DD"),
dayjs(res.data.data.evaluationEndTime, "YYYY-MM-DD"),
];
})
.catch((err) => {
message.destroy();
message.error("获取测量平信息失败");
console.log(err, "erererrerererererer");
});
};
const creoredit = () => {
if (props.edit) {
editInvistText();
} else {
createEvalText();
}
};
const editInvistText = () => {
if (!state.inputV1) {
message.destroy();
return message.info("请输入测评名称");
}
if (!state.evaluationTypeId) {
message.destroy();
return message.info("请选择测评");
}
let objei = {
evaluationName: state.inputV1,
evaluationEndTime: dayjs(state.time[1]).format("YYYY-MM-DD"),
evaluationId: props.edit ? Number(props.EditEvalId) : 0,
evaluationStartTime: dayjs(state.time[0]).format("YYYY-MM-DD"),
evaluationTypeId: state.evaluationTypeId,
evaluationTypeName: state.evaluationTypeName,
evaluationFlag: "",
evaluationPictureAddress: "",
evaluationTag: "",
updateTime: "",
};
api
.updateEvaluation(objei)
.then((res) => {
updateTask(res.data.data);
closeDrawer();
ctx.emit("changeData", false);
})
.catch((err) => {
console.log(err, "errrrrrrrrrrrrrrrrrrrrr");
});
};
//创建测评信息
const createEvalText = () => {
if (!state.inputV1) {
message.destroy();
@@ -264,36 +342,22 @@ export default {
let obj = {
evaluationName: state.inputV1,
evaluationEndTime: dayjs(state.time[1]).format("YYYY-MM-DD"),
evaluationId: props.edit ? props.evaluationId : 0,
evaluationId: props.evaluationId,
evaluationStartTime: dayjs(state.time[0]).format("YYYY-MM-DD"),
evaluationTypeId: state.evaluationTypeId,
evaluationTypeName: state.evaluationTypeName,
};
if (props.edit !== true) {
api
.createEvaluation(obj)
.then((res) => {
updateTask(res);
message.success("创建成功");
closeDrawer();
ctx.emit("changeData", false);
})
.catch(() => {
message.error("创建失败");
});
} else {
api
.updateEvaluation(obj)
.then((res) => {
updateTask(res);
message.success("编辑成功");
closeDrawer();
ctx.emit("changeData", false);
})
.catch(( ) => {
message.error("编辑失败");
});
}
api
.createEvaluation(obj)
.then((res) => {
updateTask(res.data.data);
message.success("创建成功");
closeDrawer();
ctx.emit("changeData", false);
})
.catch(() => {
message.error("创建失败");
});
};
return {
@@ -301,8 +365,12 @@ export default {
afterVisibleChange,
checkFinish,
closeDrawer,
delTag,
//增改
creoredit,
createEvalText,
queryInvistById,
editInvistText,
showEvalDrawer,
updateTask,
};