/**
 * 学习目的
 */

export default function(_this) {
  return {
    id: 'application_info_answer',
    title: '学习目的',
    required: true,
    visible() {
      return _this.visible
    },
    get: {
      action: `${webConf.apiBaseURL}/enrollment/v1.0/application-materials/${webConf.others.projectId}`,
      callback(data) {
        const { answers = [], submission_stage: submissionStage = 'FILLING' } = data.data.material
        this.form.options.disabled = submissionStage !== 'FILLING'

        const [first = {}, second = {}] = answers
        return {
          qid1: first.qid || '1',
          question1: first.question || '个人描述中文或者英文',
          answer1: first.answer,
          qid2: second.qid || '2',
          question2:
            second.question || '申请紫荆教育康博斯威尔大学教育硕士的原因？以及您的职业或个人发展的预期目标中文或者英文',
          answer2: second.answer
        }
      }
    },
    update: {
      action: `${webConf.apiBaseURL}/enrollment/v1.0/application-materials/${webConf.others.projectId}/put`,
      beforeRequest(data) {
        return {
          answers: [
            { qid: data.qid1, question: data.question1, answer: data.answer1 },
            { qid: data.qid2, question: data.question2, answer: data.answer2 }
          ]
        }
      }
    },
    form: {
      prev: { to: { query: { active: 'application_info', tab: 'application_info_career' } }, isSubmit: true },
      next: { to: { query: { active: 'application_info', tab: 'application_info_training' } }, isSubmit: true },
      options: {},
      items: [
        {
          type: 'v-input',
          label: '个人描述中文或者英文',
          model: 'answer1',
          attrs: { type: 'textarea', rows: '8', style: 'width:100%' },
          rules: [
            { required: true, message: '请输入', trigger: 'blur' }
            // { min: 60, max: 5000, message: '长度在 60 到 5000 个字符', trigger: 'blur' }
          ]
        },
        {
          type: 'v-input',
          label: '申请紫荆教育康博斯威尔大学教育硕士的原因？以及您的职业或个人发展的预期目标中文或者英文',
          model: 'answer2',
          attrs: { type: 'textarea', rows: '8', style: 'width:100%' },
          rules: [
            { required: true, message: '请输入', trigger: 'blur' }
            // { min: 60, max: 5000, message: '长度在 60 到 5000 个字符', trigger: 'blur' }
          ]
        }
      ]
    }
  }
}
