Compare commits

...

2 Commits

Author SHA1 Message Date
aixianling
1845f6cc9a 优化搜索状态同步及数据刷新逻辑 2024-11-27 15:13:20 +08:00
aixianling
a127b3ea47 添加时间戳字段以同步搜索状态 2024-11-27 10:55:44 +08:00
3 changed files with 31 additions and 9 deletions

View File

@@ -67,18 +67,18 @@ Vue.prototype.$marketBoard = Vue.observable({
screenId: '5b1849ac-4fc3-451a-844c-3362b47341ef', screenId: '5b1849ac-4fc3-451a-844c-3362b47341ef',
thirdGoods: {}, thirdGoods: {},
saleHour: undefined, saleHour: undefined,
search: {"groupCodeList": [], "currentDate": "20240701", "compareDate": "20240630", "hourNum": "18"} search: {"groupCodeList": [], "currentDate": "20240701", "compareDate": "20240630", "hourNum": "18", t: null}
}) })
Vue.prototype.$multipleStoreBoard = Vue.observable({ Vue.prototype.$multipleStoreBoard = Vue.observable({
carouselIndex: 0, carouselIndex: 0,
search: {"groupCodeList": [], "hourNum": "", type: "1"} search: {"groupCodeList": [], "hourNum": "", type: "1", t: null}
}) })
Vue.prototype.$storeBoard = Vue.observable({ Vue.prototype.$storeBoard = Vue.observable({
currentDate: "20240705", currentDate: "20240705",
dialog: false, dialog: false,
aroundStock: [], aroundStock: [],
query: {}, query: {},
search: {} search: {t: null}
}) })
Vue.component("HlsPlayer", { Vue.component("HlsPlayer", {
render: (h) => h('div', {style: {width: '100%', height: '100%'}}), render: (h) => h('div', {style: {width: '100%', height: '100%'}}),

View File

@@ -1,14 +1,14 @@
<script> <script>
const screens = [ const screens = [
{id: '5b1849ac-4fc3-451a-844c-3362b47341ef', label: '市场看板', bg: 'http://10.0.97.209/img/kengee/kengee16.png'}, {id: '5b1849ac-4fc3-451a-844c-3362b47341ef', label: '市场看板', bg: 'http://10.0.97.209/img/kengee/kengee16.png', ob: '$marketBoard'},
{id: '7d26854c-769d-418b-9bae-5c1105e716a9', label: '多店监控', bg: 'http://10.0.97.209/img/kengee/kengee17.png'}, {id: '7d26854c-769d-418b-9bae-5c1105e716a9', label: '多店监控', bg: 'http://10.0.97.209/img/kengee/kengee17.png', ob: '$multipleStoreBoard'},
{id: 'a90522ef-869b-40ea-8542-d1fc9674a1e8', label: '单店监控', bg: 'http://10.0.97.209/img/kengee/kengee18.png'}, {id: 'a90522ef-869b-40ea-8542-d1fc9674a1e8', label: '单店监控', bg: 'http://10.0.97.209/img/kengee/kengee18.png', ob: '$storeBoard'},
] ]
export default { export default {
name: "AppNavbar", name: "AppNavbar",
label: "标题栏", label: "标题栏",
data() { data() {
return {screens} return {screens, timer: null}
}, },
computed: { computed: {
groupId: v => v.$marketBoard.screenId, groupId: v => v.$marketBoard.screenId,
@@ -26,6 +26,16 @@ export default {
} }
} }
}, },
},
created() {
this.timer = setInterval(() => {
const screen = this.screens.find(e => e.id === this.groupId)
this.$set(this[screen.ob].search, 't', Date.now())
console.log(screen.ob, this[screen.ob].search.t)
}, 5000)
},
destroyed() {
this.timer && clearInterval(this.timer)
} }
} }
</script> </script>

View File

@@ -65,8 +65,12 @@ export default {
}, },
watch: { watch: {
search: { search: {
immediate: true, deep: true, handler(v) { immediate: true, deep: true, handler(v, old) {
this.getData().then(() => { 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') { if (v.interval > 0 && v.changeWay == '1') {
this.$refs.carousel?.$forceUpdate() this.$refs.carousel?.$forceUpdate()
} }
@@ -164,6 +168,14 @@ export default {
} else if (e.code == "ArrowRight") { } else if (e.code == "ArrowRight") {
this.$refs.carousel.next() 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() { mounted() {