重複配列要素を探します
indexOf&lastIndexOfでも(この文字列を使用することができる、ソートする必要はありません)
- 以前の数(のindexOf)と番号(のlastIndexOf)を参照してください添字後に矛盾しています
- arrRepeatの配列にプッシュし、その後、存在していなかったがあるかどうかを確認するには
let arrAll = []
this.bodyParams.detailList.forEach(item => {
arrAll.push(item.productNo)
})
let arrRepeat = []
let textRepeat = ''
arrAll.forEach(item => {
if (arrAll.indexOf(item) !== arrAll.lastIndexOf(item) && arrRepeat.indexOf(item) === -1) {
arrRepeat.push(item)
textRepeat += `${item} `
}
})
if (arrRepeat.length > 0) {
this.$Message.error(`产品编码 ${textRepeat}重复`)
return
}