import myClass from '@/views/BMS/$common/tableConfig/shipbillClass.js'



export const setMainColumns = (self, expData = []) => {
  return [
    {
      dataIndex: 'loadingBillNo',
      sorter: (a, b) => {
        if (!a.loadingBillNo || !b.loadingBillNo) return
        return a.loadingBillNo.replace(/[^0-9]/gi, '') - b.loadingBillNo.replace(/[^0-9]/gi, '')
      },
      title: '派车单号',
      width: 120,
      customRender: (txt, record) => {
        return self._c(
          'a',
          {
            attrs: {
              href: 'javascript:void(0)',
            },
            on: {
              click: (event) => {
                event.stopPropagation()
                return self.onEdit(record, 'view')
              },
            },
          },
          [self._v(txt)]
        )
      },
    },
    {
      dataIndex: 'payFeeCltTypeName',
      title: '支出计费单据',
      width: 120,
      sorter: (a, b) => {
        return a.payFeeCltTypeName - b.payFeeCltTypeName
      },
    },
    {
      dataIndex: 'cargoOwnerName',
      title: '货主',
      width: 120,
      sorter: (a, b) => {
        return a.cargoOwnerName != b.cargoOwnerName
      },
    },
    {
      dataIndex: 'settlementDepartment',
      title: '结算部门',
      width: 100,
      sorter: (a, b) => {
        return a.settlementDepartment - b.settlementDepartment
      },
    },
    {
      dataIndex: 'loadingDate',
      title: '调度日期',
      width: 100,
      sorter: (a, b) => {
        return +new Date(a.loadingDate) - +new Date(b.loadingDate)
      },
    },
    {
      dataIndex: 'loadingAuditDate',
      title: '调度审核日期',
      width: 120,
      sorter: (a, b) => {
        return +new Date(a.loadingAuditDate) - +new Date(b.loadingAuditDate)
      },
    },
    {
      dataIndex: 'groupName',
      title: '分组名称',
      width: 120,
      sorter: (a, b) => {
        return a.groupName.length - b.groupName.length
      },
    },
    {
      dataIndex: 'deliveryLines',
      title: '配送线路',
      width: 120,
      sorter: (a, b) => {
        return a.deliveryLines.length - b.deliveryLines.length
      },
    },
    {
      dataIndex: 'stationLines',
      title: '站点线路',
      width: 120,
      sorter: (a, b) => {
        return a.stationLines.length - b.stationLines.length
      },
    },
    {
      dataIndex: 'totalPayMileage',
      title: '支出公里数',
      width: 120,
      sorter: (a, b) => {
        return a.totalPayMileage - b.totalPayMileage
      },
    },
    {
      dataIndex: 'totalPayMileageMap',
      title: '支出地图公里数',
      width: 120,
      sorter: (a, b) => {
        return a.totalPayMileageMap - b.totalPayMileageMap
      },
    },
    {
      dataIndex: 'pickUpAreas',
      title: '提货区域',
      width: 120,
      sorter: (a, b) => {
        return a.pickUpAreas.length - b.pickUpAreas.length
      },
    },
    {
      dataIndex: 'deliveryAreas',
      title: '配送区域',
      width: 120,
      sorter: (a, b) => {
        return a.deliveryAreas.length - b.deliveryAreas.length
      },
    },
    {
      dataIndex: 'totalPayPcs',
      title: '支出件数',
      width: 120,
      sorter: (a, b) => {
        return a.totalPayPcs - b.totalPayPcs
      },
    },
    {
      dataIndex: 'totalPayWeight',
      title: '支出重量(kg)',
      width: 120,
      sorter: (a, b) => {
        return a.totalPayWeight - b.totalPayWeight
      },
    },
    {
      dataIndex: 'totalPayVolume',
      title: '支出体积(m³)',
      width: 120,
      sorter: (a, b) => {
        return a.totalPayVolume - b.totalPayVolume
      },
    },
    {
      dataIndex: 'driverName',
      title: '司机姓名',
      width: 120,
      sorter: (a, b) => {
        return a.driverName.length - b.driverName.length
      },
    },
    {
      dataIndex: 'driverPhoneNumber',
      title: '司机手机号',
      width: 120,
      sorter: (a, b) => {
        return a.driverPhoneNumber - b.driverPhoneNumber
      },
    },
    {
      dataIndex: 'vehicleAffiliationName',
      title: '司机隶属机构',
      width: 120,
      sorter: (a, b) => {
        return a.vehicleAffiliationName.length - b.vehicleAffiliationName.length
      },
    },
    {
      dataIndex: 'deliverymanName',
      title: '送货员姓名',
      width: 120,
      sorter: (a, b) => {
        return a.deliverymanName.length - b.deliverymanName.length
      },
    },
    {
      dataIndex: 'deliverymanPhoneNumber',
      title: '送货员手机号',
      width: 120,
      sorter: (a, b) => {
        return a.deliverymanPhoneNumber - b.deliverymanPhoneNumber
      },
    },
    {
      dataIndex: 'vehiclePlateNumber',
      title: '车牌号',
      width: 120,
      sorter: (a, b) => {
        if (!a.vehiclePlateNumber || !b.vehiclePlateNumber) return
        return a.vehiclePlateNumber.replace(/[^0-9]/gi, '') - b.vehiclePlateNumber.replace(/[^0-9]/gi, '')
      },
    },
    {
      dataIndex: 'vehicleAscriptionName',
      title: '车辆归属',
      width: 120,
      sorter: (a, b) => {
        return a.vehicleAscription - b.vehicleAscription
      },
    },
    {
      dataIndex: 'vehicleTypeName',
      title: '车型',
      width: 120,
      sorter: (a, b) => {
        return a.vehicleType - b.vehicleType
      },
    },
    {
      dataIndex: 'vehicleTypeCategoryName',
      title: '车辆类别',
      width: 120,
      sorter: (a, b) => {
        return a.vehicleTypeCategory - b.vehicleTypeCategory
      },
    },
    {
      dataIndex: 'vehicleWeight',
      title: '载重(kg)',
      width: 120,
      sorter: (a, b) => {
        return a.vehicleWeight - b.vehicleWeight
      },
    },
    {
      dataIndex: 'vehicleVolume',
      title: '载方(m³)',
      width: 120,
      sorter: (a, b) => {
        return a.vehicleVolume - b.vehicleVolume
      },
    },
    {
      dataIndex: 'weightLoadingRate',
      title: '装载率',
      width: 120,
      sorter: (a, b) => {
        return a.weightLoadingRate - b.weightLoadingRate
      },
    },
    {
      dataIndex: 'memo',
      title: '派车单备注',
      width: 120,
      sorter: (a, b) => {
        return a.memo.length - b.memo.length
      },
    },
    {
      dataIndex: 'synchronousStatusName',
      title: '同步状态​',
      width: 100,
      sorter: (a, b) => {
        return a.synchronousStatus - b.synchronousStatus
      },
    },
    {
      width: 100,
      dataIndex: 'synchronousDate',
      title: '同步时间',
      align: 'center',
      sorter: (a, b) => {
        return +new Date(a.synchronousDate) - +new Date(b.synchronousDate)
      },
    },
    {
      width: 100,
      dataIndex: 'synchronousFailReason',
      title: '同步失败原因',
      sorter: (a, b) => {
        return a.synchronousFailReason - b.synchronousFailReason
      },
    },
    {
      width: 100,
      dataIndex: 'costStatusName',
      title: '支出计费状态',
      sorter: (a, b) => {
        return a.costStatus - b.costStatus
      },
    },
    {
      width: 100,
      dataIndex: 'costDate',
      title: '支出计费时间',
      sorter: (a, b) => {
        return +new Date(a.costDate) - +new Date(b.costDate)
      },
    },
    {
      width: 100,
      dataIndex: 'costContract',
      title: '支出计费合同',
      sorter: (a, b) => {
        return a.costContract - b.costContract
      },
    },
    {
      width: 100,
      dataIndex: 'settlementStatusName',
      title: '支出核算状态',
      sorter: (a, b) => {
        return a.settlementStatus - b.settlementStatus
      },
    },
    {
      width: 100,
      dataIndex: 'settlementDate',
      title: '支出核算时间',
      sorter: (a, b) => {
        return +new Date(a.settlementDate) - +new Date(b.settlementDate)
      },
    },
    {
      width: 100,
      dataIndex: 'checkStatusName',
      title: '支出结算状态',
      sorter: (a, b) => {
        return a.checkStatus - b.checkStatus
      },
    },
    ...expData,
    {
      dataIndex: 'createperson',
      title: '创建人',
      width: 100,
      sorter: (a, b) => {
        return a.createperson.length - b.createperson.length
      },
    },
    {
      dataIndex: 'createtime',
      title: '创建时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.createtime) - +new Date(b.createtime)
      },
    },
    {
      dataIndex: 'updateperson',
      title: '修改人',
      width: 100,
      sorter: (a, b) => {
        return a.updateperson.length - b.updateperson.length
      },
    },
    {
      dataIndex: 'updatetime',
      title: '修改时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.updatetime) - +new Date(b.updatetime)
      },
    },
    {
      key: 'operation',
      title: '操作',
      width: 180,
      fixed: 'right',
      align: 'center',
      scopedSlots: { customRender: 'operation' },
    },
  ]
}

