123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <template>
- <el-dialog class="preview-course" :visible="visible" :title="$t('Key144')" width="1100px" @close="dialogClose">
- <template v-if="fileType === 'courseware'">
- <template v-if="category === 'NPC'">
- <booknpc
- v-if="context"
- ref="booknpc"
- task-model=""
- :is-show-save="false"
- :is-show-title="false"
- :is-answer-item-show="true"
- :context="context"
- :theme-color="themeColor"
- :preview-type="previewType"
- :preview-group-id="previewGroupId"
- :current-tree-i-d="fileId"
- :submit-cn="$store.getters.submitCn"
- />
- </template>
- <template v-if="category === 'NNPE'">
- <booknnpe
- v-if="context"
- :context="context"
- :theme-color="themeColor"
- task-model=""
- :is-show-save="false"
- :is-show-title="true"
- :preview-type="previewType"
- :preview-group-id="previewGroupId"
- :current-tree-i-d="fileId"
- />
- </template>
- <template v-if="category === 'RLC'">
- <bookrlc
- v-if="context"
- :context="context"
- :theme-color="themeColor"
- :is-show-save="false"
- :is-show-title="false"
- :is-answer-item-show="true"
- :book-font-size="bookFontSize"
- :current-tree-i-d="fileId"
- :preview-type="previewType"
- :preview-group-id="previewGroupId"
- />
- </template>
- </template>
- <template v-else-if="fileType === 'file'">
- <div v-loading="loading">
- <iframe
- v-if="fileUrl.length > 0"
- id="iframe"
- :src="`${$store.state.app.config.doc_preview_service_address}/onlinePreview?url=${fileUrl}`"
- width="100%"
- height="540px"
- ></iframe>
- </div>
- </template>
- <div slot="footer">
- <el-button @click="dialogClose">
- {{ $t('Key246') }}
- </el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- export default {
- name: 'PreviewCourse'
- };
- </script>
- <script setup>
- import { ref, watch, nextTick } from 'vue';
- import { GetFileStoreInfo } from '@/api/app';
- import { GetCoursewareContent_View } from '@/api/course';
- import { encode } from 'js-base64';
- import { Message } from 'element-ui';
- const props = defineProps({
- visible: {
- type: Boolean
- },
- fileType: {
- type: String,
- default: ''
- },
- fileId: {
- type: String,
- default: ''
- },
- previewGroupId: {
- default: '[]',
- type: String
- }
- });
- const emits = defineEmits(['dialogClose']);
- watch(
- () => props.fileType,
- (newVal) => {
- if (newVal.length === 0) return;
- if (newVal === 'courseware') {
- getCoursewareContent_View();
- } else {
- getFileStoreInfo();
- }
- }
- );
- watch(
- () => props.visible,
- (newVal) => {
- if (!newVal) {
- category.value = '';
- context.value = null;
- themeColor.value = '';
- fileUrl.value = '';
- loading.value = false;
- }
- }
- );
- const previewType = 'previewCheckShow';
- let category = ref('');
- let context = ref(null);
- let themeColor = ref('');
- let bookFontSize = ref('');
- function getCoursewareContent_View() {
- GetCoursewareContent_View({ id: props.fileId }).then(
- ({ content, category: cate, book_theme_color, book_font_size }) => {
- if (!content) {
- context.value = null;
- return;
- }
- category.value = cate;
- if (category.value === 'OC' || category.value.length === 0 || category.value === 'AILP') {
- return Message.warning('该课件类型已被废弃');
- }
- if (category.value === 'NPC') {
- themeColor.value = book_theme_color;
- context.value = JSON.parse(content);
- return;
- }
- if (category.value === 'NNPE') {
- themeColor.value = book_theme_color;
- context.value = JSON.parse(content);
- return;
- }
- if (category.value === 'RLC') {
- themeColor.value = book_theme_color;
- bookFontSize.value = book_font_size;
- context.value = JSON.parse(content);
- return;
- }
- }
- );
- }
- let fileUrl = ref('');
- let loading = ref(false);
- function getFileStoreInfo() {
- GetFileStoreInfo({ file_id: props.fileId }).then(({ file_url_https }) => {
- loading.value = true;
- fileUrl.value = encodeURIComponent(encode(file_url_https));
- nextTick(() => {
- document.getElementById('iframe').onload = () => {
- loading.value = false;
- };
- });
- });
- }
- function dialogClose() {
- emits('dialogClose');
- }
- </script>
- <style lang="scss" scoped>
- @import '~@/styles/mixin';
- .preview-course {
- @include dialog;
- :deep .el-dialog__header {
- font-weight: bold;
- }
- :deep .el-dialog__body {
- min-height: 300px;
- }
- }
- </style>
|