12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import { defineComponent, onMounted, reactive, watch } from "vue";
- import { useRoute } from "vue-router";
- // import { verifyMembershipServices } from "../vip-verify";
- import { api_lessonTrainingSubmitTraining } from "../../api";
- import state, { IDifficulty } from "/src/state";
- import { getQuery } from "/src/utils/queryString";
- import { evaluatingData } from "/src/view/evaluating";
- export default defineComponent({
- name: "EvaluatingWork",
- props: {
- workeData: {
- type: Object,
- default: () => ({}),
- },
- },
- setup(props, {expose}) {
- const query = getQuery();
- const evaluatingWorkData = reactive({
- difficulty: "" as IDifficulty,
- evaluatingRecord: props.workeData?.id,
- });
- /** 隐藏评测功能 */
- const handleHide = () => {
- const ids = ["studnetT-0"];
- for (let i = 0; i < ids.length; i++) {
- const speedBtn = document.getElementById(ids[i]);
- if (speedBtn) {
- speedBtn.style.pointerEvents = "none";
- speedBtn.style.opacity = ".5";
- }
- }
- };
- /** 获取作业详情 */
- const getWorkData = async () => {
- let trainingContent: any = {};
- try {
- trainingContent = JSON.parse(props.workeData.trainingContent);
- } catch (error) {
- console.log("🚀 ~ error:", error);
- }
- if (["BEGINNER", "ADVANCED", "PERFORMER"].includes(trainingContent.evaluateDifficult)) {
- evaluatingWorkData.difficulty = trainingContent.evaluateDifficult;
- state.setting.evaluationDifficulty = trainingContent.evaluateDifficult;
- }
- };
- /** 添加记录 */
- const addEvaluatingWorkRecored = async (data: any) => {
- try {
- const res = await api_lessonTrainingSubmitTraining({
- id: evaluatingWorkData.evaluatingRecord,
- trainingTimes: data?.score || 0,
- });
- } catch (error) {
- console.log(error);
- }
- };
- const handleAdd = () => {
- if (evaluatingData.resulstMode && evaluatingData.isComplete) {
- addEvaluatingWorkRecored(evaluatingData.resultData);
- }
- }
- onMounted(() => {
- handleHide();
- getWorkData();
- // verifyMembershipServices();
- });
- expose({
- handleAdd
- })
- return () => <div></div>;
- },
- });
|