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


export default  (self,mName='', expData = []) => {
  let consignee = new myClass({ name: '收货方', key: 'consignee' })
  let shipper = new myClass({ name: '发货方', key: 'shipper' })
  return [
    {
      dataIndex: 'id', title: 'ID', hidden: true, width: 100,
    },
    {
      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) => {
        return self._c(
          'a',
          {
            attrs: {
              href: 'javascript:void(0)',
            },
            on: {
              click: (event) => {
                event.stopPropagation()
                return self.$emit('view', record)
              },
            },
          },
          [self._v(txt)]
        )
      },
    },
    {
      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.settlementDepartmentId - ~~b.settlementDepartmentId
      },
    },
    {
      dataIndex: 'payAmount',
      title: mName+'总价(含税)',
      width: 120,
      sorter: (a, b) => {
        return a.payAmount - b.payAmount
      },
    },
    {
      dataIndex: 'contractPayAmount',
      title: '合同'+mName+'总价(含税)',
      sorter: (a, b) => {
        return a.contractPayAmount - b.contractPayAmount
      },
    },
    {
      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
      },
    },

    {
      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)
      },
    },
    {
      dataIndex: 'costContract',
      title: mName+'计费合同',
      sorter: (a, b) => {
        return a.costContract - b.costContract
      },
    },
    {
      dataIndex: 'payFeeCltTypeName',
      title: mName + '计费单据',
      align: 'center',
      sorter: (a, b) => {
        return a.payFeeCltType - b.payFeeCltType
      },
    },
    {
      width: 200,
      dataIndex: 'costFailReason',
      title: mName+'计费失败原因',
    },
    {
      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: 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) => {
      },
    },
    {
      width: 120,
      dataIndex: 'deliveryName',
      title: '送货员姓名',
      sorter: (a, b) => {
      },
    },
    {
      width: 120,
      dataIndex: 'vehicleCode',
      title: '车牌号',
      sorter: (a, b) => {
        return a.vehicleId - b.vehicleId
      },
    },
    {
      width: 120,
      dataIndex: 'vehicleTypeName',
      title: '车型',
      sorter: (a, b) => {
        return a.vehicleType - b.vehicleType
      },
    },
    {
      width: 120,
      dataIndex: 'carrierName',
      title: '承运商名称',
      sorter: (a, b) => {
        return ~~a.carrierId - ~~b.carrierId
      },
    },
    {
      width: 120,

      dataIndex: 'wmsOrderNo',
      title: 'WMS单号',
      sorter: (a, b) => {
      },
    },
    {
      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: '温度要求',
      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
      },
    },
    ...expData,

    {
      width: 160,

      dataIndex: 'orderDate',
      title: '下单时间',
      sorter: (a, b) => {
        return +new Date(a.orderDate) - +new Date(b.orderDate)
      },
    },
    {
      width: 160,

      dataIndex: 'submitDate',
      title: '提交时间',
      sorter: (a, b) => {
        return +new Date(a.submitDate) - +new Date(b.submitDate)
      },
    },
    {
      dataIndex: 'auditDate',
      title: '审核时间',
      width: 160,
      sorter: (a, b) => {
        return +new Date(a.auditDate) - +new Date(b.auditDate)
      },
    },
    {
      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: 'startDate',
      title: '实际启运时间',
      width: 160,
      sorter: (a, b) => {
        return +new Date(a.startDate) - +new Date(b.startDate)
      },
    },
    {
      dataIndex: 'deliveryDate',
      title: '实际送达时间',
      width: 160,
      sorter: (a, b) => {
        return +new Date(a.deliveryDate) - +new Date(b.deliveryDate)
      },
    },
    {
      dataIndex: 'receiptDate',
      title: '回单时间',
      width: 160,
      sorter: (a, b) => {
        return +new Date(a.receiptDate) - +new Date(b.receiptDate)
      },
    },
    {
      dataIndex: 'originalBackDate',
      title: '正本回单时间',
      width: 160,
      sorter: (a, b) => {
        return +new Date(a.originalBackDate) - +new Date(b.originalBackDate)
      },
    },
    {
      dataIndex: 'actualTime',
      title: '实际时效(小时)',
      width: 80,
      alert:'center',
      sorter: (a, b) => {
        return a.actualTime - b.actualTime
      },
    },
    {
      dataIndex: 'completeDate',
      title: '完成时间',
      width: 150,
      sorter: (a, b) => {
        return +new Date(a.completeDate) - +new Date(b.completeDate)
      },
    },

    ...consignee.init(self), //收
    // {
    //   dataIndex: 'totalMileage',
    //   title: '里程数（公里）',
    //   width: 80,
    //   sorter: (a, b) => {
    //     return a.totalMileage - b.totalMileage
    //   },
    // },

    ...shipper.init(self), //发
    {
      dataIndex: 'payTotalPcs',
      title:mName+'总件数',
      width: 120,
      sorter: (a, b) => {
        return a.totalPcs - b.totalPcs
      },
    },
    {
      dataIndex: 'payTotalWeight',
      title: mName+'总重量',
      width: 120,
      sorter: (a, b) => {
        return a.totalWeight - b.totalWeight
      },
    },
    {
      dataIndex: 'payTotalVolume',
      title: mName+'总体积',
      width: 120,
      sorter: (a, b) => {
        return a.totalVolume - b.totalVolume
      },
    },
    {
      dataIndex: 'totalPiece',
      title: '整件数',
      width: 100,
      sorter: (a, b) => {
        return a.totalPiece - b.totalPiece
      },
    },
    {
      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)
      },
    },

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

    },
  ]
}
