SentenceTemp.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <!-- -->
  2. <template>
  3. <div
  4. :class="[
  5. 'sentence-temp',
  6. sentenceTempOption,
  7. sentType == 'option' ? 'sentence-temp-option' : ''
  8. ]"
  9. v-if="detail"
  10. >
  11. <template v-if="detail.wordsList && detail.wordsList.length > 0">
  12. <div
  13. :class="[
  14. 'RLC-sentence',
  15. sentType == 'option' ? 'RLC-sentence-option' : '',
  16. detail.pyNumber && detail.pyNumber[index] > 0
  17. ? 'RLC-sentence-hasPY'
  18. : ''
  19. ]"
  20. v-for="(item, index) in detail.wordsList"
  21. :key="'wordsList' + index"
  22. >
  23. <div
  24. class="RLC-words"
  25. v-for="(pItem, pIndex) in item"
  26. :key="'wordsList' + pIndex"
  27. :class="[
  28. pItem.chs == '“' ? 'textRight' : 'textCenter',
  29. detail.pyNumber && detail.pyNumber[index] > 0
  30. ? 'RLC-words-hasPY'
  31. : ''
  32. ]"
  33. :style="{
  34. paddingLeft:
  35. pItem.wordPadding.indexOf('left') > -1 ||
  36. (detail.pyNumber && detail.pyNumber[index] > 0)
  37. ? '2px'
  38. : '0px',
  39. paddingRight:
  40. pItem.wordPadding.indexOf('right') > -1 ||
  41. (detail.pyNumber && detail.pyNumber[index] > 0)
  42. ? '2px'
  43. : '0px'
  44. }"
  45. >
  46. <template v-if="pItem.isShow">
  47. <template
  48. v-if="
  49. item[pIndex + 1] &&
  50. item[pIndex + 1].chs &&
  51. chsFhList.indexOf(item[pIndex + 1].chs) > -1
  52. "
  53. >
  54. <span class="RLC-words-box">
  55. <span
  56. v-if="
  57. detail.pyNumber &&
  58. detail.pyNumber[index] > 0 &&
  59. pyPosition == 'top'
  60. "
  61. class="RLC-pinyin"
  62. :class="[
  63. pyColor == 'black' ? 'RLC-pinyin-black' : '',
  64. pyColor == 'grey' ? 'RLC-pinyin-grey' : '',
  65. pyColor == 'sub' ? 'RLC-pinyin-sub' : '',
  66. pItem.pinyin && noFont.indexOf(pItem.pinyin) > -1
  67. ? 'noFont'
  68. : ''
  69. ]"
  70. :style="{ fontSize: baseSizePhone - 2 + 'px' }"
  71. >{{ pItem.pinyin | handlePY }}</span
  72. >
  73. <template v-if="!pItem.isHeng">
  74. <span
  75. :class="[
  76. 'RLC-chs',
  77. sentType == 'option' ? 'RLC-chs-option' : ''
  78. ]"
  79. :style="{
  80. fontSize: baseSizePhone + 6 + 'px',
  81. color: pItem.fontColor,
  82. fontFamily: pItem.fontFamily
  83. }"
  84. v-html="pItem.chs"
  85. ></span>
  86. </template>
  87. <template v-else>
  88. <template v-if="isInput">
  89. <!-- [optionIndex][optionItemIndex] -->
  90. <EditDiv
  91. :id="
  92. 'sentenceTemp_' +
  93. Math.random()
  94. .toString(36)
  95. .substr(2) +
  96. '_' +
  97. index
  98. "
  99. class="answer-input"
  100. :class="[Isexample ? 'answer-input-example' : '']"
  101. v-model="Bookanswer.completeInput[pItem.hengIndex]"
  102. :canEdit="
  103. TaskModel == 'ANSWER' ? false : Isexample ? false : true
  104. "
  105. :style="{
  106. 'min-width': detail.hengList[index]
  107. ? detail.hengList[index] * 60 + 'px'
  108. : '120px',
  109. textAlign: detail.hengList[index] ? 'center' : 'left',
  110. fontSize: baseSizePhone + 6 + 'px'
  111. }"
  112. />
  113. </template>
  114. <template v-else>
  115. <span
  116. v-if="pItem.chs != '#'"
  117. class="RLC-chs"
  118. :style="{
  119. fontSize: baseSizePhone + 6 + 'px',
  120. color: pItem.fontColor,
  121. fontFamily: pItem.fontFamily
  122. }"
  123. :class="[
  124. pItem.chs != '“' && pItem.padding ? 'padding' : '',
  125. sentType == 'option' ? 'RLC-chs-option' : ''
  126. ]"
  127. v-html="pItem.chs"
  128. ></span>
  129. </template>
  130. </template>
  131. <span
  132. v-if="
  133. detail.pyNumber &&
  134. detail.pyNumber[index] > 0 &&
  135. pyPosition == 'bottom'
  136. "
  137. class="RLC-pinyin"
  138. :class="[
  139. pyColor == 'black' ? 'RLC-pinyin-black' : '',
  140. pyColor == 'grey' ? 'RLC-pinyin-grey' : '',
  141. pyColor == 'sub' ? 'RLC-pinyin-sub' : '',
  142. noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : ''
  143. ]"
  144. :style="{ fontSize: baseSizePhone - 2 + 'px' }"
  145. >{{ pItem.pinyin | handlePY }}</span
  146. >
  147. </span>
  148. <span class="RLC-words-box" v-if="item[pIndex + 1]">
  149. <span
  150. v-if="
  151. detail.pyNumber &&
  152. detail.pyNumber[index] > 0 &&
  153. pyPosition == 'top'
  154. "
  155. class="RLC-pinyin"
  156. :class="[
  157. pyColor == 'black' ? 'RLC-pinyin-black' : '',
  158. pyColor == 'grey' ? 'RLC-pinyin-grey' : '',
  159. pyColor == 'sub' ? 'RLC-pinyin-sub' : '',
  160. noFont.indexOf(item[pIndex + 1].pinyin) > -1 ? 'noFont' : ''
  161. ]"
  162. style="text-align: left"
  163. :style="{ fontSize: baseSizePhone - 2 + 'px' }"
  164. >{{ item[pIndex + 1].pinyin | handlePY }}</span
  165. >
  166. <span
  167. :class="[
  168. 'RLC-chs',
  169. sentType == 'option' ? 'RLC-chs-option' : ''
  170. ]"
  171. :style="{
  172. fontSize: baseSizePhone + 6 + 'px',
  173. color: item[pIndex + 1].fontColor,
  174. fontFamily: item[pIndex + 1].fontFamily
  175. }"
  176. v-html="item[pIndex + 1].chs"
  177. ></span>
  178. <span
  179. v-if="
  180. detail.pyNumber &&
  181. detail.pyNumber[index] > 0 &&
  182. pyPosition == 'bottom'
  183. "
  184. class="RLC-pinyin"
  185. :class="[
  186. pyColor == 'black' ? 'RLC-pinyin-black' : '',
  187. pyColor == 'grey' ? 'RLC-pinyin-grey' : '',
  188. pyColor == 'sub' ? 'RLC-pinyin-sub' : '',
  189. noFont.indexOf(item[pIndex + 1].pinyin) > -1 ? 'noFont' : ''
  190. ]"
  191. style="text-align: left"
  192. :style="{ fontSize: baseSizePhone - 2 + 'px' }"
  193. >{{ item[pIndex + 1].pinyin | handlePY }}</span
  194. >
  195. </span>
  196. <span
  197. class="RLC-words-box"
  198. v-if="
  199. item[pIndex + 2] &&
  200. item[pIndex + 2].chs &&
  201. chsFhList.indexOf(item[pIndex + 2].chs) > -1
  202. "
  203. >
  204. <span
  205. v-if="
  206. detail.pyNumber &&
  207. detail.pyNumber[index] > 0 &&
  208. pyPosition == 'top'
  209. "
  210. :class="[
  211. 'RLC-pinyin',
  212. pyColor == 'black' ? 'RLC-pinyin-black' : '',
  213. pyColor == 'grey' ? 'RLC-pinyin-grey' : '',
  214. pyColor == 'sub' ? 'RLC-pinyin-sub' : '',
  215. noFont.indexOf(item[pIndex + 2].pinyin) > -1 ? 'noFont' : ''
  216. ]"
  217. style="text-align: left"
  218. :style="{ fontSize: baseSizePhone - 2 + 'px' }"
  219. >{{ item[pIndex + 2].pinyin }}</span
  220. >
  221. <span
  222. :class="[
  223. 'RLC-chs',
  224. sentType == 'option' ? 'RLC-chs-option' : ''
  225. ]"
  226. :style="{
  227. fontSize: baseSizePhone + 6 + 'px',
  228. color: item[pIndex + 2].fontColor,
  229. fontFamily: item[pIndex + 2].fontFamily
  230. }"
  231. v-html="item[pIndex + 2].chs"
  232. ></span>
  233. <span
  234. v-if="
  235. detail.pyNumber &&
  236. detail.pyNumber[index] > 0 &&
  237. pyPosition == 'bottom'
  238. "
  239. :class="[
  240. 'RLC-pinyin',
  241. pyColor == 'black' ? 'RLC-pinyin-black' : '',
  242. pyColor == 'grey' ? 'RLC-pinyin-grey' : '',
  243. pyColor == 'sub' ? 'RLC-pinyin-sub' : '',
  244. noFont.indexOf(item[pIndex + 2].pinyin) > -1 ? 'noFont' : ''
  245. ]"
  246. style="text-align: left"
  247. :style="{ fontSize: baseSizePhone - 2 + 'px' }"
  248. >{{ item[pIndex + 2].pinyin }}</span
  249. >
  250. </span>
  251. </template>
  252. <!--下一个元素不是标点-->
  253. <template v-else>
  254. <span
  255. v-if="
  256. detail.pyNumber &&
  257. detail.pyNumber[index] > 0 &&
  258. pyPosition == 'top'
  259. "
  260. class="RLC-pinyin"
  261. :class="[
  262. pItem.chs != '“' && pItem.padding ? 'padding' : '',
  263. pyColor == 'black' ? 'RLC-pinyin-black' : '',
  264. pyColor == 'grey' ? 'RLC-pinyin-grey' : '',
  265. pyColor == 'sub' ? 'RLC-pinyin-sub' : '',
  266. noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : ''
  267. ]"
  268. :style="{ fontSize: baseSizePhone - 2 + 'px' }"
  269. >{{ pItem.pinyin | handlePY }}</span
  270. >
  271. <template v-if="!pItem.isHeng">
  272. <span
  273. v-if="pItem.chs != '#'"
  274. class="RLC-chs"
  275. :style="{
  276. fontSize: baseSizePhone + 6 + 'px',
  277. color: pItem.fontColor,
  278. fontFamily: pItem.fontFamily
  279. }"
  280. :class="[
  281. pItem.chs != '“' && pItem.padding ? 'padding' : '',
  282. sentType == 'option' ? 'RLC-chs-option' : ''
  283. ]"
  284. v-html="pItem.chs"
  285. ></span>
  286. </template>
  287. <template v-else>
  288. <template v-if="isInput">
  289. <!-- [optionIndex][optionItemIndex] -->
  290. <EditDiv
  291. :id="
  292. 'sentenceTemp_' +
  293. Math.random()
  294. .toString(36)
  295. .substr(2) +
  296. '_' +
  297. index
  298. "
  299. class="answer-input"
  300. :class="[Isexample ? 'answer-input-example' : '']"
  301. v-model="Bookanswer.completeInput[pItem.hengIndex]"
  302. :canEdit="
  303. TaskModel == 'ANSWER' ? false : Isexample ? false : true
  304. "
  305. :style="{
  306. 'min-width':
  307. detail.hengList[index] && detail.hengList[index] > -1
  308. ? detail.hengList[index] * 60 + 'px'
  309. : '120px',
  310. textAlign: detail.hengList[index] ? 'center' : 'left',
  311. fontSize: baseSizePhone + 6 + 'px'
  312. }"
  313. />
  314. </template>
  315. <template v-else>
  316. <span
  317. v-if="pItem.chs != '#'"
  318. class="RLC-chs"
  319. :style="{
  320. fontSize: baseSizePhone + 6 + 'px',
  321. color: pItem.fontColor,
  322. textAlign: 'left',
  323. fontFamily: pItem.fontFamily
  324. }"
  325. :class="[
  326. pItem.chs != '“' && pItem.padding ? 'padding' : '',
  327. sentType == 'option' ? 'RLC-chs-option' : ''
  328. ]"
  329. v-html="pItem.chs"
  330. ></span>
  331. </template>
  332. </template>
  333. <span
  334. v-if="
  335. detail.pyNumber &&
  336. detail.pyNumber[index] > 0 &&
  337. pyPosition == 'bottom'
  338. "
  339. class="RLC-pinyin"
  340. :class="[
  341. pItem.chs != '“' && pItem.padding ? 'padding' : '',
  342. pyColor == 'black' ? 'RLC-pinyin-black' : '',
  343. pyColor == 'grey' ? 'RLC-pinyin-grey' : '',
  344. pyColor == 'sub' ? 'RLC-pinyin-sub' : '',
  345. noFont.indexOf(pItem.pinyin) > -1 ? 'noFont' : ''
  346. ]"
  347. :style="{ fontSize: baseSizePhone - 2 + 'px' }"
  348. >{{ pItem.pinyin | handlePY }}</span
  349. >
  350. </template>
  351. </template>
  352. </div>
  353. </div>
  354. </template>
  355. <template v-else-if="detail.sentenceArr && detail.sentenceArr.length > 0">
  356. <div
  357. class="sentence"
  358. v-for="(item, index) in detail.sentenceArr"
  359. :key="'sentenceArr' + index"
  360. v-html="item"
  361. :style="{ fontSize: baseSizePhone + 6 + 'px' }"
  362. ></div>
  363. </template>
  364. <template v-else-if="detail.sentence">
  365. <div
  366. class="sentence"
  367. v-html="detail.sentence"
  368. style="white-space: pre-wrap"
  369. :style="{ fontSize: baseSizePhone + 6 + 'px' }"
  370. ></div>
  371. </template>
  372. </div>
  373. </template>
  374. <script>
  375. import EditDiv from "../EditDiv.vue";
  376. export default {
  377. components: { EditDiv },
  378. props: [
  379. "detail",
  380. "pyPosition",
  381. "pyColor",
  382. "TaskModel",
  383. "Bookanswer",
  384. "isInput",
  385. "Isexample",
  386. "sentType",
  387. "baseSizePhone"
  388. ],
  389. filters: {
  390. handlePY(pinyin) {
  391. let reg = /_{2,}/g;
  392. let py = "";
  393. if (reg.test(pinyin)) {
  394. py = "";
  395. } else {
  396. py = pinyin;
  397. }
  398. return py;
  399. }
  400. },
  401. data() {
  402. return {
  403. noFont: ["~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "/"],
  404. chsFhList: [",", "。", "”", ":", "》", "?", "!", ";"],
  405. enFhList: [",", ".", ";", "?", "!", ":", ">", "<"]
  406. };
  407. },
  408. computed: {
  409. sentenceTempOption() {
  410. let classname = "";
  411. if (this.sentType != "option") {
  412. classname = "sentence-temp-24";
  413. }
  414. return classname;
  415. }
  416. },
  417. watch: {},
  418. //方法集合
  419. methods: {},
  420. //生命周期 - 创建完成(可以访问当前this实例)
  421. created() {},
  422. //生命周期 - 挂载完成(可以访问DOM元素)
  423. mounted() {
  424. // console.log(this.detail);
  425. // console.log(this.Bookanswer);
  426. },
  427. beforeCreate() {}, //生命周期 - 创建之前
  428. beforeMount() {}, //生命周期 - 挂载之前
  429. beforeUpdate() {}, //生命周期 - 更新之前
  430. updated() {}, //生命周期 - 更新之后
  431. beforeDestroy() {}, //生命周期 - 销毁之前
  432. destroyed() {}, //生命周期 - 销毁完成
  433. activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
  434. };
  435. </script>
  436. <style lang="scss" scoped>
  437. //@import url(); 引入公共css类
  438. .sentence-temp {
  439. // padding: 9px 0;
  440. .RLC-sentence {
  441. clear: both;
  442. overflow: hidden;
  443. padding: 7px 0;
  444. &-option {
  445. padding: 8px 0;
  446. }
  447. &-hasPY {
  448. padding: 3px 0;
  449. }
  450. }
  451. .RLC-words {
  452. float: left;
  453. &-box {
  454. float: left;
  455. > span {
  456. display: block;
  457. &.padding {
  458. padding: 0 3px;
  459. }
  460. }
  461. }
  462. &-hasPY {
  463. padding: 4px 0;
  464. }
  465. &.textLeft {
  466. text-align: left;
  467. }
  468. &.textCenter {
  469. text-align: center;
  470. }
  471. &.textRight {
  472. text-align: right;
  473. }
  474. > span {
  475. display: block;
  476. &.padding {
  477. padding: 0 3px;
  478. }
  479. }
  480. .answer-input {
  481. min-height: 32px;
  482. box-sizing: border-box;
  483. border: 0;
  484. border-bottom: 1px rgba(0, 0, 0, 0.45) solid;
  485. background: 0 0;
  486. min-width: 120px;
  487. outline: 0;
  488. text-align: left;
  489. font-family: "FZJCGFKTK";
  490. font-size: 24px;
  491. color: rgba(0, 0, 0, 0.45);
  492. box-sizing: border-box;
  493. color: #000000;
  494. line-height: 30px;
  495. &.answer-input-example {
  496. color: #ff3f3f;
  497. }
  498. }
  499. }
  500. .RLC-pinyin {
  501. font-family: "Sans-GBNPC";
  502. font-weight: normal;
  503. font-size: 12px;
  504. line-height: 12px;
  505. color: #000000;
  506. height: 12px;
  507. &-black {
  508. color: #000;
  509. }
  510. &-grey {
  511. color: rgba(0, 0, 0, 0.3);
  512. }
  513. &-sub {
  514. //@include font_color("sub_color");
  515. }
  516. &.noFont {
  517. font-family: initial;
  518. }
  519. &.textLeft {
  520. text-align: left;
  521. }
  522. }
  523. .RLC-chs {
  524. font-family: "FZJCGFKTK";
  525. font-size: 20px;
  526. line-height: 1.4;
  527. color: #000000;
  528. &.RLC-en {
  529. font-family: "robot";
  530. }
  531. &-pinyin {
  532. font-family: "Sans-GBNPC";
  533. }
  534. &.active {
  535. background: rgba(60, 200, 99, 0.2);
  536. }
  537. &.wordActive {
  538. color: #de4444;
  539. }
  540. }
  541. .sentence {
  542. font-family: "FZJCGFKTK";
  543. font-style: normal;
  544. font-weight: normal;
  545. font-size: 24px;
  546. line-height: 1.4;
  547. color: #000000;
  548. padding: 7px 0;
  549. }
  550. }
  551. .sentence-temp-24 {
  552. .RLC-chs {
  553. font-size: 24px;
  554. }
  555. }
  556. .sentence-temp-option {
  557. .sentence {
  558. font-size: 20px;
  559. line-height: 1.4;
  560. }
  561. }
  562. </style>