
export const setCloseGoogColumns = (_self, expData = []) => {
  if (expData.length > 0) {
    expData = [...expData]
    expData.forEach((item) => {
      item.type = 'edit'
      item.placeholder = '请输入' + item.title
    })
  }
  return [
    { dataIndex: 'id', title: 'ID', hidden: true, type: 'txt', width: 200 },
    { dataIndex: 'itemId', title: '商品Id', hidden: true, type: 'txt', width: 200 },
    {
      dataIndex: 'itemCode',
      title: '商品编码',
      type: 'txt',
      sorter: (a, b) => {
        return a.itemCode != b.itemCode
      },
    },
    {
      dataIndex: 'itemName',
      title: '商品名称',
      type: 'txt',
      sorter: (a, b) => {
        return a.itemName != b.itemName
      },
    },
    {
      dataIndex: 'itemCategoryName',
      title: '商品品类',
      type: 'txt',
      sorter: (a, b) => {
        return ~~a.itemCategory - ~~b.itemCategory
      },
    },

    {
      dataIndex: 'packTypeName',
      title: '包装类型',
      type: 'txt',
      sorter: (a, b) => {
        return ~~a.packType - ~~b.packType
      },
    },
    {
      dataIndex: 'cargoThermosphereName',
      title: '货物温层',
      type: 'txt',
    },
    {
      dataIndex: 'origPcs',
      title: '件数',
      type: 'txt',
      width: 120,
      align: 'center',
      sorter: (a, b) => {
        return ~~a.origPcs - ~~b.origPcs
      },
    },
    {
      title: '发货件数',
      dataIndex: 'deliveryPcs',
      type: 'txt',
      width: 120,
      align: 'center',
      sorter: (a, b) => {
        return ~~a.deliveryPcs - ~~b.deliveryPcs
      },
    },
    {
      title: '剩余件数',
      dataIndex: 'pcs',
      type: 'txt',
      width: 120,
      align: 'center',
      sorter: (a, b) => {
        return ~~a.pcs - ~~b.pcs
      },
    },
    {
      title: '关闭件数',
      dataIndex: 'applyPcs',
      precision: 0,
      width: 120,
      align: 'center',
      type:'number',
      customColumnProps({ name, value, record, index, props }) {

        if (record.pcs>0) {
          props.disabled=false
          props.required=true
          props.rules = [
            {
              validator(rule, value, callback) {
                let { pcs } = record
                if (value > pcs) {
                  return callback('关闭件数不能大于剩余件数')
                }
                callback()
              },
            },
          ]
        } else {
          record.applyPcs=0
          props.disabled = true
          props.required=false
          props.rules=null
        }

        //return props

      },
      on: {
        change: _self.handleClosePcsChange,
      },
      sorter: (a, b) => {
        return ~~a.applyPcs - ~~b.applyPcs
      },
    },
    {
      dataIndex: 'weight',
      title: '关闭重量',
      width: 120,
      type: 'txt',
      align: 'center',
      sorter: (a, b) => {
        return +a.weight - +b.weight
      },
    },
    {
      width: 120,
      dataIndex: 'volume',
      title: '关闭体积',
      type: 'txt',
      align: 'center',
      sorter: (a, b) => {
        return +a.volume - +b.volume
      },
    },
    { dataIndex: 'memo', title: '备注', type: 'txt', width: 120 },
    ...expData,
  ]
}
