HzModule.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-HzModule">
  4.         
  5. <div class="adult-book-input-item">
  6. <span class="adult-book-lable">标题:</span>           
  7. <el-input
  8. type="textarea"
  9. class="adult-book-input"
  10. :autosize="{ minRows: 2 }"
  11. placeholder="请输入标题"
  12. v-model="curQueItem.title"
  13. @blur="curQueItem.title = curQueItem.title.trim()"
  14. ></el-input>
  15.         
  16. </div>
  17. <div class="adult-book-input-item">
  18. <span class="adult-book-lable">图片</span>
  19. <Upload
  20. :changeFillId="changeImage"
  21. :datafileList="fileCon.img_list"
  22. :filleNumber="imgNumber"
  23. :uploadType="'image'"
  24. />
  25. </div>
  26. <div class="adult-book-input-item">
  27. <span class="adult-book-lable">内容</span>
  28. <el-input
  29. type="textarea"
  30. class="adult-book-input"
  31. :autosize="{ minRows: 2 }"
  32. placeholder="请输入文字"
  33. v-model="curQueItem.hanzi"
  34. @blur="onBlur(curQueItem, 'hanzi')"
  35. ></el-input>
  36. <div class="adult-book-input-item">
  37. <div v-if="checkList.indexOf('image_single') > -1">
  38. <el-radio
  39. @change="changeIsAnswer('single')"
  40. v-model="curQueItem.isAnswer"
  41. :label="index"
  42. >答案</el-radio
  43. >
  44. </div>
  45. <div v-if="checkList.indexOf('image_checkBox') > -1">
  46. <el-checkbox
  47. @change="changeIsAnswer('checkBox')"
  48. v-model="curQueItem.isChecked"
  49. :label="index"
  50. >答案</el-checkbox
  51. >
  52. </div>
  53. <div v-if="checkList.indexOf('image_judge') > -1">
  54. <el-radio-group v-model="curQue.correct[0].judge[index]">
  55. <el-radio label="true">正确</el-radio>
  56. <el-radio label="false">错误</el-radio>
  57. </el-radio-group>
  58. </div>
  59. <div
  60. class="adult-book-input-item"
  61. v-if="checkList.indexOf('image_spell') > -1"
  62. >
  63. <span class="adult-book-lable">答案</span>
  64. <el-input
  65. type="textarea"
  66. class="adult-book-input"
  67. :autosize="{ minRows: 2 }"
  68. placeholder="请输入答案"
  69. v-model.trim="curQue.correct[0].spell[index]"
  70. ></el-input>
  71. </div>
  72. </div>
  73. </div>
  74. <div
  75. style="margin-top: 10px"
  76. class="adult-book-input-item"
  77. v-if="
  78. checkList.indexOf('image_input') > -1 ||
  79. checkList.indexOf('image_gdcy') > -1 ||
  80. checkList.indexOf('image_dobleinput') > -1 ||
  81. checkList.indexOf('image_wordInput') > -1
  82. "
  83. >
  84. <span class="adult-book-lable" style="width: 50px">答案</span>
  85. <el-input
  86. type="textarea"
  87. class="adult-book-input"
  88. :autosize="{ minRows: 2 }"
  89. placeholder="请输入答案"
  90. v-model="curQue.correct[0].input[index]"
  91. @blur="onBlurCorrect(curQue.correct[0].input, 0)"
  92. ></el-input>
  93. </div>
  94. <div
  95. style="margin-top: 10px"
  96. class="adult-book-input-item"
  97. v-if="checkList.indexOf('image_dobleinput') > -1"
  98. >
  99. <span class="adult-book-lable" style="width: 50px">答案</span>
  100. <el-input
  101. type="textarea"
  102. class="adult-book-input"
  103. :autosize="{ minRows: 2 }"
  104. placeholder="请输入答案"
  105. v-model="curQue.correct[0].input[1]"
  106. @blur="onBlurCorrect(curQue.correct[1].input, 1)"
  107. ></el-input>
  108. </div>
  109. <div class="adult-book-input-item">
  110. <span class="adult-book-lable">音频</span>
  111. <Upload
  112. :changeFillId="changeMp3"
  113. :datafileList="fileCon.mp3_list"
  114. :filleNumber="mp3Number"
  115. :uploadType="'mp3'"
  116. />
  117. </div>
  118. </div>
  119. </template>
  120. <script>
  121. import Upload from "./Upload.vue";
  122. import "@/utils/pinyin_dict_withtone";
  123. import "@/utils/pinyinUtil";
  124. export default {
  125. components: { Upload },
  126. props: [
  127. "curQue",
  128. "curQueItem",
  129. "index",
  130. "changAnswer",
  131. "deleteOptionOne",
  132. "checkList",
  133. ],
  134. data() {
  135. return {
  136. //checkListRes: [],
  137. fileCon: {
  138. mp3_list: [],
  139. img_list: [],
  140. },
  141. mp3Number: 1,
  142. imgNumber: 1,
  143. };
  144. },
  145. computed: {},
  146. watch: {
  147. // checkList: {
  148. // handler: function (val, oldVal) {
  149. // const _this = this;
  150. // _this.checkListRes = val;
  151. // },
  152. // // 深度观察监听
  153. // deep: true,
  154. // },
  155. },
  156. //方法集合
  157. methods: {
  158. onBlur(item, field) {
  159. item[field] = item[field] ? item[field].trim() : "";
  160. },
  161. onBlurIndex(index, field) {
  162. let res = this.curQueItem[field][index].trim();
  163. this.$set(this.curQueItem[field], index, res);
  164. },
  165. onBlurCorrect(item) {
  166. item[index] = item[index].trim();
  167. },
  168. // 删除当前选项
  169. deleteOption() {
  170. this.$confirm("确定要删除此选项吗?", "提示", {
  171. confirmButtonText: "确定",
  172. cancelButtonText: "取消",
  173. type: "warning",
  174. }).then(() => {
  175. // this.deleteOptionOne(this.index);
  176. console.log(this.deleteOptionOne());
  177. });
  178. },
  179. // 修改正确答案
  180. changeIsAnswer(type) {
  181. this.changAnswer(this.index, type);
  182. },
  183. // 点击生成拼音
  184. getPinyin(item) {
  185. let bool = false;
  186. let value = "";
  187. if (item.hanzi == "") {
  188. this.$message.warning("请先输入内容,再生成拼音");
  189. bool = true;
  190. } else {
  191. value = item.hanzi;
  192. }
  193. if (bool) {
  194. return;
  195. }
  196. let result = pinyinUtil.getPinyin(value);
  197. item.pinyin = result;
  198. },
  199. changeMp3(fileList) {
  200. const articleImgList = JSON.parse(JSON.stringify(fileList));
  201. const articleImgRes = [];
  202. articleImgList.forEach((item) => {
  203. if (item.response) {
  204. const obj = {
  205. name: item.name,
  206. url: item.response.file_info_list[0].file_url,
  207. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  208. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  209. };
  210. articleImgRes.push(obj);
  211. }
  212. });
  213. this.curQueItem.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  214. },
  215. changeImage(fileList) {
  216. console.log(fileList);
  217. const articleImgList = JSON.parse(JSON.stringify(fileList));
  218. const articleImgRes = [];
  219. articleImgList.forEach((item) => {
  220. if (item.response) {
  221. const obj = {
  222. name: item.name,
  223. url: item.response.file_info_list[0].file_url,
  224. id: item.response.file_info_list[0].file_id,
  225. };
  226. articleImgRes.push(obj);
  227. }
  228. });
  229. //this.articleImgList = articleImgRes;
  230. this.curQueItem.img_list = JSON.parse(JSON.stringify(articleImgRes));
  231. },
  232. //添加释义
  233. addDef() {
  234. let leg = this.curQueItem.definition_list.length;
  235. let last = this.curQueItem.definition_list[leg - 1];
  236. if (!last) {
  237. this.$message.warning("请填写");
  238. return;
  239. }
  240. this.curQueItem.definition_list.push("");
  241. },
  242. delDef(defIndex) {
  243. this.curQueItem.definition_list.splice(defIndex, 1);
  244. },
  245. },
  246. //生命周期 - 创建完成(可以访问当前this实例)
  247. created() {},
  248. //生命周期 - 挂载完成(可以访问DOM元素)
  249. mounted() {
  250. console.log(this.curQueItem);
  251. if (this.curQueItem) {
  252. this.fileCon.img_list = this.curQueItem.img_list;
  253. this.fileCon.mp3_list = this.curQueItem.mp3_list;
  254. }
  255. },
  256. beforeCreate() {}, //生命周期 - 创建之前
  257. beforeMount() {}, //生命周期 - 挂载之前
  258. beforeUpdate() {}, //生命周期 - 更新之前
  259. updated() {}, //生命周期 - 更新之后
  260. beforeDestroy() {}, //生命周期 - 销毁之前
  261. destroyed() {}, //生命周期 - 销毁完成
  262. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  263. };
  264. </script>
  265. <style lang='scss' scoped>
  266. //@import url(); 引入公共css类
  267. .Big-Book {
  268. &-delDef {
  269. padding: 0;
  270. line-height: 32px;
  271. color: #f56c6c;
  272. }
  273. &-def-list {
  274. margin-bottom: 8px;
  275. }
  276. &-top {
  277. display: flex;
  278. justify-content: flex-start;
  279. align-items: flex-start;
  280. margin-top: 10px;
  281. span {
  282. width: 50px;
  283. }
  284. .deleteOptionBox {
  285. width: 40px;
  286. height: 40px;
  287. display: flex;
  288. justify-content: center;
  289. align-items: center;
  290. .close {
  291. width: 24px;
  292. cursor: pointer;
  293. }
  294. }
  295. .Big-Book-input {
  296. display: flex;
  297. justify-content: flex-start;
  298. align-items: flex-start;
  299. > span {
  300. line-height: 32px;
  301. margin-right: 6px;
  302. }
  303. }
  304. }
  305. &-HzModule {
  306. // display: flex;
  307. // justify-content: flex-start;
  308. // align-items: center;
  309. > div {
  310. display: flex;
  311. justify-content: flex-start;
  312. align-items: center;
  313. margin-right: 10px;
  314. > span {
  315. line-height: 32px;
  316. font-size: 14px;
  317. margin-right: 10px;
  318. }
  319. }
  320. }
  321. &-set {
  322. // min-width: 140px;
  323. }
  324. &-mp3 {
  325. margin-top: 6px;
  326. span {
  327. width: 50px;
  328. }
  329. }
  330. &-img {
  331. span {
  332. width: 50px;
  333. }
  334. }
  335. }
  336. </style>
  337. <style lang="scss">
  338. .Big-Book-HzModule {
  339. .el-textarea {
  340. width: 400px;
  341. margin-right: 15px;
  342. }
  343. }
  344. .Big-Book-input {
  345. .el-textarea {
  346. width: 160px;
  347. margin-right: 15px;
  348. }
  349. }
  350. </style>