123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <!-- -->
- <template>
- <div class="Big-Book-Single" v-if="curQue">
- <div class="Big-Book-Single-content" style="margin-top: 20px">
- <div class="adult-book-input-item">
- <span class="adult-book-lable">标题:</span>
- <el-input
- class="adult-book-input"
- :autosize="{ minRows: 2 }"
- placeholder="请输入标题"
- v-model="curQue.title"
- @blur="onBlur(curQue, 'title')"
- maxlength="500"
- show-word-limit
- ></el-input>
- </div>
- <div
- class="Big-Book-main"
- v-for="(curQueItem, index) in curQue.option"
- :key="'curQueItem' + index"
- style="border-bottom: 1px #ccc solid; margin-bottom: 20px"
- >
- <div class="adult-book-input-item">
- <span class="adult-book-lable">序号:</span>
- <el-input
- class="adult-book-input"
- :autosize="{ minRows: 2 }"
- placeholder="请输入内容"
- v-model="curQueItem.number"
- @blur="onBlur(curQueItem, 'number')"
- maxlength="200"
- show-word-limit
- ></el-input>
- <el-button type="danger" size="small" @click="deleteGroup()"
- >删除</el-button
- >
- </div>
- <div class="adult-book-input-item">
- <span class="adult-book-lable">内容:</span>
- <el-input
- class="adult-book-input"
- :autosize="{ minRows: 2 }"
- placeholder="请输入内容"
- v-model="curQueItem.con"
- @blur="onBlur(curQueItem, 'con')"
- maxlength="200"
- show-word-limit
- ></el-input>
- </div>
- <div class="adult-book-input-item">
- <span class="adult-book-lable">翻译:</span>
- <el-input
- class="adult-book-input"
- :autosize="{ minRows: 2 }"
- placeholder="请输入内容"
- v-model="curQueItem.interpret"
- @blur="onBlur(curQueItem, 'interpret')"
- maxlength="200"
- show-word-limit
- ></el-input>
- </div>
- <div class="adult-book-input-item">
- <span class="adult-book-lable">注释:</span>
- <el-input
- type="textarea"
- class="adult-book-input"
- :autosize="{ minRows: 2 }"
- placeholder="请输入内容"
- v-model="curQueItem.note"
- @blur="onBlur(curQueItem, 'note')"
- maxlength="200"
- show-word-limit
- ></el-input>
- </div>
- <div class="adult-book-input-item">
- <span class="adult-book-lable"></span>
- <Upload
- :changeFillId="changeImage"
- :datafileList="fileCon[index] && fileCon[index].img_list"
- :filleNumber="imgNumber"
- :uploadType="'image'"
- :index="index"
- />
- </div>
- </div>
- <div class="addoption" @click="addoption">添加注释</div>
- </div>
- </div>
- </template>
- <script>
- import Upload from "../common/Upload.vue";
- export default {
- name: "Single",
- props: ["curQue", "changeCurQue"],
- components: { Upload },
- data() {
- return {
- imgNumber: 10000,
- fileCon: [
- {
- img_list: [],
- mp3_list: [],
- },
- ],
- data_structure: {
- type: "notes_chs",
- name: "注释",
- title: "",
- option: [
- {
- number: "", //序号
- con: "", //内容
- interpret: "", //翻译
- note: "", //注释详情
- img_list: [],
- },
- ],
- },
- };
- },
- computed: {},
- watch: {},
- //方法集合
- methods: {
- onBlur(item, field) {
- item[field] = item[field] ? item[field].trim() : "";
- },
- addoption() {
- let res_data = JSON.parse(JSON.stringify(this.data_structure));
- let obj = res_data.option[0];
- this.curQue.option.push(obj);
- },
- deleteGroup(index) {
- if (this.curQue.option.length == 1) {
- this.$message.warning("至少剩余1个,不能全部删除");
- return;
- }
- this.curQue.option.splice(index, 1);
- },
- changeImage(fileList, duration, index) {
- 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: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
- };
- articleImgRes.push(obj);
- }
- });
- this.curQue.option[index].img_list = JSON.parse(
- JSON.stringify(articleImgRes)
- );
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {},
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {
- if (!this.curQue) {
- let res_data = JSON.parse(JSON.stringify(this.data_structure));
- this.changeCurQue(res_data);
- } else {
- let fileCon = [];
- this.curQue.option.forEach((item) => {
- let obj = { img_list: item.img_list };
- fileCon.push(obj);
- });
- this.fileCon = JSON.parse(JSON.stringify(fileCon));
- console.log(this.fileCon);
- }
- },
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {}, //生命周期 - 销毁之前
- destroyed() {}, //生命周期 - 销毁完成
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='scss' scope>
- //@import url(); 引入公共css类
- .Big-Book-Single {
- &-content {
- &.m {
- display: flex;
- justify-content: flex-start;
- align-items: flex-start;
- }
- .Big-Book-title {
- font-size: 16px;
- line-height: 40px;
- color: #000;
- margin-right: 15px;
- }
- .Big-Book-main {
- > div {
- margin-bottom: 10px;
- &.Big-Book-pinyin {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- }
- }
- }
- }
- .addoption {
- width: 565px;
- height: 40px;
- left: 40px;
- top: 304px;
- 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;
- }
- .Big-Book-con {
- display: flex;
- padding-bottom: 6px;
- border-bottom: 1px dashed rgba(0, 0, 0, 0.15);
- }
- }
- </style>
- <style lang="scss">
- </style>
|