FullTextSettings.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <el-dialog
  3. custom-class="full-text-settings"
  4. width="400px"
  5. :close-on-click-modal="false"
  6. :visible="visible"
  7. :before-close="handleClose"
  8. title="全文设置"
  9. >
  10. <el-form ref="form" :model="unified_attrib" label-width="80px" size="small">
  11. <el-form-item label="主题色">
  12. <div class="color-group">
  13. <el-color-picker v-model="unified_attrib.topic_color" />
  14. <span>辅助色</span>
  15. <el-color-picker v-model="unified_attrib.assist_color" />
  16. </div>
  17. </el-form-item>
  18. <el-form-item label="字体">
  19. <el-select v-model="unified_attrib.font" placeholder="请选择字体">
  20. <el-option label="楷体" value="楷体,微软雅黑" />
  21. <el-option label="黑体" value="黑体,微软雅黑" />
  22. <el-option label="宋体" value="宋体,微软雅黑" />
  23. <el-option label="Arial" value="Arial,Helvetica,sans-serif" />
  24. <el-option label="Times New Roman" value="Times New Roman,times,serif" />
  25. <el-option label="拼音" value="League" />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="字号">
  29. <el-select v-model="unified_attrib.font_size" placeholder="请选择字号">
  30. <el-option v-for="size in fontSizeList" :key="size" :label="size" :value="size" />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="拼音字号">
  34. <el-select v-model="unified_attrib.pinyin_size" placeholder="请选择拼音字号">
  35. <el-option v-for="size in fontSizeList" :key="size" :label="size" :value="size" />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="行距">
  39. <el-input-number v-model="unified_attrib.line_height" :min="0" :max="20" :step="0.1" />
  40. </el-form-item>
  41. <el-form-item label="文字颜色">
  42. <el-color-picker v-model="unified_attrib.text_color" />
  43. </el-form-item>
  44. <el-form-item label="对齐方式">
  45. <el-select v-model="unified_attrib.align" placeholder="请选择对齐方式">
  46. <el-option label="左对齐" value="LEFT" />
  47. <el-option label="居中" value="MIDDLE" />
  48. <el-option label="右对齐" value="RIGHT" />
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item label="拼音">
  52. <el-switch v-model="unified_attrib.view_pinyin" active-value="true" inactive-value="false" />
  53. </el-form-item>
  54. <el-form-item label="拼音位置">
  55. <el-radio-group v-model="unified_attrib.pinyin_position" :disabled="!isEnable(unified_attrib.view_pinyin)">
  56. <el-radio v-for="{ value, label } in pinyinPositionList" :key="value" :label="value">
  57. {{ label }}
  58. </el-radio>
  59. </el-radio-group>
  60. </el-form-item>
  61. </el-form>
  62. <div slot="footer" class="dialog-footer">
  63. <el-button @click="handleClose">取 消</el-button>
  64. <el-button type="primary" @click="confirm">确 定</el-button>
  65. </div>
  66. </el-dialog>
  67. </template>
  68. <script>
  69. import { pinyinPositionList, isEnable } from '@/views/book/courseware/data/common';
  70. import { GetBookUnifiedAttrib } from '@/api/book';
  71. export default {
  72. name: 'FullTextSettings',
  73. props: {
  74. visible: {
  75. type: Boolean,
  76. required: true,
  77. },
  78. settings: {
  79. type: Object,
  80. required: true,
  81. },
  82. bookId: {
  83. type: String,
  84. required: true,
  85. },
  86. },
  87. data() {
  88. return {
  89. unified_attrib: {
  90. topic_color: '#FFBBCC', // 主题色
  91. font: '宋体,微软雅黑', // 字体
  92. font_size: '12pt', // 字号
  93. pinyin_size: '12pt', // 拼音字号
  94. line_height: 1.5, // 行距
  95. text_color: '#1d2129', // 文字颜色
  96. align: 'LEFT', // 对齐方式 LEFT:左对齐 MIDDLE:居中 RIGHT:右对齐
  97. view_pinyin: 'true', // 启用拼音
  98. pinyin_position: 'top', // 拼音位置
  99. },
  100. fontSizeList: [
  101. '8pt',
  102. '10pt',
  103. '12pt',
  104. '14pt',
  105. '16pt',
  106. '18pt',
  107. '20pt',
  108. '22pt',
  109. '24pt',
  110. '26pt',
  111. '28pt',
  112. '30pt',
  113. '32pt',
  114. '34pt',
  115. '36pt',
  116. ],
  117. pinyinPositionList,
  118. isEnable,
  119. };
  120. },
  121. watch: {
  122. visible(val) {
  123. if (val) {
  124. this.unified_attrib = { ...this.settings };
  125. }
  126. },
  127. },
  128. created() {
  129. this.getBookUnifiedAttr();
  130. },
  131. methods: {
  132. getBookUnifiedAttr() {
  133. GetBookUnifiedAttrib({ book_id: this.bookId }).then(({ content }) => {
  134. if (content && (this.settings === null || Object.keys(this.settings).length > 0)) {
  135. this.unified_attrib = JSON.parse(content);
  136. }
  137. });
  138. },
  139. handleClose() {
  140. this.$emit('update:visible', false);
  141. },
  142. confirm() {
  143. this.$emit('update:visible', false);
  144. this.$emit('fullTextSettings', this.unified_attrib);
  145. },
  146. },
  147. };
  148. </script>
  149. <style lang="scss" scoped>
  150. .full-text-settings {
  151. padding: 0;
  152. .el-form {
  153. .color-group {
  154. display: flex;
  155. column-gap: 10px;
  156. align-items: center;
  157. span {
  158. white-space: nowrap;
  159. }
  160. }
  161. }
  162. }
  163. </style>