123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494 |
- <!-- -->
- <template>
- <div class="Big-Book-Single" v-if="curQue">
- <div
- class="Big-Book-Single-content"
- style="margin-left: 20px; margin-top: 20px"
- v-for="(topic, toIndex) in curQue"
- :key="toIndex + 'topic'"
- >
- <div class="adult-book-input-item" v-if="type == 'single_chs'">
- <span class="adult-book-lable">题号:</span>
- <el-input
- class="adult-book-input"
- :autosize="{ minRows: 2 }"
- type="textarea"
- placeholder="请输入题号"
- v-model="topic.topicNumber"
- @blur="topic.topicNumber = topic.topicNumber.trim()"
- maxlength="200"
- show-word-limit
- ></el-input>
- <img
- @click="deletetopic(toIndex)"
- class="close"
- src="../../../assets/adult/del-close.png"
- alt=""
- />
- </div>
- <div class="adult-book-input-item" v-else>
- <span class="adult-book-lable">标题:</span>
- <el-input
- class="adult-book-input"
- :autosize="{ minRows: 2 }"
- type="textarea"
- placeholder="请输入标题"
- v-model="topic.title"
- @blur="topic.title = topic.title.trim()"
- maxlength="500"
- show-word-limit
- ></el-input>
- <img
- @click="deletetopic(toIndex)"
- class="close"
- src="../../../assets/adult/del-close.png"
- alt=""
- />
- </div>
- <div
- class="adult-book-input-item"
- v-if="type == 'single_chs' || type == 'checkbox_chs'"
- >
- <span class="adult-book-lable">录音:</span>
- <el-radio-group v-model="topic.IsRecord">
- <el-radio :label="true">需要</el-radio>
- <el-radio :label="false">不需要</el-radio>
- </el-radio-group>
- </div>
- <div class="adult-book-input-item" v-if="topic.IsRecord">
- <span class="adult-book-lable">录音控件:</span>
- <img src="../../../assets/adult/pro.png" alt="" />
- </div>
- <div class="adult-book-input-item">
- <span class="adult-book-lable">题目:</span>
- <el-input
- class="adult-book-input"
- :autosize="{ minRows: 2 }"
- type="textarea"
- placeholder="请输入题目"
- v-model="topic.topic.con"
- @blur="topic.topic.con = topic.topic.con.trim()"
- maxlength="500"
- show-word-limit
- ></el-input>
- </div>
- <div
- class="adult-book-input-item"
- v-if="type == 'single_chs' || type == 'checkbox_chs'"
- >
- <span class="adult-book-lable">题目图片:</span>
- <Upload
- :changeFillId="timuchangeImage"
- :datafileList="topic.topic.img_list"
- :filleNumber="imgNumber"
- :uploadType="'image'"
- :index="toIndex"
- />
- </div>
- <div class="adult-book-input-item">
- <span class="adult-book-lable">题目音频:</span>
- <Upload
- :changeFillId="timuchangeMp3"
- :datafileList="topic.topic.mp3_list"
- :filleNumber="mp3Number"
- :uploadType="'mp3'"
- :index="toIndex"
- />
- </div>
- <div
- class="Big-Book-main"
- v-for="(item, index) in topic.option"
- :key="item + index"
- style="border-bottom: 1px #ccc solid; margin-bottom: 20px"
- >
- <SingleModule
- :curQueItem="item"
- :index="index"
- :toIndex="toIndex"
- :changAnswer="changAnswer"
- :deleteOptionOne="deleteOptionOne"
- :type="type"
- />
- </div>
- <div class="addoption" @click="addOption(toIndex)">添加一个选项</div>
- <div class="Big-Book-divide">
- <el-divider content-position="center">功能设置</el-divider>
- <span style="margin: 0 10px">请选择每行数量</span>
- <el-select v-model="topic.numberList.con" placeholder="请选择">
- <el-option
- v-for="(item, i) in topic.numberList.arr"
- :key="i"
- :label="item.value"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </div>
- </div>
- <div style="margin-top: 15px" class="addoption" @click="addtopic">
- 添加一个题
- </div>
- </div>
- </template>
- <script>
- import Inputmodule from "../common/Inputmodule.vue";
- import SingleModule from "../common/SingleModule.vue";
- import Upload from "../common/Upload.vue";
- export default {
- name: "Single",
- props: ["curQue", "fn_data", "changeCurQue", "type"],
- components: {
- Inputmodule,
- SingleModule,
- Upload,
- },
- data() {
- return {
- form: {
- stem: {
- con: "",
- pinyin: "",
- english: "",
- highlight: "",
- underline: "",
- img_url: [],
- mp3_url: [],
- },
- },
- imgNumber: 1,
- mp3Number: 1,
- data_structure: [
- {
- type: "single_chs",
- name: "单选题",
- topicNumber: "",
- IsRecord: false,
- topic: {
- con: "",
- img_list: [],
- mp3_list: [],
- },
- option: [
- {
- number: "",
- con: "",
- img_list: [],
- mp3_list: [],
- isAnswer: "",
- font: "",
- },
- {
- number: "",
- con: "",
- img_list: [],
- mp3_list: [],
- isAnswer: "",
- font: "",
- },
- ],
- correct: [],
- numberList: {
- type: "number",
- name: "每行几个",
- con: "2",
- arr: [
- {
- id: 1,
- value: 1,
- },
- {
- id: 2,
- value: 2,
- },
- {
- id: 3,
- value: 3,
- },
- {
- id: 4,
- value: 4,
- },
- ],
- },
- },
- ],
- data_structure2: [
- {
- type: "checkbox_chs",
- name: "多选题",
- title: "",
- IsRecord: false,
- topic: {
- con: "",
- img_list: [],
- mp3_list: [],
- },
- option: [
- {
- con: "",
- img_list: [],
- mp3_list: [],
- isAnswer: "",
- number: "",
- },
- {
- con: "",
- img_list: [],
- mp3_list: [],
- isAnswer: "",
- number: "",
- },
- ],
- correct: [],
- numberList: {
- type: "number",
- name: "每行几个",
- con: "2",
- arr: [
- {
- id: 1,
- value: 1,
- },
- {
- id: 2,
- value: 2,
- },
- {
- id: 3,
- value: 3,
- },
- {
- id: 4,
- value: 4,
- },
- ],
- },
- },
- ],
- data_structure3: [
- {
- type: "listen_record_single_chs",
- name: "听录音选答案",
- title: "",
- topic: {
- con: "",
- mp3_list: [],
- },
- option: [
- {
- con: "",
- mp3_list: [],
- isAnswer: "",
- number: "",
- },
- {
- con: "",
- mp3_list: [],
- isAnswer: "",
- number: "",
- },
- ],
- correct: [],
- numberList: {
- type: "number",
- name: "每行几个",
- con: "2",
- arr: [
- {
- id: 1,
- value: 1,
- },
- {
- id: 2,
- value: 2,
- },
- {
- id: 3,
- value: 3,
- },
- {
- id: 4,
- value: 4,
- },
- ],
- },
- },
- ],
- };
- },
- computed: {},
- watch: {},
- //方法集合
- methods: {
- // 修改正确选项中得某一个为正确答案
- changAnswer(index) {
- let arr = [];
- if (this.curQue.type == "single_chs") {
- this.curQue.option.forEach((item, i) => {
- if (index == i) {
- this.curQue.correct = [];
- arr.push(i);
- } else {
- item.isAnswer = "";
- }
- });
- this.curQue.correct = arr;
- } else if (this.curQue.type == "checkbox_chs") {
- this.curQue.option.forEach((item, i) => {
- if (index == i && item.isAnswer != "") {
- this.curQue.correct.push(i);
- } else if (index == i && item.isAnswer == "") {
- this.curQue.correct.splice(i, 1);
- }
- });
- }
- },
- // 删除其中一道题
- deletetopic(index) {
- if (this.curQue.length <= 1) {
- this.$message.warning("至少要保留1个题");
- return;
- }
- this.curQue.splice(index, 1);
- },
- // 删除其中一个选项
- deleteOptionOne(index, toIndex) {
- if (this.curQue[toIndex].option.length <= 2) {
- this.$message.warning("至少要保留两个选项");
- return;
- }
- this.curQue[toIndex].option.splice(index, 1);
- },
- // 添加一个题
- addtopic() {
- let obj;
- if (this.type == "single_chs") {
- obj = JSON.parse(JSON.stringify(this.data_structure[0]));
- } else if (this.type == "checkbox_chs") {
- obj = JSON.parse(JSON.stringify(this.data_structure2[0]));
- } else if (this.type == "listen_record_single_chs") {
- obj = JSON.parse(JSON.stringify(this.data_structure3[0]));
- }
- this.curQue.push(obj);
- },
- //添加一个选项
- addOption(index) {
- let obj;
- if (this.type == "single_chs") {
- obj = JSON.parse(JSON.stringify(this.data_structure[0].option[0]));
- } else if (this.type == "checkbox_chs") {
- obj = JSON.parse(JSON.stringify(this.data_structure2[0].option[0]));
- } else if (this.type == "listen_record_single_chs") {
- obj = JSON.parse(JSON.stringify(this.data_structure3[0].option[0]));
- }
- this.curQue[index].option.push(obj);
- },
- timuchangeMp3(fileList, items, 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]",
- media_duration: item.response.file_info_list[0].media_duration, //音频时长
- };
- articleImgRes.push(obj);
- }
- });
- this.curQue[index].topic.mp3_list = JSON.parse(
- JSON.stringify(articleImgRes)
- );
- },
- timuchangeImage(fileList, items, 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[index].topic.img_list = JSON.parse(
- JSON.stringify(articleImgRes)
- );
- },
- },
- //生命周期 - 创建完成(可以访问当前this实例)
- created() {
- if (!this.curQue) {
- if (this.type == "single_chs") {
- this.changeCurQue(this.data_structure);
- } else if (this.type == "checkbox_chs") {
- this.changeCurQue(this.data_structure2);
- } else if (this.type == "listen_record_single_chs") {
- this.changeCurQue(this.data_structure3);
- }
- }
- },
- //生命周期 - 挂载完成(可以访问DOM元素)
- mounted() {},
- 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;
- }
- .close {
- width: 24px;
- cursor: pointer;
- }
- }
- </style>
- <style lang="scss">
- </style>
|