answerTheResult.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div class="answerTheResult">
  3. <div class="atr_detail">
  4. <div class="atr_d_btn">查看详细</div>
  5. <div class="atr_d_msg">
  6. <div>参与人数</div>
  7. <span>{{workArrayLength}}/{{ workArrayLength + unsubmittedStudentsLength }}</span>
  8. </div>
  9. <div class="atr_d_msg" v-if="workDetail && workDetail.type === '45'">
  10. <div>正确率</div>
  11. <span>30%(15/30)</span>
  12. </div>
  13. <div class="atr_d_msg" v-if="workDetail && workDetail.type === '45'">
  14. <div>正确答案</div>
  15. <span>B</span>
  16. </div>
  17. <span class="atr_d_line"></span>
  18. <div class="no_submit">
  19. <div>未提交人员</div>
  20. <img @click="showNoSubmitDetail = !showNoSubmitDetail" :class="{'no_submit_active':!showNoSubmitDetail}" src="../../../assets/img/arrow_up.png" />
  21. </div>
  22. <div class="no_submitList" :class="{'no_submitList_active':showNoSubmitDetail}">
  23. <div v-for="(student, idx) in props.unsubmittedStudents" :key="student.id ?? idx">{{ student.name ?? '' }}</div>
  24. </div>
  25. </div>
  26. <div class="atr_type45Area" v-if="workDetail && workDetail.type === '45'">
  27. {{ workDetail.json }}
  28. </div>
  29. </div>
  30. </template>
  31. <script lang="ts" setup>
  32. import { ref, computed, watch} from 'vue'
  33. import api from '../../../services/course'
  34. interface Props {
  35. workArray?: object[] | null
  36. unsubmittedStudents?: object[] | null
  37. workId?:string | null
  38. }
  39. const props = withDefaults(defineProps<Props>(), {
  40. workArray: () => [],
  41. unsubmittedStudents: () => [],
  42. workId: ''
  43. })
  44. const workArrayLength = computed(() => {
  45. let _result = 0
  46. if (props.workArray) {
  47. _result = props.workArray.length
  48. }
  49. return _result
  50. })
  51. const unsubmittedStudentsLength = computed(() => {
  52. let _result = 0
  53. if (props.unsubmittedStudents) {
  54. _result = props.unsubmittedStudents.length
  55. }
  56. return _result
  57. })
  58. console.log('workArray', props.workArray)
  59. console.log('unsubmittedStudents', props.unsubmittedStudents)
  60. const workIndex = ref<number>(0)
  61. const showNoSubmitDetail = ref<boolean>(false)
  62. const workDetail = ref<any>({})
  63. // 获取作业详细
  64. const getWorkDetail = async () => {
  65. if (props.workId) {
  66. const _res = await api.getWorkDetail({id: props.workId})
  67. const _data = _res[0][0]
  68. if (_data) {
  69. _data.json = JSON.parse(_data.json)
  70. workDetail.value = _data
  71. }
  72. }
  73. }
  74. // 监听作业Id
  75. watch(
  76. () => props.workId,
  77. (newVal, oldVal) => {
  78. console.log('props.workId变化', { newVal, oldVal })
  79. if (newVal && newVal !== oldVal) {
  80. getWorkDetail()
  81. }
  82. },
  83. { immediate: true }
  84. )
  85. </script>
  86. <style lang="scss" scoped>
  87. .answerTheResult {
  88. width: 100%;
  89. height: auto;
  90. max-height: 100%;
  91. overflow: auto;
  92. box-sizing: border-box;
  93. padding: 12px;
  94. .atr_detail {
  95. width: 100%;
  96. height: auto;
  97. border-radius: 4px;
  98. padding: 10px 15px 10px 15px;
  99. box-sizing: border-box;
  100. border: solid 1px rgba(0, 0, 0, 0.1);
  101. .atr_d_btn{
  102. width: 100%;
  103. height: 40px;
  104. display: flex;
  105. align-items: center;
  106. justify-content: center;
  107. background: rgba(0, 0, 0, 0.9);
  108. color: #fff;
  109. font-weight: 500;
  110. font-size: 14px;
  111. border-radius: 4px;
  112. cursor: pointer;
  113. }
  114. .atr_d_msg{
  115. width: 100%;
  116. display: flex;
  117. align-items: center;
  118. margin-top: 15px;
  119. font-size: 14px;
  120. color: rgba(0, 0, 0, 0.9);
  121. &>div{
  122. width: 4em;
  123. margin-right: 35px;
  124. font-weight: 500;
  125. }
  126. }
  127. .atr_d_line{
  128. width: 100%;
  129. height: 2px;
  130. display: block;
  131. background: rgba(242, 243, 245, 1);
  132. margin: 20px 0;
  133. border-radius: 2px;
  134. }
  135. .no_submit{
  136. width: 100%;
  137. display: flex;
  138. align-items: center;
  139. justify-content: space-between;
  140. font-size: 14px;
  141. font-weight: 500;
  142. margin-bottom: 20px;
  143. .no_submit_active{
  144. transform: rotate(180deg);
  145. }
  146. &>img{
  147. cursor: pointer;
  148. }
  149. }
  150. .no_submitList{
  151. width: 100%;
  152. display: flex;
  153. align-items: center;
  154. flex-wrap: nowrap;
  155. overflow: hidden;
  156. gap: 10px;
  157. &>div{
  158. padding: 5px 10px;
  159. background: rgba(255, 236, 232, 1);
  160. color: rgba(245, 63, 63, 1);
  161. font-size: 14px;
  162. font-weight: 500;
  163. border-radius: 10px;
  164. }
  165. }
  166. .no_submitList_active{
  167. flex-wrap: wrap;
  168. }
  169. }
  170. .atr_type45Area{
  171. width: 100%;
  172. height: auto;
  173. }
  174. }
  175. </style>