import { getTreeList } from '@/api/volunteer'

const sex_option = [
  {
    name: '男',
  },
  {
    name: '女',
  },
]

const city_option = [
  {
    name: '重庆',
  },
  {
    name: '四川',
  },
]

const business_unit_options = [
  {
    name: '件数',
    value: 1,
  },
  {
    name: '面积',
    value: 2,
  },
   {
    name: '时间',
    value: 3,
  },
]

const rules = {
  name: [
    {
      type: 'string',
      required: true,
      message: '请填写姓名',
      trigger: ['blur', 'change'],
    },
    {
      // 此为同步验证，可以直接返回true或者false，如果是异步验证，稍微不同，见下方说明
      validator: (rule, value, callback) => {
        // 调用uview-plus自带的js验证规则，详见：https://uview-plus.jiangruyi.com/js/test.html
        return uni.$u.test.chinese(value)
      },
      message: '姓名必须为中文',
      // 触发器可以同时用blur和change，二者之间用英文逗号隔开
      trigger: ['change', 'blur'],
    },
  ],
  sex: [
    {
      type: 'string',
      max: 1,
      required: true,
      message: '请选择男或女',
      trigger: ['blur', 'change'],
    },
  ],
  age: [
    {
      type: 'string',
      required: true,
      message: '请填写年龄',
      trigger: ['blur', 'change'],
    },
    {
      validator: (rule, value, callback) => {
        return uni.$u.test.digits(value)
      },
      message: '年龄必须为数字',
      // 触发器可以同时用blur和change，二者之间用英文逗号隔开
      trigger: ['change', 'blur'],
    },
  ],
  idCard: [
    {
      type: 'string',
      required: true,
      message: '请填写证件号',
      trigger: ['blur', 'change'],
    },
  ],
  districtName: [
    {
      type: 'string',
      required: true,
      message: '请选择地区',
      trigger: ['blur', 'change'],
    },
  ],
  address: [
    {
      type: 'string',
      required: true,
      message: '请填写地址',
      trigger: ['blur', 'change'],
    },
  ],
  minQuantity: [
    {
      type: 'string',
      required: true,
      message: '请填写最少购买',
      trigger: ['blur', 'change'],
    },
  ],
  skillDescribe: [
    {
      type: 'string',
      required: true,
      message: '请填写个人简介',
      trigger: ['blur', 'change'],
    },
  ],
  businessManagementId: [
    {
      type: 'string',
      required: true,
      message: '请选择服务项目',
      trigger: ['blur', 'change'],
    },
  ],
  businessDescribe: [
    {
      type: 'string',
      required: true,
      message: '请填写服务描述',
      trigger: ['blur', 'change']
    }
  ],
  businessUnit: [
    {
      type: 'string',
      required: true,
      message: '请选择购买单位',
      trigger: ['blur', 'change'],
    },
  ],
}

const column = [
  {
    label: '姓名',
    key: 'name',
    type: 'input',
    rules: rules.name,
    required: true,
  },
  {
    label: '性别',
    key: 'sex',
    type: 'select',
    option: sex_option,
    rules: rules.sex,
    required: true,
  },
  {
    label: '年龄',
    key: 'age',
    type: 'input',
    rules: rules.age,
    required: true,
  },
  {
    label: '手机号',
    key: 'phonenumber',
    type: 'phone-code',
  },
  {
    label: '地区',
    key: 'districtName',
    type: 'city',
    option: city_option,
    rules: rules.districtName,
    required: true,
  },
  {
    label: '详细地址',
    key: 'address',
    type: 'input',
    rules: rules.address,
    required: true,
  },
  // {
  //   label: '最少购买',
  //   key: 'minQuantity',
  //   type: 'input',
  //   rules: rules.minQuantity,
  //   required: true,
  // },
  // {
  //   label: '购买单位',
  //   key: 'businessUnit',
  //   type: 'select',
  //   option: business_unit_options,
  //   rules: rules.businessUnit,
  //   required: true,
  // },
  {
    label: '个人简介',
    key: 'skillDescribe',
    type: 'textarea',
    rules: rules.skillDescribe,
    required: true,
  },
  // {
  //   label: '服务描述',
  //   key: 'businessDescribe',
  //   type: 'textarea',
  //   rules: rules.businessDescribe,
  //   required: true,
  // },
]
export { column }
