优化搜索状态同步及数据刷新逻辑

This commit is contained in:
aixianling
2024-11-27 15:13:20 +08:00
parent a127b3ea47
commit 1845f6cc9a

View File

@@ -65,8 +65,12 @@ export default {
},
watch: {
search: {
immediate: true, deep: true, handler(v) {
this.getData().then(() => {
immediate: true, deep: true, handler(v, old) {
if (old) {
delete v.t
old?.t && delete old.t
}
(old && JSON.stringify(v) == JSON.stringify(old) ? this.refreshData() : this.getData()).then(() => {
if (v.interval > 0 && v.changeWay == '1') {
this.$refs.carousel?.$forceUpdate()
}
@@ -164,6 +168,14 @@ export default {
} else if (e.code == "ArrowRight") {
this.$refs.carousel.next()
}
},
async refreshData() {
return Promise.all([this.getStoreKeyGoods(), this.getCategorySales()]).then(() => {
this.stores.map(store => {
store.keyGoods = this.storeKeyGoods.filter(e => e.storeCode == store.storeCode) || []
store.categorySale = this.categorySales.filter(e => e.storeCode == store.storeCode) || []
})
})
}
},
mounted() {