<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">
        <el-upload ref="upload" action="no" accept="image/*" drag :show-file-list="false">
          <div>点击或拖拽图片到此上传</div>
          <div>只有 jpg, png, gif 等格式文件可以上传，文件大小不得超过 5MB</div>
        </el-upload>
      </div>

      <div v-if="data.property.is_enable_reference_answer" class="reference-answer">
        <span class="subtitle">参考答案：</span>
        <el-input v-model="data.reference_answer" type="textarea" rows="3" placeholder="输入参考答案" />
      </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-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_reference_answer"
            :label="value"
          >
            {{ label }}
          </el-radio>
        </el-form-item>
      </el-form>
    </template>
  </QuestionBase>
</template>

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

import { talkPictrueData } from '@/views/exercise_questions/data/talkPicture';

export default {
  name: 'TalkPicture',
  mixins: [QuestionMixin],
  data() {
    return {
      data: JSON.parse(JSON.stringify(talkPictrueData)),
    };
  },
  methods: {},
};
</script>

<style lang="scss" scoped>
.content {
  :deep .el-upload {
    width: 100%;

    &-dragger {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 90px;
      font-size: 14px;

      :first-child {
        color: #000;
      }

      :last-child {
        color: $text-color;
      }
    }
  }
}

.reference-answer {
  display: flex;
  flex-direction: column;
  row-gap: 8px;
  margin-top: 8px;

  .subtitle {
    font-size: 14px;
  }
}
</style>
