<template>
  <QuestionBase>
    <template #content>
      <div class="stem">
        <el-input
          v-if="data.property.stem_type === stemTypeList[0].value"
          v-model="data.stem"
          rows="3"
          resize="none"
          type="textarea"
          placeholder="输入题干"
        />

        <RichText v-if="data.property.stem_type === stemTypeList[1].value" v-model="data.stem" placeholder="输入题干" />

        <el-input
          v-show="isEnable(data.property.is_enable_description)"
          v-model="data.description"
          rows="3"
          resize="none"
          type="textarea"
          placeholder="输入题目要求"
        />
      </div>

      <div class="content">
        <label class="title-little">阅读材料：</label>
        <RichText v-model="data.article" placeholder="输入阅读材料" />
        <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>
    </template>

    <template #property>
      <el-form :model="data.property">
        <el-form-item label="题干">
          <el-radio
            v-for="{ value, label } in stemTypeList"
            :key="value"
            v-model="data.property.stem_type"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-form-item>
        <el-form-item label="题号">
          <el-input v-model="data.property.question_number" />
        </el-form-item>
        <el-form-item label-width="45px">
          <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-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 scoreTypeList"
            :key="value"
            v-model="data.property.score_type"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-form-item>
        <el-form-item label-width="45px">
          <el-input v-model="data.property.score" type="number" />
        </el-form-item>
        <el-form-item label="词数">
          <el-input-number v-model="data.property.word_num" 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_voice_answer"
            :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 { changeOptionType } from '@/views/exercise_questions/data/common';
import { writeData } from '@/views/exercise_questions/data/write';

export default {
  name: 'WriteQuestion',
  mixins: [QuestionMixin],
  data() {
    return {
      changeOptionType,
      data: JSON.parse(JSON.stringify(writeData)),
    };
  },
  methods: {},
};
</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>
