
export const setColumns = (self) => {
  return [
    {
      dataIndex: 'groupName', title: '分组名称', width: 250, fixed: "left",
      customRender: (txt, record) => {
        const { recordTagWord} = record
      let text= 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  self._c(
            'span',
            {},
            [text]
          )
        }

      },
    },
    // {
    //   dataIndex: "shipbillIds", title: "shipbillIds",
    //   width: 280,
    //   },
    {
      dataIndex: 'id', title: 'id', hidden: true,
    },
    // {
    //   dataIndex: 'shipbillIds', title: '运单号', hidden: true,
    // },
    {
      dataIndex: 'shippingOrder', align: 'center', title: '配送顺序',
      sorter: (a, b) => {
        return a.shippingOrder - b.shippingOrder
      },
    },
    {
      dataIndex: 'cargoOwnerQty', align: 'center', title: '货主数', width: 100,
      sorter: (a, b) => {
        return a.cargoOwnerQty - b.cargoOwnerQty
      },
    },
    {
      dataIndex: 'oderQty',
      align: 'center', title: '可配载运单数', width: 120,
      sorter: (a, b) => {
        return ~~a.oderQty - ~~b.oderQty
      },
      customRender(txt, record) {

        const { shipbillQty,shipbillIds} = record
        let idArr = shipbillIds?.split(',')??null;
        let disabledIds = self.disabledIds.concat(self.done);
        let oderQty = shipbillQty
        if (idArr) {
          for (let i = 0; i < idArr.length; i++){
            if (disabledIds.includes(idArr[i])) {
              oderQty--
            }
          }

          record.oderQty = txt = oderQty

        }
        console.log(txt)
        if (~~txt < 0) {
          record.oderQty= txt=0
        }

        return self._c('span', { style: !record.pId?'color:#2b80ff':'color:#ccc' },  [self._v(txt)])
      }
    },

    {
      dataIndex: 'minEstimatedPickupTime', align: 'center', title: '最早提货时间', width: 160,
      sorter: (a, b) => {
        return +new Date(a.minEstimatedPickupTime) - +new Date(b.minEstimatedPickupTime)
      },
    },
    {
      dataIndex: 'maxEstimatedDeliveryTime', align: 'center', title: '最晚送达时间', width: 160,
      sorter: (a, b) => {
        return +new Date(a.maxEstimatedDeliveryTime) - +new Date(b.maxEstimatedDeliveryTime)
      },
    },

    {
      dataIndex: 'shipbillQty', align: 'center', title: '运单数', width: 100,
      sorter: (a, b) => {
        return a.shipbillQty - b.shipbillQty
      },
    },
    {
      dataIndex: 'coldChainShipbillQty', align: 'center', title: '冷链运单数', width: 100,
      sorter: (a, b) => {
        return a.coldChainShipbillQty - b.coldChainShipbillQty
      },
    },
    {
      dataIndex: 'urgentShipbillQty', align: 'center', title: '紧急加急运单数', width: 120,
      sorter: (a, b) => {
        return a.urgentShipbillQty - b.urgentShipbillQty
      },
    },
    {
      dataIndex: 'consigneeQty',
      title: '收货方数',
      align: 'center',
      width: 100,
      sorter: (a, b) => {
        return a.consigneeQty - b.consigneeQty
      },
    },

    {
      dataIndex: 'totalPickUpSiteQty',
      title: '总提货点数',
      align: 'center',
      width: 100,
      sorter: (a, b) => {
        return a.totalPickUpSiteQty - b.totalPickUpSiteQty
      },
    },
    {
      dataIndex: 'totalDeliverySiteQty',
      title: '总配送点数',
      align: 'center',
      width: 100,
      sorter: (a, b) => {
        return a.totalDeliverySiteQty - b.totalDeliverySiteQty
      },
    },
    {
      dataIndex: 'totalSitQty',
      title: '总站点数',
      align: 'center',
      width: 100,
      sorter: (a, b) => {
        return a.totalSitQty - b.totalSitQty
      },
    },
    {
      dataIndex: 'packageWholePiece', title: '总整件数', align: 'center', width: 100,
      sorter: (a, b) => {
        return a.packageWholePiece - b.packageWholePiece
      },
    },
    {
      dataIndex: 'totalLclPieceQty', title: '总拼箱数', align: 'center', width: 100,
      sorter: (a, b) => {
        return a.totalLclPieceQty - b.totalLclPieceQty
      },
    },

    {
      dataIndex: 'totalPieceQty', title: '总件数', align: 'center', width: 100,
      sorter: (a, b) => {
        return a.totalPieceQty - b.totalPieceQty
      },
    },
    {
      dataIndex: 'totalWeightQty', title: '总重量', align: 'center', width: 100,
      sorter: (a, b) => {
        return a.totalWeightQty - b.totalWeightQty
      },
    },
    {
      dataIndex: 'totalVolumeQty', title: '总体积', align: 'center', width: 100,
      sorter: (a, b) => {
        return a.totalVolumeQty - b.totalVolumeQty
      },
    },

  ]
}
export const t2_setColumns = (self, str) => {
  let right = [

      {
      dataIndex: "state", title: "分配状态",
      align: 'center',
      customRender(txt, record) {
        if (self.done.length > 0 && self.done.includes(record.shipbillId)) {
          record.state=1
          return  self._c('span', { style: 'color:green' },[self._v('已调度')])
        } else if (self.disabledIds.length > 0 && self.disabledIds.includes(record.shipbillId)) {
          record.state=2
          return  self._c('span', { style: 'color:#999' },[self._v('已分配')])
        }
        return self._c('span', { style: 'color:#2b80ff' },[self._v('可分配')])
      }
    },


  ]
  let left = [

    {
    dataIndex: "pickUpOrder", title: "提货顺序", width: 80,
    align: 'center',
  },
  {
    dataIndex: "shippingOrder", title: "配送顺序", width: 80,
    align: 'center',
  },
  ]
  return [
    ...eval(str),
    {
      dataIndex: "shipbillNo", title: "运单号", width: 200,
      customRender: (txt, record) => {
        const { recordTagWord } = record
      let text= 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  self._c(
            'span',
            {},
            [text]
          )
        }

      },
    },

    {
      dataIndex: "totalPcs", title: "总件数",
      align: 'center', width: 100,
      sorter: (a, b) => {
        return a.totalPcs - b.totalPcs
      },
    },
    {
      dataIndex: "totalWeight", title: "总重量",
      align: 'center', width: 100,
      sorter: (a, b) => {
        return a.totalWeight - b.totalWeight
      },

    },
    {
      dataIndex: "totalVolume", title: "总体积",
      align: 'center', width: 100,
      sorter: (a, b) => {
        return a.totalVolume - b.totalVolume
      },
    },
    { dataIndex: "cargoOwnerName", title: "货主" },
    { dataIndex: "lineDirectionName", title: "方向" },
    { dataIndex: "orderNo", title: "订单号" },
    { dataIndex: "orderTypeName", title: "订单类型" },
    { dataIndex: "orderBusinessTypeName", title: "业务类型" },
    { dataIndex: "temperatureRequirementName", title: "温度要求" },
    { dataIndex: "lineName", title: "线路" },
    { dataIndex: "orderDate", title: "订单下单日期" },
    { dataIndex: "estimatedPickupStartTime", title: "预计提货日期" },
    { dataIndex: "estimatedDeliveryStartTime", title: "预计送达时间" },
    { dataIndex: "shipperTypeName", title: "发货方类型" },
    { dataIndex: "shipperUnitName", title: "发货方单位" },
    { dataIndex: "shipperName", title: "发货方" },
    { dataIndex: "shipperProvinceCityDistrict", title: "始发地" },
    { dataIndex: "shipperAddress", title: "详细地址" },
    { dataIndex: "consigneeTypeName", title: "收货方类型" },
    { dataIndex: "consigneeUnitName", title: "收货方单位" },
    { dataIndex: "consigneeName", title: "收货方" },
    { dataIndex: "consigneeProvinceCityDistrict", title: "目的地" },
    { dataIndex: "consigneeAddress", title: "详细地址" },

  ]
}