| | |
| | | <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> |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | }) |
| | |
| | | </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' |
| | | |
| | |
| | | |
| | | const enterprise = useCounterStore() |
| | | |
| | | console.log(enterprise.count++) |
| | | const companyId = computed(() => { |
| | | return enterprise.companyId |
| | | }) |
| | | const departId = computed(() => { |
| | | return enterprise.departId |
| | | }) |
| | | |
| | | start() |
| | | start1() |
| | |
| | | |
| | | onMounted(()=> { |
| | | // getSensorData() |
| | | getTop(8, 36) |
| | | .then(res => { |
| | | console.log(res) |
| | | }) |
| | | // getTop(8, 36) |
| | | // .then(res => { |
| | | // console.log(res) |
| | | // }) |
| | | }) |
| | | |
| | | onBeforeUnmount(()=>{ |