| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600 |
- <template>
- <div class="check-article">
- <div class="main">
- <div class="main-top">
- <div style="display: flex">
- <b>校对样式</b>
- </div>
- <!-- <div class="btn-box">
- <el-button type="primary" @click="savePinyin">保存</el-button>
- </div> -->
- </div>
- <div class="article">
- <div v-for="(item, index) in indexArr" :key="index + 'paragraph'" class="paragraph">
- <div v-for="(items, indexs) in item" :key="indexs + 'words'" class="sentence-box">
- <div
- class="sentence"
- :style="{
- marginRight: items.marginRight ? '8px' : '',
- color: activeIndex === index + '_' + items.sentenceIndex + '_' + items.wordIndex ? '#F2555A' : '',
- }"
- @click="selectItem(items, index)"
- >
- <span
- class="words"
- :class="[/^[0-9]*$/.test(items.text)] ? (/^[\u4e00-\u9fa5]/.test(items.text) ? 'hanzi' : 'en') : ''"
- :style="{
- fontFamily: items.fontFamily,
- color: items.color,
- textDecoration: items.textDecoration,
- borderBottom: items.border === 'dotted' ? '1px dotted' : '',
- fontWeight: items.fontWeight,
- }"
- >
- {{ items.text }}
- </span>
- </div>
- </div>
- </div>
- </div>
- </div>
- <el-dialog
- v-if="dialogFlag"
- :visible.sync="dialogFlag"
- :show-close="false"
- :close-on-click-modal="false"
- :modal-append-to-body="false"
- :modal="false"
- width="400px"
- class="login-dialog"
- >
- <div class="check-box">
- <div class="content">
- <div class="words-box">
- <span
- class="words"
- :style="{
- fontFamily: itemActive.fontFamily,
- color: itemActive.color,
- textDecoration: itemActive.textDecoration,
- borderBottom: itemActive.border === 'dotted' ? '1px dotted' : '',
- fontWeight: itemActive.fontWeight,
- }"
- >
- {{ itemActive.text }}
- </span>
- </div>
- </div>
- <div ref="toolbarMenu" class="toolbar">
- <el-select v-model="itemActive.fontFamily" placeholder="请选择">
- <el-option v-for="item in fontFamilyList" :key="item.value" :label="item.name" :value="item.value" />
- </el-select>
- <span class="picker-area" :class="['tool-item', itemActive.color ? 'active' : '']">
- <el-color-picker
- ref="colorPicker"
- v-model="itemActive.color"
- @click="itemActive.color = itemActive.color"
- />
- <SvgIcon icon-class="fontcolor" title="字体颜色" size="18" />
- </span>
- <span :class="['tool-item', itemActive.textDecoration === 'underline' ? 'active' : '']">
- <SvgIcon icon-class="underline" title="下划线" size="18" @click="setActiveTextStyle('underline')" />
- </span>
- <span :class="['tool-item', itemActive.fontWeight === 'bold' ? 'active' : '']">
- <SvgIcon icon-class="bold" title="加粗" size="20" @click="setActiveTextStyle('bold')" />
- </span>
- <span :class="['tool-item', itemActive.textDecoration === 'line-through' ? 'active' : '']">
- <SvgIcon icon-class="strikethrough" title="删除线" size="20" @click="setActiveTextStyle('line-through')" />
- </span>
- <span :class="['tool-item', itemActive.border === 'dotted' ? 'active' : '']">
- <SvgIcon icon-class="borderDotted" title="下划虚线" size="16" @click="setActiveTextStyle('border')" />
- </span>
- </div>
- <div class="match-info">
- <label>关联生词:</label>
- <el-input
- v-model="itemActive.matchWords"
- placeholder="请输入生词表的“生词/短语”"
- @blur="onBlur(itemActive, 'matchWords')"
- ></el-input>
- </div>
- <div class="match-info">
- <label>关联注释:</label>
- <el-input
- v-model="itemActive.matchNotes"
- placeholder="请输入注释表的“内容”"
- @blur="onBlur(itemActive, 'matchNotes')"
- ></el-input>
- <el-color-picker v-model="itemActive.notesColor"></el-color-picker>
- </div>
- <div class="btn-box">
- <el-button type="info" size="small" @click="cancleDialog">取消</el-button>
- <el-button type="primary" size="small" @click="surePinyin">保存</el-button>
- </div>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- // import { publicMethods, reparse } from '@/api/api';
- import { fileUpload } from '@/api/app';
- export default {
- components: {},
- props: ['data'],
- data() {
- return {
- loading: false,
- id: '',
- ArticelData: null,
- indexArr: [], // 索引数组
- activeIndex: null,
- itemActive: null,
- dialogFlag: false,
- checkPinyinInput: '',
- oldInput: '',
- toneList: [' ', 'ˉ', 'ˊ', 'ˇ', 'ˋ'],
- fontFamilyList: [
- {
- value: '楷体, 微软雅黑',
- name: '楷体',
- },
- {
- value: '黑体, 微软雅黑',
- name: '黑体',
- },
- {
- value: '宋体, 微软雅黑',
- name: '宋体',
- },
- {
- value: 'arial, helvetica, sans-serif',
- name: 'Arial',
- },
- {
- value: 'times new roman, times, serif',
- name: 'Times New Roman',
- },
- {
- value: 'League',
- name: '拼音',
- },
- // {
- // value: 'Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, sans-serif, alabo',
- // name: '系统字体',
- // },
- ],
- };
- },
- // 生命周期 - 创建完成(可以访问当前this实例)
- created() {
- this.getArticleData();
- },
- methods: {
- onBlur(item, field) {
- item[field] = item[field] ? item[field].trim() : '';
- },
- // 获取分析结果
- getArticleData() {
- this.loading = true;
- let newdata = [];
- this.data.detail.forEach((item) => {
- if (item.wordsList.length !== 0 || (item.noticeWordList && item.noticeWordList.length !== 0)) {
- newdata.push(item);
- }
- });
- // this.ArticelData = JSON.parse(JSON.stringify(newdata));
- let saveArr = [];
- let arr = [];
- let saveIndex = 0;
- // 添加索引
- newdata.forEach((item, index) => {
- arr.push([]);
- if (item.wordsList.length > 0) {
- item.wordsList.forEach((items, indexs) => {
- items.forEach((itemss, indexss) => {
- let obj = {
- text: itemss.chs,
- paraIndex: item.paraIndex,
- sentenceIndex: indexs,
- wordIndex: indexss,
- marginRight: true,
- saveIndex,
- fontFamily: itemss.fontFamily,
- textDecoration: itemss.textDecoration,
- fontWeight: itemss.fontWeight,
- border: itemss.border,
- color: itemss.color,
- matchWords: itemss.matchWords,
- matchNotes: itemss.matchNotes,
- notesColor: itemss.notesColor,
- img: itemss.img,
- imgPosition: itemss.imgPosition,
- };
- arr[index].push(obj);
- let saveObj = {
- word: itemss.chs,
- // pinyin_lt: itemss.pinyin_lt?itemss.pinyin_lt:''
- };
- saveArr.push(saveObj);
- saveIndex++;
- });
- });
- } else {
- item.noticeWordList.forEach((items, indexs) => {
- items.forEach((itemss, indexss) => {
- let obj = {
- text: itemss.chs,
- paraIndex: item.paraIndex,
- sentenceIndex: indexs,
- wordIndex: indexss,
- marginRight: true,
- saveIndex,
- fontFamily: itemss.fontFamily,
- textDecoration: itemss.textDecoration,
- fontWeight: itemss.fontWeight,
- border: itemss.border,
- color: itemss.color,
- matchWords: itemss.matchWords,
- matchNotes: itemss.matchNotes,
- notesColor: itemss.notesColor,
- img: itemss.img,
- imgPosition: itemss.imgPosition,
- };
- arr[index].push(obj);
- let saveObj = {
- word: itemss.chs,
- // pinyin_lt: itemss.pinyin_lt?itemss.pinyin_lt:''
- };
- saveArr.push(saveObj);
- saveIndex++;
- });
- });
- }
- });
- this.indexArr = arr;
- this.ArticelData = saveArr;
- this.loading = false;
- },
- selectItem(item, index) {
- this.activeIndex = `${index}_${item.sentenceIndex}_${item.wordIndex}`;
- this.itemActive = item;
- this.dialogFlag = true;
- this.checkPinyinInput = '';
- },
- cancleDialog() {
- this.activeIndex = null;
- this.itemActive = null;
- this.checkPinyinInput = '';
- this.oldInput = '';
- this.dialogFlag = false;
- },
- surePinyin() {
- this.saveStyle();
- this.dialogFlag = false;
- },
- saveStyle() {
- this.$emit(
- 'saveStyle',
- this.itemActive.paraIndex,
- this.itemActive.sentenceIndex,
- this.itemActive.wordIndex,
- this.itemActive.fontFamily,
- this.itemActive.textDecoration,
- this.itemActive.fontWeight,
- this.itemActive.border,
- this.itemActive.color,
- this.itemActive.matchWords,
- this.itemActive.matchNotes,
- this.itemActive.notesColor,
- this.itemActive.img,
- this.itemActive.imgPosition,
- );
- this.$message.success('保存成功');
- this.activeIndex = null;
- // this.itemActive = null;
- this.dialogFlag = false;
- },
- // 设置样式
- setActiveTextStyle(type) {
- let style = this.itemActive;
- if (type === 'line-through') {
- style.textDecoration = style.textDecoration === 'line-through' ? '' : 'line-through';
- this.$set(this.itemActive, 'textDecoration', style.textDecoration);
- } else if (type === 'bold') {
- style.fontWeight = style.fontWeight === 'bold' ? '' : 'bold';
- this.$set(this.itemActive, 'fontWeight', style.fontWeight);
- } else if (type === 'underline') {
- style.textDecoration = style.textDecoration === 'underline' ? '' : 'underline';
- this.$set(this.itemActive, 'textDecoration', style.textDecoration);
- } else if (type === 'border') {
- style.border = style.border === 'dotted' ? '' : 'dotted';
- this.$set(this.itemActive, 'border', style.border);
- }
- },
- // 处理超出图片个数操作
- handleExceed(files, fileList) {
- this.$message.warning(
- `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`,
- );
- },
- // 图片上传前处理
- handleBeforeImage(file) {
- // 判断文件是否为图片
- if (!file.type.includes('image')) {
- this.$message.error('请选择图片文件');
- return false;
- }
- },
- // 图片上传
- handleImage(file) {
- fileUpload('Mid', file, { isGlobalprogress: true }).then(({ file_info_list }) => {
- if (file_info_list.length > 0) {
- this.itemActive.img = file_info_list;
- this.itemActive.img[0].name = file_info_list[0].file_name;
- }
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .check-article {
- min-height: 100%;
- background: #f6f6f6;
- .wheader {
- background: #fff;
- }
- .el-button {
- padding: 5px 16px;
- font-size: 14px;
- font-weight: 400;
- line-height: 22px;
- color: #4e5969;
- background: #f2f3f5;
- border: 1px solid #f2f3f5;
- border-radius: 2px;
- &.el-button--primary {
- color: #fff;
- background: #165dff;
- border: 1px solid #165dff;
- }
- }
- .main {
- background: #fff;
- &-top {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 24px;
- b {
- margin-left: 16px;
- font-size: 24px;
- font-weight: 500;
- line-height: 34px;
- color: #000;
- }
- }
- .go-back {
- display: flex;
- align-items: center;
- width: 60px;
- padding: 5px 8px;
- font-size: 14px;
- font-weight: 400;
- line-height: 22px;
- color: #333;
- cursor: pointer;
- background: #fff;
- border: 1px solid #d9d9d9;
- border-radius: 4px;
- box-shadow: 0 2px 0 0 rgba(0, 0, 0, 2%);
- .el-icon-arrow-left {
- margin-right: 8px;
- font-size: 16px;
- }
- }
- .article {
- padding: 8px;
- background: #fcfcfc;
- border: 1px solid rgba(0, 0, 0, 8%);
- border-radius: 2px;
- }
- .paragraph {
- display: flex;
- flex-flow: wrap;
- width: 100%;
- margin-bottom: 24px;
- text-align: center;
- .sentence-box {
- display: flex;
- flex-flow: wrap;
- float: left;
- .sentence {
- margin-top: 8px;
- color: #000;
- text-align: center;
- cursor: pointer;
- .words {
- display: block;
- font-size: 20px;
- font-weight: 400;
- line-height: 28px;
- }
- .pinyin {
- display: block;
- height: 14px;
- font-family: 'League';
- font-size: 14px;
- font-weight: 400;
- line-height: 1;
- }
- }
- }
- }
- }
- }
- .check-box {
- padding: 24px;
- background: #fff;
- border-radius: 4px;
- box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 25%);
- .content {
- display: flex;
- align-items: center;
- justify-content: center;
- .words-box {
- color: #000;
- text-align: center;
- .words {
- display: block;
- font-size: 28px;
- font-weight: 400;
- line-height: 40px;
- }
- .pinyin {
- display: block;
- height: 20px;
- font-family: 'League';
- font-size: 20px;
- font-weight: 400;
- line-height: 1;
- }
- }
- }
- .checkPinyinInput {
- margin: 16px 0 8px;
- }
- .tips {
- margin: 0 0 24px;
- font-size: 12px;
- font-weight: 400;
- line-height: 18px;
- color: #a0a0a0;
- }
- .btn-box {
- text-align: right;
- .el-button {
- padding: 2px 12px;
- font-size: 12px;
- line-height: 20px;
- }
- }
- }
- .toolbar {
- display: flex;
- column-gap: 10px;
- align-items: center;
- margin: 10px 0;
- cursor: pointer;
- .picker-area {
- position: relative;
- :deep .el-color-picker {
- position: absolute;
- &__trigger {
- border: none;
- }
- &__color {
- border: none !important;
- &-inner {
- background-color: rgba(0, 0, 0, 0%) !important;
- }
- }
- &__icon {
- display: none !important;
- }
- }
- }
- .tool-item {
- padding: 4px 6px;
- border-radius: 8px;
- &.active {
- background: #a6ccf7;
- }
- }
- }
- .match-info {
- display: flex;
- align-items: center;
- margin: 10px 0;
- label {
- width: 100px;
- }
- }
- .remark-box {
- display: flex;
- gap: 8px;
- align-items: center;
- justify-content: center;
- width: fit-content;
- height: 24px;
- padding: 2px 12px;
- font-size: 12px;
- font-weight: 400;
- line-height: 20px; /* 166.667% */
- color: #165dff;
- cursor: pointer;
- border: 1px solid #165dff;
- border-radius: 2px;
- }
- </style>
- <style lang="scss">
- .check-article {
- .login-dialog {
- .el-dialog__header {
- padding: 0;
- }
- .el-dialog__body {
- padding: 0;
- }
- .el-input__inner {
- text-align: center;
- background: #f3f3f3;
- }
- }
- .el-color-picker__empty {
- display: none;
- }
- }
- </style>
|