Ver Fonte

review code

dusenyao há 1 ano atrás
pai
commit
5b070ed0f7

+ 9 - 0
src/styles/common.scss

@@ -53,3 +53,12 @@
     margin-left: 8px;
   }
 }
+
+.title-little {
+  display: block;
+  margin: 8px 0;
+  font-size: 14px;
+  font-weight: 400;
+  line-height: 22px;
+  color: #4e5969;
+}

+ 0 - 9
src/views/exercise_questions/create/components/common/QuestionBase.vue

@@ -106,15 +106,6 @@ export default {
             }
           }
         }
-
-        .title-little {
-          display: block;
-          margin: 8px 0;
-          font-size: 14px;
-          font-weight: 400;
-          line-height: 22px;
-          color: #4e5969;
-        }
       }
 
       .footer {

+ 1 - 6
src/views/exercise_questions/create/components/exercises/ChineseQuestion.vue

@@ -1,4 +1,3 @@
-<!-- 选择题 -->
 <template>
   <QuestionBase>
     <template #content>
@@ -94,17 +93,13 @@
 </template>
 
 <script>
-import UploadAudio from '../common/UploadAudio.vue';
 import QuestionMixin from '../common/QuestionMixin.js';
 
-import { scoreTypeList, changeOptionType } from '@/views/exercise_questions/data/common';
+import { changeOptionType } from '@/views/exercise_questions/data/common';
 import { chineseData, getOption, learnTypeList } from '@/views/exercise_questions/data/chinese';
 
 export default {
   name: 'ChineseQuestion',
-  components: {
-    UploadAudio,
-  },
   mixins: [QuestionMixin],
   data() {
     return {

+ 10 - 36
src/views/exercise_questions/create/components/exercises/WriteQuestion.vue

@@ -1,4 +1,3 @@
-<!-- 选择题 -->
 <template>
   <QuestionBase>
     <template #content>
@@ -28,7 +27,7 @@
         <label class="title-little">文章:</label>
         <RichText v-model="data.article" placeholder="输入文章" />
         <template v-if="data.property.is_enable_sample_text">
-          <el-divider class="write-divider"></el-divider>
+          <el-divider class="write-divider" />
           <label class="title-little">范文:</label>
           <RichText v-model="data.sample_text" placeholder="输入范文" />
           <p class="tips">多篇范文之间使用分割线(---)</p>
@@ -85,7 +84,7 @@
           <el-input v-model="data.property.score" type="number" />
         </el-form-item>
         <el-form-item label="词数">
-          <el-input-number class="word-num-input" v-model="data.property.word_num" :precision="0"></el-input-number>
+          <el-input-number v-model="data.property.word_num" class="word-num-input" :precision="0" />
         </el-form-item>
         <el-form-item label="范文">
           <el-radio
@@ -133,41 +132,21 @@
 </template>
 
 <script>
-import UploadAudio from '../common/UploadAudio.vue';
 import QuestionMixin from '../common/QuestionMixin.js';
 
-import { scoreTypeList, changeOptionType } from '@/views/exercise_questions/data/common';
-import { wirteData, getOption } from '@/views/exercise_questions/data/write';
+import { changeOptionType } from '@/views/exercise_questions/data/common';
+import { writeData } from '@/views/exercise_questions/data/write';
 
 export default {
   name: 'WriteQuestion',
-  components: {
-    UploadAudio,
-  },
   mixins: [QuestionMixin],
   data() {
     return {
       changeOptionType,
-      data: JSON.parse(JSON.stringify(wirteData)),
+      data: JSON.parse(JSON.stringify(writeData)),
     };
   },
-  methods: {
-    /**
-     * 智能识别
-     * @param {String} text 识别数据
-     */
-    recognition(text) {
-      let arr = text
-        .split(/[\r\n]/)
-        .map((item) => item.trim())
-        .filter((item) => item);
-
-      if (arr.length > 0) {
-        this.data.stem = arr[0];
-        this.data.option_list = arr.slice(1).map((content) => getOption(content));
-      }
-    },
-  },
+  methods: {},
 };
 </script>
 
@@ -188,19 +167,14 @@ export default {
 .property {
   .word-num-input {
     width: 100%;
-  }
-}
-</style>
-<style lang="scss">
-.property {
-  .word-num-input {
-    .el-input-number__increase,
+
+    :deep .el-input-number__increase,
     .el-input-number__decrease {
-      background: #f2f3f5;
+      background-color: #f2f3f5;
     }
 
     .el-input input.el-input__inner {
-      background: #e5e6eb;
+      background-color: #e5e6eb;
     }
   }
 }

+ 24 - 24
src/views/exercise_questions/data/chinese.js

@@ -3,33 +3,33 @@ import { getRandomNumber } from '@/utils/index';
 
 // 汉字类型列表
 export const learnTypeList = [
-    { value: 'miao', label: '描红' },
-    { value: 'write', label: '书写' },
-    { value: 'learn', label: '笔画学习' },
+  { value: 'miao', label: '描红' },
+  { value: 'write', label: '书写' },
+  { value: 'learn', label: '笔画学习' },
 ];
 export function getOption(content = '') {
-    return { content, mark: getRandomNumber() };
+  return { content, mark: getRandomNumber() };
 }
 
 // 选择题数据模板
 export const chineseData = {
-    type: 'chinese', // 题型
-    stem: '', // 题干
-    option_number_show_mode: optionTypeList[0].value, // 选项类型
-    description: '', // 描述
-    content: '', // 题目
-    answer: { select_list: [], score: 0, score_type: scoreTypeList[0].value }, // 答案
-    // 题型属性
-    property: {
-        stem_type: stemTypeList[0].value, // 题干类型
-        question_number: 1, // 题号
-        is_enable_description: false, // 描述
-        score: 1, // 分值
-        score_type: scoreTypeList[0].value, // 分值类型
-        learn_type: learnTypeList[0].value,
-    },
-    // 其他属性
-    other: {
-        question_number_type: questionNumberTypeList[0].value, // 题号类型
-    },
-};
+  type: 'chinese', // 题型
+  stem: '', // 题干
+  option_number_show_mode: optionTypeList[0].value, // 选项类型
+  description: '', // 描述
+  content: '', // 题目
+  answer: { select_list: [], score: 0, score_type: scoreTypeList[0].value }, // 答案
+  // 题型属性
+  property: {
+    stem_type: stemTypeList[0].value, // 题干类型
+    question_number: 1, // 题号
+    is_enable_description: false, // 描述
+    score: 1, // 分值
+    score_type: scoreTypeList[0].value, // 分值类型
+    learn_type: learnTypeList[0].value,
+  },
+  // 其他属性
+  other: {
+    question_number_type: questionNumberTypeList[0].value, // 题号类型
+  },
+};

+ 28 - 28
src/views/exercise_questions/data/write.js

@@ -2,33 +2,33 @@ import { optionTypeList, stemTypeList, scoreTypeList, questionNumberTypeList } f
 import { getRandomNumber } from '@/utils/index';
 
 export function getOption(content = '') {
-    return { content, mark: getRandomNumber() };
+  return { content, mark: getRandomNumber() };
 }
 
-// 选择题数据模板
-export const wirteData = {
-    type: 'write', // 题型
-    stem: '', // 题干
-    option_number_show_mode: optionTypeList[0].value, // 选项类型
-    description: '', // 描述
-    article: '', // 文章
-    sample_text: '', // 范文
-    answer: { select_list: [], score: 0, score_type: scoreTypeList[0].value }, // 答案
-    // 题型属性
-    property: {
-        stem_type: stemTypeList[0].value, // 题干类型
-        question_number: 1, // 题号
-        is_enable_description: false, // 描述
-        score: 1, // 分值
-        score_type: scoreTypeList[0].value, // 分值类型
-        word_num: 50, // 词数
-        is_enable_sample_text: true, // 范文开启
-        is_enable_voice_answer: true, // 语音作答
-        is_enable_upload: true, // 上传附件
-        is_enable_model_essay: true, // 参考范文
-    },
-    // 其他属性
-    other: {
-        question_number_type: questionNumberTypeList[0].value, // 题号类型
-    },
-};
+// 数据模板
+export const writeData = {
+  type: 'write', // 题型
+  stem: '', // 题干
+  option_number_show_mode: optionTypeList[0].value, // 选项类型
+  description: '', // 描述
+  article: '', // 文章
+  sample_text: '', // 范文
+  answer: { select_list: [], score: 0, score_type: scoreTypeList[0].value }, // 答案
+  // 题型属性
+  property: {
+    stem_type: stemTypeList[0].value, // 题干类型
+    question_number: 1, // 题号
+    is_enable_description: false, // 描述
+    score: 1, // 分值
+    score_type: scoreTypeList[0].value, // 分值类型
+    word_num: 50, // 词数
+    is_enable_sample_text: true, // 范文开启
+    is_enable_voice_answer: true, // 语音作答
+    is_enable_upload: true, // 上传附件
+    is_enable_model_essay: true, // 参考范文
+  },
+  // 其他属性
+  other: {
+    question_number_type: questionNumberTypeList[0].value, // 题号类型
+  },
+};