TalkPictureQuestion.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <QuestionBase>
  3. <template #content>
  4. <div class="stem">
  5. <RichText v-model="data.stem" :font-size="18" placeholder="输入题干" />
  6. <RichText
  7. v-if="isEnable(data.property.is_enable_description)"
  8. v-model="data.description"
  9. placeholder="输入提示"
  10. />
  11. </div>
  12. <div class="content">
  13. <div v-for="(item, index) in data.option_list" :key="index" class="content-item">
  14. <template v-if="pic_list[item.picture_file_id]">
  15. <span class="question-number" title="双击切换序号类型" @dblclick="changeOptionType(data)">
  16. {{ computedQuestionNumber(index, data.option_number_show_mode) }}
  17. </span>
  18. <div class="item-left">
  19. <el-image
  20. style="width: 72px; height: 72px"
  21. :src="pic_list[item.picture_file_id]"
  22. :preview-src-list="[pic_list[item.picture_file_id]]"
  23. fit="contain"
  24. />
  25. <button class="delete-btn" @click="delectOptions(index, item.picture_file_id)">
  26. <i class="el-icon-delete"></i>删除
  27. </button>
  28. </div>
  29. <div class="item-right">
  30. <div class="item-rich">
  31. <label class="">图片信息</label>
  32. <RichText v-model="item.picture_info" :font-size="12" placeholder="输入图片信息" />
  33. </div>
  34. <div v-if="isEnable(data.property.is_enable_reference_answer)" class="item-rich">
  35. <label class="">参考答案</label>
  36. <RichText v-model="item.reference_answer" placeholder="输入参考答案" />
  37. </div>
  38. <div v-if="isEnable(data.property.is_enable_analysis)" class="item-rich">
  39. <label>解析</label>
  40. <RichText v-model="item.analysis" :font-size="14" placeholder="输入解析" />
  41. </div>
  42. </div>
  43. </template>
  44. <el-divider />
  45. </div>
  46. <UploadDrag ref="uploadDrag" :limit="999" @fileUploadSuccess="fileUploadSuccess" />
  47. </div>
  48. </template>
  49. <template #property>
  50. <el-form :model="data.property" label-width="72px" label-position="left">
  51. <el-form-item label="题号">
  52. <el-input v-model="data.property.question_number" />
  53. </el-form-item>
  54. <el-form-item>
  55. <el-radio
  56. v-for="{ value, label } in questionNumberTypeList"
  57. :key="value"
  58. v-model="data.other.question_number_type"
  59. :label="value"
  60. >
  61. {{ label }}
  62. </el-radio>
  63. </el-form-item>
  64. <el-form-item label="题干题号">
  65. <el-select v-model="data.property.stem_question_number_font_size">
  66. <el-option v-for="item in fontSizeList" :key="item" :label="item" :value="item" />
  67. </el-select>
  68. </el-form-item>
  69. <el-form-item label="提示">
  70. <el-radio
  71. v-for="{ value, label } in switchOption"
  72. :key="value"
  73. v-model="data.property.is_enable_description"
  74. :label="value"
  75. >
  76. {{ label }}
  77. </el-radio>
  78. </el-form-item>
  79. <el-form-item label="分值">
  80. <el-radio
  81. v-for="{ value, label } in scoreTypeList"
  82. :key="value"
  83. v-model="data.property.score_type"
  84. :label="value"
  85. >
  86. {{ label }}
  87. </el-radio>
  88. </el-form-item>
  89. <el-form-item>
  90. <el-input-number
  91. v-model="data.property.score"
  92. :min="0"
  93. :step="data.property.score_type === scoreTypeList[0].value ? 1 : 0.1"
  94. />
  95. </el-form-item>
  96. <!-- <el-form-item label="语音作答">
  97. <el-radio
  98. v-for="{ value, label } in switchOption"
  99. :key="value"
  100. v-model="data.property.is_enable_voice_answer"
  101. :label="value"
  102. >
  103. {{ label }}
  104. </el-radio>
  105. </el-form-item> -->
  106. <el-form-item label="参考答案">
  107. <el-radio
  108. v-for="{ value, label } in switchOption"
  109. :key="value"
  110. v-model="data.property.is_enable_reference_answer"
  111. :label="value"
  112. >
  113. {{ label }}
  114. </el-radio>
  115. </el-form-item>
  116. <el-form-item label="解析">
  117. <el-radio
  118. v-for="{ value, label } in switchOption"
  119. :key="value"
  120. v-model="data.property.is_enable_analysis"
  121. :label="value"
  122. >
  123. {{ label }}
  124. </el-radio>
  125. </el-form-item>
  126. </el-form>
  127. </template>
  128. </QuestionBase>
  129. </template>
  130. <script>
  131. import QuestionMixin from '../common/QuestionMixin.js';
  132. import UploadDrag from '../common/UploadDrag.vue';
  133. import { talkPictrueData, getOption } from '@/views/exercise_questions/data/talkPicture';
  134. import { GetFileStoreInfo } from '@/api/app';
  135. import { changeOptionType } from '@/views/exercise_questions/data/common';
  136. export default {
  137. name: 'TalkPicture',
  138. components: { UploadDrag },
  139. mixins: [QuestionMixin],
  140. data() {
  141. return {
  142. changeOptionType,
  143. data: JSON.parse(JSON.stringify(talkPictrueData)),
  144. pic_list: {},
  145. is_first: true,
  146. };
  147. },
  148. watch: {
  149. 'data.file_id_list': {
  150. handler() {
  151. if (this.is_first) {
  152. this.handleData();
  153. }
  154. },
  155. deep: true,
  156. },
  157. },
  158. created() {},
  159. mounted() {},
  160. methods: {
  161. // 初始化数据
  162. handleData() {
  163. this.data.file_id_list.forEach((item) => {
  164. GetFileStoreInfo({ file_id: item }).then(({ file_id, file_url }) => {
  165. this.$set(this.pic_list, file_id, file_url);
  166. });
  167. });
  168. this.is_first = false;
  169. },
  170. // 删除
  171. delectOptions(i, id) {
  172. this.$confirm('是否删除该条全部信息?', '提示', {
  173. confirmButtonText: '确定',
  174. cancelButtonText: '取消',
  175. type: 'warning',
  176. })
  177. .then(() => {
  178. delete this.pic_list[id];
  179. this.data.file_id_list.splice(this.data.file_id_list.indexOf(id), 1);
  180. this.data.option_list.splice(i, 1);
  181. this.$refs.uploadDrag.clearFiles();
  182. })
  183. .catch(() => {});
  184. },
  185. fileUploadSuccess(file_id, file_url) {
  186. this.data.file_id_list.push(file_id);
  187. this.data.option_list.push(getOption());
  188. this.data.option_list[this.data.option_list.length - 1].picture_file_id = file_id;
  189. this.$set(this.pic_list, file_id, file_url);
  190. },
  191. /**
  192. * 智能识别
  193. * @param {String} text 识别数据
  194. */
  195. recognition(text) {
  196. this.recognitionCommon(text);
  197. },
  198. },
  199. };
  200. </script>
  201. <style lang="scss" scoped>
  202. .content {
  203. :deep .el-upload {
  204. width: 100%;
  205. &-dragger {
  206. display: flex;
  207. flex-direction: column;
  208. align-items: center;
  209. justify-content: center;
  210. width: 100%;
  211. height: 90px;
  212. font-size: 14px;
  213. :first-child {
  214. color: #000;
  215. }
  216. :last-child {
  217. color: $text-color;
  218. }
  219. }
  220. }
  221. .content-item {
  222. display: flex;
  223. flex-wrap: wrap;
  224. column-gap: 8px;
  225. margin-bottom: 24px;
  226. }
  227. .delete-btn {
  228. width: 100%;
  229. padding: 5px 8px;
  230. font-size: 14px;
  231. line-height: 22px;
  232. color: #f53f3f;
  233. background: #fff4f4;
  234. border: none;
  235. border-radius: 4px;
  236. .el-icon-delete {
  237. margin-right: 8px;
  238. }
  239. &:hover {
  240. color: #f53f3f;
  241. }
  242. &:focus {
  243. outline: none;
  244. }
  245. }
  246. .item-left {
  247. width: 72px;
  248. }
  249. .item-right {
  250. flex: 1;
  251. .item-rich {
  252. display: flex;
  253. > label {
  254. flex-shrink: 0;
  255. width: 64px;
  256. font-size: 14px;
  257. line-height: 32px;
  258. color: $font-light-color;
  259. }
  260. :deep .rich-wrapper {
  261. flex: 1;
  262. }
  263. }
  264. }
  265. .question-number {
  266. min-width: 40px;
  267. height: 32px;
  268. padding: 4px 0;
  269. color: $text-color;
  270. text-align: center;
  271. cursor: default;
  272. background-color: $fill-color;
  273. border-radius: 2px;
  274. }
  275. }
  276. </style>