export default {
  id: 'education',
  title: '教育背景',
  showProgress: true,
  progress: 0,
  get: {
    action: '/zws/v1/enrollment/educations?project_id=1001',
    callback(data) {
      return data.map(item => {
        const { start_date: startDate, end_date: endDate } = item
        if (startDate) {
          item.times = [startDate + '', endDate + '']
        }
        return item
      })
    }
  },
  update: {
    action: '/zws/v1/enrollment/educations/batch-upload',
    data: { project_id: 1001 },
    beforeRequest(data) {
      const records = data.map(item => {
        let [startDate, endDate] = item.times
        item.start_date = startDate.replace(/-/, '')
        item.end_date = endDate.replace(/-/, '')
        return item
      })
      return { records }
    }
  },
  form: {
    hint: `<div style="color:red;font-size:18px;">请务必如实提供高中以上所有学历学位的详细信息。</div>
    <div>按照从最高学历至第一学历的顺序，请您依次填写：博士、硕士、本科、专科，<br>并且填写您获得学位所在学校的国家和城市</div>`,
    options: {
      labelWidth: '110px'
    },
    hasAdd: true,
    defaultModel: {
      times: [],
      start_date: null,
      end_date: null,
      school_name_cn: '',
      school_city: '',
      major_cn: '',
      degree: 0
    },
    items: [
      {
        type: 'date-picker-form',
        elemType: 'monthrange',
        label: '教育时间',
        model: 'times',
        attrs: { 'value-format': 'yyyy-MM' },
        rules: [{ required: true, message: '请选择教育时间', trigger: 'blur' }]
      },
      {
        type: 'input-form',
        label: '学校名称',
        model: 'school_name_cn',
        rules: [{ required: true, message: '请输入学校名称', trigger: 'blur' }]
      },
      {
        type: 'input-form',
        label: '学校所在国家',
        model: 'school_country',
        rules: [
          { required: true, message: '请输入学校所在国家', trigger: 'blur' }
        ]
      },
      {
        type: 'input-form',
        label: '学校所在城市',
        model: 'school_city',
        rules: [
          { required: true, message: '请输入学校所在城市', trigger: 'blur' }
        ]
      },
      {
        type: 'input-form',
        label: '专业名称',
        model: 'major_cn',
        rules: [{ required: true, message: '请输入专业名称', trigger: 'blur' }]
      },
      {
        type: 'select-form',
        values: [
          { label: '请选择', value: 0 },
          { label: '专科', value: 1 },
          { label: '本科', value: 2 },
          { label: '本科/学士', value: 3 },
          { label: '硕士研究生', value: 4 },
          { label: '研究生/硕士', value: 5 },
          { label: '博士研究生', value: 6 },
          { label: '研究生/博士', value: 7 },
          { label: '其他', value: 9 }
        ],
        label: '学历/学位',
        model: 'degree',
        rules: [
          { required: true, message: '请选择学历/学位', trigger: 'change' }
        ]
      }
    ]
  }
}
