// 手动改变tree树默认选中值
let keys = ['customerName']
dataChecked.forEach((item, index) => {
keys.push(item.attribute)
});
this.checkedKeys = keys
// 保持原有排序状态下增减
if (this.dataChecked.length === 0) {
this.dataChecked = JSON.parse(JSON.stringify(dataChecked));
} else {
let jiuARR = []
// 获取两边相等字段
dataChecked.forEach(item => {
let flag = this.dataChecked.filter((f) => f.id === item.id);
if (flag.length>0) jiuARR.push(item)
});
// 获取新增字段
let aa = JSON.parse(JSON.stringify(dataChecked))
jiuARR.forEach(item => {
aa.forEach((item1,index) => {
if (item.id === item1.id) {
aa.splice(index, 1)
}
});
})
// 获取删除字段
let bb = JSON.parse(JSON.stringify(this.dataChecked))
jiuARR.forEach(item => {
bb.forEach((item1,index) => {
if (item.id === item1.id) {
bb.splice(index, 1)
}
});
})
// cc是获取删除后的字段
let cc = JSON.parse(JSON.stringify(this.dataChecked))
bb.forEach(item => {
cc.forEach((item1,index) => {
if (item.id === item1.id) {
cc.splice(index, 1)
}
})
})
let aQQa = cc.concat(aa)
this.dataChecked = JSON.parse(JSON.stringify(aQQa))
}
筛选两个动态数组中增加减少的值
最新推荐文章于 2023-07-25 09:30:00 发布