export default class {
  constructor({ key, name, label, customRender }) {
    this.key = key
    this.name = name
    this.label = label
    this.customRender = customRender
  }
  init(self) {
    let customRender = this.customRender
    let baseName = this.key
    let baseLabel = this.label
    let title = this.name
    let TYPE = this.key.toUpperCase()
    let label = ['', '客户', '仓库', '供应商']

    let _field = [
      'ProvinceCity',
      'Contact',
      'PhoneNumber',
      'LandlineNumber',
      'Email',
      'RelatedPhoneNumber',
      'Address',
      'Memo',
      'Latitude',
      'Longitude',
      'ProvinceName',
      'Province',
      'CityName',
      'City',
      'District',
      'DistrictName',
    ]

    return [
      {
        dataIndex: baseName + 'TypeName',
        title: title + '类型',
        width: 120,
        sorter: (a, b) => {
          return a[baseName + 'TypeName'] - b[baseName + 'TypeName']
        },
      },
      {
        dataIndex: baseName + 'UnitName',
        title: title + '单位',
        width: 120,
        sorter: (a, b) => {
          return a[baseName + 'UnitName'] != b[baseName + 'UnitName']
        },
      },
      {
        dataIndex: baseName + 'Name',
        title: title,
        width: 120,
        sorter: (a, b) => {
          return a[baseName + 'Name'] != b[baseName + 'Name']
        },
      },
      {
        dataIndex: baseName + 'ProvinceCityDistrict',
        sorter: (a, b) => {
          return a[baseName + 'ProvinceCityDistrict'] != b[baseName + 'ProvinceCityDistrict']
        },
        title: baseName === 'consignee' ? '目的地' : baseName === 'shipper' ? '始发地' : '',
        width: 120,
      },
      {
        dataIndex: baseName + 'Contact',
        title: title + '联系人',
        width: 120,
        sorter: (a, b) => {
          if (baseName + 'Contact') {
            return a[baseName + 'Contact'] != b[baseName + 'Contact']
          }
        },
      },
      {
        dataIndex: baseName + 'PhoneNumber',
        title: title + '手机号',
        width: 120,
        sorter: (a, b) => {
          return a[baseName + 'PhoneNumber'] != b[baseName + 'PhoneNumber']
        },
      },
      {
        dataIndex: baseName + 'LandlineNumber',
        title: title + '座机号',
        width: 120,
        sorter: (a, b) => {
          return a[baseName + 'LandlineNumber'] != b[baseName + 'LandlineNumber']
        },
      },
      {
        dataIndex: baseName + 'Email',
        title: title + '邮箱',
        width: 120,
        sorter: (a, b) => {
          return a[baseName + 'Email'] != b[baseName + 'Email']
        },
      },
      {
        dataIndex: baseName + 'Address',
        title: title + '详细地址',
        width: 120,
        sorter: (a, b) => {
          return a[baseName + 'Address'] != b[baseName + 'Address']
        },
      },
      {
        dataIndex: baseName + 'Memo',
        title: title + '备注',
        width: 120,
        sorter: (a, b) => {
          return a[baseName + 'Memo'] != b[baseName + 'Memo']
        },
      },
      {
        dataIndex: baseName + 'Positioning',
        title: title + '位置',
        width: 120,
        sorter: (a, b) => {
          return a[baseName + 'Positioning'] - b[baseName + 'Positioning']
        },
      },
    ]
  }
}
