Notes.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <ModuleBase :type="data.type">
  3. <template #content>
  4. <label>标题:</label>
  5. <RichText
  6. v-model="data.title_con"
  7. :inline="true"
  8. :placeholder="'输入标题'"
  9. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
  10. />
  11. <el-table :data="data.option" border style="width: 100%">
  12. <el-table-column fixed prop="number" label="序号" width="70">
  13. <template slot-scope="scope">
  14. <el-input v-model="scope.row.number" />
  15. </template>
  16. </el-table-column>
  17. <el-table-column fixed prop="con" label="内容" width="200">
  18. <template slot-scope="scope">
  19. <RichText
  20. v-model="scope.row.con"
  21. :inline="true"
  22. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
  23. @handleRichTextBlur="handleBlurCon"
  24. />
  25. </template>
  26. </el-table-column>
  27. <el-table-column prop="interpret" label="翻译" width="200">
  28. <template slot-scope="scope">
  29. <RichText
  30. v-model="scope.row.interpret"
  31. :inline="true"
  32. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
  33. />
  34. </template>
  35. </el-table-column>
  36. <el-table-column prop="note" label="注释">
  37. <template slot-scope="scope">
  38. <RichText
  39. v-model="scope.row.note"
  40. :inline="true"
  41. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
  42. />
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="操作" width="150">
  46. <template slot-scope="scope">
  47. <el-button size="mini" type="text" @click="handleDelete(scope.$index)">删除</el-button>
  48. <el-button size="mini" type="text" @click="moveElement(scope.row, scope.$index, 'up')">上移</el-button>
  49. <el-button size="mini" type="text" @click="moveElement(scope.row, scope.$index, 'down')">下移</el-button>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. <el-button icon="el-icon-plus" style="margin: 24px 0" @click="addElement">增加一个</el-button>
  54. <el-button @click="handleMultilingual">多语言</el-button>
  55. <MultilingualFill
  56. :visible.sync="multilingualVisible"
  57. :text="multilingualText"
  58. :translations="data.multilingual"
  59. @SubmitTranslation="handleMultilingualTranslation"
  60. />
  61. </template>
  62. </ModuleBase>
  63. </template>
  64. <script>
  65. import ModuleMixin from '../../common/ModuleMixin';
  66. import { getNotesData, getOption } from '@/views/book/courseware/data/notes';
  67. export default {
  68. name: 'NotesPage',
  69. components: {},
  70. mixins: [ModuleMixin],
  71. data() {
  72. return {
  73. data: getNotesData(),
  74. multilingualText: '',
  75. };
  76. },
  77. watch: {
  78. 'data.option': 'handleMindMap',
  79. },
  80. methods: {
  81. // 删除行
  82. handleDelete(index) {
  83. this.data.option.splice(index, 1);
  84. },
  85. // 上移下移
  86. moveElement(dItem, index, type) {
  87. let obj = JSON.parse(JSON.stringify(dItem));
  88. if (type == 'up' && index > 0) {
  89. this.data.option.splice(index - 1, 0, obj);
  90. this.data.option.splice(index + 1, 1);
  91. }
  92. if (type == 'down' && index < this.data.option.length - 1) {
  93. this.data.option[index] = this.data.option.splice(index + 1, 1, this.data.option[index])[0];
  94. }
  95. },
  96. // 增加
  97. addElement() {
  98. this.data.option.push(getOption());
  99. },
  100. handleMindMap() {
  101. // 思维导图数据
  102. let node_list = [];
  103. this.data.option.forEach((item) => {
  104. node_list.push({
  105. name: item.con.replace(/<[^>]*>?/gm, ''),
  106. id: Math.random().toString(36).substring(2, 12),
  107. });
  108. });
  109. this.data.mind_map.node_list = node_list;
  110. },
  111. handleBlurCon() {
  112. this.handleMindMap();
  113. },
  114. handleMultilingual() {
  115. this.multilingualText = this.data.title_con ? this.data.title_con : '<p>&nbsp;</p>';
  116. this.data.option.forEach((item) => {
  117. this.multilingualText += item.con ? item.con : '<p>&nbsp;</p>';
  118. this.multilingualText += item.note ? item.note : '<p>&nbsp;</p>';
  119. });
  120. this.multilingualVisible = true;
  121. },
  122. },
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. .upload-file {
  127. display: flex;
  128. column-gap: 12px;
  129. align-items: center;
  130. margin: 8px 0;
  131. .file-name {
  132. display: flex;
  133. column-gap: 14px;
  134. align-items: center;
  135. justify-content: space-between;
  136. max-width: 360px;
  137. padding: 8px 12px;
  138. font-size: 14px;
  139. color: #1d2129;
  140. background-color: #f7f8fa;
  141. span {
  142. display: flex;
  143. column-gap: 14px;
  144. align-items: center;
  145. }
  146. }
  147. .svg-icon {
  148. cursor: pointer;
  149. }
  150. }
  151. </style>
  152. <style lang="scss">
  153. .tox .tox-editor-header {
  154. z-index: 3 !important;
  155. }
  156. </style>