

//派车单
export const setMainColumns = (self, mName='', 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.$emit('view', record)
              },
            },
          },
          [self._v(txt)]
        )
      },
    },
    {
      dataIndex: 'statusName',
      title: '派车单状态',
      width: 120,
      sorter: (a, b) => {
        return a.status - b.status
      },
    },
    {
      dataIndex: 'payFeeCltTypeName',
      title: ' 支出计费单据',
      width: 120,
      sorter: (a, b) => {
        return a.payFeeCltType - b.payFeeCltType
      },
    },
    {
      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: 160,
      sorter: (a, b) => {
        return +new Date(a.loadingDate) - +new Date(b.loadingDate)
      },
    },
    {
      dataIndex: 'loadingAuditDate',
      title: '调度审核日期',
      width: 160,
      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:'totalMileage',
      title: mName+'公里数',
      width: 120,
      sorter: (a, b) => {
        return a.totalMileage - b.totalMileage
      },
    },
    {
      dataIndex: 'totalMapMileage',
      title: mName+'地图公里数',
      width: 120,
      sorter: (a, b) => {
        return a.totalMapMileage - b.totalMapMileage
      },
    },
    {
      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:'totalPcs',
      title: mName+'总件数',
      width: 120,
      sorter: (a, b) => {
        return a.totalPcs - b.totalPcs
      },
    },
    {
      dataIndex: 'totalWeight',
      title: mName+'重量(kg)',
      width: 120,
      sorter: (a, b) => {
        return a.totalWeight - b.totalWeight
      },
    },
    {
      dataIndex: 'totalVolume',
      title: mName+'体积(m³)',
      width: 120,
      sorter: (a, b) => {
        return a.totalVolume - b.totalVolume
      },
    },
    {
      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
      },
    },
    {
      width: 120,
      dataIndex: 'carrierName',
      title: '承运商名称',
      sorter: (a, b) => {
        return ~~a.carrierId - ~~b.carrierId
      },
    },
    {
      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: 160,
      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: mName+'计费状态',
      sorter: (a, b) => {
        return a.costStatus - b.costStatus
      },
    },
    {
      width: 160,
      dataIndex: 'costDate',
      title: mName+'计费时间',
      sorter: (a, b) => {
        return +new Date(a.costDate) - +new Date(b.costDate)
      },
    },
    {
      width: 100,
      dataIndex: 'costContract',
      title: mName+'计费合同',
      sorter: (a, b) => {
        return a.costContract - b.costContract
      },
    },
    {
      width: 100,
      dataIndex: 'settlementStatusName',
      title: mName+'核算状态',
      sorter: (a, b) => {
        return a.settlementStatus - b.settlementStatus
      },
    },
    {
      width: 160,
      dataIndex: 'settlementDate',
      title: mName+'核算时间',
      sorter: (a, b) => {
        return +new Date(a.settlementDate) - +new Date(b.settlementDate)
      },
    },
    {
      width: 160,
      dataIndex: 'costStatusName',
      title: mName+'计费状态',
      sorter: (a, b) => {
        return ~~a.costStatus - ~~b.costStatus
      },
    },

      {
      width: 160,
      dataIndex: 'checkStatusName',
      title: '支出结算状态',
      sorter: (a, b) => {
        return ~~a.checkStatus - ~~b.checkStatus
      },
    },

    {
      width: 160,
      dataIndex: 'settlementDate',
      title: mName+'核算时间',
      sorter: (a, b) => {
        return +new Date(a.settlementDate) - +new Date(b.settlementDate)
      },
    },

    {
      dataIndex: mName=='支出'?'payAmount':'amount',
      title: mName+'总价',
      width: 100,
      sorter: (a, b) => {
        return ~~a.payAmount - ~~b.payAmount
      },
    },
    {
      dataIndex: mName=='支出'?'contractPayAmount':'contractAmount',
      title: '合同'+mName+'总价',
      width: 140,
      sorter: (a, b) => {
        return ~~a.contractPayAmount - ~~b.contractPayAmount
      },
    },
    ...expData,
    {
      dataIndex: 'createperson',
      title: '创建人',
      width: 100,
      sorter: (a, b) => {
        return a.createperson.length - b.createperson.length
      },
    },
    {
      dataIndex: 'createtime',
      title: '创建时间',
      width: 160,
      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: 160,
      sorter: (a, b) => {
        return +new Date(a.updatetime) - +new Date(b.updatetime)
      },
    },
    {
      key: 'operation',
      title: '操作',
      width: 160,
      fixed: 'right',
      align: 'center',
      scopedSlots: { customRender: 'operation' },
    },
  ]
}
