| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <template>
- <el-dialog
- custom-class="full-text-settings"
- width="400px"
- :close-on-click-modal="false"
- :visible="visible"
- :before-close="handleClose"
- title="全文设置"
- >
- <el-form ref="form" :model="unified_attrib" label-width="80px" size="small">
- <el-form-item label="主题色">
- <div class="color-group">
- <el-color-picker v-model="unified_attrib.topic_color" />
- <span>辅助色</span>
- <el-color-picker v-model="unified_attrib.assist_color" />
- </div>
- </el-form-item>
- <el-form-item label="字体">
- <el-select v-model="unified_attrib.font" placeholder="请选择字体">
- <el-option label="楷体" value="楷体,微软雅黑" />
- <el-option label="黑体" value="黑体,微软雅黑" />
- <el-option label="宋体" value="宋体,微软雅黑" />
- <el-option label="Arial" value="Arial,Helvetica,sans-serif" />
- <el-option label="Times New Roman" value="Times New Roman,times,serif" />
- <el-option label="拼音" value="League" />
- </el-select>
- </el-form-item>
- <el-form-item label="字号">
- <el-select v-model="unified_attrib.font_size" placeholder="请选择字号">
- <el-option v-for="size in fontSizeList" :key="size" :label="size" :value="size" />
- </el-select>
- </el-form-item>
- <el-form-item label="拼音字号">
- <el-select v-model="unified_attrib.pinyin_size" placeholder="请选择拼音字号">
- <el-option v-for="size in fontSizeList" :key="size" :label="size" :value="size" />
- </el-select>
- </el-form-item>
- <el-form-item label="行距">
- <el-input-number v-model="unified_attrib.line_height" :min="0" :max="20" :step="0.1" />
- </el-form-item>
- <el-form-item label="文字颜色">
- <el-color-picker v-model="unified_attrib.text_color" />
- </el-form-item>
- <el-form-item label="对齐方式">
- <el-select v-model="unified_attrib.align" placeholder="请选择对齐方式">
- <el-option label="左对齐" value="LEFT" />
- <el-option label="居中" value="MIDDLE" />
- <el-option label="右对齐" value="RIGHT" />
- </el-select>
- </el-form-item>
- <el-form-item label="拼音">
- <el-switch v-model="unified_attrib.view_pinyin" active-value="true" inactive-value="false" />
- </el-form-item>
- <el-form-item label="拼音位置">
- <el-radio-group v-model="unified_attrib.pinyin_position" :disabled="!isEnable(unified_attrib.view_pinyin)">
- <el-radio v-for="{ value, label } in pinyinPositionList" :key="value" :label="value">
- {{ label }}
- </el-radio>
- </el-radio-group>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="handleClose">取 消</el-button>
- <el-button type="primary" @click="confirm">确 定</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import { pinyinPositionList, isEnable } from '@/views/book/courseware/data/common';
- import { GetBookUnifiedAttrib } from '@/api/book';
- export default {
- name: 'FullTextSettings',
- props: {
- visible: {
- type: Boolean,
- required: true,
- },
- settings: {
- type: Object,
- required: true,
- },
- bookId: {
- type: String,
- required: true,
- },
- },
- data() {
- return {
- unified_attrib: {
- topic_color: '#FFBBCC', // 主题色
- font: '宋体,微软雅黑', // 字体
- font_size: '12pt', // 字号
- pinyin_size: '12pt', // 拼音字号
- line_height: 1.5, // 行距
- text_color: '#1d2129', // 文字颜色
- align: 'LEFT', // 对齐方式 LEFT:左对齐 MIDDLE:居中 RIGHT:右对齐
- view_pinyin: 'true', // 启用拼音
- pinyin_position: 'top', // 拼音位置
- },
- fontSizeList: [
- '8pt',
- '10pt',
- '12pt',
- '14pt',
- '16pt',
- '18pt',
- '20pt',
- '22pt',
- '24pt',
- '26pt',
- '28pt',
- '30pt',
- '32pt',
- '34pt',
- '36pt',
- ],
- pinyinPositionList,
- isEnable,
- };
- },
- watch: {
- visible(val) {
- if (val) {
- this.unified_attrib = { ...this.settings };
- }
- },
- },
- created() {
- this.getBookUnifiedAttr();
- },
- methods: {
- getBookUnifiedAttr() {
- GetBookUnifiedAttrib({ book_id: this.bookId }).then(({ content }) => {
- if (content && (this.settings === null || Object.keys(this.settings).length > 0)) {
- this.unified_attrib = JSON.parse(content);
- }
- });
- },
- handleClose() {
- this.$emit('update:visible', false);
- },
- confirm() {
- this.$emit('update:visible', false);
- this.$emit('fullTextSettings', this.unified_attrib);
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .full-text-settings {
- padding: 0;
- .el-form {
- .color-group {
- display: flex;
- column-gap: 10px;
- align-items: center;
- span {
- white-space: nowrap;
- }
- }
- }
- }
- </style>
|