Sfoglia il codice sorgente

单休修改为可增加题

秦鹏 3 anni fa
parent
commit
c22adb5783

+ 4 - 0
src/components/Adult/common/data3.js

@@ -766,6 +766,10 @@ let fnData = [{
         type: "newWord_preview_chs",
         name: "生字展示",
     },
+    {
+        type: "listen_record_single_syllable_chs",
+        name: "听录音选音节",
+    },
 ]
 
 

+ 89 - 10
src/components/Adult/inputModules/PurePreview.vue

@@ -10,25 +10,47 @@
         <el-input
           class="adult-book-input"
           type="textarea"
-          autosize
+          :autosize="{ minRows: 2 }"
           placeholder="请输入标题"
           v-model="curQue.title"
           @blur="onBlur(curQue, 'title')"
         ></el-input>
       </div>
+      <template v-if="type == 'listen_record_single_syllable_chs'">
+        <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.number"
+            @blur="onBlur(curQue, 'number')"
+          ></el-input>
+        </div>
+        <div class="adult-book-input-item">
+          <span class="adult-book-lable">音频:</span>
+          <Upload
+            :changeFillId="timuchangeMp3"
+            :datafileList="curQue.mp3_list"
+            :filleNumber="mp3Number"
+            :uploadType="'mp3'"
+          />
+        </div>
+      </template>
       <div
         class="Big-Book-main"
         v-for="(item, index) in curQue.option"
         :key="item + index"
         style="margin-bottom: 20px"
       >
-        <template v-if="this.type == 'text_problem_chs'">
+        <template v-if="type == 'text_problem_chs'">
           <div class="adult-book-input-item">
             <span class="adult-book-lable">序号:</span>
             <el-input
               class="adult-book-input"
               type="textarea"
-              autosize
+              :autosize="{ minRows: 2 }"
               placeholder="请输入序号"
               v-model="item.number"
               @blur="onBlur(item, 'number')"
@@ -44,13 +66,13 @@
             <SentenceSegwordChs :curQue="item.detail" />
           </div>
         </template>
-        <template v-if="this.type == 'newWord_preview_chs'">
+        <template v-if="type == 'newWord_preview_chs'">
           <div class="adult-book-input-item">
             <span class="adult-book-lable">拼音:</span>
             <el-input
               class="adult-book-input"
               type="textarea"
-              autosize
+              :autosize="{ minRows: 2 }"
               placeholder="请输入拼音"
               v-model="item.pinyin"
               @blur="onBlur(item, 'pinyin')"
@@ -67,7 +89,7 @@
             <el-input
               class="adult-book-input"
               type="textarea"
-              autosize
+              :autosize="{ minRows: 2 }"
               placeholder="请输入生字"
               v-model="item.con"
               @blur="onBlur(item, 'con')"
@@ -80,7 +102,26 @@
               :datafileList="item.mp3_list"
               :filleNumber="mp3Number"
               :uploadType="'mp3'"
-              :index='index'
+              :index="index"
+            />
+          </div>
+        </template>
+        <template v-if="type == 'listen_record_single_syllable_chs'">
+          <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.pinyin"
+              @blur="onBlur(item, 'pinyin')"
+            ></el-input>
+            <img
+              @click="deleteOptionOne"
+              class="close"
+              src="../../../assets/adult/del-close.png"
+              alt=""
             />
           </div>
         </template>
@@ -151,6 +192,18 @@ export default {
           },
         ],
       },
+      data_structure3: {
+        type: "listen_record_single_syllable_chs",
+        name: "听录音选择音节",
+        title: "",
+        mp3_list: [],
+        number: "",
+        option: [
+          {
+            pinyin: "", //拼音
+          },
+        ],
+      },
     };
   },
   computed: {},
