export type C4zipArrType = {
  description: string
  effect: string
  fileName: string
  filePath: string
  importId: string
  isFlag: number
  isTrue: number
  moduleName: string
  num: string
  thumb: string
  type: string
  id: number
}

export type C4zipType = {
  type: '' | '上传' | '查看'
  succ: C4zipArrType[]
  err: C4zipArrType[]
  file?: { fileName: string; filePath: string }
}

// zip数据整理
export const C4zipResDtaFu = (arr: C4zipArrType[], isLook?: boolean) => {
  const succArr: C4zipArrType[] = []

  const errArr: C4zipArrType[] = []

  if (isLook) {
    arr.forEach((v, i) => {
      if (v.description === '成功') succArr.push(v)
      else errArr.push(v)
    })
  } else {
    arr.forEach((v, i) => {
      if (v.isTrue === 1 && v.isFlag === 1 && v.effect) {
        succArr.push({
          ...v,
          id: i,
          description: '成功'
        })
      } else {
        let description = ''
        if (v.isFlag === 0) description = '未匹配到藏品；'
        else if (!v.effect) description += '未匹配到用途；'
        errArr.push({
          ...v,
          id: i,
          description
        })
      }
    })
  }

  return { succArr, errArr }
}
