function conver(arr, idKey, objKey, objNameKey, dateArr, dateKey, type) {
  // 去重数据
  const ret = []
  const newret = []
  arr.forEach((item, index, self) => {
    const compare = []
    ret.forEach((retitem, retindex, retself) => {
      compare.push(retitem[idKey])
    })
    if (compare.indexOf(item[idKey]) === -1) {
      ret.push(item)
    }
  })
  ret.forEach(function(retitem) {
    newret.push(retitem[objKey][objNameKey])
  })
  // return {newret}
  const echarArr = []
  ret.forEach(function(item) {
    echarArr.push({
      id: item[idKey],
      name: item[objKey][objNameKey],
      type: type,
      stack: '总量',
      data: dateArr.map(function() {
        return 0
      })
    })
  })
  dateArr.forEach(function(date, index) {
    arr.forEach(function(arrItem) {
      echarArr.forEach(function(seriesItem) {
        if (arrItem[idKey] === seriesItem.id && arrItem[dateKey] === date) {
          seriesItem.data[index] = arrItem.quantity
        }
      })
    })
  })
  return { echarArr, newret }
}
function interval(arr, idKey, objKey, dateArr, dateKey, type) {
  // 去重数据
  const ret = []
  const newret = []
  arr.forEach((item, index, self) => {
    const compare = []
    ret.forEach((retitem, retindex, retself) => {
      compare.push(retitem[idKey])
    })
    if (compare.indexOf(item[idKey]) === -1) {
      ret.push(item)
    }
  })
  ret.forEach(function(retitem) {
    newret.push(retitem[objKey])
  })
  // return {newret}
  const echarArr = []
  ret.forEach(function(item) {
    echarArr.push({
      id: item[idKey],
      name: item[objKey],
      type: type,
      stack: '总量',
      data: dateArr.map(function() {
        return 0
      })
    })
  })
  dateArr.forEach(function(date, index) {
    arr.forEach(function(arrItem) {
      echarArr.forEach(function(seriesItem) {
        if (arrItem[idKey] === seriesItem.id && arrItem[dateKey] === date) {
          seriesItem.data[index] = arrItem.quantity
        }
      })
    })
  })
  return { echarArr, newret }
}
const echartMathods = {
  conver: conver,
  interval: interval
}
export default echartMathods
