Notes.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <div>
  3. <label>标题:</label>
  4. <RichText
  5. v-if="property.isGetContent"
  6. ref="richText"
  7. v-model="data.title_con"
  8. :inline="true"
  9. :placeholder="'输入标题'"
  10. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
  11. class="title-box"
  12. :font-size="unifiedAttrib?.font_size"
  13. :font-family="unifiedAttrib?.font"
  14. />
  15. <el-table :data="data.option" border style="width: 100%">
  16. <el-table-column fixed prop="number" label="序号" width="70">
  17. <template slot-scope="scope">
  18. <el-input v-model="scope.row.number" />
  19. </template>
  20. </el-table-column>
  21. <el-table-column fixed prop="con" label="内容" width="200">
  22. <template slot-scope="scope">
  23. <RichText
  24. v-if="property.isGetContent"
  25. ref="richText"
  26. v-model="scope.row.con"
  27. :inline="true"
  28. :item-index="scope.$index"
  29. :font-size="unifiedAttrib?.font_size"
  30. :font-family="unifiedAttrib?.font"
  31. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
  32. @handleRichTextBlur="handleBlurCon"
  33. />
  34. </template>
  35. </el-table-column>
  36. <el-table-column v-if="isEnable(data.property.view_pinyin)" prop="con" label="拼音" width="150">
  37. <template slot-scope="scope">
  38. <RichText
  39. v-if="property.isGetContent"
  40. ref="richText"
  41. v-model="scope.row.pinyin"
  42. :inline="true"
  43. :font-size="unifiedAttrib?.pinyin_size"
  44. :font-family="'League'"
  45. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
  46. />
  47. </template>
  48. </el-table-column>
  49. <el-table-column prop="interpret" label="翻译" width="200">
  50. <template slot-scope="scope">
  51. <RichText
  52. v-if="property.isGetContent"
  53. ref="richText"
  54. v-model="scope.row.interpret"
  55. :inline="true"
  56. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
  57. :font-size="unifiedAttrib?.font_size"
  58. :font-family="unifiedAttrib?.font"
  59. />
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop="note" label="注释" width="200">
  63. <template slot-scope="scope">
  64. <RichText
  65. v-if="property.isGetContent"
  66. ref="richText"
  67. v-model="scope.row.note"
  68. :inline="true"
  69. toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright"
  70. :font-size="unifiedAttrib?.font_size"
  71. :font-family="unifiedAttrib?.font"
  72. />
  73. </template>
  74. </el-table-column>
  75. <!-- <el-table-column prop="img_list" label="图片" width="300">
  76. <template slot-scope="scope">
  77. <UploadPicture
  78. :file-info="scope.row.file_list[0]"
  79. :item-index="scope.$index"
  80. :show-upload="!scope.row.file_list[0]"
  81. @upload="uploadPic"
  82. @deleteFile="deletePic"
  83. />
  84. </template>
  85. </el-table-column> -->
  86. <el-table-column prop="notesColor" label="在课文中的颜色" width="130">
  87. <template slot-scope="scope">
  88. <el-color-picker v-model="scope.row.notesColor"></el-color-picker>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="操作" width="150">
  92. <template slot-scope="scope">
  93. <el-button size="mini" type="text" @click="handleDelete(scope.$index)">删除</el-button>
  94. <el-button size="mini" type="text" @click="moveElement(scope.row, scope.$index, 'up')">上移</el-button>
  95. <el-button size="mini" type="text" @click="moveElement(scope.row, scope.$index, 'down')">下移</el-button>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <el-button icon="el-icon-plus" style="margin: 24px 0" @click="addElement">增加一个</el-button>
  100. <el-form :model="data.property" label-width="72px" label-position="left">
  101. <el-form-item label="拼音">
  102. <el-switch v-model="data.property.view_pinyin" active-value="true" inactive-value="false" />
  103. </el-form-item>
  104. <el-form-item label="拼音位置">
  105. <el-radio
  106. v-for="{ value, label } in pinyinPositionLists"
  107. :key="value"
  108. v-model="data.property.pinyin_position"
  109. :label="value"
  110. :disabled="!isEnable(data.property.view_pinyin)"
  111. >
  112. {{ label }}
  113. </el-radio>
  114. </el-form-item>
  115. <el-form-item label="">
  116. <el-checkbox
  117. v-model="data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case"
  118. :disabled="!isEnable(data.property.view_pinyin)"
  119. true-label="true"
  120. false-label="false"
  121. >句首大写</el-checkbox
  122. >
  123. </el-form-item>
  124. </el-form>
  125. </div>
  126. </template>
  127. <script>
  128. import ModuleMixin from '../../common/ModuleMixin';
  129. import RichText from '@/components/RichText.vue';
  130. import UploadPicture from '../new_word/components/UploadPicture.vue';
  131. import { pinyinPositionLists } from '@/views/book/courseware/data/notes';
  132. import { isEnable } from '@/views/book/courseware/data/common';
  133. export default {
  134. name: 'NotesPage',
  135. components: {
  136. RichText,
  137. UploadPicture,
  138. },
  139. props: ['dataNotes', 'unifiedAttrib'],
  140. mixins: [ModuleMixin],
  141. data() {
  142. return {
  143. data: this.dataNotes,
  144. pinyinPositionLists,
  145. isEnable,
  146. };
  147. },
  148. watch: {
  149. 'data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case': {
  150. handler(val, oldVal) {
  151. if (val === oldVal) return;
  152. if (isEnable(this.data.property.view_pinyin)) {
  153. this.handlePinyin();
  154. }
  155. },
  156. deep: true,
  157. },
  158. },
  159. methods: {
  160. // 删除行
  161. handleDelete(index) {
  162. this.data.option.splice(index, 1);
  163. },
  164. // 上移下移
  165. moveElement(dItem, index, type) {
  166. let obj = JSON.parse(JSON.stringify(dItem));
  167. if (type == 'up' && index > 0) {
  168. this.data.option.splice(index - 1, 0, obj);
  169. this.data.option.splice(index + 1, 1);
  170. }
  171. if (type == 'down' && index < this.data.option.length - 1) {
  172. this.data.option[index] = this.data.option.splice(index + 1, 1, this.data.option[index])[0];
  173. }
  174. },
  175. // 增加
  176. addElement() {
  177. this.data.option.push(this.getOption());
  178. },
  179. getOption() {
  180. return {
  181. number: '',
  182. con: '',
  183. pinyin: '',
  184. interpret: '', // 翻译
  185. note: '', // 注释
  186. img_list: [],
  187. file_list: [''], // 图片
  188. notesColor: '#8206BF', // 在课文中预览的注释颜色
  189. };
  190. },
  191. uploadPic(file_id, index) {
  192. this.data.option[index].file_list[0] = file_id;
  193. this.data.file_id_list.push(file_id);
  194. this.refreshKey = Math.random();
  195. },
  196. deletePic(file_id, index) {
  197. this.data.option[index].file_list[0] = '';
  198. this.data.file_id_list = this.data.file_id_list.filter((item) => item !== file_id);
  199. },
  200. handleBlurCon(i) {
  201. let text = this.data.option[i].con.replace(/<[^>]+>/g, '');
  202. this.data.option[i].pinyin = cnchar
  203. .spell(
  204. text,
  205. 'array',
  206. this.data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case === 'true' ? 'high' : 'low',
  207. 'tone',
  208. )
  209. .join(' ');
  210. },
  211. handlePinyin() {
  212. this.data.option.forEach((item) => {
  213. let text = item.con.replace(/<[^>]+>/g, '');
  214. item.pinyin = cnchar
  215. .spell(
  216. text,
  217. 'array',
  218. this.data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case === 'true' ? 'high' : 'low',
  219. 'tone',
  220. )
  221. .join(' ');
  222. });
  223. },
  224. },
  225. };
  226. </script>
  227. <style lang="scss" scoped>
  228. .upload-file {
  229. display: flex;
  230. column-gap: 12px;
  231. align-items: center;
  232. margin: 8px 0;
  233. .file-name {
  234. display: flex;
  235. column-gap: 14px;
  236. align-items: center;
  237. justify-content: space-between;
  238. max-width: 360px;
  239. padding: 8px 12px;
  240. font-size: 14px;
  241. color: #1d2129;
  242. background-color: #f7f8fa;
  243. span {
  244. display: flex;
  245. column-gap: 14px;
  246. align-items: center;
  247. }
  248. }
  249. .svg-icon {
  250. cursor: pointer;
  251. }
  252. }
  253. .title-box {
  254. padding: 5px;
  255. margin: 5px 0;
  256. background-color: #f2f3f5;
  257. border: 1px solid #f2f3f5;
  258. border-radius: 4px;
  259. :deep p {
  260. margin: 0;
  261. }
  262. }
  263. </style>
  264. <style lang="scss">
  265. .tox .tox-editor-header {
  266. z-index: 3 !important;
  267. }
  268. </style>