Describe.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <ModuleBase :type="data.type">
  3. <template #content>
  4. <RichText
  5. ref="rich"
  6. v-model="data.content"
  7. :font-size="18"
  8. placeholder="输入描述"
  9. :is-view-pinyin="isEnable(data.property.view_pinyin)"
  10. @crateParsedTextInfoPinyin="crateParsedTextInfoPinyin"
  11. />
  12. <el-divider v-if="isEnable(data.property.view_pinyin)" content-position="left">拼音效果</el-divider>
  13. <PinyinText
  14. v-if="isEnable(data.property.view_pinyin)"
  15. :id="richId + '_pinyin_text'"
  16. :paragraph-list="data.paragraph_list"
  17. :pinyin-position="data.property.pinyin_position"
  18. @fillCorrectPinyin="fillCorrectPinyin"
  19. />
  20. </template>
  21. </ModuleBase>
  22. </template>
  23. <script>
  24. import { getDescribeData } from '@/views/book/courseware/data/describe';
  25. import { CrateParsedTextInfo_Pinyin } from '@/api/book';
  26. import { isEnable } from '@/views/book/courseware/data/common';
  27. import ModuleMixin from '../../common/ModuleMixin';
  28. import RichText from '@/components/RichText.vue';
  29. import PinyinText from '@/components/PinyinText.vue';
  30. export default {
  31. name: 'DescribePage',
  32. components: { RichText, PinyinText },
  33. mixins: [ModuleMixin],
  34. data() {
  35. return {
  36. isEnable,
  37. data: getDescribeData(),
  38. selectContent: '',
  39. richId: '',
  40. };
  41. },
  42. watch: {
  43. 'data.property': {
  44. handler(val) {
  45. let text = this.data.content.replace(/<[^>]+>/g, '');
  46. if (isEnable(val.view_pinyin) && text) {
  47. this.data.paragraph_list_parameter.text = text;
  48. this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case =
  49. val.is_first_sentence_first_hz_pinyin_first_char_upper_case;
  50. this.crateParsedTextInfoPinyin(text);
  51. }
  52. },
  53. deep: true,
  54. immediate: true,
  55. },
  56. },
  57. methods: {
  58. showSetting() {
  59. this.richId = this.$refs.rich.id;
  60. this.$emit('showSetting', this.data.property, this.data.type, this.id, {
  61. richId: this.richId,
  62. });
  63. },
  64. // 获取拼音解析文本
  65. crateParsedTextInfoPinyin(text) {
  66. if (text === '') {
  67. this.data.paragraph_list_parameter.pinyin_proofread_word_list = [];
  68. return;
  69. }
  70. this.data.paragraph_list_parameter.text = text.replace(/<[^>]+>/g, '');
  71. this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case =
  72. this.data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case;
  73. CrateParsedTextInfo_Pinyin(this.data.paragraph_list_parameter).then((res) => {
  74. if (res.parsed_text) {
  75. this.data.paragraph_list = res.parsed_text.paragraph_list;
  76. }
  77. });
  78. },
  79. // 填充校对后的拼音
  80. fillCorrectPinyin(selectContent, tonePinyin, i, j, k) {
  81. this.data.paragraph_list_parameter.pinyin_proofread_word_list.push({
  82. paragraph_index: `${i}`,
  83. sentence_index: `${j}`,
  84. word_index: `${k}`,
  85. word: selectContent,
  86. pinyin: tonePinyin,
  87. });
  88. this.data.paragraph_list[i][j][k].pinyin = tonePinyin;
  89. },
  90. },
  91. };
  92. </script>
  93. <style lang="scss" scoped></style>