WritePictureQuestion.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <QuestionBase>
  3. <template #content>
  4. <div class="stem">
  5. <el-input
  6. v-if="data.property.stem_type === stemTypeList[0].value"
  7. v-model="data.stem"
  8. rows="3"
  9. resize="none"
  10. type="textarea"
  11. placeholder="输入题干"
  12. />
  13. <RichText v-if="data.property.stem_type === stemTypeList[1].value" v-model="data.stem" placeholder="输入题干" />
  14. </div>
  15. <div class="content">
  16. <div v-for="(item, index) in data.option_list" :key="index" class="content-item">
  17. <div v-if="pic_list[item.picture_file_id]" class="content-pic">
  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_title" placeholder="输入图片标题" />
  33. </div>
  34. <div class="item-rich">
  35. <label class="">图片信息</label>
  36. <RichText v-model="item.picture_info" placeholder="输入图片信息" />
  37. </div>
  38. </div>
  39. </div>
  40. <template v-if="isEnable(data.property.is_enable_description)">
  41. <label class="title-little">题目要求:</label>
  42. <el-input v-model="item.description" rows="3" resize="none" type="textarea" placeholder="输入题目要求" />
  43. </template>
  44. <label class="title-little">阅读材料:</label>
  45. <RichText v-model="item.article" placeholder="输入阅读材料" />
  46. <template v-if="isEnable(data.property.is_enable_sample_text)">
  47. <el-divider class="write-divider" />
  48. <label class="title-little">范文:</label>
  49. <RichText v-model="item.sample_text" placeholder="输入范文" :wordlimit-num="5000" />
  50. <p class="tips">多篇范文之间使用分割线(---)</p>
  51. </template>
  52. </div>
  53. <UploadDrag @fileUploadSuccess="fileUploadSuccess" :limit="999" ref="uploadDrag"></UploadDrag>
  54. </div>
  55. </template>
  56. <template #property>
  57. <el-form :model="data.property">
  58. <el-form-item label="题干">
  59. <el-radio
  60. v-for="{ value, label } in stemTypeList"
  61. :key="value"
  62. v-model="data.property.stem_type"
  63. :label="value"
  64. >
  65. {{ label }}
  66. </el-radio>
  67. </el-form-item>
  68. <el-form-item label="题号">
  69. <el-input v-model="data.property.question_number" />
  70. </el-form-item>
  71. <el-form-item label-width="45px">
  72. <el-radio
  73. v-for="{ value, label } in questionNumberTypeList"
  74. :key="value"
  75. v-model="data.other.question_number_type"
  76. :label="value"
  77. >
  78. {{ label }}
  79. </el-radio>
  80. </el-form-item>
  81. <el-form-item label="题目要求">
  82. <el-radio
  83. v-for="{ value, label } in switchOption"
  84. :key="value"
  85. v-model="data.property.is_enable_description"
  86. :label="value"
  87. >
  88. {{ label }}
  89. </el-radio>
  90. </el-form-item>
  91. <el-form-item label="分值">
  92. <el-radio
  93. v-for="{ value, label } in scoreTypeList"
  94. :key="value"
  95. v-model="data.property.score_type"
  96. :label="value"
  97. >
  98. {{ label }}
  99. </el-radio>
  100. </el-form-item>
  101. <el-form-item label-width="45px">
  102. <el-input-number
  103. v-model="data.property.score"
  104. :min="0"
  105. :step="data.property.score_type === scoreTypeList[0].value ? 1 : 0.1"
  106. />
  107. </el-form-item>
  108. <el-form-item label="词数">
  109. <el-input-number :min="1" :step="10" v-model="data.property.word_num" class="word-num-input" :precision="0" />
  110. </el-form-item>
  111. <el-form-item label="范文">
  112. <el-radio
  113. v-for="{ value, label } in switchOption"
  114. :key="value"
  115. v-model="data.property.is_enable_sample_text"
  116. :label="value"
  117. >
  118. {{ label }}
  119. </el-radio>
  120. </el-form-item>
  121. <el-form-item label="上传附件">
  122. <el-radio
  123. v-for="{ value, label } in switchOption"
  124. :key="value"
  125. v-model="data.property.is_enable_upload_accessory"
  126. :label="value"
  127. >
  128. {{ label }}
  129. </el-radio>
  130. </el-form-item>
  131. </el-form>
  132. </template>
  133. </QuestionBase>
  134. </template>
  135. <script>
  136. import QuestionMixin from '../common/QuestionMixin.js';
  137. import { writePictrueData, getOption } from '@/views/exercise_questions/data/writePicture';
  138. import { GetFileStoreInfo } from '@/api/app';
  139. import UploadDrag from '../common/UploadDrag.vue';
  140. export default {
  141. name: 'TalkPicture',
  142. mixins: [QuestionMixin],
  143. components: { UploadDrag },
  144. data() {
  145. return {
  146. data: JSON.parse(JSON.stringify(writePictrueData)),
  147. pic_list: {},
  148. is_first: true,
  149. };
  150. },
  151. watch: {
  152. 'data.file_id_list': {
  153. handler() {
  154. if (this.is_first) {
  155. this.handleData();
  156. }
  157. },
  158. deep: true,
  159. },
  160. },
  161. created() {},
  162. mounted() {},
  163. methods: {
  164. // 初始化数据
  165. handleData() {
  166. this.data.file_id_list.forEach((item) => {
  167. GetFileStoreInfo({ file_id: item }).then(({ file_id, file_url }) => {
  168. this.$set(this.pic_list, file_id, file_url);
  169. });
  170. });
  171. this.is_first = false;
  172. },
  173. // 删除
  174. delectOptions(i, id) {
  175. this.$confirm('是否删除该条全部信息?', '提示', {
  176. confirmButtonText: '确定',
  177. cancelButtonText: '取消',
  178. type: 'warning',
  179. })
  180. .then(() => {
  181. delete this.pic_list[id];
  182. this.data.file_id_list.splice(this.data.file_id_list.indexOf(id), 1);
  183. this.data.option_list.splice(i, 1);
  184. this.$refs.uploadDrag.clearFiles();
  185. })
  186. .catch(() => {});
  187. },
  188. fileUploadSuccess(file_id, file_url) {
  189. this.data.file_id_list.push(file_id);
  190. this.data.option_list.push(getOption());
  191. this.data.option_list[this.data.option_list.length - 1].picture_file_id = file_id;
  192. this.$set(this.pic_list, file_id, file_url);
  193. },
  194. },
  195. };
  196. </script>
  197. <style lang="scss" scoped>
  198. .content {
  199. :deep .el-upload {
  200. width: 100%;
  201. &-dragger {
  202. display: flex;
  203. flex-direction: column;
  204. align-items: center;
  205. justify-content: center;
  206. width: 100%;
  207. height: 90px;
  208. font-size: 14px;
  209. :first-child {
  210. color: #000;
  211. }
  212. :last-child {
  213. color: $text-color;
  214. }
  215. }
  216. }
  217. .content-item {
  218. .content-pic {
  219. display: flex;
  220. column-gap: 8px;
  221. margin-bottom: 24px;
  222. }
  223. }
  224. .delete-btn {
  225. width: 100%;
  226. padding: 5px 8px;
  227. font-size: 14px;
  228. line-height: 22px;
  229. color: #f53f3f;
  230. background: #fff4f4;
  231. border: none;
  232. border-radius: 4px;
  233. .el-icon-delete {
  234. margin-right: 8px;
  235. }
  236. &:hover {
  237. color: #f53f3f;
  238. }
  239. &:focus {
  240. outline: none;
  241. }
  242. }
  243. .item-left {
  244. width: 72px;
  245. }
  246. .item-right {
  247. flex: 1;
  248. .item-rich {
  249. display: flex;
  250. > label {
  251. flex-shrink: 0;
  252. width: 64px;
  253. font-size: 14px;
  254. line-height: 32px;
  255. color: #4e5969;
  256. }
  257. }
  258. }
  259. }
  260. </style>