1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 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: () => ({}),
- },
- pageShow:{
- type: Boolean,
- default: true,
- }
- },
- setup(props) {
- 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);
- }
- };
- watch(
- () => evaluatingData.resulstMode,
- () => {
- if (evaluatingData.resulstMode && evaluatingData.isComplete) {
- addEvaluatingWorkRecored(evaluatingData.resultData);
- }
- }
- );
- onMounted(() => {
- handleHide();
- getWorkData();
- // verifyMembershipServices();
- });
- return () => <div></div>;
- },
- });
|