| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <template>
- <el-dialog
- title="全教材设置"
- :visible="visible"
- width="600px"
- :close-on-click-modal="false"
- class="book-unified-attr"
- @close="dialogClose"
- >
- <div class="setting-top">
- <div class="form">
- <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>
- </div>
- <div class="tips" @click="applyBookUnifiedAttr">
- <p>重置当前教材所有内容</p>
- <p style="color: #f00">(不包含富文本的现有文字属性)</p>
- </div>
- </div>
- <div class="setting-bottom">
- <span>拼音</span>
- <el-switch v-model="unified_attrib.view_pinyin" active-value="true" inactive-value="false" />
- <span>拼音位置</span>
- <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>
- </div>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogClose">取 消</el-button>
- <el-button type="primary" @click="saveBookUnifiedAttr">确定</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- import { pinyinPositionList, isEnable } from '@/views/book/courseware/data/common';
- import { GetBookUnifiedAttrib, ApplyBookUnifiedAttrib, SaveBookUnifiedAttrib } from '@/api/book';
- import { unified_attrib } from '@/common/data';
- export default {
- name: 'BookUnifiedAttrPage',
- props: {
- visible: {
- type: Boolean,
- required: true,
- },
- bookId: {
- type: String,
- required: true,
- },
- },
- data() {
- return {
- unified_attrib,
- fontSizeList: [
- '8pt',
- '10pt',
- '12pt',
- '14pt',
- '16pt',
- '18pt',
- '20pt',
- '22pt',
- '24pt',
- '26pt',
- '28pt',
- '30pt',
- '32pt',
- '34pt',
- '36pt',
- ],
- pinyinPositionList,
- isEnable,
- };
- },
- watch: {
- visible(newVal) {
- if (newVal) {
- this.getBookUnifiedAttr();
- }
- },
- },
- methods: {
- getBookUnifiedAttr() {
- GetBookUnifiedAttrib({ book_id: this.bookId }).then(({ content }) => {
- if (content) {
- this.unified_attrib = JSON.parse(content);
- }
- });
- },
- applyBookUnifiedAttr() {
- let loading = this.$loading({ fullscreen: true, text: '正在应用,请稍后...' });
- ApplyBookUnifiedAttrib({
- book_id: this.bookId,
- content: JSON.stringify(this.unified_attrib),
- })
- .then(() => {
- this.$message.success('应用成功');
- this.dialogClose();
- })
- .finally(() => {
- loading.close();
- });
- },
- saveBookUnifiedAttr() {
- SaveBookUnifiedAttrib({
- book_id: this.bookId,
- content: JSON.stringify(this.unified_attrib),
- }).then(() => {
- this.$message.success('保存成功');
- this.dialogClose();
- });
- },
- dialogClose() {
- this.$emit('update:visible', false);
- this.$emit('close');
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .book-unified-attr {
- .setting-top {
- display: flex;
- .form {
- flex: 1;
- .el-input-number {
- width: calc(100% - 42px);
- }
- .color-group {
- display: flex;
- column-gap: 10px;
- align-items: center;
- span {
- white-space: nowrap;
- }
- }
- }
- .tips {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width: 240px;
- font-size: 12px;
- line-height: 1.5;
- text-align: center;
- cursor: pointer;
- background-color: rgba(22, 93, 255, 8%);
- border-radius: 8px;
- }
- }
- .setting-bottom {
- display: flex;
- column-gap: 10px;
- align-items: center;
- padding-top: 20px;
- margin-top: 20px;
- border-top: $border;
- }
- }
- </style>
|