number.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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;align-items: center;">
  10. <!-- + `(${option[checkJson.type].name})` -->
  11. <span class="g_t_index" style="min-width: fit-content;">{{ tindex + 1}}</span>
  12. <span>{{ checkJson.title }}</span>
  13. <!-- <span style="min-width: fit-content;color: #efa030;">{{ checkJson.score ? '(分值:'+checkJson.score+'分)' : '' }}</span> -->
  14. </div>
  15. <!-- <span style="color: #efa030;display: flex;margin-top: 5px;line-height: 18px;">
  16. <span style="min-width: fit-content;" v-if="!checkJson.answer && see">暂无参考答案</span>
  17. <span style="min-width: fit-content;display: flex;" v-else-if="see">
  18. <span style="min-width: fit-content;">参考答案:</span>
  19. <span>{{ checkJson.answer }}</span>
  20. </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="detail" v-if="checkJson.detail" v-html="checkJson.detail"
  32. style="color: #00000066;margin-top: 5px;"></div>
  33. <div class="choices">
  34. <el-input-number :controls="false" v-model="checkJson.answer2" :precision="numberTypePrecision" :placeholder="numberTypePlaceholder[checkJson.type]"></el-input-number>
  35. <span v-if="checkJson.type=='4'">%</span>
  36. <!-- <textarea :readonly="checktype == 2" rows="2" v-autoHeight="68" class="binfo_input binfo_textarea" cols v-model="checkJson.answer"
  37. placeholder=""></textarea> -->
  38. </div>
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. export default {
  44. props: {
  45. tindex:{
  46. type: Number
  47. },
  48. cJson: {
  49. type: Object,
  50. },
  51. checktype: {
  52. type: Number,
  53. default: 1
  54. },
  55. see:{
  56. type:Boolean,
  57. default:false
  58. },
  59. isTeacher: {
  60. type: Number,
  61. default: 2
  62. }
  63. },
  64. data() {
  65. return {
  66. option: {
  67. 1: { name: '字数' },
  68. },
  69. userid:this.$route.query.userid,
  70. checkJson: undefined,
  71. numberTypePlaceholder:{
  72. "1":"请输入整数",
  73. "2":"请输入数字并保留一位小数",
  74. "3":"请输入数字并保留两位小数",
  75. "4":"请输入百分比"
  76. },
  77. }
  78. },
  79. watch: {
  80. checkJson: {
  81. handler(newValue) {
  82. this.$emit('update:cJson', newValue)
  83. },
  84. deep: true
  85. },
  86. cJson: {
  87. handler(newValue) {
  88. if(newValue.answer2 !== this.checkJson.answer2){
  89. this.checkJson = this.depthCopy(newValue)
  90. this.$forceUpdate()
  91. }
  92. },
  93. deep: true
  94. },
  95. },
  96. computed:{
  97. numberTypePrecision(){
  98. let _result = 0;
  99. if(this.checkJson.type=='1'){
  100. _result = 0
  101. }else if(this.checkJson.type=='2'){
  102. _result = 1
  103. }else if(this.checkJson.type=='3'){
  104. _result = 2
  105. }else if(this.checkJson.type=='4'){
  106. _result = 0
  107. }
  108. return _result
  109. }
  110. },
  111. methods: {
  112. depthCopy(s) {
  113. return JSON.parse(JSON.stringify(s));
  114. },
  115. },
  116. mounted() {
  117. this.checkJson = this.cJson ? this.depthCopy(this.cJson) : undefined
  118. if(this.checkJson.answer2){
  119. setTimeout(() => {
  120. this.checkJson.answer2 += "*0*%*";
  121. setTimeout(() => {
  122. this.checkJson.answer2 = this.checkJson.answer2.replaceAll("*0*%*", "");
  123. }, 0);
  124. }, 100);
  125. }
  126. }
  127. }
  128. </script>
  129. <style scoped>
  130. .c_box {
  131. width: 100%;
  132. position: relative;
  133. padding-left: 45px;
  134. }
  135. .mask {
  136. position: absolute;
  137. height: 100%;
  138. width: 100%;
  139. z-index: 2;
  140. }
  141. .choice_box {
  142. white-space: pre-line;
  143. }
  144. .choice_box> .c_title .title {
  145. font-weight: bold;
  146. width: 100%;
  147. word-break: break-all;
  148. }
  149. .choice_box> .c_title {
  150. display: flex;
  151. justify-content: space-between;
  152. }
  153. .choice_box> .c_title .p_box{
  154. margin-left: 5px;
  155. min-width: fit-content;
  156. display: flex;
  157. align-items: center;
  158. }
  159. .choice_box>.choices {
  160. margin-top: 10px;
  161. }
  162. .choices>span{
  163. font-size: 20px;
  164. }
  165. .binfo_input {
  166. width: 100%;
  167. margin: 0;
  168. padding: 12px 14px;
  169. display: block;
  170. min-width: 0;
  171. outline: none;
  172. box-sizing: border-box;
  173. background: none;
  174. border: none;
  175. border-radius: 4px;
  176. background: #fff;
  177. font-size: 16px;
  178. resize: none;
  179. font-family: 'Microsoft YaHei';
  180. min-height: 48px;
  181. /* border: 1px solid #3682fc00; */
  182. border: 1.5px solid #CAD1DC;
  183. }
  184. .binfo_textarea {
  185. border: 1.5px solid #CAD1DC;
  186. font-size: 16px;
  187. resize: none;
  188. /* background: #f6f6f6; */
  189. font-family: 'Microsoft YaHei';
  190. }
  191. .binfo_input:focus-visible {
  192. border: 1.5px solid #3681FC !important;
  193. }
  194. .c_input {
  195. width: 90px;
  196. }
  197. .c_input >>> .el-input__inner{
  198. padding: 0 5px;
  199. text-align: right;
  200. }
  201. .g_t_index{
  202. color: #3681FC;
  203. font-size: 28px;
  204. font-weight: bold;
  205. position: relative;
  206. margin-right: 30px;
  207. margin-left: -40px;
  208. }
  209. .g_t_index+span{
  210. font-weight: bold;
  211. font-size: 18px;
  212. }
  213. .g_t_index::after{
  214. content: "";
  215. width: 18px;
  216. height: 2px;
  217. position: absolute;
  218. right: -18px;
  219. top: 50%;
  220. transform: translateY(-50%);
  221. background: #3681FC;
  222. }
  223. .g_t_index::before{
  224. content: "";
  225. width: 6px;
  226. height: 6px;
  227. border-right: 2px solid #3681FC;
  228. border-top: 2px solid #3681FC;
  229. position: absolute;
  230. right: -15px;
  231. top: 50%;
  232. transform: rotate(45deg) translateY(-5px);
  233. }
  234. .choices>textarea{
  235. border-color: #E7E7E7;
  236. border-radius: 8px;
  237. }
  238. </style>