@@ -171,7 +224,13 @@ export default {
     // 新增选项
     addOption() {
       let obj;
-      obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
+      if (this.type == "newWord_preview_chs") {
+        obj = JSON.parse(JSON.stringify(this.data_structure2.option[0]));
+      } else if (this.type == "text_problem_chs") {
+        obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
+      } else if (this.type == "listen_record_single_syllable_chs") {
+        obj = JSON.parse(JSON.stringify(this.data_structure3.option[0]));
+      }
       this.curQue.option.push(obj);
     },
     initcurQue() {
@@ -180,10 +239,12 @@ export default {
         data = JSON.parse(JSON.stringify(this.data_structure2));
       } else if (this.type == "text_problem_chs") {
         data = JSON.parse(JSON.stringify(this.data_structure));
+      } else if (this.type == "listen_record_single_syllable_chs") {
+        data = JSON.parse(JSON.stringify(this.data_structure3));
       }
       this.changeCurQue(data);
     },
-    changeMp3(fileList,item,index) {
+    changeMp3(fileList, item, index) {
       const articleImgList = JSON.parse(JSON.stringify(fileList));
       const articleImgRes = [];
       articleImgList.forEach((item) => {
@@ -198,7 +259,25 @@ export default {
           articleImgRes.push(obj);
         }
       });
-      this.curQue.option[index].mp3_list = JSON.parse(JSON.stringify(articleImgRes));
+      this.curQue.option[index].mp3_list = JSON.parse(
+        JSON.stringify(articleImgRes)
+      );
+    },
+    timuchangeMp3(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: "[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.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
     },
   },
   //生命周期 - 创建完成(可以访问当前this实例)

+ 165 - 137
src/components/Adult/inputModules/Single.vue

@@ -4,6 +4,8 @@
     <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>
@@ -12,8 +14,8 @@
           :autosize="{ minRows: 2 }"
           type="textarea"
           placeholder="请输入题号"
-          v-model="curQue.topicNumber"
-          @blur="onBlur(curQue, 'topicNumber')"
+          v-model="topic.topicNumber"
+          @blur="topic.topicNumber = topic.topicNumber.trim()"
         ></el-input>
       </div>
       <div class="adult-book-input-item" v-else>
@@ -23,8 +25,8 @@
           :autosize="{ minRows: 2 }"
           type="textarea"
           placeholder="请输入标题"
-          v-model="curQue.title"
-          @blur="onBlur(curQue, 'title')"
+          v-model="topic.title"
+          @blur="topic.title = topic.title.trim()"
         ></el-input>
       </div>
       <div
@@ -32,12 +34,12 @@
         v-if="type == 'single_chs' || type == 'checkbox_chs'"
       >
         <span class="adult-book-lable">录音:</span>
-        <el-radio-group v-model="curQue.IsRecord">
+        <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="curQue.IsRecord">
+      <div class="adult-book-input-item" v-if="topic.IsRecord">
         <span class="adult-book-lable">录音控件:</span>
         <img src="../../../assets/adult/pro.png" alt="" />
       </div>
@@ -48,8 +50,8 @@
           :autosize="{ minRows: 2 }"
           type="textarea"
           placeholder="请输入题目"
-          v-model="curQue.topic.con"
-          @blur="curQue.topic.con = curQue.topic.con.trim()"
+          v-model="topic.topic.con"
+          @blur="topic.topic.con = topic.topic.con.trim()"
         ></el-input>
       </div>
       <div
@@ -59,7 +61,7 @@
         <span class="adult-book-lable">题目图片:</span>
         <Upload
           :changeFillId="timuchangeImage"
-          :datafileList="curQue.topic.img_list"
+          :datafileList="topic.topic.img_list"
           :filleNumber="imgNumber"
           :uploadType="'image'"
         />
@@ -68,14 +70,14 @@
         <span class="adult-book-lable">题目音频:</span>
         <Upload
           :changeFillId="timuchangeMp3"
-          :datafileList="curQue.topic.mp3_list"
+          :datafileList="topic.topic.mp3_list"
           :filleNumber="mp3Number"
           :uploadType="'mp3'"
         />
       </div>
       <div
         class="Big-Book-main"
-        v-for="(item, index) in curQue.option"
+        v-for="(item, index) in topic.option"
         :key="item + index"
         style="border-bottom: 1px #ccc solid; margin-bottom: 20px"
       >
@@ -87,13 +89,13 @@
           :type="curQue.type"
         />
       </div>
-      <div class="addoption" @click="addOption">添加一个选项</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="curQue.numberList.con" placeholder="请选择">
+        <el-select v-model="topic.numberList.con" placeholder="请选择">
           <el-option
-            v-for="(item, i) in curQue.numberList.arr"
+            v-for="(item, i) in topic.numberList.arr"
             :key="i"
             :label="item.value"
             :value="item.id"
@@ -102,6 +104,7 @@
         </el-select>
       </div>
     </div>
+    <div class="addoption" @click="addtopic">添加一个题</div>
   </div>
 </template>
 
@@ -133,155 +136,161 @@ export default {
       },
       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: "",
-          },
-          {
-            number: "",
+      data_structure: [
+        {
+          type: "single_chs",
+          name: "单选题",
+          topicNumber: "",
+          IsRecord: false,
+          topic: {
             con: "",
             img_list: [],
             mp3_list: [],
-            isAnswer: "",
           },
-        ],
-        correct: [],
-        numberList: {
-          type: "number",
-          name: "每行几个",
-          con: "2",
-          arr: [
+          option: [
             {
-              id: 1,
-              value: 1,
+              number: "",
+              con: "",
+              img_list: [],
+              mp3_list: [],
+              isAnswer: "",
             },
             {
-              id: 2,
-              value: 2,
-            },
-            {
-              id: 3,
-              value: 3,
-            },
-            {
-              id: 4,
-              value: 4,
+              number: "",
+              con: "",
+              img_list: [],
+              mp3_list: [],
+              isAnswer: "",
             },
           ],
-        },
-      },
-      data_structure2: {
-        type: "checkbox_chs",
-        name: "多选题",
-        title: "",
-        IsRecord: false,
-        topic: {
-          con: "",
-          img_list: [],
-          mp3_list: [],
-        },
-        option: [
-          {
-            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_structure2: [
+        {
+          type: "checkbox_chs",
+          name: "多选题",
+          title: "",
+          IsRecord: false,
+          topic: {
             con: "",
             img_list: [],
             mp3_list: [],
-            isAnswer: "",
-            number: "",
           },
-        ],
-        correct: [],
-        numberList: {
-          type: "number",
-          name: "每行几个",
-          con: "2",
-          arr: [
-            {
-              id: 1,
-              value: 1,
-            },
-            {
-              id: 2,
-              value: 2,
-            },
+          option: [
             {
-              id: 3,
-              value: 3,
+              con: "",
+              img_list: [],
+              mp3_list: [],
+              isAnswer: "",
+              number: "",
             },
             {
-              id: 4,
-              value: 4,
+              con: "",
+              img_list: [],
+              mp3_list: [],
+              isAnswer: "",
+              number: "",
             },
           ],
-        },
-      },
-      data_structure3: {
-        type: "listen_record_single_chs",
-        name: "听录音选答案",
-        title: "",
-        topic: {
-          con: "",
-          mp3_list: [],
-        },
-        option: [
-          {
-            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,
+              },
+            ],
           },
-          {
+        },
+      ],
+      data_structure3: [
+        {
+          type: "listen_record_single_chs",
+          name: "听录音选答案",
+          title: "",
+          topic: {
             con: "",
             mp3_list: [],
-            isAnswer: "",
-            number: "",
           },
-        ],
-        correct: [],
-        numberList: {
-          type: "number",
-          name: "每行几个",
-          con: "2",
-          arr: [
-            {
-              id: 1,
-              value: 1,
-            },
-            {
-              id: 2,
-              value: 2,
-            },
+          option: [
             {
-              id: 3,
-              value: 3,
+              con: "",
+              mp3_list: [],
+              isAnswer: "",
+              number: "",
             },
             {
-              id: 4,
-              value: 4,
+              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: {},
@@ -319,10 +328,29 @@ export default {
       }
       this.curQue.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() {
-      let obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
-      this.curQue.option.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) {
       console.log(fileList);

+ 2 - 1
src/views/adultInput3.vue

@@ -293,7 +293,8 @@
                     <template
                       v-if="
                         topicIitem.type == 'text_problem_chs' ||
-                        topicIitem.type == 'newWord_preview_chs'
+                        topicIitem.type == 'newWord_preview_chs' ||
+                        topicIitem.type == 'listen_record_single_syllable_chs'
                       "
                     >
                       <template v-if="topicIitem.is_edit">