Jelajahi Sumber

表格 移动端适配

natasha 5 bulan lalu
induk
melakukan
46bb63572f

+ 5 - 4
src/components/Adult/phonePreview/AudioLine.vue

@@ -24,8 +24,8 @@
           :format-tooltip="formatProcessToolTip"
           @change="changeCurrentTime"
         />
-        <span
-          ><template v-if="audio.playing">-</template
+        <span :style="{ fontSize: baseSizePhone + 2 + 'px' }"
+          >123<template v-if="audio.playing">-</template
           >{{
             audio.maxTime
               ? realFormatSecond(audio.maxTime - audio.currentTime)
@@ -81,7 +81,8 @@ export default {
     "bg",
     "audioId",
     "type",
-    "borderRadius"
+    "borderRadius",
+    "baseSizePhone"
   ],
   data() {
     // 这里存放数据
@@ -388,7 +389,7 @@ export default {
     align-items: center;
     width: 100%;
     height: 40px;
-    background: #ffffff;
+    // background: #ffffff;
     // border: 1px solid rgba(0, 0, 0, 0.1);
     // box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);
     box-sizing: border-box;

+ 4 - 1
src/components/Adult/phonePreview/ConfigurableTable.vue

@@ -9,7 +9,10 @@
           curQue.isShadow ? '4px 4px 4px rgba(0, 0, 0, 0.3)' : ''
         }`,
         border: `${curQue.marginHighlight ? '1.1px solid #949494' : ''}`,
-        width: curQue.tableData.body.length > 5 ? width_total + 'px' : '',
+        width:
+          curQue.tableData.colsConfig.width.length > 5
+            ? width_total + 'px'
+            : '',
         fontSize: baseSizePhone + 2 + 'px'
       }"
     >

+ 6 - 5
src/components/Adult/phonePreview/PlayRecordView.vue

@@ -4,6 +4,7 @@
       audioId="playRecordAudio"
       :mp3="curQue.mp3_list[0].id"
       :getCurTime="getCurTime"
+      :baseSizePhone="baseSizePhone"
       ref="audioLine"
     />
   </div>
@@ -16,11 +17,11 @@ import AudioLine from "./AudioLine.vue";
 export default {
   //import引入的组件需要注入到对象中才能使用
   components: { AudioLine },
-  props: ["curQue", "fn_data", "type"],
+  props: ["curQue", "fn_data", "type", "baseSizePhone"],
   data() {
     //这里存放数据
     return {
-        curTime:0,
+      curTime: 0
     };
   },
   //计算属性 类似于data概念
@@ -31,7 +32,7 @@ export default {
   methods: {
     getCurTime(curTime) {
       this.curTime = curTime * 1000;
-    },
+    }
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {},
@@ -50,11 +51,11 @@ export default {
   //生命周期-销毁完成
   destoryed() {},
   //如果页面有keep-alive缓存功能,这个函数会触发
-  activated() {},
+  activated() {}
 };
 </script>
 <style lang="scss" scoped>
 /* @import url(); 引入css类 */
 .PlayRecordView {
 }
-</style>
+</style>

+ 1 - 0
src/components/Adult/phonePreview/RecordModule.vue

@@ -7,6 +7,7 @@
       :class="[curQue.type]"
       :answerRecordList="curQue.Bookanswer.recordList"
       :TaskModel="TaskModel"
+      :baseSizePhone="baseSizePhone"
     />
   </div>
 </template>

+ 3 - 1
src/components/Adult/phonePreview/Soundrecord.vue

@@ -18,6 +18,7 @@
           selectIndex || selectIndex == 0 ? 'record-black' : '',
           type && type == 'normal' ? 'record-time-flex' : ''
         ]"
+        :style="{ fontSize: baseSizePhone + 2 + 'px' }"
         >{{ isPlaying ? "-" : "" }}{{ handleDateTime(recordtime) }}</span
       >
       <div v-if="type && type == 'normal'" class="line" />
@@ -147,7 +148,8 @@ export default {
     "tmsIndex",
     "index",
     "indexs",
-    "sddIndex"
+    "sddIndex",
+    "baseSizePhone"
   ],
   data() {
     return {

+ 101 - 67
src/components/Adult/phonePreview/TableView.vue

@@ -1,14 +1,23 @@
 <template>
-  <div class="TableView" v-if="curQue&&curQue.Bookanswer">
+  <div class="TableView-phone" v-if="curQue && curQue.Bookanswer">
     <!-- 表格 -->
     <div class="table">
-      <table>
+      <table
+        :style="{
+          width:
+            curQue.option[0] && curQue.option[0].length > 5 ? '860px' : '100%'
+        }"
+      >
         <template v-if="curQue.isHeader">
           <tr>
             <th
               v-for="(item, headIndex) in curQue.headerList"
               :key="'header' + headIndex"
-              :style="{ width: curQue.colWidthList[headIndex].width + '%',textAlign:(curQue.align?curQue.align:'center') }"
+              :style="{
+                width: curQue.colWidthList[headIndex].width + '%',
+                textAlign: curQue.align ? curQue.align : 'center',
+                fontSize: baseSizePhone + 2 + 'px'
+              }"
             >
               {{ item.con }}
             </th>
@@ -18,39 +27,59 @@
           <td
             v-for="(col, colIndex) in row"
             :key="'col' + colIndex"
-            :style="{ width: curQue.colWidthList[colIndex].width + '%',textAlign:(curQue.align?curQue.align:'center') }"
+            :style="{
+              width: curQue.colWidthList[colIndex].width + '%',
+              textAlign: curQue.align ? curQue.align : 'center',
+              fontSize: baseSizePhone + 2 + 'px'
+            }"
           >
             <template v-if="!col.isNull">
               {{ col.con }}
             </template>
             <template v-else>
-                <!-- <div v-html="curQue.Bookanswer.curCorrect[rowIndex][colIndex]" contenteditable="true" placeholder="输入" class="input" @input="handleMaxlength" ></div> -->
-                <el-input
-                    type="textarea"
-                    autosize
-                    placeholder=""
-                    v-model="curQue.Bookanswer.curCorrect[rowIndex][colIndex]"
-                    :readonly="TaskModel=='ANSWER'"
-                    maxlength="200">
-                </el-input>
+              <!-- <div v-html="curQue.Bookanswer.curCorrect[rowIndex][colIndex]" contenteditable="true" placeholder="输入" class="input" @input="handleMaxlength" ></div> -->
+              <el-input
+                type="textarea"
+                autosize
+                placeholder=""
+                v-model="curQue.Bookanswer.curCorrect[rowIndex][colIndex]"
+                :readonly="TaskModel == 'ANSWER'"
+                maxlength="200"
+                :style="{ 'font-size': baseSizePhone + 2 + 'px' }"
+              >
+              </el-input>
             </template>
           </td>
         </tr>
       </table>
     </div>
     <!-- 提示语 -->
-    <div class="hint" v-if="curQue.hintOtion.length>0&&curQue.hintOtion[0].con">
-      <p>{{ curQue.hintTitle }}</p>
+    <div
+      class="hint"
+      v-if="curQue.hintOtion.length > 0 && curQue.hintOtion[0].con"
+    >
+      <p :style="{ fontSize: baseSizePhone + 2 + 'px' }">
+        {{ curQue.hintTitle }}
+      </p>
       <div>
         <div v-for="(item, i) in curQue.hintOtion" :key="'hint' + i">
-          <p>{{ item.pinyin }}</p>
-          <p>{{ item.con }}</p>
+          <p :style="{ fontSize: baseSizePhone + 2 + 'px' }">
+            {{ item.pinyin }}
+          </p>
+          <p :style="{ fontSize: baseSizePhone + 6 + 'px' }">{{ item.con }}</p>
         </div>
       </div>
     </div>
     <!-- 录音 -->
     <div class="record">
-      <Soundrecord :answerRecordList="curQue.Bookanswer.recordList" @handleWav="handleWav" :TaskModel="TaskModel" type="pro-plus" class="luyin-box" />
+      <Soundrecord
+        :answerRecordList="curQue.Bookanswer.recordList"
+        @handleWav="handleWav"
+        :TaskModel="TaskModel"
+        type="normal"
+        class="luyin-box"
+        :baseSizePhone="baseSizePhone"
+      />
     </div>
   </div>
 </template>
@@ -58,14 +87,14 @@
 <script>
 //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 //例如:import 《组件名称》from ‘《组件路径》';
-import Soundrecord from "../preview/Soundrecord.vue"; // 录音模板
+import Soundrecord from "../phonePreview/Soundrecord.vue"; // 录音模板
 
 export default {
   //import引入的组件需要注入到对象中才能使用
   components: {
-    Soundrecord,
+    Soundrecord
   },
-  props: ["curQue","TaskModel"],
+  props: ["curQue", "TaskModel", "baseSizePhone"],
   data() {
     //这里存放数据
     return {};
@@ -80,35 +109,35 @@ export default {
       tmIndex = tmIndex ? tmIndex : 0;
       this.$set(this.curQue.Bookanswer, "recordList", list);
     },
-    handleMaxlength(e){
-        if(e.target.innerHTML.length>200){
-            e.target.innerHTML = e.target.innerHTML.substring(0, 200);
-        }
-        this.$forceUpdate()
-    },
+    handleMaxlength(e) {
+      if (e.target.innerHTML.length > 200) {
+        e.target.innerHTML = e.target.innerHTML.substring(0, 200);
+      }
+      this.$forceUpdate();
+    }
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
-      let curCorrect = [];
-      this.curQue.option.forEach((item) => {
-        let curCorrectItem = []
-        item.forEach((it)=>{
-            if (it.con == "") {
-                curCorrectItem.push('')
-                it.isNull = true
-            }else{
-                curCorrectItem.push(null)
-            }
-        })
-        curCorrect.push(curCorrectItem)
-      });
-      if (!this.curQue.Bookanswer) {
-        let bookanswer = {
-            curCorrect : curCorrect,
-            recordList: [],
+    let curCorrect = [];
+    this.curQue.option.forEach(item => {
+      let curCorrectItem = [];
+      item.forEach(it => {
+        if (it.con == "") {
+          curCorrectItem.push("");
+          it.isNull = true;
+        } else {
+          curCorrectItem.push(null);
         }
-        this.$set(this.curQue, "Bookanswer", bookanswer);
-      }
+      });
+      curCorrect.push(curCorrectItem);
+    });
+    if (!this.curQue.Bookanswer) {
+      let bookanswer = {
+        curCorrect: curCorrect,
+        recordList: []
+      };
+      this.$set(this.curQue, "Bookanswer", bookanswer);
+    }
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {},
@@ -125,12 +154,12 @@ export default {
   //生命周期-销毁完成
   destoryed() {},
   //如果页面有keep-alive缓存功能,这个函数会触发
-  activated() {},
+  activated() {}
 };
 </script>
 <style lang="scss" scoped>
 /* @import url(); 引入css类 */
-.TableView {
+.TableView-phone {
   width: 100%;
   margin-bottom: 16px;
   .hint {
@@ -145,13 +174,14 @@ export default {
     }
     > div {
       display: flex;
+      flex-flow: wrap;
+      gap: 5px;
       > div {
         min-width: 82px;
         min-height: 70px;
         padding: 8px 16px;
         background: #f7f7f7;
         border-radius: 8px;
-        margin-right: 8px;
         p {
           margin: 0;
         }
@@ -178,7 +208,7 @@ export default {
   }
   .record {
     margin-top: 11px;
-    width: 292px;
+    width: max-content;
     height: 40px;
     padding: 0 12px;
     display: flex;
@@ -190,6 +220,7 @@ export default {
   }
   .table {
     width: 100%;
+    overflow: auto;
     table {
       width: 100%;
       border-collapse: collapse; //取消单元格之间的间距
@@ -212,10 +243,10 @@ export default {
           text-align: center;
           color: #000000;
           font-size: 16px;
-          padding: 6px 16px;
-          .input{
+          padding: 6px;
+          .input {
             width: 100%;
-            min-height:24px;
+            min-height: 24px;
             margin: 0 auto;
             font-size: 16px;
             line-height: 1.5;
@@ -231,18 +262,21 @@ export default {
 }
 </style>
 <style lang="scss">
-.NPC-Big-Book-preview{
-    .el-textarea__inner{
-        resize: none;
-        border: none;
-        outline: none;
-        width: 100%;
-        min-height:24px;
-        margin: 0 auto;
-        font-size: 16px;
-        line-height: 1.5;
-        color: #000000;
-        overflow:hidden; 
-    }
+.TableView-phone {
+  .el-textarea__inner {
+    resize: none;
+    border: none;
+    outline: none;
+    width: 100%;
+    min-height: 24px;
+    margin: 0 auto;
+    font-size: auto;
+    line-height: 1.5;
+    color: #000000;
+    overflow: hidden;
+    display: flex;
+    align-items: center; /* 垂直居中 */
+    justify-content: center;
+  }
 }
-</style>
+</style>

+ 74 - 58
src/components/Adult/preview/TableView.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="TableView" v-if="curQue&&curQue.Bookanswer">
+  <div class="TableView" v-if="curQue && curQue.Bookanswer">
     <!-- 表格 -->
     <div class="table">
       <table>
@@ -8,7 +8,10 @@
             <th
               v-for="(item, headIndex) in curQue.headerList"
               :key="'header' + headIndex"
-              :style="{ width: curQue.colWidthList[headIndex].width + '%',textAlign:(curQue.align?curQue.align:'center') }"
+              :style="{
+                width: curQue.colWidthList[headIndex].width + '%',
+                textAlign: curQue.align ? curQue.align : 'center'
+              }"
             >
               {{ item.con }}
             </th>
@@ -18,28 +21,35 @@
           <td
             v-for="(col, colIndex) in row"
             :key="'col' + colIndex"
-            :style="{ width: curQue.colWidthList[colIndex].width + '%',textAlign:(curQue.align?curQue.align:'center') }"
+            :style="{
+              width: curQue.colWidthList[colIndex].width + '%',
+              textAlign: curQue.align ? curQue.align : 'center'
+            }"
           >
             <template v-if="!col.isNull">
               {{ col.con }}
             </template>
             <template v-else>
-                <!-- <div v-html="curQue.Bookanswer.curCorrect[rowIndex][colIndex]" contenteditable="true" placeholder="输入" class="input" @input="handleMaxlength" ></div> -->
-                <el-input
-                    type="textarea"
-                    autosize
-                    placeholder=""
-                    v-model="curQue.Bookanswer.curCorrect[rowIndex][colIndex]"
-                    :readonly="TaskModel=='ANSWER'"
-                    maxlength="200">
-                </el-input>
+              <!-- <div v-html="curQue.Bookanswer.curCorrect[rowIndex][colIndex]" contenteditable="true" placeholder="输入" class="input" @input="handleMaxlength" ></div> -->
+              <el-input
+                type="textarea"
+                autosize
+                placeholder=""
+                v-model="curQue.Bookanswer.curCorrect[rowIndex][colIndex]"
+                :readonly="TaskModel == 'ANSWER'"
+                maxlength="200"
+              >
+              </el-input>
             </template>
           </td>
         </tr>
       </table>
     </div>
     <!-- 提示语 -->
-    <div class="hint" v-if="curQue.hintOtion.length>0&&curQue.hintOtion[0].con">
+    <div
+      class="hint"
+      v-if="curQue.hintOtion.length > 0 && curQue.hintOtion[0].con"
+    >
       <p>{{ curQue.hintTitle }}</p>
       <div>
         <div v-for="(item, i) in curQue.hintOtion" :key="'hint' + i">
@@ -50,7 +60,13 @@
     </div>
     <!-- 录音 -->
     <div class="record">
-      <Soundrecord :answerRecordList="curQue.Bookanswer.recordList" @handleWav="handleWav" :TaskModel="TaskModel" type="pro-plus" class="luyin-box" />
+      <Soundrecord
+        :answerRecordList="curQue.Bookanswer.recordList"
+        @handleWav="handleWav"
+        :TaskModel="TaskModel"
+        type="pro-plus"
+        class="luyin-box"
+      />
     </div>
   </div>
 </template>
@@ -63,9 +79,9 @@ import Soundrecord from "../preview/Soundrecord.vue"; // 录音模板
 export default {
   //import引入的组件需要注入到对象中才能使用
   components: {
-    Soundrecord,
+    Soundrecord
   },
-  props: ["curQue","TaskModel"],
+  props: ["curQue", "TaskModel"],
   data() {
     //这里存放数据
     return {};
@@ -80,35 +96,35 @@ export default {
       tmIndex = tmIndex ? tmIndex : 0;
       this.$set(this.curQue.Bookanswer, "recordList", list);
     },
-    handleMaxlength(e){
-        if(e.target.innerHTML.length>200){
-            e.target.innerHTML = e.target.innerHTML.substring(0, 200);
-        }
-        this.$forceUpdate()
-    },
+    handleMaxlength(e) {
+      if (e.target.innerHTML.length > 200) {
+        e.target.innerHTML = e.target.innerHTML.substring(0, 200);
+      }
+      this.$forceUpdate();
+    }
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
-      let curCorrect = [];
-      this.curQue.option.forEach((item) => {
-        let curCorrectItem = []
-        item.forEach((it)=>{
-            if (it.con == "") {
-                curCorrectItem.push('')
-                it.isNull = true
-            }else{
-                curCorrectItem.push(null)
-            }
-        })
-        curCorrect.push(curCorrectItem)
-      });
-      if (!this.curQue.Bookanswer) {
-        let bookanswer = {
-            curCorrect : curCorrect,
-            recordList: [],
+    let curCorrect = [];
+    this.curQue.option.forEach(item => {
+      let curCorrectItem = [];
+      item.forEach(it => {
+        if (it.con == "") {
+          curCorrectItem.push("");
+          it.isNull = true;
+        } else {
+          curCorrectItem.push(null);
         }
-        this.$set(this.curQue, "Bookanswer", bookanswer);
-      }
+      });
+      curCorrect.push(curCorrectItem);
+    });
+    if (!this.curQue.Bookanswer) {
+      let bookanswer = {
+        curCorrect: curCorrect,
+        recordList: []
+      };
+      this.$set(this.curQue, "Bookanswer", bookanswer);
+    }
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {},
@@ -125,7 +141,7 @@ export default {
   //生命周期-销毁完成
   destoryed() {},
   //如果页面有keep-alive缓存功能,这个函数会触发
-  activated() {},
+  activated() {}
 };
 </script>
 <style lang="scss" scoped>
@@ -213,9 +229,9 @@ export default {
           color: #000000;
           font-size: 16px;
           padding: 6px 16px;
-          .input{
+          .input {
             width: 100%;
-            min-height:24px;
+            min-height: 24px;
             margin: 0 auto;
             font-size: 16px;
             line-height: 1.5;
@@ -231,18 +247,18 @@ export default {
 }
 </style>
 <style lang="scss">
-.NPC-Big-Book-preview{
-    .el-textarea__inner{
-        resize: none;
-        border: none;
-        outline: none;
-        width: 100%;
-        min-height:24px;
-        margin: 0 auto;
-        font-size: 16px;
-        line-height: 1.5;
-        color: #000000;
-        overflow:hidden; 
-    }
+.TableView {
+  .el-textarea__inner {
+    resize: none;
+    border: none;
+    outline: none;
+    width: 100%;
+    min-height: 24px;
+    margin: 0 auto;
+    font-size: 16px;
+    line-height: 1.5;
+    color: #000000;
+    overflow: hidden;
+  }
 }
-</style>
+</style>