<template>
  <el-dialog v-if="visible" ref="dialog" :visible.sync="visible" title="题目纠错">
    <el-form ref="form" :model="model" :rules="rules" label-width="100px">
      <el-form-item label="题目编号" prop="questionid">{{model.questionid}}</el-form-item>
      <el-form-item label="错误描述" prop="remark">
        <el-input v-model="model.remark" type="textarea" rows="6" placeholder="请描述错误细节"></el-input>
      </el-form-item>
      <el-form-item label="">
        <el-button type="primary" @click="handleSubmit">提交</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
import { correctQuestion2 } from '@/api/webApi/front.js'
export default {
  name: 'correct-question-dialog',
  data() {
    return {
      model: {
        questionid: '',
        remark: ''
      },
      rules: {
        questionid: [{ required: true, message: '未知题目编号' }],
        remark: [{ required: true, message: '错误描述不能为空' }],
      },
      visible: false
    }
  },
  methods: {
    handleSubmit: function () {
      this.$refs.form.validate().then(res => {
        correctQuestion2(this.model).then(_ => {
          this.visible = false
          this.msgSuccess('提交成功')
        })
      })
    },
    // api
    open(questionid) {
      this.model = {
        questionid: questionid,
        remark: ''
      }
      this.visible = true
    }
  }
}
</script>

<style scoped>
</style>
