printNew.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. <template>
  2. <div class="none_writeTable writeTable printTable" v-if="dataConfig">
  3. <div class="none_word_main_table" v-for="(data, indexT) in dataConfig" :key="indexT">
  4. <div class="writeTop" :class="[data.left.fileList ? 'writeTop-nopadding' : '']">
  5. <div
  6. class="left left-preview"
  7. :class="[data.left.fileList.length === 0 ? 'left-big' : '']"
  8. :style="{ borderColor: data.borderColor }"
  9. >
  10. <div class="header-info-preview">
  11. <h5 :style="{ textAlign: data.fontAlign }">{{ data.headerCon }}</h5>
  12. <label :style="{ background: data.borderColor }">{{ data.label }}</label>
  13. </div>
  14. <div class="item-image" v-if="data.left.fileList.length > 0">
  15. <el-image
  16. style="width: 568px; height: 294px"
  17. :src="data.left.fileList[0].fileUrl"
  18. :preview-src-list="[data.left.fileList[0].fileUrl]"
  19. fit="contain"
  20. />
  21. </div>
  22. <h2 :class="['con-preview', data.left.fileList.length === 0 ? 'con-preview-big' : '']">
  23. {{ data.left.con }}
  24. </h2>
  25. </div>
  26. <div class="right right-preview left-preview" :style="{ borderColor: data.borderColor }">
  27. <div
  28. :style="{
  29. display: 'flex',
  30. justifyContent: !(data.right.collocation && data.right.exampleSent) ? 'center' : 'auto',
  31. }"
  32. >
  33. <div style="width: max-content">
  34. <AudioPlay
  35. :file-id="data.right.audio_file"
  36. v-if="data.right.audio_file"
  37. :style="{ background: data.borderColor }"
  38. />
  39. <div class="hz-box">
  40. <div class="hz-item" v-for="(itemh, indexh) in data.right.hz_info" :key="indexh">
  41. <p :style="{ color: data.borderColor }">
  42. {{ data.right.pinyin.split(' ')[indexh] ? data.right.pinyin.split(' ')[indexh] : '' }}
  43. </p>
  44. <Strockplay
  45. className="adult-strockplay"
  46. :Book_text="itemh.con"
  47. :playStorkes="true"
  48. :strokePlayColor="data.borderColor"
  49. :strokeColor="'#000000'"
  50. :palyWidth="'18px'"
  51. :BoxbgType="'0'"
  52. :curItem="itemh.hzDetail.hz_json"
  53. :targetDiv="'writeTops-item-' + '-' + indexh + '-' + itemh.con"
  54. :class="[indexh !== 0 ? 'writeTop-item-noLeft' : '']"
  55. class="writeTop-item"
  56. :style="{ borderColor: data.borderColor }"
  57. />
  58. </div>
  59. </div>
  60. </div>
  61. <div
  62. class="definition-box"
  63. v-if="data.right.collocation || data.right.exampleSent"
  64. style="flex: 1; margin: 100px 0 0 16px"
  65. >
  66. <div v-if="data.right.cixing">
  67. <label class="card-label">词性:</label>
  68. <p>{{ data.right.cixing }}</p>
  69. </div>
  70. <div v-if="data.right.definition">
  71. <label class="card-label">释义:</label>
  72. <p>{{ data.right.definition }}</p>
  73. </div>
  74. </div>
  75. </div>
  76. <div
  77. class="definition-box"
  78. :style="{
  79. width: !(data.right.collocation && data.right.exampleSent) ? data.right.hz_info.length * 98 + 'px' : '',
  80. margin: !(data.right.collocation && data.right.exampleSent) ? '16px auto 0 auto' : '',
  81. }"
  82. >
  83. <template v-if="!(data.right.collocation && data.right.exampleSent)">
  84. <div v-if="data.right.cixing">
  85. <label class="card-label">词性:</label>
  86. <p>{{ data.right.cixing }}</p>
  87. </div>
  88. <div v-if="data.right.definition">
  89. <label class="card-label">释义:</label>
  90. <p>{{ data.right.definition }}</p>
  91. </div>
  92. </template>
  93. <div v-if="data.right.collocation">
  94. <label class="card-label">搭配:</label>
  95. <p>{{ data.right.collocation }}</p>
  96. </div>
  97. <div v-if="data.right.exampleSent">
  98. <label class="card-label">例句:</label>
  99. <p>{{ data.right.exampleSent }}</p>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. <!-- <div class="writeBottom">
  105. <span>BLCUP 全球国际中文教学云平台</span>
  106. <b>{{ indexT + 1 + '/' + dataConfig.result.length }}</b>
  107. <a>www.chinesedu.com</a>
  108. </div> -->
  109. </div>
  110. </div>
  111. </template>
  112. <script>
  113. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  114. import StrockplayredlineTable from '../../components/corpus/StrockplayredlineTable.vue';
  115. import Strockplay from '../../components/corpus/Strockplay.vue';
  116. import Strockred from '../../components/corpus/Strockred.vue';
  117. import FreewriteLettle from '../../components/corpus/FreewriteLettle.vue';
  118. import UploadDrag from './UploadDrag.vue';
  119. import AudioPlay from './AudioPlay.vue';
  120. const HanziWriter = require('hanzi-writer');
  121. import { getLogin } from '@/api/api';
  122. export default {
  123. //import引入的组件需要注入到对象中才能使用
  124. components: {
  125. StrockplayredlineTable,
  126. Strockplay,
  127. Strockred,
  128. FreewriteLettle,
  129. UploadDrag,
  130. AudioPlay,
  131. },
  132. //props: ["dataConfig", "data", "indexT", "totalNumber", "type", "none"],
  133. data() {
  134. //这里存放数据
  135. return {
  136. ifFreeShow: false,
  137. activeIndex: null,
  138. activeColIndex: null,
  139. dataConfig: null,
  140. loading: false,
  141. userID: this.$route.query.userID ? this.$route.query.userID : '',
  142. id: this.$route.query.id ? this.$route.query.id : '',
  143. };
  144. },
  145. //计算属性 类似于data概念
  146. computed: {},
  147. //监控data中数据变化
  148. watch: {},
  149. //方法集合
  150. methods: {
  151. download2() {
  152. document.getElementsByClassName('printTable')[0].style.zoom = 2;
  153. //执行window.print打印功能
  154. window.print();
  155. this.$message({
  156. message: '操作成功',
  157. type: 'success',
  158. });
  159. this.$router.replace({
  160. path: '/wordcard/cread',
  161. query: { cachesType: 'push', userID: this.userID, id: this.id },
  162. });
  163. return false;
  164. },
  165. changePraShow() {
  166. this.ifFreeShow = false;
  167. },
  168. closeifFreeShow(data, rowIndex, colIndex) {
  169. this.ifFreeShow = false;
  170. this.$forceUpdate();
  171. },
  172. freeWrite(item, row, col) {
  173. this.ifFreeShow = true;
  174. this.activeIndex = row;
  175. this.activeColIndex = col;
  176. // this.currentHz = this.curQue.option[indexs].rightOption[rightindex].con;
  177. if (item) {
  178. this.currenHzData = item;
  179. } else {
  180. this.currenHzData = {};
  181. }
  182. },
  183. ExerciseChangeCurQue(answer, rowIndex, colIndex) {
  184. if (answer) {
  185. this.data[rowIndex][colIndex].strokes_image_url = answer.strokes_image_url;
  186. this.data[rowIndex][colIndex].history = answer.history;
  187. this.$forceUpdate();
  188. }
  189. },
  190. changeFillId(file, fileList) {
  191. let obj = {
  192. name: file.name,
  193. fileId: file.file_id,
  194. fileUrl: file.file_url_open,
  195. };
  196. this.data.fileList.push(obj);
  197. },
  198. handleDeleteImg() {
  199. this.data.fileList = [];
  200. },
  201. initHanziwrite() {
  202. let _this = this;
  203. this.dataConfig.result.forEach((item, pageNumber) => {
  204. if (item.hz_info && item.hz_info.length === 1) {
  205. let node = document.getElementById(`character-target-info-div` + pageNumber);
  206. if (node && node.children.length > 1) {
  207. node.removeChild(node.children[1]);
  208. }
  209. //var ren = require("hanzi-writer-data/国");
  210. _this.writer = HanziWriter.default.create(`character-target-info-div` + pageNumber, item.hz_info[0].con, {
  211. width: 22,
  212. height: 22,
  213. padding: 0,
  214. radicalColor: '#000000',
  215. strokeColor: '#fff',
  216. });
  217. }
  218. });
  219. },
  220. },
  221. //生命周期 - 创建完成(可以访问当前this实例)
  222. created() {},
  223. //生命周期 - 挂载完成(可以访问DOM元素)
  224. mounted() {
  225. let _this = this;
  226. let writeTableData = localStorage.getItem('newEditTable');
  227. if (writeTableData) {
  228. _this.dataConfig = JSON.parse(writeTableData);
  229. if (_this.dataConfig) {
  230. _this.dataConfig.forEach((item) => {
  231. if (item.left.con.trim()) {
  232. let MethodName = 'tool-TextToVoiceFile';
  233. let datas = {
  234. text: item.left.con.trim(),
  235. };
  236. getLogin(MethodName, datas)
  237. .then((res) => {
  238. if (res.status === 1) {
  239. item.right.audio_file = res.file_id;
  240. }
  241. })
  242. .catch(() => {});
  243. }
  244. });
  245. // _this.$nextTick(() => {
  246. // _this.initHanziwrite();
  247. // });
  248. }
  249. setTimeout(() => {
  250. _this.download2();
  251. }, 2000);
  252. }
  253. },
  254. //生命周期-创建之前
  255. beforeCreated() {},
  256. //生命周期-挂载之前
  257. beforeMount() {},
  258. //生命周期-更新之前
  259. beforUpdate() {},
  260. //生命周期-更新之后
  261. updated() {},
  262. //生命周期-销毁之前
  263. beforeDestory() {},
  264. //生命周期-销毁完成
  265. destoryed() {},
  266. //如果页面有keep-alive缓存功能,这个函数会触发
  267. activated() {},
  268. };
  269. </script>
  270. <style lang="scss" scoped>
  271. .none_writeTable {
  272. width: 540px;
  273. display: flex;
  274. justify-content: center;
  275. align-items: flex-start;
  276. flex-wrap: wrap;
  277. padding-top: 10px;
  278. .writeTop {
  279. padding-top: 0;
  280. }
  281. }
  282. .header-info-preview {
  283. position: absolute;
  284. width: 100%;
  285. left: 0;
  286. top: 0;
  287. z-index: 1;
  288. padding: 0 16px;
  289. box-sizing: border-box;
  290. h5 {
  291. color: #000;
  292. font-size: 24px;
  293. font-weight: 400;
  294. line-height: 32px;
  295. padding: 0 12px;
  296. }
  297. label {
  298. position: absolute;
  299. right: 20px;
  300. top: -4px;
  301. border-radius: 0px 8px;
  302. background: #fff;
  303. padding: 0px 16px 0px 8px;
  304. color: #fff;
  305. font-size: 24px;
  306. font-weight: 500;
  307. line-height: 150%;
  308. }
  309. }
  310. .writeTable {
  311. background: #ffffff;
  312. box-sizing: border-box;
  313. .writeTop {
  314. height: 783px;
  315. .writeTop-row {
  316. display: flex;
  317. justify-content: center;
  318. .writeTop-item {
  319. border: 1px solid #de4444;
  320. &.writeTop-item-noLeft {
  321. border-left: none;
  322. }
  323. }
  324. }
  325. }
  326. .writeTop {
  327. height: auto;
  328. .left,
  329. .right {
  330. width: 600px;
  331. height: 450px;
  332. padding: 8px 12px 18px 12px;
  333. border-radius: 24px;
  334. background: #fff;
  335. box-sizing: border-box;
  336. position: relative;
  337. overflow: hidden;
  338. .header-info {
  339. display: flex;
  340. width: 100%;
  341. justify-content: space-between;
  342. margin-bottom: 12px;
  343. :deep .el-input__inner {
  344. color: rgba(0, 0, 0, 1);
  345. font-size: 24px;
  346. font-weight: 400;
  347. line-height: 100%;
  348. height: 24px;
  349. border: none;
  350. padding: 0;
  351. }
  352. .label {
  353. :deep .el-input__inner {
  354. text-align: right;
  355. }
  356. }
  357. }
  358. }
  359. .left-preview {
  360. padding-top: 40px;
  361. padding-bottom: 32px;
  362. }
  363. .left-big {
  364. display: flex;
  365. align-items: center;
  366. justify-content: center;
  367. }
  368. .del-btn {
  369. cursor: pointer;
  370. border-radius: 8px;
  371. background: #f56767;
  372. padding: 8px;
  373. position: absolute;
  374. right: 24px;
  375. bottom: 24px;
  376. color: #fff;
  377. }
  378. .overturn-btn {
  379. position: absolute;
  380. right: 24px;
  381. bottom: 24px;
  382. border-radius: 8px;
  383. background: #e0e0e0;
  384. padding: 8px;
  385. width: 24px;
  386. height: 24px;
  387. color: #fff;
  388. font-size: 24px;
  389. line-height: 1;
  390. cursor: pointer;
  391. }
  392. .right {
  393. display: flex;
  394. align-items: center;
  395. flex-flow: wrap;
  396. padding: 120px 86px;
  397. row-gap: 8px;
  398. label {
  399. width: 100%;
  400. color: #4e5969;
  401. font-size: 14px;
  402. font-weight: 400;
  403. line-height: 22px;
  404. height: 22px;
  405. }
  406. :deep .el-textarea {
  407. height: 140px;
  408. }
  409. }
  410. .right-preview {
  411. padding: 36px 72px;
  412. display: block;
  413. .hz-box {
  414. justify-content: center;
  415. width: 100%;
  416. .hz-item {
  417. text-align: center;
  418. :deep .strockplayInner {
  419. width: 98px;
  420. height: 98px;
  421. }
  422. p {
  423. color: #de4444;
  424. font-feature-settings: 'cv01' on;
  425. font-family: League;
  426. font-size: 20px;
  427. line-height: 120%;
  428. margin-bottom: 8px;
  429. }
  430. }
  431. }
  432. :deep .audio-wrapper {
  433. margin: 0 auto 8px auto;
  434. border-radius: 40px;
  435. background: #f3f3f3;
  436. padding: 16px;
  437. width: 56px;
  438. height: 56px;
  439. box-sizing: border-box;
  440. cursor: pointer;
  441. .voice-play {
  442. width: 24px;
  443. height: 24px;
  444. }
  445. }
  446. .definition-box {
  447. white-space: pre;
  448. > div {
  449. display: flex;
  450. margin-bottom: 16px;
  451. label,
  452. p {
  453. width: 40px;
  454. color: #000;
  455. font-size: 24px;
  456. font-weight: 400;
  457. line-height: 150%;
  458. }
  459. label {
  460. width: 68px;
  461. }
  462. }
  463. }
  464. }
  465. .right-preview-rota {
  466. transform: rotateY(-180deg);
  467. }
  468. .item-image {
  469. position: relative;
  470. // background: #f2f3f5;
  471. border-radius: 8px;
  472. overflow: hidden;
  473. .item-image-del {
  474. position: absolute;
  475. top: 8px;
  476. right: 8px;
  477. width: 16px;
  478. height: 16px;
  479. display: block;
  480. cursor: pointer;
  481. background-color: #ffffff;
  482. color: #ee3232;
  483. padding: 8px;
  484. border-radius: 50%;
  485. box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
  486. }
  487. }
  488. .item-con {
  489. width: 100%;
  490. display: flex;
  491. align-items: center;
  492. margin-top: 8px;
  493. label {
  494. color: #4e5969;
  495. font-size: 14px;
  496. font-weight: 400;
  497. line-height: 22px;
  498. width: 44px;
  499. }
  500. :deep .el-input__inner {
  501. border-radius: 2px;
  502. background: #f2f3f5;
  503. width: 235px;
  504. border: none;
  505. font-size: 14px;
  506. font-weight: 400;
  507. line-height: 22px;
  508. height: 32px;
  509. font-family: FZJCGFKTK;
  510. }
  511. .pinyin {
  512. :deep .el-input__inner {
  513. font-family: League;
  514. }
  515. }
  516. }
  517. .con-preview {
  518. margin-top: 16px;
  519. color: #000;
  520. text-align: center;
  521. font-family: 'FZJCGFKTK';
  522. font-size: 64px;
  523. font-weight: 400;
  524. line-height: 100%;
  525. &-big {
  526. font-size: 96px;
  527. margin-top: 0;
  528. }
  529. }
  530. .writeTop-row {
  531. display: flex;
  532. justify-content: center;
  533. }
  534. }
  535. .item-info {
  536. display: flex;
  537. width: 100%;
  538. padding: 0 46px 8px 46px;
  539. column-gap: 16px;
  540. box-sizing: border-box;
  541. &-left {
  542. .writeTop-item {
  543. width: 98px;
  544. height: 98px;
  545. :deep .strock-play-box {
  546. width: 18px !important;
  547. height: 18px !important;
  548. }
  549. :deep .playStorkes-btn {
  550. width: 18px !important;
  551. height: 18px !important;
  552. }
  553. &-small {
  554. width: 62px;
  555. height: 62px;
  556. :deep .strock-play-box {
  557. width: 11px !important;
  558. height: 11px !important;
  559. }
  560. :deep .playStorkes-btn {
  561. width: 11px !important;
  562. height: 11px !important;
  563. }
  564. }
  565. }
  566. &-long {
  567. width: 100%;
  568. }
  569. }
  570. &-right {
  571. flex: 1;
  572. }
  573. :deep .el-textarea__inner {
  574. resize: none;
  575. background-color: #f3f3f3;
  576. border: none;
  577. outline: none;
  578. }
  579. .voice-box {
  580. width: 100%;
  581. height: 32px;
  582. display: flex;
  583. align-items: center;
  584. justify-content: center;
  585. column-gap: 4px;
  586. img {
  587. width: 24px;
  588. height: 24px;
  589. }
  590. span {
  591. font-family: League;
  592. font-size: 16px;
  593. font-weight: 400;
  594. color: #de4444;
  595. }
  596. }
  597. .item-info-row {
  598. display: flex;
  599. column-gap: 11px;
  600. margin-bottom: 6px;
  601. :deep .el-input__inner {
  602. background-color: #f3f3f3;
  603. border: none;
  604. outline: none;
  605. height: 32px;
  606. }
  607. }
  608. .item-info-half,
  609. .item-info-all {
  610. width: 50%;
  611. display: flex;
  612. font-size: 14px;
  613. line-height: 22px;
  614. height: 22px;
  615. }
  616. .item-info-all {
  617. width: 100%;
  618. }
  619. }
  620. .hz-box {
  621. display: flex;
  622. width: max-content;
  623. }
  624. .writeTop-item {
  625. border: 1px solid #de4444;
  626. }
  627. .writeTop-item-noLeft {
  628. border-left: none;
  629. }
  630. .tian-div {
  631. width: 100%;
  632. height: 100%;
  633. position: relative;
  634. .tian {
  635. width: 100%;
  636. height: 100%;
  637. }
  638. img {
  639. width: 100%;
  640. height: 100%;
  641. position: absolute;
  642. left: 0;
  643. top: 0;
  644. }
  645. }
  646. .flipped {
  647. transform: rotateY(180deg);
  648. }
  649. .flipped-back {
  650. transform: rotateY(0deg);
  651. }
  652. }
  653. .item-info {
  654. display: flex;
  655. width: 100%;
  656. padding: 16px 46px;
  657. column-gap: 16px;
  658. box-sizing: border-box;
  659. &-left {
  660. .writeTop-item {
  661. width: 98px;
  662. height: 98px;
  663. :deep .strock-play-box {
  664. width: 18px !important;
  665. height: 18px !important;
  666. }
  667. :deep .playStorkes-btn {
  668. width: 18px !important;
  669. height: 18px !important;
  670. }
  671. &-small {
  672. width: 62px;
  673. height: 62px;
  674. :deep .strock-play-box {
  675. width: 11px !important;
  676. height: 11px !important;
  677. }
  678. :deep .playStorkes-btn {
  679. width: 11px !important;
  680. height: 11px !important;
  681. }
  682. }
  683. }
  684. &-long {
  685. width: 100%;
  686. }
  687. }
  688. &-right {
  689. flex: 1;
  690. }
  691. :deep .el-textarea__inner {
  692. resize: none;
  693. background-color: #f3f3f3;
  694. border: none;
  695. outline: none;
  696. }
  697. .voice-box {
  698. width: 100%;
  699. height: 32px;
  700. display: flex;
  701. align-items: center;
  702. justify-content: center;
  703. column-gap: 4px;
  704. img {
  705. width: 24px;
  706. height: 24px;
  707. }
  708. span {
  709. font-family: League;
  710. font-size: 16px;
  711. font-weight: 400;
  712. color: #de4444;
  713. }
  714. }
  715. .item-info-row {
  716. display: flex;
  717. column-gap: 11px;
  718. margin-bottom: 6px;
  719. :deep .el-input__inner {
  720. background-color: #f3f3f3;
  721. border: none;
  722. outline: none;
  723. height: 32px;
  724. }
  725. }
  726. .item-info-half,
  727. .item-info-all {
  728. width: 50%;
  729. display: flex;
  730. font-size: 14px;
  731. line-height: 22px;
  732. height: 22px;
  733. }
  734. .item-info-all {
  735. width: 100%;
  736. }
  737. }
  738. .hz-box {
  739. display: flex;
  740. width: max-content;
  741. }
  742. .writeTop-item {
  743. border: 1px solid #de4444;
  744. }
  745. .punctuation-box {
  746. position: relative;
  747. width: 100%;
  748. height: 100%;
  749. .character-target-div {
  750. position: absolute;
  751. width: 100%;
  752. height: 100%;
  753. top: 0;
  754. left: 0;
  755. .svg-icon {
  756. width: 100%;
  757. height: 100%;
  758. }
  759. }
  760. h3 {
  761. position: absolute;
  762. width: 100%;
  763. height: 100%;
  764. top: 0;
  765. left: 0;
  766. font-family: FZJCGFKTK;
  767. text-align: center;
  768. font-weight: normal;
  769. }
  770. }
  771. </style>