ZiLine.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-PurePreview" v-if="curQue">
  4. <div
  5. class="Big-Book-Single-content"
  6. style="margin-left: 20px; margin-top: 20px"
  7. >
  8. <div class="adult-book-input-item">
  9. <span class="adult-book-lable">标题:</span>
  10. <el-input
  11. class="adult-book-input"
  12. type="textarea"
  13. :autosize="{ minRows: 2 }"
  14. placeholder="请输入标题"
  15. v-model="curQue.title"
  16. @blur="onBlur(curQue, 'title')"
  17. ></el-input>
  18. </div>
  19. <div class="adult-book-input-item">
  20. <span class="adult-book-lable">排列方式:</span>
  21. <el-radio-group v-model="curQue.arrangeWay" @change="changearrangeWay">
  22. <el-radio label="单列">单列</el-radio>
  23. <el-radio label="双列">双列</el-radio>
  24. <el-radio label="四列">四列</el-radio>
  25. </el-radio-group>
  26. </div>
  27. <div class="adult-book-input-item">
  28. <span class="adult-book-lable">配置:</span>
  29. <div class="xorl">
  30. <el-switch v-model="curQue.Isnumber" active-text="序号"> </el-switch>
  31. <el-switch v-model="curQue.IsRecord" active-text="录音"> </el-switch>
  32. </div>
  33. </div>
  34. <div class="main">
  35. <div
  36. class="row"
  37. v-for="(row, rowIndex) in curQue.option"
  38. :key="'row' + rowIndex"
  39. >
  40. <div
  41. :style="{
  42. width: `${
  43. curQue.arrangeWay == '单列'
  44. ? '732px'
  45. : curQue.arrangeWay == '双列'
  46. ? '362px'
  47. : '177px'
  48. }`,
  49. }"
  50. class="col"
  51. v-for="(col, colIndex) in row"
  52. :key="'col' + colIndex"
  53. >
  54. <div class="td">
  55. <span v-if="curQue.Isnumber">{{ col.number }}</span>
  56. <div class="content">
  57. <div
  58. style="display: flex"
  59. v-for="(item, i) in col.list"
  60. :key="'cont' + i"
  61. >
  62. <div
  63. v-for="(text, txIndex) in item.conList"
  64. :key="'text' + txIndex"
  65. style="display: flex"
  66. >
  67. <div v-if="text != '_'">
  68. {{ text }}
  69. </div>
  70. <span v-else>
  71. {{ text }}
  72. </span>
  73. </div>
  74. <img
  75. v-if="curQue.IsRecord"
  76. src="../../../assets/adult/mini.png"
  77. alt=""
  78. />
  79. </div>
  80. </div>
  81. </div>
  82. <p>
  83. <span @click="edit(col, rowIndex, colIndex)"> 编辑 </span>
  84. </p>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <el-dialog
  90. title="提示"
  91. :visible.sync="dialogVisible"
  92. width="80%"
  93. :before-close="handleClose"
  94. >
  95. <div class="Module" v-if="dialogData">
  96. <div class="adult-book-input-item">
  97. <el-radio-group v-model="dialogData.type">
  98. <el-radio label="英文">英文</el-radio>
  99. <el-radio label="拼音+中文">拼音+中文</el-radio>
  100. </el-radio-group>
  101. </div>
  102. <div class="Modulemain">
  103. <div>
  104. <div class="adult-book-input-item">
  105. <span class="adult-book-lable">内容:</span>
  106. <el-input
  107. class="adult-book-input"
  108. type="textarea"
  109. :autosize="{ minRows: 2 }"
  110. placeholder="请输入内容"
  111. v-model="dialogData.leftCon"
  112. @blur="onBlur(dialogData, 'leftCon')"
  113. @change="changecon(dialogData)"
  114. ></el-input>
  115. </div>
  116. <div
  117. class="adult-book-input-item"
  118. v-if="dialogData.type == '拼音+中文'"
  119. >
  120. <span class="adult-book-lable">拼音:</span>
  121. <el-input
  122. class="adult-book-input"
  123. type="textarea"
  124. :autosize="{ minRows: 2 }"
  125. placeholder="请输入拼音"
  126. v-model="dialogData.leftPinyin"
  127. @blur="onBlur(dialogData, 'leftPinyin')"
  128. ></el-input>
  129. </div>
  130. </div>
  131. <div>
  132. <div class="adult-book-input-item" v-if="curQue.Isnumber">
  133. <span class="adult-book-lable">序号:</span>
  134. <el-input
  135. class="adult-book-input"
  136. type="textarea"
  137. :autosize="{ minRows: 2 }"
  138. placeholder="请输入标题"
  139. v-model="dialogData.number"
  140. @blur="onBlur(dialogData, 'number')"
  141. ></el-input>
  142. </div>
  143. <div v-for="(item, index) in dialogData.list" :key="'h' + index">
  144. <div class="adult-book-input-item">
  145. <span class="adult-book-lable">内容:</span>
  146. <el-input
  147. class="adult-book-input"
  148. type="textarea"
  149. :autosize="{ minRows: 2 }"
  150. placeholder="请输入内容"
  151. v-model="item.con"
  152. @blur="onBlur(item, 'con')"
  153. @change="changecon(item)"
  154. ></el-input>
  155. <img
  156. @click="deleterow(index)"
  157. class="close"
  158. src="../../../assets/adult/del-close.png"
  159. alt=""
  160. />
  161. </div>
  162. <div
  163. class="adult-book-input-item"
  164. v-if="dialogData.type == '拼音+中文'"
  165. >
  166. <span class="adult-book-lable">拼音:</span>
  167. <el-input
  168. class="adult-book-input"
  169. type="textarea"
  170. :autosize="{ minRows: 2 }"
  171. placeholder="请输入拼音"
  172. v-model="item.pinyin"
  173. @blur="onBlur(item, 'pinyin')"
  174. ></el-input>
  175. </div>
  176. <div
  177. class="adult-book-input-item"
  178. v-if="dialogData.type == '拼音+中文'"
  179. >
  180. <span class="adult-book-lable">拼音位置:</span>
  181. <el-radio-group v-model="item.pinyinSite">
  182. <el-radio label="top">上</el-radio>
  183. <el-radio label="bottom">下</el-radio>
  184. <el-radio label="left">左</el-radio>
  185. <el-radio label="right">右</el-radio>
  186. </el-radio-group>
  187. </div>
  188. <div
  189. class="adult-book-input-item"
  190. v-for="(answ, anIndex) in item.answer"
  191. :key="'anw' + anIndex"
  192. >
  193. <span class="adult-book-lable">答案:</span>
  194. <el-input
  195. class="adult-book-input"
  196. type="textarea"
  197. :autosize="{ minRows: 2 }"
  198. placeholder="请输入答案"
  199. v-model="answ.con"
  200. @blur="onBlur(answ, 'con')"
  201. ></el-input>
  202. <img
  203. @click="deleteAnswer(index, anIndex)"
  204. class="close"
  205. src="../../../assets/adult/del-close.png"
  206. alt=""
  207. />
  208. </div>
  209. <div class="addoption" @click="addAnswer(index)">增加答案</div>
  210. </div>
  211. <div class="addoption" @click="addrowCol">增加</div>
  212. </div>
  213. </div>
  214. </div>
  215. <span slot="footer" class="dialog-footer">
  216. <el-button @click="handleClose">取 消</el-button>
  217. <el-button type="primary" @click="save">确 定</el-button>
  218. </span>
  219. </el-dialog>
  220. </div>
  221. </template>
  222. <script>
  223. import Upload from "../common/Upload";
  224. import SentenceSegwordChs from "../common/SentenceSegwordChs/index.vue";
  225. export default {
  226. name: "PurePreview",
  227. props: ["curQue", "fn_data", "changeCurQue", "type"],
  228. components: {
  229. SentenceSegwordChs,
  230. Upload,
  231. },
  232. data() {
  233. return {
  234. checkList: [],
  235. mp3Number: 1,
  236. form: {
  237. stem: {
  238. con: "",
  239. pinyin: "",
  240. english: "",
  241. highlight: "",
  242. underline: "",
  243. img_url: [],
  244. mp3_url: [],
  245. },
  246. },
  247. data_structure: {
  248. type: "zi_transverse_line_chs",
  249. name: "字+横线",
  250. title: "",
  251. arrangeWay: "单列", //排列方式
  252. Isnumber: false, //需不需要 序号
  253. IsRecord: false, //需不需要录音
  254. option: [
  255. [
  256. {
  257. type: "英文", //英文还是拼音+中文
  258. number: "",
  259. list: [
  260. {
  261. leftCon: "",
  262. leftPinyin: "",
  263. con: "",
  264. pinyin: "",
  265. pinyinSite: "", //拼音的位置
  266. answer: [
  267. {
  268. con: "",
  269. },
  270. ],
  271. },
  272. ],
  273. },
  274. ],
  275. ],
  276. numberList: {
  277. type: "number",
  278. name: "每行几个",
  279. con: "2",
  280. arr: [
  281. {
  282. id: 1,
  283. value: 1,
  284. },
  285. {
  286. id: 2,
  287. value: 2,
  288. },
  289. {
  290. id: 3,
  291. value: 3,
  292. },
  293. {
  294. id: 4,
  295. value: 4,
  296. },
  297. ],
  298. },
  299. },
  300. dialogVisible: false,
  301. dialogData: null,
  302. rowIndex: null,
  303. colIndex: null,
  304. };
  305. },
  306. computed: {},
  307. watch: {},
  308. //方法集合
  309. methods: {
  310. changecon(value) {
  311. value.conList = value.con.split("");
  312. },
  313. // 增加答案
  314. addAnswer(index) {
  315. let obj = JSON.stringify(this.data_structure.option[0][0].list[0].answer);
  316. this.dialogData.list[index].answer.push(obj);
  317. },
  318. // 删除答案
  319. deleteAnswer(index, anindex) {
  320. if (this.dialogData.list[index].answer.length <= 1) {
  321. this.$message.warning("至少要存在一个答案");
  322. return;
  323. }
  324. this.dialogData.list[index].answer.splice(anindex, 1);
  325. },
  326. // 删除某一个的行
  327. deleterow(index) {
  328. if (this.dialogData.list.length <= 1) {
  329. this.$message.warning("至少要存在一个");
  330. return;
  331. }
  332. this.dialogData.list.splice(index, 1);
  333. },
  334. // 增加某一个的行数
  335. addrowCol() {
  336. let obj = JSON.parse(
  337. JSON.stringify(this.data_structure.option[0][0].list[0])
  338. );
  339. this.dialogData.list.push(obj);
  340. },
  341. // 保存
  342. save() {
  343. this.curQue.option[this.rowIndex][this.colIndex] = JSON.parse(
  344. JSON.stringify(this.dialogData)
  345. );
  346. this.rowIndex = null;
  347. this.colIndex = null;
  348. },
  349. // 编辑某一个
  350. edit(item, rindex, cindex) {
  351. console.log(item);
  352. this.dialogData = JSON.parse(JSON.stringify(item));
  353. this.dialogVisible = true;
  354. // 记录索引
  355. this.rowIndex = rindex;
  356. this.colIndex = cindex;
  357. },
  358. // 关闭弹窗
  359. handleClose() {
  360. this.dialogVisible = false;
  361. this.dialogData = null;
  362. this.rowIndex = null;
  363. this.colIndex = null;
  364. },
  365. // 修改排列方式
  366. changearrangeWay(value) {
  367. let obj = this.data_structure.option[0][0];
  368. if (value == "双列") {
  369. this.curQue.option.forEach((row) => {
  370. if (row.length > 1) {
  371. row.splice(2, row.length - 1);
  372. } else {
  373. row.push(obj);
  374. }
  375. });
  376. } else if (value == "四列") {
  377. this.curQue.option.forEach((row) => {
  378. if (row.length >= 2) {
  379. for (let i = 0; i < 2; i++) {
  380. row.push(obj);
  381. }
  382. } else {
  383. for (let i = 0; i < 3; i++) {
  384. row.push(obj);
  385. }
  386. }
  387. });
  388. } else if (value == "单列") {
  389. this.curQue.option.forEach((row) => {
  390. row.splice(1, row.length - 1);
  391. });
  392. }
  393. },
  394. onBlur(item, field) {
  395. item[field] = item[field] ? item[field].trim() : "";
  396. },
  397. // 增加拼音
  398. addpinyin(index) {
  399. let obj;
  400. obj = JSON.parse(
  401. JSON.stringify(this.data_structure.option[0].pinyinList[0])
  402. );
  403. this.curQue.option[index].pinyinList.push(obj);
  404. },
  405. // 删除拼音
  406. deletepinyin(aindex, index) {
  407. if (this.type == "zi_transverse_line_chs") {
  408. if (this.curQue.option[index].pinyinList.length <= 1) {
  409. this.$message.warning("至少要保留1个拼音");
  410. return;
  411. }
  412. this.curQue.option[index].pinyinList.splice(aindex, 1);
  413. }
  414. },
  415. // 增加答案
  416. addanswer(index) {
  417. let obj;
  418. if (this.type == "zi_transverse_line_chs") {
  419. obj = JSON.parse(
  420. JSON.stringify(this.data_structure.option[0].answer[0])
  421. );
  422. this.curQue.option[index].answer.push(obj);
  423. }
  424. },
  425. // 删除答案
  426. deleteanswer(aindex, index) {
  427. if (this.curQue.option[index].answer.length <= 1) {
  428. this.$message.warning("至少要保留1个答案");
  429. return;
  430. }
  431. this.curQue.option[index].answer.splice(aindex, 1);
  432. },
  433. // 删除其中一个选项
  434. deleteOptionOne(index) {
  435. if (this.curQue.option.length <= 1) {
  436. this.$message.warning("至少要保留1个选项");
  437. return;
  438. }
  439. this.curQue.option.splice(index, 1);
  440. },
  441. // 新增选项
  442. addOption() {
  443. let obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
  444. this.curQue.option.push(obj);
  445. },
  446. initcurQue() {
  447. let data = JSON.parse(JSON.stringify(this.data_structure));
  448. this.changeCurQue(data);
  449. },
  450. // 选项的音频
  451. changeMp3(fileList, item, index) {
  452. const articleImgList = JSON.parse(JSON.stringify(fileList));
  453. const articleImgRes = [];
  454. articleImgList.forEach((item) => {
  455. if (item.response) {
  456. const obj = {
  457. name: item.name,
  458. url: item.response.file_info_list[0].file_url,
  459. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  460. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  461. };
  462. articleImgRes.push(obj);
  463. }
  464. });
  465. this.curQue.option[index].mp3_list = JSON.parse(
  466. JSON.stringify(articleImgRes)
  467. );
  468. },
  469. // 题目的音频
  470. timuchangeMp3(fileList) {
  471. const articleImgList = JSON.parse(JSON.stringify(fileList));
  472. const articleImgRes = [];
  473. articleImgList.forEach((item) => {
  474. if (item.response) {
  475. const obj = {
  476. name: item.name,
  477. url: item.response.file_info_list[0].file_url,
  478. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  479. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  480. };
  481. articleImgRes.push(obj);
  482. }
  483. });
  484. this.curQue.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  485. },
  486. },
  487. //生命周期 - 创建完成(可以访问当前this实例)
  488. created() {
  489. if (!this.curQue) {
  490. this.initcurQue();
  491. }
  492. },
  493. //生命周期 - 挂载完成(可以访问DOM元素)
  494. mounted() {},
  495. beforeCreate() {}, //生命周期 - 创建之前
  496. beforeMount() {}, //生命周期 - 挂载之前
  497. beforeUpdate() {}, //生命周期 - 更新之前
  498. updated() {}, //生命周期 - 更新之后
  499. beforeDestroy() {}, //生命周期 - 销毁之前
  500. destroyed() {}, //生命周期 - 销毁完成
  501. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  502. };
  503. </script>
  504. <style lang='scss' scope>
  505. //@import url(); 引入公共css类
  506. .Big-Book-PurePreview {
  507. &-content {
  508. &.m {
  509. display: flex;
  510. justify-content: flex-start;
  511. align-items: flex-start;
  512. }
  513. .Big-Book-title {
  514. font-size: 16px;
  515. line-height: 40px;
  516. color: #000;
  517. margin-right: 15px;
  518. }
  519. .Big-Book-main {
  520. > div {
  521. margin-bottom: 10px;
  522. &.Big-Book-pinyin {
  523. display: flex;
  524. justify-content: flex-start;
  525. align-items: center;
  526. }
  527. }
  528. }
  529. }
  530. .addoption {
  531. width: 200px;
  532. height: 40px;
  533. background: #f3f3f3;
  534. border: 1px dashed rgba(0, 0, 0, 0.15);
  535. box-sizing: border-box;
  536. border-radius: 4px;
  537. text-align: center;
  538. line-height: 40px;
  539. cursor: pointer;
  540. margin-bottom: 15px;
  541. }
  542. .Big-Book-addrole {
  543. > div {
  544. width: 300px;
  545. height: 40px;
  546. background: #f3f3f3;
  547. border: 1px dashed rgba(0, 0, 0, 0.15);
  548. box-sizing: border-box;
  549. border-radius: 4px;
  550. text-align: center;
  551. line-height: 40px;
  552. cursor: pointer;
  553. }
  554. }
  555. .Big-Book-more {
  556. .Big-Book-more-text {
  557. position: relative;
  558. text-align: center;
  559. }
  560. .Big-Book-more-text:before,
  561. .Big-Book-more-text:after {
  562. position: absolute;
  563. background: #ccc;
  564. content: "";
  565. height: 1px;
  566. top: 50%;
  567. width: 45%;
  568. }
  569. .Big-Book-more-text:before {
  570. left: 10px;
  571. }
  572. .Big-Book-more-text:after {
  573. right: 10px;
  574. }
  575. .Big-Book-more-main {
  576. display: flex;
  577. > :not(:nth-child(1)) {
  578. margin-left: 30px;
  579. }
  580. }
  581. }
  582. .Big-Book-con {
  583. display: flex;
  584. align-items: center;
  585. }
  586. .close {
  587. width: 24px;
  588. cursor: pointer;
  589. }
  590. .xorl {
  591. display: flex;
  592. align-items: center;
  593. margin-top: 5px;
  594. > :nth-child(1) {
  595. margin-right: 33px;
  596. }
  597. }
  598. .main {
  599. width: 780px;
  600. min-height: 251px;
  601. background: #f2f2f2;
  602. border: 1px solid rgba(0, 0, 0, 0.1);
  603. box-sizing: border-box;
  604. border-radius: 8px;
  605. padding: 24px 20px;
  606. .row {
  607. display: flex;
  608. .col {
  609. width: 732px;
  610. margin: 0 4px;
  611. .td {
  612. width: 100%;
  613. background: #ffffff;
  614. border: 1px solid rgba(0, 0, 0, 0.1);
  615. box-sizing: border-box;
  616. border-radius: 8px;
  617. min-height: 48px;
  618. display: flex;
  619. align-items: center;
  620. padding: 8px 12px;
  621. > div {
  622. margin: 0 8px;
  623. flex: 1;
  624. > :nth-child(1) {
  625. margin-bottom: 8px;
  626. }
  627. }
  628. > span {
  629. display: inline-block;
  630. width: 16px;
  631. height: 16px;
  632. color: white;
  633. background: #de4444;
  634. border-radius: 50%;
  635. text-align: center;
  636. font-size: 12px;
  637. line-height: 16px;
  638. }
  639. }
  640. > p {
  641. width: 100%;
  642. text-align: center;
  643. span {
  644. cursor: pointer;
  645. }
  646. }
  647. }
  648. }
  649. }
  650. .Module {
  651. .Modulemain {
  652. display: flex;
  653. }
  654. }
  655. }
  656. </style>
  657. <style lang="scss">
  658. </style>