Notes.vue 9.3 KB

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