FullTextSettings.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. import { unified_attrib } from '@/common/data';
  72. export default {
  73. name: 'FullTextSettings',
  74. props: {
  75. visible: {
  76. type: Boolean,
  77. required: true,
  78. },
  79. settings: {
  80. type: Object,
  81. default: () => unified_attrib,
  82. },
  83. bookId: {
  84. type: String,
  85. required: true,
  86. },
  87. },
  88. data() {
  89. return {
  90. unified_attrib,
  91. fontSizeList: [
  92. '8pt',
  93. '10pt',
  94. '12pt',
  95. '14pt',
  96. '16pt',
  97. '18pt',
  98. '20pt',
  99. '22pt',
  100. '24pt',
  101. '26pt',
  102. '28pt',
  103. '30pt',
  104. '32pt',
  105. '34pt',
  106. '36pt',
  107. ],
  108. pinyinPositionList,
  109. isEnable,
  110. };
  111. },
  112. watch: {
  113. visible(val) {
  114. if (val) {
  115. this.$set(this, 'unified_attrib', { ...this.unified_attrib, ...this.settings });
  116. }
  117. },
  118. },
  119. created() {
  120. this.getBookUnifiedAttr();
  121. },
  122. methods: {
  123. getBookUnifiedAttr() {
  124. GetBookUnifiedAttrib({ book_id: this.bookId }).then(({ content }) => {
  125. if (content && (this.settings === null || Object.keys(this.settings).length <= 0)) {
  126. this.unified_attrib = JSON.parse(content);
  127. }
  128. });
  129. },
  130. handleClose() {
  131. this.$emit('update:visible', false);
  132. },
  133. confirm() {
  134. this.$emit('update:visible', false);
  135. this.$emit('fullTextSettings', this.unified_attrib);
  136. },
  137. },
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. .full-text-settings {
  142. padding: 0;
  143. .el-form {
  144. .color-group {
  145. display: flex;
  146. column-gap: 10px;
  147. align-items: center;
  148. span {
  149. white-space: nowrap;
  150. }
  151. }
  152. }
  153. }
  154. </style>