123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- <!-- -->
- <template>
- <div class="Big-Book-PurePreview" v-if="curQue">
- <div
- class="Big-Book-Single-content"
- style="margin-left: 20px; margin-top: 20px"
- >
- <div class="adult-book-input-item">
- <span class="adult-book-lable">标题:</span>
- <el-input
- class="adult-book-input"
- type="textarea"
- :autosize="{ minRows: 2 }"
- placeholder="请输入标题"
- v-model="curQue.title"
- @blur="onBlur(curQue, 'title')"
- ></el-input>
- </div>
- <div v-for="(item, Cindex) in curQue.con" :key="'con' + Cindex">
- <div class="adult-book-input-item">
- <span class="adult-book-lable">内容标题:</span>
- <el-input
- class="adult-book-input"
- type="textarea"
- :autosize="{ minRows: 2 }"
- placeholder="请输入内容标题"
- v-model="item.title"
- @blur="onBlur(item, 'title')"
- ></el-input>
- <img
- @click="deleteCon(Cindex)"
- class="close"
- src="../../../assets/adult/del-close.png"
- alt=""
- />
- </div>
- <div class="adult-book-input-item">
- <span class="adult-book-lable">内容文本:</span>
- <el-input
- class="adult-book-input"
- type="textarea"
- :autosize="{ minRows: 2 }"
- placeholder="请输入内容"
- v-model="item.con"
- @blur="onBlur(item, 'con')"
- ></el-input>
- </div>
- </div>
- <div class="addoption" @click="addCon">添加一个内容</div>
- <div v-for="(item, Oindex) in curQue.option" :key="'op' + Oindex">
- <div class="adult-book-input-item">
- <span class="adult-book-lable">选项:</span>
- <el-input
- class="adult-book-input"
- type="textarea"
- :autosize="{ minRows: 2 }"
- placeholder="请输入选项内容"
- v-model="item.con"
- @blur="onBlur(item, 'con')"
- ></el-input>
- <img
- @click="deleteOptionOne(Oindex)"
- class="close"
- src="../../../assets/adult/del-close.png"
- alt=""
- />
- </div>
- </div>
- <div class="addoption" @click="addOption">添加一个选项</div>
- <div v-for="(item, awindex) in curQue.answer" :key="'aw' + awindex">
- <div class="adult-book-input-item">
- <span class="adult-book-lable">答案:</span>
- <el-input
- class="adult-book-input"
- type="textarea"
- :autosize="{ minRows: 2 }"
- placeholder="请输入答案"
- v-model="item.con"
- @blur="onBlur(item, 'con')"
- ></el-input>
- <img
- @click="deleteAnswer(awindex)"
- class="close"
- src="../../../assets/adult/del-close.png"
- alt=""
- />
- </div>
- </div>
- <div class="addoption" @click="addAnswer">添加一个答案</div>
- </div>
- </div>
- </template>
- <script>
- import Upload from "../common/Upload";
- import SentenceSegwordChs from "../common/SentenceSegwordChs/index.vue";
- export default {
- name: "PurePreview",
- props: ["curQue", "fn_data", "changeCurQue", "type"],
- components: {
- SentenceSegwordChs,
- Upload,
- },
- data() {
- return {
- checkList: [],
- mp3Number: 1,
- form: {
- stem: {
- con: "",
- pinyin: "",
- english: "",
- highlight: "",
- underline: "",
- img_url: [],
- mp3_url: [],
- },
- },
- data_structure: {
- type: "选择填空控件",
- name: "select_input_chs",
- title: "",
- option: [
- {
- con: "",
- },
- ],
- con: [
- {
- title: "",
- con: "",
- },
- ],
- answer: [
- {
- con: "",
- },
- ],
- },
- };
- },
- computed: {},
- watch: {},
- //方法集合
- methods: {
- onBlur(item, field) {
- item[field] = item[field] ? item[field].trim() : "";
- },
- deleteCon(index) {
- this.$confirm("确定要删除吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- if (this.curQue.con.length <= 1) {
- this.$message.warning("至少要保留1个内容");
- return;
- }
- this.curQue.con.splice(index, 1);
- })
- },
- addCon() {
- let obj = JSON.parse(JSON.stringify(this.data_structure.con[0]));
- this.curQue.con.push(obj);
- },
- // 删除其中一个选项
- deleteOptionOne(index) {
- this.$confirm("确定要删除吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- if (this.curQue.option.length <= 1) {
- this.$message.warning("至少要保留1个选项");
- return;
- }
- this.curQue.option.splice(index, 1);
- })
- },
- // 新增选项
- addOption() {
- let obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
- this.curQue.option.push(obj);
- },
- // 添加答案
- addAnswer() {
- let obj = JSON.parse(JSON.stringify(this.data_structure.answer[0]));
- this.curQue.answer.push(obj);
- },
- // 删除其中一个答案
- deleteAnswer(index) {
- this.$confirm("确定要删除吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- if (this.curQue.answer.length <= 1) {
- this.$message.warning("至少要保留1个答案");
- return;
- }
- this.curQue.answer.splice(index, 1);
- })
- },
- initcurQue() {
- let data = JSON.parse(JSON.stringify(this.data_structure));
- this.changeCurQue(data);
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {
- if (!this.curQue) {
- this.initcurQue();
- }
- },
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {},
- beforeCreate() {}, //生命周期 - 创建之前
- beforeMount() {}, //生命周期 - 挂载之前
- beforeUpdate() {}, //生命周期 - 更新之前
- updated() {}, //生命周期 - 更新之后
- beforeDestroy() {}, //生命周期 - 销毁之前
- destroyed() {}, //生命周期 - 销毁完成
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
- };
- </script>
- <style lang='scss' scope>
- //@import url(); 引入公共css类
- .Big-Book-PurePreview {
- &-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: 200px;
- 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-addrole {
- > div {
- width: 300px;
- 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;
- }
- }
- .Big-Book-more {
- .Big-Book-more-text {
- position: relative;
- text-align: center;
- }
- .Big-Book-more-text:before,
- .Big-Book-more-text:after {
- position: absolute;
- background: #ccc;
- content: "";
- height: 1px;
- top: 50%;
- width: 45%;
- }
- .Big-Book-more-text:before {
- left: 10px;
- }
- .Big-Book-more-text:after {
- right: 10px;
- }
- .Big-Book-more-main {
- display: flex;
- > :not(:nth-child(1)) {
- margin-left: 30px;
- }
- }
- }
- .Big-Book-con {
- display: flex;
- align-items: center;
- }
- .close {
- width: 24px;
- cursor: pointer;
- }
- }
- </style>
- <style lang="scss">
- </style>
|