123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <!-- -->
- <template>
- <div class="Big-Book-sentence">
- <div
- class="Big-Book-Single-content"
- style="margin-left: 50px; margin-top: 20px"
- >
- <div class="Big-Book-con">
- <span>标题</span>
- <el-input
- style="width: 300px"
- type="textarea"
- autosize
- placeholder="请输入标题"
- v-model="curQue.title"
- @blur="onBlur(curQue, 'title')"
- ></el-input>
- </div>
- <div
- class="Big-Book-main"
- v-for="(item, index) in curQue.option"
- :key="item + index"
- style="margin-bottom: 20px"
- >
- <SentenceModule
- :curQueItem="item"
- :curQue="curQue"
- :deleteOptionOne="deleteOptionOne"
- :index="index"
- :type="type"
- />
- </div>
- <div class="Big-Book-addrole">
- <div class="addoption" @click="addOption">添加一个</div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import SentenceModule from "../common/SentenceModule.vue";
- export default {
- name: "Single",
- props: ["curQue", "fn_data", "changeCurQue", "type"],
- components: {
- SentenceModule,
- },
- data() {
- return {
- checkList: [],
- form: {
- stem: {
- con: "",
- pinyin: "",
- english: "",
- highlight: "",
- underline: "",
- img_url: [],
- mp3_url: [],
- },
- },
- data_structure: {
- type: "recordHZ_inputPY_chs",
- name: "读汉字写拼音",
- title: "",
- option: [
- {
- number: "",
- con: "",
- answer: "",
- IsRecord: false,
- },
- ],
- },
- data_structure2: {
- type: "inputItem_chs",
- name: "输入选项",
- title: "",
- option: [
- {
- number: "",
- con: "",
- answer: "",
- },
- ],
- },
- };
- },
- computed: {},
- watch: {},
- //方法集合
- methods: {
- onBlur(item, field) {
- item[field] = item[field] ? item[field].trim() : "";
- },
- // 修改正确选项中得某一个为正确答案
- changAnswer(index) {
- this.curQue.option.forEach((item, i) => {
- if (index == i) {
- this.curQue.correct[0].input[index] = item.Answer;
- }
- });
- },
- // 删除其中一个选项
- deleteOptionOne(index) {
- if (this.curQue.option.length <= 1) {
- this.$message.warning("至少要保留1个选项");
- return;
- }
- this.curQue.option.splice(index, 1);
- },
- // 新增选项
- addOption() {
- let obj;
- if (this.type == "recordHZ_inputPY_chs") {
- obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
- } else if (this.type == "inputItem_chs") {
- obj = JSON.parse(JSON.stringify(this.data_structure2.option[0]));
- }
- this.curQue.option.push(obj);
- },
- // 更多配置选择
- handleCheckedFnChange(value) {
- // let fn_list = JSON.parse(JSON.stringify(this.curQue.fn_list));
- // this.curQue.fn_list = fn_list.map((item) => {
- // if (value.indexOf(item.name) > -1) {
- // this.checkList.push(item.name);
- // item.isFn = true;
- // } else {
- // item.isFn = false;
- // this.curQue.con.forEach((it) => {
- // it.annotation = "";
- // });
- // }
- // return item;
- // });
- },
- initcurQue() {
- let data = null;
- if (this.type == "recordHZ_inputPY_chs") {
- data = JSON.parse(JSON.stringify(this.data_structure));
- } else if (this.type == "inputItem_chs") {
- data = JSON.parse(JSON.stringify(this.data_structure2));
- }
- 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-sentence {
- &-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;
- }
- }
- }
- }
- .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;
- > span {
- width: 50px;
- }
- }
- }
- </style>
- <style lang="scss">
- </style>
|