export default {
  id: 'profile',
  title: '个人信息',
  showProgress: true,
  progress: 0,
  get: {
    action: '/zws/v1/enrollment/profiles?project_id=1000',
    callback(data) {
      data.date_of_starting_to_work = data.date_of_starting_to_work + ''
      let arr = []
      arr[0] = data.address_province
      arr[1] = data.address_city
      data.city_select_str = arr.join('-')
      return data
    }
  },
  update: {
    action: '/zws/v1/enrollment/profiles',
    data: { project_id: 1000 },
    beforeRequest(data) {
      let arr = data.city_select_str.split('-')
      data.address_province = arr[0]
      data.address_city = arr[1]
      return [
        'real_name_cn',
        'phone_number',
        'email',
        'id_type',
        'id_number',
        'birthday',
        'gender',
        'nationality',
        'address_province',
        'address_city',
        'date_of_starting_to_work',
        'we_chat_account',
        'mailing_address',
        'emergency_contact_name',
        'emergency_contacts_phone'
      ].reduce((result, key) => {
        result[key] = data[key]
        return result
      }, {})
    }
  },
  form: {
    options: {
      labelWidth: '150px'
    },
    items: [
      /* 姓名 */
      {
        type: 'input-form',
        label: '姓名',
        model: 'real_name_cn',
        modelWidth: '300px',
        placeholder: '请输入姓名',
        rules: [{ required: true, message: '请输入姓名', trigger: 'blur' }]
      },
      /* 手机号 */
      {
        type: 'input-form',
        label: '手机号',
        model: 'phone_number',
        modelWidth: '300px',
        placeholder: '请输入手机号',
        rules: [{ required: true, message: '请输入英文名', trigger: 'blur' }]
      },
      /* 邮箱 */
      {
        type: 'input-form',
        label: '邮箱',
        model: 'email',
        modelWidth: '300px',
        placeholder: '请输入邮箱',
        rules: [{ required: true, message: '请输入邮箱', trigger: 'blur' }],
        hint: '（后续报名信息将发送至此邮箱，请认真填写）'
      },
      /* 证件类型 */
      {
        type: 'select-form',
        label: '证件类型',
        model: 'id_type',
        modelWidth: '300px',
        placeholder: '请选择证件类型',
        values: [
          { label: '居民身份证', value: 0 },
          { label: '港澳台身份证', value: 1 },
          { label: '护照号', value: 2 },
          { label: '军官证', value: 3 },
          { label: '其他', value: 9 }
        ],
        rules: [
          { required: true, message: '请选择证件类型', trigger: 'change' }
        ]
      },
      /* 证件号码 */
      {
        type: 'input-form',
        label: '证件号码',
        model: 'id_number',
        modelWidth: '300px',
        placeholder: '请输入证件号码',
        rules: [{ required: true, message: '请输入证件号码', trigger: 'blur' }]
      },
      /* 出生日期 */
      {
        type: 'date-picker-form',
        elemType: 'date',
        label: '出生日期',
        model: 'birthday',
        modelWidth: '300px',
        placeholder: '请选择出生日期',
        attrs: { 'value-format': 'yyyy-MM-dd' },
        rules: [{ required: true, message: '请选择出生日期', trigger: 'blur' }]
      },
      /* 性别 */
      {
        type: 'radio-group-form',
        label: '性别',
        model: 'gender',
        modelWidth: '300px',
        values: [
          { label: '男', value: 1 },
          { label: '女', value: 2 }
        ],
        rules: [{ required: true, message: '请选择性别', trigger: 'change' }]
      },
      /* 国籍 */
      {
        type: 'select-form',
        label: '国籍',
        model: 'nationality',
        modelWidth: '300px',
        placeholder: '请选择国籍',
        values: [
          { label: '中国', value: 1 },
          { label: '其他国家', value: 9 }
        ],
        rules: [{ required: true, message: '请选择国籍', trigger: 'blur' }]
      },
      /* 现居住城市 */
      {
        type: 'city-select-form',
        label: '现居住城市',
        labelWidth: '160px',
        model: 'city_select_str',
        separator: '-',
        placeholder0: '请选择省份',
        placeholder1: '请选择城市',
        rules: [{ required: true, message: '请选择居住城市', trigger: 'blur' }]
      },
      /* 参加工作年份 */
      {
        type: 'date-picker-form',
        elemType: 'year',
        label: '参加工作年份',
        model: 'date_of_starting_to_work',
        modelWidth: '300px',
        placeholder: '请选择参加工作年份',
        attrs: { 'value-format': 'yyyy' },
        rules: [
          { required: true, message: '请选择参加工作年份', trigger: 'blur' }
        ]
      },
      /* 微信号 */
      {
        type: 'input-form',
        label: '微信号',
        model: 'we_chat_account',
        modelWidth: '300px',
        placeholder: '请输入微信号',
        rules: [{ required: true, message: '请输入微信号', trigger: 'blur' }]
      },
      /* 邮寄地址 */
      {
        type: 'input-form',
        label: '邮寄地址',
        model: 'mailing_address',
        modelWidth: '300px',
        placeholder: '请输入邮寄地址',
        rules: [{ required: true, message: '请输入邮寄地址', trigger: 'blur' }]
      },
      /* 紧急联系人 */
      {
        type: 'input-form',
        label: '紧急联系人',
        model: 'emergency_contact_name',
        modelWidth: '300px',
        placeholder: '请输入紧急联系人',
        rules: [
          { required: true, message: '请输入紧急联系人', trigger: 'blur' }
        ]
      },
      /* 紧急联系电话 */
      {
        type: 'input-form',
        label: '紧急联系电话',
        model: 'emergency_contacts_phone',
        modelWidth: '300px',
        placeholder: '请输入紧急联系电话',
        rules: [
          { required: true, message: '请输入紧急联系电话', trigger: 'blur' }
        ]
      }
    ]
  }
}
