Mr.Shi
2023-08-22 5f303821bd4052317db4b3e71342fb300ce5c3c9
大屏
已修改3个文件
47 ■■■■ 文件已修改
screen_standard/src/App.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
screen_standard/src/stores/counter.js 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
screen_standard/src/views/index.vue 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
screen_standard/src/App.vue
@@ -1,6 +1,15 @@
<script setup>
import AppLayout from './components/AppLayout.vue'
import { useCounterStore } from '@/stores/counter.js'
import { useRoute } from 'vue-router'
const enterprise = useCounterStore()
const route = useRoute()
console.log(route.query)
// enterprise.setCompanyId(8)
// enterprise.setDepartId(111)
</script>
<template>
screen_standard/src/stores/counter.js
@@ -2,14 +2,23 @@
import { defineStore } from 'pinia';
export const useCounterStore = defineStore('enterprise', {
  state: () => {
    return { count: 0 }
    // 678
    return { companyId: '8', departId: '132' };
  },
  // 也可以定义为
  // state: () => ({ count: 0 })
  actions: {
    increment() {
      this.count++
    // 设置企业id
    setCompanyId(companyId) {
      this.companyId = companyId;
      window.sessionStorage.setItem('companyId', companyId);
    },
    // 设置组织id
    setDepartId(departId) {
      this.departId = departId;
      window.sessionStorage.setItem('departId', departId);
    }
  }
})
screen_standard/src/views/index.vue
@@ -185,7 +185,7 @@
</template>
<script setup>
    import { reactive, ref, onMounted, onBeforeUnmount, onUnmounted, nextTick } from 'vue'
    import { reactive, ref, onMounted, onBeforeUnmount, onUnmounted, nextTick, computed } from 'vue'
    import { getTop } from '@/utils/api.js'
    import { useCounterStore } from '@/stores/counter.js'
@@ -218,7 +218,12 @@
    const enterprise = useCounterStore()
    console.log(enterprise.count++)
    const companyId = computed(() => {
        return enterprise.companyId
    })
    const departId = computed(() => {
        return enterprise.departId
    })
    start()
    start1()
@@ -244,10 +249,10 @@
    
    onMounted(()=> {
        // getSensorData()
        getTop(8, 36)
            .then(res => {
                console.log(res)
            })
        // getTop(8, 36)
        //     .then(res => {
        //         console.log(res)
        //     })
    })
    onBeforeUnmount(()=>{