gap.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="c_box">
  3. <!-- <div class="mask"></div> -->
  4. <div v-if="!checkJson">暂未设置题目</div>
  5. <div v-else class="choice_box">
  6. <!-- <div class="title"><div>{{ `(${option[checkJson.type].name})` }}</div><div v-html="checkJson.title"></div></div> -->
  7. <div class="c_title">
  8. <div class="title">
  9. <div style="display: flex;">
  10. <span style="min-width: fit-content;">{{ tindex + 1 + "、" + `(${option[checkJson.type].name})` }}</span>
  11. <span>{{ checkJson.title }}</span>
  12. <span style="min-width: fit-content;color: #efa030;">{{ checkJson.score ? '(分值:'+checkJson.score+'分)' : '' }}</span>
  13. </div>
  14. <span style="color: #efa030;display: flex;margin-top: 5px;line-height: 18px;">
  15. <span style="min-width: fit-content;" v-if="!checkJson.answer && see">暂无参考答案</span>
  16. <span style="min-width: fit-content;display: flex;" v-else-if="see">
  17. <span style="min-width: fit-content;">参考答案:</span>
  18. <span>{{ checkJson.answer }}</span>
  19. </span>
  20. <!-- <span style="min-width: fit-content;margin-left: 10px;">{{ checkJson.score ? '分值:'+checkJson.score+'分' : '' }}</span> -->
  21. </span>
  22. <!-- </div><div v-html="checkJson.title"></div> -->
  23. </div>
  24. <div class="p_box" v-if="isTeacher == 1 && checkJson.score">
  25. <el-input v-model="checkJson.score2" class="c_input" @change="numberPan" placeholder="请输入得分"></el-input><span style="margin: 0 10px;">/</span><span>{{ checkJson.score }}分</span>
  26. </div>
  27. <div class="p_box" v-if="isTeacher == 2 && checkJson.score2">
  28. <span>{{ checkJson.score2 }}分</span><span style="margin: 0 10px;">/</span><span>{{ checkJson.score }}分</span>
  29. </div>
  30. </div>
  31. <div class="choices">
  32. <textarea :readonly="checktype == 2" rows="2" v-autoHeight="68" class="binfo_input binfo_textarea" cols v-model="checkJson.answer2"
  33. placeholder=""></textarea>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. export default {
  40. props: {
  41. tindex:{
  42. type: Number
  43. },
  44. cJson: {
  45. type: Object,
  46. },
  47. checktype: {
  48. type: Number,
  49. default: 1
  50. },
  51. see:{
  52. type:Boolean,
  53. default:false
  54. },
  55. isTeacher: {
  56. type: Number,
  57. default: 2
  58. }
  59. },
  60. data() {
  61. return {
  62. option: {
  63. 1: { name: '问答题' },
  64. },
  65. checkJson: undefined
  66. }
  67. },
  68. watch: {
  69. checkJson: {
  70. handler(newValue) {
  71. this.$emit('update:cJson', newValue)
  72. },
  73. deep: true
  74. },
  75. },
  76. directives: {
  77. autoHeight: {
  78. update(el, binding) {
  79. const { value } = binding
  80. if (value && typeof value === 'number') {
  81. el.style.height = `${value}px`
  82. } else {
  83. el.style.height = 'auto'
  84. }
  85. },
  86. componentUpdated(el) {
  87. el.style.height = `${el.scrollHeight + 5}px`
  88. },
  89. },
  90. },
  91. methods: {
  92. depthCopy(s) {
  93. return JSON.parse(JSON.stringify(s));
  94. },
  95. numberPan() {
  96. if (/[^\d]/.test(this.checkJson.score2) || parseInt(this.checkJson.score2) < 0) {
  97. this.$message.error('请输入大于0的数字')
  98. this.checkJson.score2 = ''
  99. }
  100. if(parseInt(this.checkJson.score2) > parseInt(this.checkJson.score)){
  101. this.$message.error('不能输入大于得分的数字')
  102. this.checkJson.score2 = this.checkJson.score
  103. }
  104. },
  105. },
  106. mounted() {
  107. this.checkJson = this.cJson ? this.depthCopy(this.cJson) : undefined
  108. if(this.checkJson.answer2){
  109. setTimeout(() => {
  110. this.checkJson.answer2 += "*0*%*";
  111. setTimeout(() => {
  112. this.checkJson.answer2 = this.checkJson.answer2.replaceAll("*0*%*", "");
  113. }, 0);
  114. }, 100);
  115. }
  116. }
  117. }
  118. </script>
  119. <style scoped>
  120. .c_box {
  121. width: 100%;
  122. position: relative;
  123. }
  124. .mask {
  125. position: absolute;
  126. height: 100%;
  127. width: 100%;
  128. z-index: 2;
  129. }
  130. .choice_box {
  131. white-space: pre-line;
  132. }
  133. .choice_box> .c_title .title {
  134. font-weight: bold;
  135. width: 100%;
  136. word-break: break-all;
  137. }
  138. .choice_box> .c_title {
  139. display: flex;
  140. justify-content: space-between;
  141. }
  142. .choice_box> .c_title .p_box{
  143. margin-left: 5px;
  144. min-width: fit-content;
  145. display: flex;
  146. align-items: center;
  147. }
  148. .choice_box>.choices {
  149. margin-top: 10px;
  150. }
  151. .binfo_input {
  152. width: 100%;
  153. margin: 0;
  154. padding: 12px 14px;
  155. display: block;
  156. min-width: 0;
  157. outline: none;
  158. box-sizing: border-box;
  159. background: none;
  160. border: none;
  161. border-radius: 4px;
  162. background: #fff;
  163. font-size: 16px;
  164. resize: none;
  165. font-family: 'Microsoft YaHei';
  166. min-height: 48px;
  167. /* border: 1px solid #3682fc00; */
  168. border: 1.5px solid #CAD1DC;
  169. }
  170. .binfo_textarea {
  171. border: 1.5px solid #CAD1DC;
  172. font-size: 16px;
  173. resize: none;
  174. /* background: #f6f6f6; */
  175. font-family: 'Microsoft YaHei';
  176. }
  177. .binfo_input:focus-visible {
  178. border: 1.5px solid #3681FC !important;
  179. }
  180. .c_input {
  181. width: 90px;
  182. }
  183. .c_input >>> .el-input__inner{
  184. padding: 0 5px;
  185. text-align: right;
  186. }
  187. </style>