HzModule.vue 13 KB

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