123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <!-- -->
- <template>
- <div class="Big-Book-input">
- <div class="Big-Book-content m">
- <div class="Big-Book-main">
-
- <div class="Big-Book-en">
- <span>汉字:</span>
- <el-input
- style="width: 300px; margin-right: 10px"
- placeholder="请输入汉字"
- v-model="curQueItem.new_word"
- @blur="onBlur(curQueItem, 'new_word')"
- ></el-input>
- <el-button type="danger" size="small" @click="deleteGroup"
- >删除</el-button
- >
- </div>
- <div class="Big-Book-en">
- <span>拼音:</span>
- <el-input
- style="width: 300px; margin-right: 10px"
- placeholder="请输入拼音"
- v-model="curQueItem.pinyin"
- @blur="onBlur(curQueItem, 'pinyin')"
- ></el-input>
- <el-button type="primary" size="small" @click="getPinyin(curQueItem)"
- >生成拼音</el-button
- >
- </div>
- <div class="Big-Book-en">
- <span>词性:</span>
- <el-input
- style="width: 300px"
- placeholder="请输入词性"
- v-model="curQueItem.cixing"
- @blur="onBlur(curQueItem, 'cixing')"
- ></el-input>
- </div>
- <div class="Book_flex_start">
- <span>释义:</span>
- <div>
- <div
- class="Big-Book-en"
- v-for="(item, i) in curQueItem.definition_list"
- :key="i"
- >
- <el-input
- style="width: 300px"
- type="textarea"
- :autosize="{ minRows: 2, maxRows: 4 }"
- placeholder="请输入释义"
- v-model="curQueItem.definition_list[i]"
- @blur="trimEvent(i)"
- ></el-input>
- <img
- @click="deletecn(i)"
- class="close"
- src="../../../assets/adult/del-close.png"
- alt=""
- />
- </div>
- </div>
- </div>
- <div class="addoption" @click="Addcn">添加释义</div>
- <div class="Big-Book-mp3">
- <Upload
- :changeFillId="changeMp3"
- :datafileList="fileCon.mp3_list"
- :filleNumber="mp3Number"
- :uploadType="'mp3'"
- />
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Upload from "./Upload.vue";
- import "@/utils/pinyin_dict_withtone";
- import "@/utils/pinyinUtil";
- export default {
- components: {
- Upload,
- },
- props: ["curQueItem", "index", "type", "deleteGroup"],
- data() {
- return {
- mp3Number: 1,
- fileCon: {
- img_list: [],
- mp3_list: [],
- },
- };
- },
- computed: {},
- watch: {},
- //方法集合
- methods: {
- onBlur(item, field) {
- item[field] = item[field] ? item[field].trim() : "";
- },
- trimEvent(i) {
- let str = this.curQueItem.definition_list[i].trim();
- this.$set(this.curQueItem.definition_list, i, str);
- },
- // 删除释义
- deletecn(index) {
- if (this.curQueItem.definition_list.length <= 1) {
- this.$message.warning("至少要保留一个");
- return;
- }
- this.curQueItem.definition_list.splice(index, 1);
- },
- // 点击生成拼音
- getPinyin(item) {
- console.log(item);
- let bool = false;
- let value = "";
- if (item.new_word == "") {
- this.$message.info("请先输入内容,再生成拼音");
- bool = true;
- } else {
- value = item.new_word;
- }
- if (bool) {
- return;
- }
- let result = pinyinUtil.getPinyin(value);
- item.pinyin = result;
- },
- // 添加释义
- Addcn() {
- this.curQueItem.definition_list.push("");
- },
- changeMp3(fileList) {
- const articleImgList = JSON.parse(JSON.stringify(fileList));
- const articleImgRes = [];
- articleImgList.forEach((item) => {
- if (item.response) {
- const obj = {
- name: item.name,
- url: item.response.file_info_list[0].file_url,
- id: item.response.file_info_list[0].file_id,
- media_duration: item.response.file_info_list[0].media_duration,
- file_relative_path:
- item.response.file_info_list[0].file_relative_path,
- };
- articleImgRes.push(obj);
- }
- });
- //this.articleImgList = articleImgRes;
- this.curQueItem.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
- },
- changeImage(fileList) {
- console.log(fileList);
- const articleImgList = JSON.parse(JSON.stringify(fileList));
- const articleImgRes = [];
- articleImgList.forEach((item) => {
- if (item.response) {
- const obj = {
- name: item.name,
- url: item.response.file_info_list[0].file_url,
- id: item.response.file_info_list[0].file_id,
- file_relative_path: file_relative_path,
- };
- articleImgRes.push(obj);
- }
- });
- //this.articleImgList = articleImgRes;
- this.curQueItem.img_list = JSON.parse(JSON.stringify(articleImgRes));
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- if (this.curQueItem) {
- this.fileCon.img_list = this.curQueItem.img_list;
- this.fileCon.mp3_list = this.curQueItem.mp3_list;
- }
- },
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {}, //生命周期 - 销毁之前
- destroyed() {}, //生命周期 - 销毁完成
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='scss' scoped>
- //@import url(); 引入公共css类
- .Big-Book-input {
- .Big-Book-content {
- &.m {
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
- }
- .Big-Book-con {
- display: flex;
- align-items: center;
- }
- .Big-Book-title {
- font-size: 16px;
- line-height: 40px;
- color: #000;
- margin-right: 15px;
- }
- .Big-Book-main {
- position: relative;
- width: 100%;
- > div {
- margin-bottom: 10px;
- &.Big-Book-pinyin,
- &.Big-Book-con,
- &.Big-Book-en {
- margin-bottom: 8px;
- span {
- width: 60px;
- text-align: right;
- }
- }
- &.Big-Book-yb {
- display: flex;
- align-items: flex-start;
- span {
- width: 60px;
- text-align: right;
- }
- }
- }
- .close {
- width: 24px;
- cursor: pointer;
- }
- }
- }
- .addoption {
- width: 148px;
- height: 40px;
- background: #f3f3f3;
- border: 1px dashed rgba(0, 0, 0, 0.15);
- box-sizing: border-box;
- border-radius: 4px;
- text-align: center;
- line-height: 40px;
- cursor: pointer;
- font-size: 14px;
- color: #000000;
- margin-top: 20px;
- }
- }
- </style>
|