数组去重
This commit is contained in:
@@ -101,8 +101,9 @@ export default {
|
||||
},
|
||||
activated () {
|
||||
if (this.$store.getters.materArr.length > 0) {
|
||||
this.dataList = [...this.dataList, ...this.$store.getters.materArr]
|
||||
this.removeRepeat(this.dataList)
|
||||
let arr = this.$store.getters.materArr
|
||||
this.removeRepeat(this.dataList, arr)
|
||||
this.dataList = [...this.dataList, ...arr]
|
||||
this.dataList.map(el => {
|
||||
let res = accMul(el.canuse_qty, el.unit_weight)
|
||||
res = accDiv(res, 1000)
|
||||
@@ -115,11 +116,11 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
// 数组去重
|
||||
removeRepeat (arr) {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
for (let j = i + 1; j < arr.length; j++) {
|
||||
if (arr[i].a === arr[j].a) {
|
||||
arr.splice(j, 1)
|
||||
removeRepeat (arr1, arr2) {
|
||||
for (let i = 0; i < arr1.length; i++) {
|
||||
for (let j = 0; j < arr2.length; j++) {
|
||||
if (arr1[i].struct_name === arr2[j].struct_name) {
|
||||
arr2.splice(j, 1)
|
||||
j--
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user