index.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. },
  16. setup(props, {expose}) {
  17. const query = getQuery();
  18. const evaluatingWorkData = reactive({
  19. difficulty: "" as IDifficulty,
  20. evaluatingRecord: props.workeData?.id,
  21. });
  22. /** 隐藏评测功能 */
  23. const handleHide = () => {
  24. const ids = ["studnetT-0"];
  25. for (let i = 0; i < ids.length; i++) {
  26. const speedBtn = document.getElementById(ids[i]);
  27. if (speedBtn) {
  28. speedBtn.style.pointerEvents = "none";
  29. speedBtn.style.opacity = ".5";
  30. }
  31. }
  32. };
  33. /** 获取作业详情 */
  34. const getWorkData = async () => {
  35. let trainingContent: any = {};
  36. try {
  37. trainingContent = JSON.parse(props.workeData.trainingContent);
  38. } catch (error) {
  39. console.log("🚀 ~ error:", error);
  40. }
  41. if (["BEGINNER", "ADVANCED", "PERFORMER"].includes(trainingContent.evaluateDifficult)) {
  42. evaluatingWorkData.difficulty = trainingContent.evaluateDifficult;
  43. state.setting.evaluationDifficulty = trainingContent.evaluateDifficult;
  44. }
  45. };
  46. /** 添加记录 */
  47. const addEvaluatingWorkRecored = async (data: any) => {
  48. try {
  49. const res = await api_lessonTrainingSubmitTraining({
  50. id: evaluatingWorkData.evaluatingRecord,
  51. trainingTimes: data?.score || 0,
  52. });
  53. } catch (error) {
  54. console.log(error);
  55. }
  56. };
  57. const handleAdd = () => {
  58. if (evaluatingData.resulstMode && evaluatingData.isComplete) {
  59. addEvaluatingWorkRecored(evaluatingData.resultData);
  60. }
  61. }
  62. onMounted(() => {
  63. handleHide();
  64. getWorkData();
  65. // verifyMembershipServices();
  66. });
  67. expose({
  68. handleAdd
  69. })
  70. return () => <div></div>;
  71. },
  72. });