<template>
  <QuestionBase>
    <template #content>
      <div class="stem">
        <RichText v-model="data.stem" :font-size="18" placeholder="输入题干" />
        <RichText
          v-if="isEnable(data.property.is_enable_description)"
          v-model="data.description"
          placeholder="输入提示"
        />
      </div>

      <div class="content">
        <template v-if="isEnable(data.property.is_enable_sample_text)">
          <el-divider class="write-divider" />
          <label class="title-little">范文：</label>
          <RichText v-model="data.sample_text" placeholder="输入范文" :wordlimit-num="5000" />
          <p class="tips">多篇范文之间使用分割线（---）</p>
        </template>
      </div>

      <div v-if="isEnable(data.property.is_enable_analysis)" class="analysis">
        <div class="analysis-title">解析：</div>
        <RichText v-model="data.analysis" :is-border="true" :font-size="14" placeholder="输入解析" />
      </div>
    </template>

    <template #property>
      <el-form :model="data.property" label-width="72px" label-position="left">
        <el-form-item label="题号">
          <el-input v-model="data.property.question_number" />
        </el-form-item>
        <el-form-item>
          <el-radio
            v-for="{ value, label } in questionNumberTypeList"
            :key="value"
            v-model="data.other.question_number_type"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-form-item>
        <el-form-item label="题干题号">
          <el-select v-model="data.property.stem_question_number_font_size">
            <el-option v-for="item in fontSizeList" :key="item" :label="item" :value="item" />
          </el-select>
        </el-form-item>
        <el-form-item label="提示">
          <el-radio
            v-for="{ value, label } in switchOption"
            :key="value"
            v-model="data.property.is_enable_description"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-form-item>
        <el-form-item label="解析">
          <el-radio
            v-for="{ value, label } in switchOption"
            :key="value"
            v-model="data.property.is_enable_analysis"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-form-item>
        <el-form-item label="分值">
          <el-radio
            v-for="{ value, label } in scoreTypeList"
            :key="value"
            v-model="data.property.score_type"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-form-item>
        <el-form-item>
          <el-input-number
            v-model="data.property.score"
            :min="0"
            :step="data.property.score_type === scoreTypeList[0].value ? 1 : 0.1"
          />
        </el-form-item>
        <el-form-item label="字数">
          <el-input-number v-model="data.property.word_num" :min="1" :step="10" class="word-num-input" :precision="0" />
        </el-form-item>
        <el-form-item label="范文">
          <el-radio
            v-for="{ value, label } in switchOption"
            :key="value"
            v-model="data.property.is_enable_sample_text"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-form-item>
        <el-form-item label="上传附件">
          <el-radio
            v-for="{ value, label } in switchOption"
            :key="value"
            v-model="data.property.is_enable_upload_accessory"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-form-item>
      </el-form>
    </template>
  </QuestionBase>
</template>

<script>
import QuestionMixin from '../common/QuestionMixin.js';

import { analysisRecognitionWriteData, writeData } from '@/views/exercise_questions/data/write';

export default {
  name: 'WriteQuestion',
  mixins: [QuestionMixin],
  data() {
    return {
      data: JSON.parse(JSON.stringify(writeData)),
    };
  },
  methods: {
    /**
     * 智能识别
     * @param {String} text 识别数据
     */
    recognition(text) {
      let arr = this.recognitionCommon(text);
      let obj = analysisRecognitionWriteData(arr);
      this.recognitionCommonSetObj(obj);
    },
  },
};
</script>

<style lang="scss" scoped>
.content {
  .write-divider {
    margin: 8px 0;
  }

  .tips {
    margin: 8px 0;
    font-size: 12px;
    line-height: 20px;
    color: #8e8e8e;
  }
}

.property {
  .word-num-input {
    width: 100%;

    :deep .el-input-number__increase,
    .el-input-number__decrease {
      background-color: #f2f3f5;
    }

    .el-input input.el-input__inner {
      background-color: #e5e6eb;
    }
  }
}
</style>
