123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462 |
- <!-- -->
- <template>
- <div
- class="NNPE-Book-Article Big-Book-Maxwidth"
- v-if="curQue"
- v-loading="loading"
- >
- <div class="Big-Book-img">
- <UploadArt
- :change-fill-id="changeImage"
- :datafile-list="fileCon.img_list"
- upload-type="image"
- class="article_pdf"
- :filleNumber="imageNumber"
- />
- <ul
- class="uploadArt_list"
- v-if="curQue.img_list && curQue.img_list.length > 0"
- >
- <li
- v-for="(artItem, artIndex) in curQue.img_list"
- :key="'articleImgList' + artIndex"
- >
- <img :src="artItem.url" style="width: 26px" />
- <span class="art_name">{{ artItem.name }}</span>
- <p>
- 图片放到第<el-input
- class="imgNumber"
- type="number"
- v-model="artItem.imgNumber"
- size="mini"
- @input="forceUpdate"
- ></el-input
- >段落的后面
- </p>
- <img
- src="@/assets/adult/del-close.png"
- class="del-close"
- @click="delImage(artIndex)"
- />
- </li>
- </ul>
- </div>
- <div class="Big-Book-mp3">
- <Upload
- type="mp3"
- :changeFillId="changeMp3"
- :datafileList="fileCon.mp3_list"
- :filleNumber="mp3Number"
- :uploadType="'mp3'"
- />
- </div>
- <div
- class="NPC-dia-art-option"
- v-for="(item, index) in curQue.option"
- :key="'daChs' + index"
- >
- <!--对话角色-->
- <div class="NPC-da-role">
- <!-- <RoleChs :roleCon="item.role" /> -->
- <el-button type="primary" @click="editRole(item, index)"
- >编辑角色</el-button
- >
- </div>
- <!--对话内容-->
- <div class="NPC-da-article">
- <el-button type="primary" @click="editDialogue(item, index)"
- >编辑对话内容</el-button
- >
- </div>
- <!--标注信息-->
- <div class="NPC-da-tag">
- <el-button type="primary">编辑标注</el-button>
- </div>
- </div>
- <el-dialog title="段落分句字幕打点" :visible.sync="cTVisible" width="30%">
- <Createtimelist ref="createtimelist" :curQue="curQue" />
- <span slot="footer" class="dialog-footer">
- <el-button @click="cTVisible = false">取 消</el-button>
- <el-button type="primary" @click="saveTimeList">保 存</el-button>
- </span>
- </el-dialog>
- <el-dialog title="编辑角色" :visible.sync="isEditRole" width="60%">
- <template v-if="curOption">
- <RoleChs ref="roleChs" :curRole="curOption.role" />
- </template>
- <span slot="footer" class="dialog-footer">
- <el-button @click="isEditRole = false">取 消</el-button>
- <el-button type="primary" @click="saveRole">保 存</el-button>
- </span>
- </el-dialog>
- <el-dialog
- title="编辑对话内容"
- top="30px"
- :visible.sync="isEditDia"
- width="60%"
- >
- <template v-if="curOption">
- <el-steps
- :active="active"
- finish-status="success"
- simple
- style="margin-top: 20px"
- >
- <el-step title="对话内容"></el-step>
- <el-step title="分段结果"></el-step>
- <el-step title="分句结果"></el-step>
- <el-step title="分词结果"></el-step>
- </el-steps>
- <template v-if="active == 1">
- <ArticleChs
- ref="articleChs"
- :curOption="curOption"
- :changeActive="changeActive"
- />
- </template>
- <template v-if="active == 2">
- <ParagraphChs
- ref="articleChs"
- :curOption="curOption"
- :changeActive="changeActive"
- />
- </template>
- </template>
- <span slot="footer" class="dialog-footer">
- <el-button @click="isEditDia = false">取 消</el-button>
- <el-button type="primary" @click="saveDialogue">保 存</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { segSentences, BatchSegContent, createPinyin } from "@/api/ajax";
- const Base64 = require("js-base64").Base64;
- import Upload from "../../common/Upload.vue";
- import UploadArt from "../../common/UploadArt.vue";
- import ParagraphChs from "./components/ParagraphChs.vue";
- import Clauseresult from "./components/ClauseresultChs.vue";
- import Segbyword from "./components/SegbywordChs.vue";
- import Createtimelist from "./components/CreatetimelistChs.vue";
- import RoleChs from "./components/RoleChs.vue";
- import ArticleChs from "./components/ArticleChs.vue";
- export default {
- name: "DialogueArticleChs",
- components: {
- Upload,
- UploadArt,
- ParagraphChs,
- Clauseresult,
- Segbyword,
- Createtimelist,
- RoleChs,
- ArticleChs,
- },
- props: ["curQue", "changeCurQue", "tmIndex"],
- data() {
- return {
- imageNumber: 1000,
- mp3Number: 1,
- fileCon: {
- img_list: [],
- mp3_list: [],
- },
- isClause: false,
- isByWord: false,
- paraIndex: 0, //段落索引
- cTVisible: false,
- loading: false,
- segList: null,
- isEditRole: false,
- isEditDia: false,
- curOpIndex: -1,
- curOption: null,
- active: 1,
- data_structure: {
- type: "dialog_article_chs",
- name: "对话课文",
- model: 1,
- pyPosition: "top", //top 拼音在上面;bottom 拼音在下面
- title: "", //描述
- option: [
- {
- site: "left",
- role: {
- roleName: "",
- fullName: "",
- segList: [],
- seg_words: "",
- wordsList: [],
- namePinyin: "",
- },
- article: "",
- detail: [],
- },
- ],
- },
- };
- },
- computed: {},
- watch: {},
- //方法集合
- methods: {
- changeMp3(fileList) {
- const articleImgList = JSON.parse(JSON.stringify(fileList));
- const articleImgRes = [];
- articleImgList.forEach((item) => {
- if (item.response) {
- const obj = {
- name: item.name,
- duration: item.response.file_info_list[0].media_duration,
- url: item.response.file_info_list[0].file_url,
- id: "[FID##" + item.response.file_info_list[0].file_id + "#FID]",
- media_duration: item.response.file_info_list[0].media_duration, //音频时长
- };
- articleImgRes.push(obj);
- }
- });
- this.curQue.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
- },
- changeImage(file) {
- console.log(file);
- if (file.response) {
- const obj = {
- name: file.name,
- url: file.response.file_info_list[0].file_url,
- id: "[FID##" + item.response.file_info_list[0].file_id + "#FID]",
- imgNumber: 0,
- };
- this.curQue.img_list.push(obj);
- this.$forceUpdate();
- }
- },
- forceUpdate() {
- this.$forceUpdate();
- },
- delImage(index) {
- this.curQue.img_list.splice(index, 1);
- this.fileCon.img_list.splice(index, 1);
- },
- //生成分句
- sureSeg() {
- let detail = JSON.parse(JSON.stringify(this.curQue.detail));
- let leg = detail.length;
- let flag = false;
- for (let i = 0; i < leg; i++) {
- if (!detail[i].para) {
- flag = true;
- break;
- }
- }
- if (!flag) {
- let textList = [];
- detail.forEach((item) => {
- let str = Base64.encode(item.para);
- textList.push(str);
- });
- this.loading = true;
- let data = {
- text: textList,
- };
- segSentences(data).then((res) => {
- this.loading = false;
- let result = res.data.result;
- result.forEach((item, index) => {
- this.$set(this.curQue.detail[index], "sentences", item);
- });
- this.isClause = true;
- });
- } else {
- this.$message.warning("段落不能为空");
- }
- },
- changeIsClause(isClause) {
- this.isClause = isClause;
- },
- //生成分词
- segByWord(sentences, paraIndex) {
- console.log(sentences);
- this.loading = true;
- let textList = [];
- sentences.forEach((item) => {
- let str = Base64.encode(item);
- textList.push(str);
- });
- let data = {
- textList: textList,
- };
- BatchSegContent(data).then((res) => {
- this.paraIndex = paraIndex;
- this.loading = false;
- let list = res.data.result.list;
- this.$set(this.curQue.detail[paraIndex], "segList", list);
- this.segList = list;
- this.isByWord = true;
- });
- },
- uploadLRC() {
- this.cTVisible = true;
- },
- //保存字幕节点
- saveTimeList() {
- this.cTVisible = false;
- let detail = JSON.parse(JSON.stringify(this.$refs.createtimelist.detail));
- let detailRes = detail.map((item) => {
- let timeList = item.time_str.split("\n");
- item.timeList = this.handleTimeReg(timeList);
- return item;
- });
- this.curQue.detail = JSON.parse(JSON.stringify(detailRes));
- console.log(this.curQue.detail);
- },
- handleTimeReg(list) {
- list = list.map((item) => {
- let regArr = item.split("]");
- let reg = regArr[0];
- item = reg.replace("[", "");
- return item;
- });
- return list;
- },
- //点击字幕节点
- editTimeList() {
- this.cTVisible = true;
- },
- initCurQueData() {
- let res_data = JSON.parse(JSON.stringify(this.data_structure));
- this.changeCurQue(res_data);
- },
- //编辑角色
- editRole(item, index) {
- this.isEditRole = true;
- this.curOption = item;
- this.curOpIndex = index;
- },
- //保存角色
- saveRole() {
- this.isEditRole = false;
- console.log(this.curQue);
- },
- //编辑对话内容
- editDialogue(item, index) {
- this.isEditDia = true;
- this.curOption = item;
- this.curOpIndex = index;
- },
- //保存对话内容
- saveDialogue() {},
- changeActive(active) {
- this.active = active;
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- console.log("ArticleTem");
- console.log(this.curQue);
- if (this.curQue) {
- // if (this.curQue.detail[0].sentences.length > 0) {
- // this.isClause = true;
- // }
- // if (this.curQue.detail[0].seg_words.length > 0) {
- // this.isByWord = true;
- // }
- // if (!this.curQue.img_list) {
- // this.curQue.img_list = [];
- // }
- // if (!this.curQue.mp3_list) {
- // this.curQue.mp3_list = [];
- // }
- // this.fileCon.img_list = JSON.parse(JSON.stringify(this.curQue.img_list));
- // this.fileCon.mp3_list = JSON.parse(JSON.stringify(this.curQue.mp3_list));
- } else {
- this.initCurQueData();
- }
- },
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {}, //生命周期 - 销毁之前
- destroyed() {}, //生命周期 - 销毁完成
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='scss' scoped>
- //@import url(); 引入公共css类
- p {
- margin: 0;
- padding: 0;
- }
- .uploadArt_list {
- border: 1px #ccc solid;
- border-bottom: 0;
- margin-top: 10px;
- > li {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- border-bottom: 1px #ccc solid;
- > span {
- width: 320px;
- word-wrap: break-word;
- font-size: 14px;
- color: rgb(112, 110, 110);
- border-right: 1px #ccc solid;
- padding: 5px 10px;
- }
- > p {
- flex: 1;
- padding: 5px 10px;
- }
- .imgNumber {
- width: 80px;
- }
- .del-close {
- width: 24px;
- height: 24px;
- cursor: pointer;
- margin-right: 10px;
- }
- }
- }
- .NNPE-Book-Article {
- > div {
- margin-bottom: 20px;
- }
- }
- .NNPE-Book-model {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- > span {
- margin: 0;
- }
- }
- .lrc-box {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- > span {
- font-size: 14px;
- margin-right: 16px;
- }
- }
- .NPC-dia-art-option {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- > div {
- margin-right: 10px;
- cursor: pointer;
- }
- }
- </style>
|