

export const setGoogColumns = (_self, expData = []) => {
  if (expData.length > 0) {
    expData.forEach(item => {
      if (item.type === 'input') {
        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',
      width: 200,
      sorter: (a, b) => {
        return a.itemCode !=b.itemCode
      }
    },
    {
      dataIndex: 'itemName', title: '商品名称', type: 'txt',
      width: 200,
      sorter: (a, b) => {
        return a.itemName !=b.itemName
      },
    },
    {
      dataIndex: 'itemCategoryName', title: '商品品类', type: 'txt',
      sorter: (a, b) => {
        return ~~a.itemCategory - ~~b.itemCategory
      },
    },

    {
      dataIndex: 'packTypeName',
      title: '包装类型',
      width: 100,
      type: 'txt',
      sorter: (a, b) => {
        return ~~a.packType - ~~b.packType
      },
    },
    {
      dataIndex: 'cargoThermosphereName',
      title: '货物温层',
      type: 'txt',
      width: 100,


    },


    {
      dataIndex: 'origPcs',
      title: '件数',
      type: 'txt',
      align: 'center',
      width: 120,
      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: 'closingPcs',
      type: 'txt',
      width: 120,
      align: 'center',
      sorter: (a, b) => {
        return ~~a.closingPcs - ~~b.closingPcs
      },
    },
    {
      title: '剩余件数',
      dataIndex: 'pcs',
      type: 'txt',
      width: 120,
      align: 'center',
      sorter: (a, b) => {
        return ~~a.pcs - ~~b.pcs
      },
    },
   {
      dataIndex: 'applyPcs',
      title: '申请数量',
      type: 'number',
      align: 'center',
      customColumnProps({ name, value, record, index, props }) {
        if (record.pcs>0) {
          props.disabled=false
          props.required=true
          props.rules = [
            {
              // message: '申请不能大于供应商可用数量或当前数量',
              validator(rule, value, callback) {
                let { pcs, providerPcs } = record
              if (value > pcs) {
                  callback('申请不能大于当前件数')
                }
                callback()
              },
            },
          ]
        } else {
          props.disabled = true
          props.required=false
          props.rules=null
        }

        return props
      },
      on: {
        change: _self.handleChange,
      },
      sorter: (a, b) => {
        return ~~a.applyPcs - ~~b.applyPcs
      },
      width: 120,
    },
    {
      dataIndex: 'weight',
      title: '重量',
      width: 120,
      type:'txt',
      // required:!_self.isAfterWMS,
      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: 'edit',width: 180},
    {
      dataIndex: 'branchName',
      title: '默认存放仓库',
      width: 120,
      type: 'txt',
      sorter: (a, b) => {
        return a.branchName !=b.branchName
      },
    },
    {
      dataIndex: 'inventoryPcs',
      title: '库存数量',
      width: 120,
      type: 'txt',
      sorter: (a, b) => {
        return ~~a.inventoryPcs - ~~b.inventoryPcs
      },
    },
    {
      dataIndex: 'stagingLocation',
      title: '暂存位',
      type: 'txt',
      width: 120,
      // sorter: (a, b) => {
      //   return a.memo.length - b.memo.length
      // },
    },
    ...expData,

  ].filter(item=>item)
}