 <template>
  <ai-detail>
    <template slot="title">
      <ai-title title="规则设置" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
      </ai-title>
    </template>
    <template slot="content">
      <ai-card title="规则设置">
        <template #content>
          <el-form ref="form" class="ai-form" :model="form" label-width="110px" label-position="right">
            <el-form-item label="投票设置" style="width: 100%" prop="title" :rules="[{required: true, message: '请输入投票设置', trigger: 'blur'}]">
              <el-input-number v-model="form.day" size="small" placeholder="请输入投票设置"></el-input-number>
            </el-form-item>
            <el-form-item label="前言设置" style="width: 100%" prop="preface" :rules="[{required: true, message: '请输入视频简介', trigger: 'blur'}]">
              <ai-editor v-model="form.preface" :instance="instance"/>
            </el-form-item>
            <el-form-item label="结尾设置" style="width: 100%" prop="end" :rules="[{required: true, message: '请输入视频简介', trigger: 'blur'}]">
              <ai-editor v-model="form.end" :instance="instance"/>
            </el-form-item>
          </el-form>
        </template>
      </ai-card>
    </template>
  </ai-detail>
</template>

<script>
  export default {
    name: 'Detail',

    props: {
      instance: Function,
      dict: Object,
      params: Object
    },

    data () {
      return {
        form: {
          day: '',
          preface: '',
          end: ''
        }
      }
    },

    created () {
      this.getInfo()
    },

    methods: {
      getInfo () {

      },

      onConfirm () {
        this.$refs.form.validate((valid) => {
          if (valid) {
            this.instance.post(`/app/appassessmentscorev2task/addOrUpdate`, {
              ...this.form,
              beginTime: this.form.date[0],
              endTime: this.form.date[1],
              date: ''
            }).then(res => {
              if (res.code == 0) {
                this.$message.success('提交成功！')
                this.isShow = false

                this.getList()
              }
            })
          }
        })
      },

      cancel () {
        this.$emit('change', {
          type: 'List',
          isRefresh: true
        })
      }
    }
  }
</script>

<style scoped lang="scss">
</style>
