const customRender = (self, type) => {
  return (text, data) => {
    if (self.options[type] && Array.isArray(self.options[type])) {
      let value = self.options[type].find((item) => item.value === text)
      return value ? value.label : text
    }
    return text
  }
}

//收货方
export const setNextColumns = (self) => {
  let deliveryTime = []
  if (self.deliveryTime) {
    deliveryTime = [
      {
        dataIndex: 'deliveryTime',
        title: '实际送达时间',
        width: 200,
      },
    ]
  }

  return [
    { dataIndex: 'id', title: 'id', hidden: true },
    { dataIndex: 'shipbillId', title: '运单id', hidden: true },
    { dataIndex: 'consigneeUnitName', title: '收货方单位', width: 200 },
    { dataIndex: 'consigneeName', title: '收货方', width: 200 },
    { dataIndex: 'consigneePhoneNumber', title: '手机号', width: 200 },
    { dataIndex: 'consigneeLandlineNumber', title: '座机号', width: 100 },
    {
      dataIndex: 'consigneeProvinceCityDistrict',
      title: '目的地',
      width: 100,
    },
    {
      dataIndex: 'consigneeAddress',
      title: '详细地址',
      align: 'center',
      width: 200,
    },
    {
      dataIndex: 'carrierName',
      title: '承运商',
      align: 'center',
      width: 100,
    },
    {
      dataIndex: 'driverName',
      title: '司机',
      width: 100,
    },
    {
      dataIndex: 'vehiclePlateNumber',
      title: '车牌号',
      width: 200,
    },
    {
      dataIndex: 'estimatedDeliveryTime',
      title: '预计送达时间',
      width: 200,
    },
    ...deliveryTime,
    // {
    //   dataIndex: 'deliveryTime',
    //   title: '实际送达时间',
    //   width: 200
    // },
    { dataIndex: 'shipperUnitName', title: '发货方单位', width: 120 },
    { dataIndex: 'shipperName', title: '发货方', width: 120 },
    { dataIndex: 'count', title: '运单数', width: 120, align: 'center' },
    { dataIndex: 'totalWholePiece', title: '总整件数', align: 'center', width: 120 },
    { dataIndex: 'totalLclPiece', title: '总拼箱数', align: 'center', width: 80 },
    { dataIndex: 'totalPcs', title: '总件数', align: 'center', width: 120 },
    { dataIndex: 'totalWeight', title: '总重量', align: 'center', width: 120 },
    { dataIndex: 'totalVolume', title: '总体积', align: 'center', width: 120 },

    {
      key: 'operation',
      title: '操作',
      fixed: 'right',
      align: 'center',
      scopedSlots: { customRender: 'operation' },
      ...self.operation,
    },
  ]
}
