Просмотр исходного кода

fix:修改详情‘/n’字符下显示

DESKTOP-HI4L4AH\Administrator 4 месяцев назад
Родитель
Сommit
b7e133227f
1 измененных файлов с 19 добавлено и 7 удалено
  1. 19 7
      src/components/education/question-preview.vue

+ 19 - 7
src/components/education/question-preview.vue

@@ -39,7 +39,7 @@
            <el-col :span="18">
 <!--             G 目标导向-->
              <el-form-item label="目标" prop="question_name" label-width="140px" >
-               <el-input disabled v-model="form.gOriented" placeholder="" type="textarea" autosize></el-input>
+               <el-input class="preserve-newlines" disabled v-model="form.gOriented" placeholder="" type="textarea" autosize></el-input>
              </el-form-item>
            </el-col>
          </el-row>
@@ -47,7 +47,7 @@
           <el-row>
             <el-col :span="18">
               <el-form-item label="问题定义(评价标准)" prop="question_name" label-width="140px" >
-                <el-input disabled v-model="form.pScoreStd" placeholder="" type="textarea" autosize></el-input>
+                <el-input class="preserve-newlines" disabled v-model="form.pScoreStd" placeholder="" type="textarea" autosize></el-input>
               </el-form-item>
             </el-col>
           </el-row>
@@ -55,7 +55,7 @@
           <el-row>
             <el-col :span="18">
               <el-form-item label="系统拆解(评价标准)" prop="question_name" label-width="140px" >
-                <el-input disabled v-model="form.sScoreStd" placeholder="" type="textarea" autosize></el-input>
+                <el-input  class="preserve-newlines" disabled v-model="form.sScoreStd" placeholder="" type="textarea" autosize></el-input>
               </el-form-item>
             </el-col>
           </el-row>
@@ -63,7 +63,7 @@
           <el-row>
             <el-col :span="18">
               <el-form-item label="结果整合(评价标准)" prop="question_name" label-width="140px" >
-                <el-input disabled v-model="form.eScoreStd" placeholder="" type="textarea" autosize></el-input>
+                <el-input class="preserve-newlines" disabled v-model="form.eScoreStd" placeholder="" type="textarea" autosize></el-input>
               </el-form-item>
             </el-col>
           </el-row>
@@ -71,7 +71,7 @@
           <el-row>
             <el-col :span="18">
               <el-form-item label="结果评估(评价标准)" prop="question_name" label-width="140px" >
-                <el-input disabled v-model="form.rScoreStd" placeholder="" type="textarea" autosize></el-input>
+                <el-input class="preserve-newlines" disabled v-model="form.rScoreStd" placeholder="" type="textarea" autosize></el-input>
               </el-form-item>
             </el-col>
           </el-row>
@@ -120,6 +120,16 @@
             if (val) {
               this.questionInfoData = { ...val } // 使用展开运算符创建新对象
               this.form = { ...val }
+
+              // 处理换行符
+              const textFields = ['gOriented', 'pScoreStd', 'sScoreStd', 'eScoreStd', 'rScoreStd']
+              textFields.forEach(field => {
+                if (this.form[field] && typeof this.form[field] === 'string') {
+                  this.form[field] = this.form[field].replace(/\\n/g, '\n')
+                  console.log("处理换行符",this.form[field])
+                }
+              })
+
               let options = this.questionInfoData.options
               if (options) {
                 let optionList = JSON.parse(options)
@@ -172,6 +182,8 @@
   .radio_item {
     margin: 20px;
   }
-
-
+  .preserve-newlines >>> .el-textarea__inner {
+    white-space: pre-line;
+    line-height: 1.5;
+  }
 </style>