123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <!-- eslint-disable vue/no-v-html -->
- <template>
- <div class="notes-preview" :style="getAreaStyle()">
- <SerialNumberPosition v-if="isEnable(data.property.sn_display_mode)" :property="data.property" />
- <div class="main">
- <div class="NPC-zhedie">
- <div class="topTitle">
- <div class="NPC-top-left">
- <span class="NPC-topTitle-text" v-html="data.title_con"></span>
- <span class="NPC-topTitle-text" v-if="showLang">
- {{ titleTrans[getLang()] }}
- </span>
- </div>
- <div class="NPC-top-right" @click="handleChangeTab">
- <span class="NPC-top-right-text">{{ wordShow ? '收起' : '展开' }}</span>
- <img v-if="wordShow" src="@/assets/down.png" alt="" />
- <img v-else class="rotate" src="@/assets/down.png" alt="" />
- </div>
- </div>
- <el-collapse-transition>
- <div v-show="wordShow" class="NPC-notes-list">
- <div v-for="(item, index) in data.option" :key="'NPC-notes' + index" class="NPC-notes">
- <div class="NPC-notes-con">
- <span class="NPC-notes-con-number" v-html="item.number"></span>
- <span class="NPC-notes-con-text" v-html="item.con"></span>
- <span class="multilingual" v-if="showLang">
- {{
- multilingualTextList[getLang()] &&
- multilingualTextList[getLang()][index] &&
- multilingualTextList[getLang()][index][0]
- ? multilingualTextList[getLang()][index][0]
- : ''
- }}
- </span>
- </div>
- <div class="NPC-notes-trans" v-html="item.interpret"></div>
- <div v-if="item.note" class="NPC-notes-note" v-html="item.note"></div>
- <div v-if="item.file_list[0]" class="NPC-notes-note-img">
- <el-image :src="item.pic_url" :preview-src-list="[item.pic_url]" fit="contain" />
- </div>
- <div class="NPC-notes-note" v-if="showLang">
- {{
- multilingualTextList[getLang()] &&
- multilingualTextList[getLang()][index] &&
- multilingualTextList[getLang()][index][1]
- ? multilingualTextList[getLang()][index][1]
- : ''
- }}
- </div>
- </div>
- </div>
- </el-collapse-transition>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { getNotesData, isEnable } from '@/views/book/courseware/data/notes';
- import PreviewMixin from '../common/PreviewMixin';
- import { GetFileURLMap } from '@/api/app';
- export default {
- name: 'NotesPreview',
- components: {},
- props: ['notesData'],
- mixins: [PreviewMixin],
- data() {
- return {
- data: this.notesData ? this.notesData : getNotesData(),
- wordShow: true,
- multilingualTextList: {}, // 多语言对应的切割后的翻译
- titleTrans: {},
- };
- },
- computed: {},
- watch: {
- 'data.option.length': {
- handler(val) {
- if (val) {
- // this.wordShow = isEnable(this.data.property.is_word_show);
- this.handleData();
- }
- },
- deep: true,
- immediate: true,
- },
- },
- created() {},
- methods: {
- handleChangeTab() {
- this.wordShow = !this.wordShow;
- },
- handleData() {
- if (this.showLang) {
- this.data.multilingual.forEach((item) => {
- let trans_arr = item.translation.split('\n');
- this.$set(this.titleTrans, item.type, trans_arr[0] ? trans_arr[0] : '');
- let chunkSize = 2;
- let chunkedArr = trans_arr.splice(1).reduce((acc, curr, index) => {
- // 当索引是chunkSize的倍数时,开始一个新的子数组
- if (index % chunkSize === 0) {
- acc.push([curr]); // 开始新的子数组并添加当前元素
- } else {
- acc[acc.length - 1].push(curr); // 将当前元素添加到最后一个子数组中
- }
- return acc;
- }, []);
- this.$set(this.multilingualTextList, item.type, chunkedArr);
- });
- }
- this.data.option.forEach((item) => {
- if (item.file_list && item.file_list[0]) {
- GetFileURLMap({ file_id_list: item.file_list }).then(({ url_map }) => {
- this.$set(item, 'pic_url', url_map[item.file_list[0]]);
- });
- }
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- @use '@/styles/mixin.scss' as *;
- .notes-preview {
- @include preview-base;
- .NPC-zhedie {
- // margin-bottom: 24px;
- .topTitle {
- display: flex;
- justify-content: space-between;
- width: 100%;
- height: 48px;
- padding-right: 16px;
- padding-left: 24px;
- overflow: hidden;
- background: #e35454;
- border: 1px solid rgba(0, 0, 0, 10%);
- border-radius: 8px 8px 0 0;
- :deep p {
- margin: 0;
- }
- .NPC-top-left {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- .NPC-topTitle-text {
- margin: 0 8px 0 0;
- font-family: 'sourceR';
- font-size: 16px;
- font-weight: bold;
- color: #fff;
- }
- }
- .NPC-top-right {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- cursor: pointer;
- &-text {
- font-size: 14px;
- font-weight: normal;
- line-height: 16px;
- color: #fff;
- }
- img {
- width: 16px;
- height: 16px;
- margin-left: 4px;
- }
- }
- .rotate {
- animation-name: firstrotate;
- animation-timing-function: linear;
- animation-direction: 2s;
- animation-fill-mode: both;
- }
- }
- .NPC-notes-list {
- padding: 24px 24px 5px;
- border: 1px solid rgba(0, 0, 0, 10%);
- border-top: none;
- border-radius: 0 0 8px 8px;
- .NPC-notes {
- width: 100%;
- margin-bottom: 24px;
- :deep p {
- margin: 0;
- }
- .NPC-notes-con {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- margin-bottom: 12px;
- > span {
- font-size: 14px;
- font-style: normal;
- font-weight: normal;
- line-height: 150%;
- color: #e35454;
- &.NPC-notes-con-number {
- font-family: 'robot';
- }
- &.NPC-notes-con-text {
- // flex: 1;
- margin: 0 5px;
- }
- }
- }
- .NPC-notes-trans {
- padding-left: 27px;
- margin-bottom: 12px;
- font-size: 14px;
- font-style: normal;
- font-weight: bold;
- line-height: 150%;
- color: #000;
- }
- .NPC-notes-note {
- font-size: 14px;
- font-style: normal;
- font-weight: normal;
- line-height: 150%;
- color: #000;
- text-indent: 27px;
- word-break: break-word;
- }
- }
- }
- .NPC-notes-note-img {
- width: 100%;
- > div {
- max-width: 100%;
- > img {
- max-width: 100%;
- }
- }
- }
- }
- @keyframes firstrotate {
- 0% {
- transform: rotateZ(0deg);
- }
- 100% {
- transform: rotateZ(180deg);
- }
- }
- @keyframes huifuRotate {
- 0% {
- transform: rotateZ(180deg);
- }
- 100% {
- transform: rotateZ(0deg);
- }
- }
- }
- </style>
|