|  | @@ -0,0 +1,171 @@
 | 
	
		
			
				|  |  | +<template>
 | 
	
		
			
				|  |  | +  <el-dialog class="preview-course" :visible="visible" :title="$t('Key144')" width="1100px" @close="dialogClose">
 | 
	
		
			
				|  |  | +    <template v-if="fileType === 'courseware'">
 | 
	
		
			
				|  |  | +      <template v-if="category === 'OC' || category.length === 0">
 | 
	
		
			
				|  |  | +        <bookquestion ref="courseware" :context="context" />
 | 
	
		
			
				|  |  | +      </template>
 | 
	
		
			
				|  |  | +      <template v-else-if="category === 'AILP'">
 | 
	
		
			
				|  |  | +        <bookailp :context="context" :ui-type="ui_type" :preview-width="800" :preview-height="450" />
 | 
	
		
			
				|  |  | +      </template>
 | 
	
		
			
				|  |  | +      <template v-else-if="category === 'NPC'">
 | 
	
		
			
				|  |  | +        <booknpc
 | 
	
		
			
				|  |  | +          v-if="context"
 | 
	
		
			
				|  |  | +          ref="booknpc"
 | 
	
		
			
				|  |  | +          task-model=""
 | 
	
		
			
				|  |  | +          :is-show-save="false"
 | 
	
		
			
				|  |  | +          :context="context"
 | 
	
		
			
				|  |  | +          :theme-color="themeColor"
 | 
	
		
			
				|  |  | +        />
 | 
	
		
			
				|  |  | +      </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"
 | 
	
		
			
				|  |  | +        />
 | 
	
		
			
				|  |  | +      </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"
 | 
	
		
			
				|  |  | +        />
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +    </template>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    <div slot="footer">
 | 
	
		
			
				|  |  | +      <el-button @click="dialogClose">
 | 
	
		
			
				|  |  | +        {{ $t('Key246') }}
 | 
	
		
			
				|  |  | +      </el-button>
 | 
	
		
			
				|  |  | +    </div>
 | 
	
		
			
				|  |  | +  </el-dialog>
 | 
	
		
			
				|  |  | +</template>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +<script>
 | 
	
		
			
				|  |  | +import { GetFileStoreInfo } from '@/api/app';
 | 
	
		
			
				|  |  | +import { GetCoursewareContent_View } from '@/api/course';
 | 
	
		
			
				|  |  | +import { encode } from 'js-base64';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +export default {
 | 
	
		
			
				|  |  | +  props: {
 | 
	
		
			
				|  |  | +    visible: {
 | 
	
		
			
				|  |  | +      type: Boolean
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    fileType: {
 | 
	
		
			
				|  |  | +      type: String,
 | 
	
		
			
				|  |  | +      default: ''
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    fileId: {
 | 
	
		
			
				|  |  | +      type: String,
 | 
	
		
			
				|  |  | +      default: ''
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  data() {
 | 
	
		
			
				|  |  | +    return {
 | 
	
		
			
				|  |  | +      category: '',
 | 
	
		
			
				|  |  | +      context: null,
 | 
	
		
			
				|  |  | +      themeColor: '',
 | 
	
		
			
				|  |  | +      fileUrl: '',
 | 
	
		
			
				|  |  | +      loading: false
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  watch: {
 | 
	
		
			
				|  |  | +    fileType(newVal) {
 | 
	
		
			
				|  |  | +      if (newVal.length === 0) return;
 | 
	
		
			
				|  |  | +      if (newVal === 'courseware') {
 | 
	
		
			
				|  |  | +        this.getCoursewareContent_View();
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +        this.getFileStoreInfo();
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    visible(newVal) {
 | 
	
		
			
				|  |  | +      if (!newVal) {
 | 
	
		
			
				|  |  | +        this.category = '';
 | 
	
		
			
				|  |  | +        this.context = null;
 | 
	
		
			
				|  |  | +        this.themeColor = '';
 | 
	
		
			
				|  |  | +        this.fileUrl = '';
 | 
	
		
			
				|  |  | +        this.loading = false;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  },
 | 
	
		
			
				|  |  | +  methods: {
 | 
	
		
			
				|  |  | +    getCoursewareContent_View() {
 | 
	
		
			
				|  |  | +      GetCoursewareContent_View({ id: this.fileId }).then(({ content, category, book_theme_color }) => {
 | 
	
		
			
				|  |  | +        if (!content) {
 | 
	
		
			
				|  |  | +          this.context = null;
 | 
	
		
			
				|  |  | +          return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        this.category = category;
 | 
	
		
			
				|  |  | +        if (category === 'OC' || category.length === 0) {
 | 
	
		
			
				|  |  | +          this.context = {
 | 
	
		
			
				|  |  | +            id: this.material_id,
 | 
	
		
			
				|  |  | +            ui_type: JSON.parse(content).question.ui_type,
 | 
	
		
			
				|  |  | +            content: JSON.parse(content)
 | 
	
		
			
				|  |  | +          };
 | 
	
		
			
				|  |  | +          return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (category === 'AILP') {
 | 
	
		
			
				|  |  | +          const contents = JSON.parse(content);
 | 
	
		
			
				|  |  | +          if (contents.question && contents.question.length > 0) {
 | 
	
		
			
				|  |  | +            this.context = JSON.parse(contents.question);
 | 
	
		
			
				|  |  | +            this.ui_type = contents.ui_type ? contents.ui_type : '';
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (category === 'NPC') {
 | 
	
		
			
				|  |  | +          this.themeColor = book_theme_color;
 | 
	
		
			
				|  |  | +          this.context = JSON.parse(content);
 | 
	
		
			
				|  |  | +          return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (category === 'NNPE') {
 | 
	
		
			
				|  |  | +          this.themeColor = book_theme_color;
 | 
	
		
			
				|  |  | +          this.context = JSON.parse(content);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    getFileStoreInfo() {
 | 
	
		
			
				|  |  | +      GetFileStoreInfo({ file_id: this.fileId }).then(({ file_url_https }) => {
 | 
	
		
			
				|  |  | +        this.loading = true;
 | 
	
		
			
				|  |  | +        this.fileUrl = encodeURIComponent(encode(file_url_https));
 | 
	
		
			
				|  |  | +        this.$nextTick(() => {
 | 
	
		
			
				|  |  | +          document.getElementById('iframe').onload = () => {
 | 
	
		
			
				|  |  | +            this.loading = false;
 | 
	
		
			
				|  |  | +          };
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    dialogClose() {
 | 
	
		
			
				|  |  | +      this.$emit('dialogClose');
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +</script>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +<style lang="scss" scoped>
 | 
	
		
			
				|  |  | +@import '~@/styles/mixin';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +.preview-course {
 | 
	
		
			
				|  |  | +  @include dialog;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  ::v-deep .el-dialog__header {
 | 
	
		
			
				|  |  | +    font-weight: bold;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  ::v-deep .el-dialog__body {
 | 
	
		
			
				|  |  | +    min-height: 300px;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +</style>
 |