HzModule.vue 11 KB

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