export const setDetailsColumns = (self, expData = []) => {
  let consignee = new myClass({ name: '收货方', key: 'consignee' })
  let shipper = new myClass({ name: '发货方', key: 'shipper' })
  return [
    {
      dataIndex: 'shipbillNo',
      sorter: (a, b) => {
        if (!a.shipbillNo || !b.shipbillNo) return
        return a.shipbillNo.replace(/[^0-9]/gi, '') - b.shipbillNo.replace(/[^0-9]/gi, '')
      },
      title: '运单号',
      width: 200,
      customRender: (txt, record) => {
        const { recordTagWord, colorTagFontColor } = record
        let text = self._c(
          'a',
          {
            attrs: {
              href: 'javascript:void(0)',
            },
            style: { [colorTagFontColor && 'color']: colorTagFontColor },
            on: {
              click: (event) => {
                event.stopPropagation()
                return self.onDetailsView(record)
              },
            },
          },
          [self._v(txt)])
        if (recordTagWord) {
          return self._c('a-space', {}, [text, self._c('a-badge', {
            attrs: {
              numberStyle: { boxShadow: 'none' },
              count: recordTagWord,
              overflowCount: Infinity
            }
          },
          )])
        } else {
          return text
        }
      },
    },
    {
      dataIndex: 'cargoOwnerName',
      title: '货主',
      width: 120,
      sorter: (a, b) => {
        return a.cargoOwnerName != b.cargoOwnerName
      },
    },
    {
      dataIndex: 'orderNo',
      title: '订单号',
      width: 120,
      sorter: (a, b) => {
        if (!a.orderNo || !b.orderNo) {
          return
        }
        return a.orderNo.replace(/[^0-9]/gi, '') - b.orderNo.replace(/[^0-9]/gi, '')
      },
    },
    {
      dataIndex: 'settlementCompany',
      title: '结算公司',
      width: 100,
      sorter: (a, b) => {
        return a.settlementCompany - b.settlementCompany
      },
    },
    {
      dataIndex: 'settlementDepartment',
      title: '结算部门',
      width: 100,
      sorter: (a, b) => {
        return a.settlementDepartment - b.settlementDepartment
      },
    },
    {
      dataIndex: 'synchronousStatusName',
      title: '同步状态​',
      width: 100,
      sorter: (a, b) => {
        return a.synchronousStatus - b.synchronousStatus
      },
    },
    {
      width: 100,
      dataIndex: 'synchronousDate',
      title: '同步时间',
      align: 'center',
      sorter: (a, b) => {
        return +new Date(a.synchronousDate) - +new Date(b.synchronousDate)
      },
    },
    {
      width: 100,
      dataIndex: 'synchronousFailReason',
      title: '同步失败原因',
      sorter: (a, b) => {
        return a.synchronousFailReason - b.synchronousFailReason
      },
    },
    {
      width: 100,
      dataIndex: 'costStatusName',
      title: '计费状态',
      sorter: (a, b) => {
        return a.costStatusName - b.costStatusName
      },
    },
    {
      width: 100,
      dataIndex: 'costDate',
      title: '计费时间',
      sorter: (a, b) => {
        return +new Date(a.costDate) - +new Date(b.costDate)
      },
    },
    {
      width: 100,
      dataIndex: 'costContract',
      title: '计费合同',
      sorter: (a, b) => {
        return a.costContract - b.costContract
      },
    },
    {
      dataIndex: 'feeCltTypeName',
      title: '计费单据',
      width: 120,
      sorter: (a, b) => {
        return a.feeCltType - b.feeCltType
      },
    },
    {
      width: 100,
      dataIndex: 'costFailReason',
      title: '计费失败原因',
      sorter: (a, b) => {
        return a.costFailReason.length - b.costFailReason.length
      },
    },
    {
      width: 100,
      dataIndex: 'settlementStatusName',
      title: '核算状态',
      sorter: (a, b) => {
        return a.settlementStatus - b.settlementStatus
      },
    },
    {
      width: 100,
      dataIndex: 'settlementDate',
      title: '核算时间',
      sorter: (a, b) => {
        return +new Date(a.settlementDate) - +new Date(b.settlementDate)
      },
    },
    {
      width: 100,
      dataIndex: 'shipBillStatusName',
      title: '运单状态',
      sorter: (a, b) => {
        return a.shipBillStatus - b.shipBillStatus
      },
    },
    {
      width: 100,
      dataIndex: 'abnormalStatusName',
      title: '异常状态',
      sorter: (a, b) => {
        return a.abnormalStatus - b.abnormalStatus
      },
    },
    {
      width: 100,
      dataIndex: 'carrierTypeName',
      title: '承运方类型',
      sorter: (a, b) => {
        return a.carrierType - b.carrierType
      },
    },
    {
      width: 160,
      dataIndex: 'loadingBillNo',
      title: '调度单号',
      sorter: (a, b) => {
        return a.loadingBillNo - b.loadingBillNo
      },
    },
    {
      width: 120,
      dataIndex: 'carrierName',
      title: '承运方名称',
      sorter: (a, b) => {
        return a.carrierName.length - b.carrierType.length
      },
    },
    {
      width: 120,
      dataIndex: 'deliveryName',
      title: '送货员姓名',
      sorter: (a, b) => {
        return a.deliveryName.length - b.deliveryName.length
      },
    },
    {
      width: 120,
      dataIndex: 'vehicleCode',
      title: '车牌号',
      sorter: (a, b) => {
        return a.vehicleId - b.vehicleId

      },
    },
    {
      width: 120,
      dataIndex: 'carrierName',
      title: '承运商名称',
      sorter: (a, b) => {
        return a.carrierId - b.carrierId
      },
    },
    {
      width: 120,
      dataIndex: 'wmsOrderNo',
      title: 'WMS单号',
      sorter: (a, b) => {
        if (!a.wmsOrderNo || !b.wmsOrderNo) {
          return
        }
        return a.wmsOrderNo.replace(/[^0-9]/gi, '') - b.wmsOrderNo.replace(/[^0-9]/gi, '')
      },
    },
    {
      width: 100,
      dataIndex: 'orderTypeName',
      title: '订单类型',
      sorter: (a, b) => {
        return a.orderType - b.orderType
      },
    },
    {
      width: 100,
      dataIndex: 'orderBusinessTypeName',
      title: '业务类型',
      sorter: (a, b) => {
        return a.orderBusinessType - b.orderBusinessType
      },
    },
    {
      width: 100,
      dataIndex: 'deliveryMethodTypeName',
      title: '配送方式',
      sorter: (a, b) => {
        return a.deliveryMethodType - b.deliveryMethodType
      },
    },
    {
      width: 100,
      dataIndex: 'transportTypeName',
      title: '运输模式',
      sorter: (a, b) => {
        return a.transportType - b.transportType
      },
    },
    {
      width: 100,
      dataIndex: 'temperatureRequirementName',
      title: '温度要求',
      width: 120,
      sorter: (a, b) => {
        return a.temperatureRequirement - b.temperatureRequirement
      },
    },

    {
      width: 120,
      dataIndex: 'memo',
      title: '备注',
      sorter: (a, b) => {
        if (!a.memo || !b.memo) {
          return -1
        }
        return a.memo.length - b.memo.length
      },
    },
    {
      width: 150,
      dataIndex: 'orderDate',
      title: '下单时间',
      sorter: (a, b) => {
        return +new Date(a.orderDate) - +new Date(b.orderDate)
      },
    },
    {
      width: 150,
      dataIndex: 'submitDate',
      title: '提交时间',
      sorter: (a, b) => {
        return +new Date(a.submitDate) - +new Date(b.submitDate)
      },
    },
    {
      dataIndex: 'auditDate',
      title: '审核时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.auditDate) - +new Date(b.auditDate)
      },
    },
    {
      dataIndex: 'loadingDate',
      title: '调度时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.loadingDate) - +new Date(b.loadingDate)
      },
    },
    {
      dataIndex: 'loadingAuditDate',
      title: '调度审核时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.loadingAuditDate) - +new Date(b.loadingAuditDate)
      },
    },
    {
      dataIndex: 'startDate',
      title: '实际启运时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.startDate) - +new Date(b.startDate)
      },
    },
    {
      dataIndex: 'deliveryDate',
      title: '实际送达时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.deliveryDate) - +new Date(b.deliveryDate)
      },
    },
    {
      dataIndex: 'receiptDate',
      title: '回单时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.receiptDate) - +new Date(b.receiptDate)
      },
    },
    {
      dataIndex: 'originalBackDate',
      title: '正本回单时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.originalBackDate) - +new Date(b.originalBackDate)
      },
    },
    {
      dataIndex: 'transportAging',
      title: '实际时效',
      width: 80,
      sorter: (a, b) => {
        return a.transportAging - b.transportAging
      },
    },
    {
      dataIndex: 'completionDate',
      title: '完成时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.completionDate) - +new Date(b.completionDate)
      },
    },
    ...consignee.init(self), //收
    ...shipper.init(self), //发
    {
      dataIndex: 'totalPcs',
      title: '总件数',
      width: 100,
      sorter: (a, b) => {
        return a.totalPcs - b.totalPcs
      },
    },
    {
      dataIndex: 'totalWeight',
      title: '总重量',
      width: 100,
      sorter: (a, b) => {
        return a.totalWeight - b.totalWeight
      },
    },
    {
      dataIndex: 'totalVolume',
      title: '总体积',
      width: 100,
      sorter: (a, b) => {
        return a.totalVolume - b.totalVolume
      },
    },
    {
      dataIndex: 'totalWholePiece',
      title: '整件数',
      width: 100,
      sorter: (a, b) => {
        return a.totalWholePiece - b.totalWholePiece
      },
    },
    {
      dataIndex: 'packageLclPiece',
      title: '拼箱数',
      width: 100,
      sorter: (a, b) => {
        return a.packageLclPiece - b.packageLclPiece
      },
    },
    {
      dataIndex: 'packageTotalWeight',
      title: '包裹总重量',
      width: 100,
      sorter: (a, b) => {
        return a.packageTotalWeight - b.packageTotalWeight
      },
    },
    {
      dataIndex: 'packageTotalVolume',
      title: '包裹总体积',
      width: 100,
      sorter: (a, b) => {
        return a.packageTotalVolume - b.packageTotalVolume
      },
    },
    {
      dataIndex: 'sourceName',
      title: '来源',
      width: 100,
      sorter: (a, b) => {
        return a.source - b.source
      },
    },
    {
      dataIndex: 'importBatchNumber',
      title: '导入批次号',
      width: 100,
      sorter: (a, b) => {
        return a.importBatchNumber - b.importBatchNumber
      },
    },
    {
      dataIndex: 'createperson',
      title: '创建人',
      width: 100,
      sorter: (a, b) => {
        return a.createperson.length - b.createperson.length
      },
    },
    {
      dataIndex: 'createtime',
      title: '创建时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.createtime) - +new Date(b.createtime)
      },
    },
    {
      dataIndex: 'updateperson',
      title: '修改人',
      width: 100,
      sorter: (a, b) => {
        return a.updateperson.length - b.updateperson.length
      },
    },
    {
      dataIndex: 'updatetime',
      title: '修改时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.updatetime) - +new Date(b.updatetime)
      },
    },
  ]
}