123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658 |
- <template>
- <div :class="['writeTable']" v-if="data" v-loading="loading">
- <div class="writeTop" :class="[data.fileList ? 'writeTop-nopadding' : '']">
- <template v-if="data.fileList">
- <UploadDrag
- :fileList="data.fileList"
- @changeFillId="changeFillId"
- v-if="data.fileList.length === 0"
- :disabled="is_preview"
- ></UploadDrag>
- <div class="item-image" v-else>
- <el-image
- style="width: 593px; height: 224px"
- :src="data.fileList[0].fileUrl"
- :preview-src-list="[data.fileList[0].fileUrl]"
- fit="cover"
- />
- <span v-if="!is_preview" class="item-image-del" @click="handleDeleteImg"><i class="el-icon-delete"></i></span>
- </div>
- <div class="item-info">
- <template v-if="data.hz_info.length === 1">
- <div class="item-info-left">
- <p v-if="dataConfig.wordPinyin || dataConfig.wordVoice" class="voice-box">
- <AudioPlay :file-id="audio_file" v-if="audio_file" />
- <span v-if="dataConfig.wordPinyin">{{ data.pinyin }}</span>
- </p>
- <div class="hz-box">
- <Strockplay
- className="adult-strockplay"
- :strokePlayColor="dataConfig.borderColor"
- :Book_text="itemh.con"
- :playStorkes="dataConfig.playStorkes"
- :strokeColor="dataConfig.fontColor"
- :palyWidth="dataConfig.playWidth"
- :BoxbgType="dataConfig.BoxbgType"
- :curItem="itemh.hzDetail.hz_json"
- :targetDiv="'writeTops-item-' + pageNumber + '-' + indexh + '-' + itemh.con"
- :fontSize="fontSize"
- :class="[indexh !== 0 ? 'writeTop-item-noLeft' : '']"
- class="writeTop-item"
- v-for="(itemh, indexh) in data.hz_info"
- :key="indexh"
- />
- </div>
- </div>
- <div class="item-info-right">
- <p class="voice-box" v-if="dataConfig.wordPinyin || dataConfig.wordVoice"></p>
- <div class="item-info-row">
- <div class="item-info-half">
- <label>部首:</label>
- <div>{{ data.radical }}</div>
- </div>
- <div class="item-info-half">
- <label>笔画:</label>
- {{ data.hz_info[0].hzDetail.hz_json.medians.length }}
- </div>
- </div>
- <template v-if="is_preview">
- <div class="item-info-row">
- <div class="item-info-half">
- <label>释义:</label>
- {{ data.info.definition }}
- </div>
- <div class="item-info-half">
- <label>搭配:</label>
- {{ data.info.collocation }}
- </div>
- </div>
- <div class="item-info-row">
- <div class="item-info-all">{{ data.info.exampleSent }}</div>
- </div>
- </template>
- <template v-else>
- <div class="item-info-row">
- <el-input
- v-model="data.info.definition"
- placeholder="输入释义"
- @blur="changeInfoObj('definition')"
- ></el-input>
- <el-input
- v-model="data.info.collocation"
- placeholder="输入搭配"
- @blur="changeInfoObj('collocation')"
- ></el-input>
- </div>
- <div class="item-info-row">
- <el-input
- v-model="data.info.exampleSent"
- placeholder="输入例句"
- @blur="changeInfoObj('exampleSent')"
- ></el-input>
- </div>
- </template>
- </div>
- </template>
- <template v-else>
- <div class="item-info-left item-info-left-long">
- <p v-if="dataConfig.wordPinyin || dataConfig.wordVoice" class="voice-box">
- <AudioPlay :file-id="audio_file" v-if="audio_file" />
- <span v-if="dataConfig.wordPinyin">{{ data.pinyin }}</span>
- </p>
- <div class="hz-box" :style="{ margin: '0 auto 4px auto' }">
- <Strockplay
- className="adult-strockplay"
- :strokePlayColor="dataConfig.borderColor"
- :Book_text="itemh.con"
- :playStorkes="dataConfig.playStorkes"
- :strokeColor="dataConfig.fontColor"
- :palyWidth="dataConfig.playWidth"
- :BoxbgType="dataConfig.BoxbgType"
- :curItem="itemh.hzDetail.hz_json"
- :targetDiv="'writeTops-item-' + pageNumber + '-' + indexh + '-' + itemh.con"
- :fontSize="fontSize"
- :class="[indexh !== 0 ? 'writeTop-item-noLeft' : '']"
- class="writeTop-item writeTop-item-small"
- v-for="(itemh, indexh) in data.hz_info"
- :key="indexh"
- />
- </div>
- <template v-if="is_preview">
- <div class="item-info-row" :style="{ height: '48px' }">
- <div class="item-info-all">{{ data.info.definition }}</div>
- </div>
- </template>
- <el-input
- v-else
- type="textarea"
- v-model="data.info.definition"
- rows="2"
- placeholder="输入"
- @blur="changeInfoObj('definition')"
- ></el-input>
- </div>
- </template>
- </div>
- </template>
- <div
- class="writeTop-row"
- v-for="(itemR, indexR) in data.list"
- :key="'writeTop-' + indexR"
- :style="{ marginBottom: dataConfig.marginBottom }"
- >
- <div
- class="writeTop-item"
- :class="[indexI !== 0 ? 'writeTop-item-noLeft' : '']"
- v-for="(itemI, indexI) in itemR"
- :key="'writeTop-item' + indexI"
- :style="{
- width: dataConfig.width,
- height: dataConfig.width,
- borderColor: dataConfig.borderColor,
- }"
- >
- <template v-if="itemI && itemI.con && itemI.isPunctuation">
- <!-- 不是汉字的内容 -->
- <div class="punctuation-box">
- <div class="character-target-div">
- <svg-icon
- icon-class="tian"
- className="tian-bg"
- v-if="dataConfig.BoxbgType == 0"
- :style="{ color: '#DEDEDE' }"
- />
- <svg-icon
- icon-class="mi"
- className="tian-bg"
- v-if="dataConfig.BoxbgType == 1"
- :style="{ color: '#DEDEDE' }"
- />
- </div>
- <h3
- :style="{
- lineHeight: dataConfig.width,
- color: itemI.miaoRed ? dataConfig.writeColor : dataConfig.fontColor,
- fontSize: dataConfig.fontSize,
- }"
- >
- {{ itemI.con }}
- </h3>
- </div>
- </template>
- <template v-else-if="itemI && itemI.con && !itemI.write && !itemI.answer && !itemI.miaoRed">
- <Strockplay
- v-if="'writeTop-item-' + pageNumber + '-' + indexI + type"
- className="adult-strockplay"
- :strokePlayColor="dataConfig.borderColor"
- :Book_text="itemI.con"
- :playStorkes="dataConfig.playStorkes"
- :strokeColor="dataConfig.fontColor"
- :palyWidth="dataConfig.playWidth"
- :BoxbgType="dataConfig.BoxbgType"
- :curItem="itemI.hzDetail"
- :targetDiv="'writeTop-item-' + pageNumber + '-' + indexR + '-' + indexI + type + itemI.con"
- :fontSize="fontSize"
- />
- </template>
- <template v-else-if="itemI && itemI.answer">
- <StrockplayredlineTable
- :Book_text="itemI.con"
- :playStorkes="false"
- :strokeColorgray="dataConfig.miaoRedBgcolor"
- :strokeColor="dataConfig.fontColor"
- :strokeNumber="itemI.answer"
- :curItem="itemI.hzDetail"
- :BoxbgType="dataConfig.BoxbgType"
- :targetDiv="'write-item-miaohong-' + pageNumber + '-' + indexR + '-' + indexI + type + itemI.con"
- :targetDivGray="'write-item-miaohong-gray-' + pageNumber + '-' + indexR + '-' + indexI + type + itemI.con"
- :fontSize="fontSize"
- />
- </template>
- <template v-else-if="itemI && itemI.miaoRed">
- <Strockred
- v-if="'write-item-' + pageNumber + '-' + indexI + type"
- className="adult-strockplay"
- :strokePlayColor="dataConfig.borderColor"
- :Book_text="itemI.con"
- :curItem="itemI.hzDetail"
- :hanzicolor="dataConfig.miaoRedBgcolor"
- :drawingColor="dataConfig.writeColor"
- :BoxbgType="dataConfig.BoxbgType"
- :targetDiv="'write-item-' + pageNumber + '-' + indexR + '-' + indexI + type + itemI.con"
- :fontSize="fontSize"
- />
- </template>
- <div v-else-if="itemI" class="tian-div" @click="freeWrite(itemI, indexR, indexI)">
- <svg-icon
- icon-class="tian"
- className="tian"
- v-if="dataConfig.BoxbgType == 0"
- :style="{ color: '#DEDEDE' }"
- />
- <svg-icon icon-class="mi" className="tian" v-if="dataConfig.BoxbgType == 1" :style="{ color: '#DEDEDE' }" />
- <img v-if="itemI && itemI.strokes_image_url" :src="itemI.strokes_image_url" alt="" />
- </div>
- </div>
- </div>
- </div>
- <!-- <div class="writeBottom">
- <span>BLCUP 全球国际中文教学云平台</span>
- <b>{{ pageNumber + '/' + totalNumber }}</b>
- <a>www.chinesedu.com</a>
- </div> -->
- <div class="practiceBox practiceBoxStrock" v-if="ifFreeShow">
- <FreewriteLettle
- :changePraShow="changePraShow"
- ref="freePaint"
- :currenHzData="currenHzData"
- :rowIndex="activeIndex"
- :colIndex="activeColIndex"
- :closeifFreeShow="closeifFreeShow"
- @ExerciseChangeCurQue="ExerciseChangeCurQue"
- :BoxbgType="dataConfig.BoxbgType"
- :lineColor="dataConfig.writeColor"
- />
- </div>
- </div>
- </template>
- <script>
- //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
- import StrockplayredlineTable from '../../components/corpus/StrockplayredlineTable.vue';
- import Strockplay from '../../components/corpus/Strockplay.vue';
- import Strockred from '../../components/corpus/Strockred.vue';
- import FreewriteLettle from '../../components/corpus/FreewriteLettle.vue';
- import UploadDrag from './UploadDrag.vue';
- import AudioPlay from './AudioPlay.vue';
- const HanziWriter = require('hanzi-writer');
- import { getLogin } from '@/api/api';
- export default {
- //import引入的组件需要注入到对象中才能使用
- components: {
- StrockplayredlineTable,
- Strockplay,
- Strockred,
- FreewriteLettle,
- UploadDrag,
- AudioPlay,
- },
- props: [
- 'dataConfig',
- 'data',
- 'pageNumber',
- 'totalNumber',
- 'type',
- 'none',
- 'fontSize',
- 'audio_file_obj',
- 'is_preview',
- 'infoObj',
- ],
- data() {
- //这里存放数据
- return {
- ifFreeShow: false,
- activeIndex: null,
- activeColIndex: null,
- fileList: [],
- info: {
- definition: '',
- collocation: '',
- exampleSent: '',
- },
- writer: null,
- audio_file: '',
- loading: false,
- };
- },
- //计算属性 类似于data概念
- computed: {},
- //监控data中数据变化
- watch: {
- pageNumber: {
- handler: function (val, oldVal) {
- if (val != oldVal) {
- this.initHanziwrite();
- }
- },
- deep: true,
- },
- },
- //方法集合
- methods: {
- changePraShow() {
- this.ifFreeShow = false;
- },
- closeifFreeShow(data, rowIndex, colIndex) {
- this.ifFreeShow = false;
- this.$forceUpdate();
- },
- freeWrite(item, row, col) {
- this.ifFreeShow = true;
- this.activeIndex = row;
- this.activeColIndex = col;
- // this.currentHz = this.curQue.option[indexs].rightOption[rightindex].con;
- if (item) {
- this.currenHzData = item;
- } else {
- this.currenHzData = {};
- }
- },
- ExerciseChangeCurQue(answer, rowIndex, colIndex) {
- if (answer) {
- this.data.list[rowIndex][colIndex].strokes_image_url = answer.strokes_image_url;
- this.data.list[rowIndex][colIndex].history = answer.history;
- this.$forceUpdate();
- }
- },
- changeFillId(file, fileList) {
- let obj = {
- name: file.name,
- fileId: file.file_id,
- fileUrl: file.file_url_open,
- };
- this.data.fileList.push(obj);
- this.infoObj[this.data.con].fileList = [obj];
- },
- handleDeleteImg() {
- this.data.fileList = [];
- this.infoObj[this.data.con].fileList = [];
- },
- initHanziwrite() {
- // let _this = this;
- // let node = document.getElementById(`character-target-info-div` + _this.pageNumber);
- // if (node && node.children.length > 1) {
- // node.removeChild(node.children[1]);
- // }
- // _this.writer = HanziWriter.default.create(
- // `character-target-info-div` + _this.pageNumber,
- // _this.data.hz_info[0].con,
- // {
- // width: 22,
- // height: 22,
- // padding: 0,
- // radicalColor: '#000000',
- // strokeColor: '#fff',
- // },
- // );
- if (this.data.con) {
- this.loading = true;
- let MethodName = 'tool-TextToVoiceFile';
- let datas = {
- text: this.data.con,
- };
- getLogin(MethodName, datas)
- .then((res) => {
- this.loading = false;
- if (res.status === 1) {
- this.audio_file = res.file_id;
- }
- })
- .catch(() => {
- this.loading = false;
- });
- }
- },
- changeInfoObj(param) {
- this.infoObj[this.data.con][param] = this.data.info[param] ? this.data.info[param].trim() : '';
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {
- this.initHanziwrite();
- },
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- // let _this = this;
- // _this.$nextTick(() => {
- // if (_this.data.hz_info && _this.data.hz_info.length === 1) {
- // _this.initHanziwrite();
- // }
- // });
- },
- //生命周期-创建之前
- beforeCreated() {},
- //生命周期-挂载之前
- beforeMount() {},
- //生命周期-更新之前
- beforUpdate() {},
- //生命周期-更新之后
- updated() {},
- //生命周期-销毁之前
- beforeDestory() {},
- //生命周期-销毁完成
- destoryed() {},
- //如果页面有keep-alive缓存功能,这个函数会触发
- activated() {},
- };
- </script>
- <style lang="scss" scoped>
- .writeTable {
- background: #ffffff;
- border: 1px solid rgba(0, 0, 0, 0.08);
- width: 595px;
- height: 842px;
- box-sizing: border-box;
- .writeTop {
- height: 794px;
- padding-top: 48px;
- .item-image {
- position: relative;
- .item-image-del {
- position: absolute;
- top: 8px;
- right: 8px;
- width: 16px;
- height: 16px;
- display: block;
- cursor: pointer;
- background-color: #ffffff;
- color: #ee3232;
- padding: 8px;
- border-radius: 50%;
- box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
- }
- }
- .writeTop-row {
- display: flex;
- justify-content: center;
- }
- }
- .writeTop-nopadding {
- padding-top: 0;
- height: 842px;
- }
- .item-info {
- display: flex;
- width: 100%;
- padding: 0 46px 8px 46px;
- column-gap: 16px;
- box-sizing: border-box;
- &-left {
- .writeTop-item {
- width: 98px;
- height: 98px;
- :deep .strock-play-box {
- width: 18px !important;
- height: 18px !important;
- }
- :deep .playStorkes-btn {
- width: 18px !important;
- height: 18px !important;
- }
- &-small {
- width: 62px;
- height: 62px;
- :deep .strock-play-box {
- width: 11px !important;
- height: 11px !important;
- }
- :deep .playStorkes-btn {
- width: 11px !important;
- height: 11px !important;
- }
- }
- }
- &-long {
- width: 100%;
- }
- }
- &-right {
- flex: 1;
- }
- :deep .el-textarea__inner {
- resize: none;
- background-color: #f3f3f3;
- border: none;
- outline: none;
- }
- .voice-box {
- width: 100%;
- height: 32px;
- display: flex;
- align-items: center;
- justify-content: center;
- column-gap: 4px;
- img {
- width: 24px;
- height: 24px;
- }
- span {
- font-family: League;
- font-size: 16px;
- font-weight: 400;
- color: #de4444;
- }
- }
- .item-info-row {
- display: flex;
- column-gap: 11px;
- margin-bottom: 6px;
- :deep .el-input__inner {
- background-color: #f3f3f3;
- border: none;
- outline: none;
- height: 32px;
- }
- }
- .item-info-half,
- .item-info-all {
- width: 50%;
- display: flex;
- font-size: 14px;
- line-height: 22px;
- height: 22px;
- }
- .item-info-all {
- width: 100%;
- }
- }
- .hz-box {
- display: flex;
- width: max-content;
- }
- .writeTop-item {
- border: 1px solid #de4444;
- }
- .writeTop-item-noLeft {
- border-left: none;
- }
- .writeBottom {
- display: flex;
- width: 100%;
- justify-content: space-between;
- padding: 0 38px;
- box-sizing: border-box;
- position: relative;
- span {
- font-weight: 500;
- font-size: 10px;
- line-height: 14px;
- color: #000000;
- opacity: 0.2;
- }
- b {
- font-weight: 400;
- font-size: 14px;
- line-height: 14px;
- color: #000000;
- width: 60px;
- text-align: center;
- position: absolute;
- left: 50%;
- margin-left: -30px;
- top: 0px;
- }
- a {
- font-weight: 500;
- font-size: 12px;
- line-height: 14px;
- color: #000000;
- opacity: 0.2;
- }
- }
- .tian-div {
- width: 100%;
- height: 100%;
- position: relative;
- .tian {
- width: 100%;
- height: 100%;
- }
- img {
- width: 100%;
- height: 100%;
- position: absolute;
- left: 0;
- top: 0;
- }
- }
- .practiceBox {
- position: fixed;
- left: 0;
- top: 0;
- z-index: 100100;
- width: 100%;
- height: 100vh;
- background: rgba(0, 0, 0, 0.19);
- box-sizing: border-box;
- overflow: hidden;
- overflow-y: auto;
- &.practiceBoxStrock {
- display: flex;
- justify-content: center;
- align-items: center;
- padding-top: 0px;
- }
- }
- .punctuation-box {
- position: relative;
- width: 100%;
- height: 100%;
- .character-target-div {
- position: absolute;
- width: 100%;
- height: 100%;
- top: 0;
- left: 0;
- .svg-icon {
- width: 100%;
- height: 100%;
- }
- }
- h3 {
- position: absolute;
- width: 100%;
- height: 100%;
- top: 0;
- left: 0;
- font-family: FZJCGFKTK;
- text-align: center;
- font-weight: normal;
- }
- }
- }
- </style>
|