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