index.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { defineComponent, onMounted, reactive, watch } from "vue";
  2. import { useRoute } from "vue-router";
  3. // import { verifyMembershipServices } from "../vip-verify";
  4. import { api_lessonTrainingSubmitTraining } from "../../api";
  5. import state, { IDifficulty } from "/src/state";
  6. import { getQuery } from "/src/utils/queryString";
  7. import { evaluatingData } from "/src/view/evaluating";
  8. export default defineComponent({
  9. name: "EvaluatingWork",
  10. props: {
  11. workeData: {
  12. type: Object,
  13. default: () => ({}),
  14. },
  15. pageShow:{
  16. type: Boolean,
  17. default: true,
  18. }
  19. },
  20. setup(props) {
  21. const query = getQuery();
  22. const evaluatingWorkData = reactive({
  23. difficulty: "" as IDifficulty,
  24. evaluatingRecord: props.workeData?.id,
  25. });
  26. /** 隐藏评测功能 */
  27. const handleHide = () => {
  28. const ids = ["studnetT-0"];
  29. for (let i = 0; i < ids.length; i++) {
  30. const speedBtn = document.getElementById(ids[i]);
  31. if (speedBtn) {
  32. speedBtn.style.pointerEvents = "none";
  33. speedBtn.style.opacity = ".5";
  34. }
  35. }
  36. };
  37. /** 获取作业详情 */
  38. const getWorkData = async () => {
  39. let trainingContent: any = {};
  40. try {
  41. trainingContent = JSON.parse(props.workeData.trainingContent);
  42. } catch (error) {
  43. console.log("🚀 ~ error:", error);
  44. }
  45. if (["BEGINNER", "ADVANCED", "PERFORMER"].includes(trainingContent.evaluateDifficult)) {
  46. evaluatingWorkData.difficulty = trainingContent.evaluateDifficult;
  47. state.setting.evaluationDifficulty = trainingContent.evaluateDifficult;
  48. }
  49. };
  50. /** 添加记录 */
  51. const addEvaluatingWorkRecored = async (data: any) => {
  52. try {
  53. const res = await api_lessonTrainingSubmitTraining({
  54. id: evaluatingWorkData.evaluatingRecord,
  55. trainingTimes: data?.score || 0,
  56. });
  57. } catch (error) {
  58. console.log(error);
  59. }
  60. };
  61. watch(
  62. () => evaluatingData.resulstMode,
  63. () => {
  64. if (evaluatingData.resulstMode && evaluatingData.isComplete) {
  65. addEvaluatingWorkRecored(evaluatingData.resultData);
  66. }
  67. }
  68. );
  69. onMounted(() => {
  70. handleHide();
  71. getWorkData();
  72. // verifyMembershipServices();
  73. });
  74. return () => <div></div>;
  75. },
  76. });