| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import { onMounted, onBeforeUnmount } from 'vue' |
| | | |
| | | /** |
| | | * æ°æ®è½®è¯¢ composable |
| | | * @param {Function} fetchFn - æ°æ®è·å彿° |
| | | * @param {Object} options - é
ç½®é项 |
| | | * @param {number} options.interval - 轮询é´éï¼æ¯«ç§ï¼ï¼é»è®¤ 60000ï¼60ç§ï¼ |
| | | * @param {boolean} options.immediate - æ¯å¦ç«å³æ§è¡ä¸æ¬¡ï¼é»è®¤ true |
| | | * @returns {Object} { start, stop, isPolling } |
| | | */ |
| | | export function usePolling(fetchFn, options = {}) { |
| | | const { |
| | | interval = 60000, |
| | | immediate = true |
| | | } = options |
| | | |
| | | let pollingTimer = null |
| | | const isPolling = { value: false } |
| | | |
| | | const start = () => { |
| | | if (pollingTimer) return |
| | | |
| | | if (immediate) { |
| | | fetchFn() |
| | | } |
| | | |
| | | pollingTimer = setInterval(() => { |
| | | fetchFn() |
| | | }, interval) |
| | | |
| | | isPolling.value = true |
| | | } |
| | | |
| | | const stop = () => { |
| | | if (pollingTimer) { |
| | | clearInterval(pollingTimer) |
| | | pollingTimer = null |
| | | } |
| | | isPolling.value = false |
| | | } |
| | | |
| | | // ç»ä»¶æè½½æ¶èªå¨å¯å¨ |
| | | onMounted(() => { |
| | | start() |
| | | }) |
| | | |
| | | // ç»ä»¶å¸è½½æ¶èªå¨åæ¢ |
| | | onBeforeUnmount(() => { |
| | | stop() |
| | | }) |
| | | |
| | | return { |
| | | start, |
| | | stop, |
| | | isPolling |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¤å½æ°è½®è¯¢ composable |
| | | * @param {Function[]} fetchFns - æ°æ®è·å彿°æ°ç» |
| | | * @param {Object} options - é
ç½®é项 |
| | | * @param {number} options.interval - 轮询é´éï¼æ¯«ç§ï¼ï¼é»è®¤ 60000ï¼60ç§ï¼ |
| | | * @param {boolean} options.immediate - æ¯å¦ç«å³æ§è¡ä¸æ¬¡ï¼é»è®¤ true |
| | | * @returns {Object} { start, stop, isPolling } |
| | | */ |
| | | export function usePollingMultiple(fetchFns, options = {}) { |
| | | const { |
| | | interval = 60000, |
| | | immediate = true |
| | | } = options |
| | | |
| | | let pollingTimer = null |
| | | const isPolling = { value: false } |
| | | |
| | | const fetchAll = () => { |
| | | fetchFns.forEach(fn => { |
| | | if (typeof fn === 'function') { |
| | | fn() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const start = () => { |
| | | if (pollingTimer) return |
| | | |
| | | if (immediate) { |
| | | fetchAll() |
| | | } |
| | | |
| | | pollingTimer = setInterval(() => { |
| | | fetchAll() |
| | | }, interval) |
| | | |
| | | isPolling.value = true |
| | | } |
| | | |
| | | const stop = () => { |
| | | if (pollingTimer) { |
| | | clearInterval(pollingTimer) |
| | | pollingTimer = null |
| | | } |
| | | isPolling.value = false |
| | | } |
| | | |
| | | // ç»ä»¶æè½½æ¶èªå¨å¯å¨ |
| | | onMounted(() => { |
| | | start() |
| | | }) |
| | | |
| | | // ç»ä»¶å¸è½½æ¶èªå¨åæ¢ |
| | | onBeforeUnmount(() => { |
| | | stop() |
| | | }) |
| | | |
| | | return { |
| | | start, |
| | | stop, |
| | | isPolling |
| | | } |
| | | } |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from 'vue' |
| | | import { ref } from 'vue' |
| | | import Echarts from '@/components/Echarts/echarts.vue' |
| | | import PanelHeader from './PanelHeader.vue' |
| | | import { profitTrendAnalysis } from '@/api/viewIndex.js' |
| | | import { usePolling } from '@/hooks/usePolling.js' |
| | | |
| | | const chartStyle = { width: '100%', height: '150%' } |
| | | const grid = { left: '3%', right: '4%', bottom: '3%', top: '4%', containLabel: true } |
| | |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchData() |
| | | }) |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePolling(fetchData) |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from 'vue' |
| | | import { ref } from 'vue' |
| | | import * as echarts from 'echarts' |
| | | import Echarts from '@/components/Echarts/echarts.vue' |
| | | import { incomeExpenseAnalysis } from '@/api/viewIndex.js' |
| | | import { usePolling } from '@/hooks/usePolling.js' |
| | | |
| | | const chartStyle = { width: '100%', height: '100%' } |
| | | const grid = { |
| | |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchData() |
| | | }) |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePolling(fetchData) |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { onMounted, ref } from 'vue' |
| | | import { ref } from 'vue' |
| | | import { getMonthlyIncome, getMonthlyExpenditure } from '@/api/viewIndex' |
| | | import { usePollingMultiple } from '@/hooks/usePolling.js' |
| | | |
| | | const income = ref({ |
| | | amount: 0, |
| | |
| | | return Number(metric.trend) >= 0 ? 'â' : 'â' |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchMonthlyIncome() |
| | | fetchMonthlyExpenditure() |
| | | }) |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePollingMultiple([fetchMonthlyIncome, fetchMonthlyExpenditure]) |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted, onBeforeUnmount, computed } from 'vue' |
| | | import { ref, onBeforeUnmount, computed } from 'vue' |
| | | import Echarts from '@/components/Echarts/echarts.vue' |
| | | import PanelHeader from './PanelHeader.vue' |
| | | import ProductTypeSwitch from './ProductTypeSwitch.vue' |
| | | import { expenseCompositionAnalysis } from '@/api/viewIndex.js' |
| | | import { useChartBackground } from '@/hooks/useChartBackground.js' |
| | | import { usePolling } from '@/hooks/usePolling.js' |
| | | |
| | | const pieWrapperRef = ref(null) |
| | | const pieBackgroundRef = ref(null) |
| | |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchData() |
| | | initBackground() |
| | | }) |
| | | |
| | | onBeforeUnmount(() => { |
| | | cleanupBackground() |
| | | }) |
| | | |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePolling(fetchData) |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from 'vue' |
| | | import { ref } from 'vue' |
| | | import { getAmountHalfYear } from '@/api/viewIndex.js' |
| | | import PanelHeader from './PanelHeader.vue' |
| | | import Echarts from '@/components/Echarts/echarts.vue' |
| | | import { usePolling } from '@/hooks/usePolling.js' |
| | | |
| | | const chartStyle = { |
| | | width: '100%', |
| | |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchData() |
| | | }) |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePolling(fetchData) |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from 'vue' |
| | | import { ref } from 'vue' |
| | | import { completedInspectionCount } from '@/api/viewIndex.js' |
| | | import PanelHeader from './PanelHeader.vue' |
| | | import Echarts from '@/components/Echarts/echarts.vue' |
| | | import { usePolling } from '@/hooks/usePolling.js' |
| | | |
| | | const chartStyle = { |
| | | width: '100%', |
| | |
| | | fetchData() |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchData() |
| | | }) |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePolling(fetchData) |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { computed, getCurrentInstance, ref, onMounted } from 'vue' |
| | | import { computed, getCurrentInstance, ref } from 'vue' |
| | | import Echarts from '@/components/Echarts/echarts.vue' |
| | | import { nonComplianceWarning } from '@/api/viewIndex.js' |
| | | import { usePolling } from '@/hooks/usePolling.js' |
| | | |
| | | const { proxy } = getCurrentInstance() || {} |
| | | |
| | |
| | | // å
ææªå¾åéæâè¿7天âï¼åç»æçå®çé鿱忥å
¥ |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchWarnings() |
| | | }) |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePolling(fetchWarnings) |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from 'vue' |
| | | import { ref } from 'vue' |
| | | import { qualityInspectionCount } from '@/api/viewIndex.js' |
| | | import { usePolling } from '@/hooks/usePolling.js' |
| | | |
| | | const statItems = ref([]) |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchData() |
| | | }) |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePolling(fetchData) |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | import PanelHeader from './PanelHeader.vue' |
| | | import DateTypeSwitch from './DateTypeSwitch.vue' |
| | | import { rawMaterialDetection, processDetection, factoryDetection } from '@/api/viewIndex.js' |
| | | import { usePolling } from '@/hooks/usePolling.js' |
| | | |
| | | const QUALIFIED_COLOR = '#4EE4FF' |
| | | const UNQUALIFIED_COLOR = '#3378FF' |
| | |
| | | fetchSectionData(section) |
| | | }) |
| | | }) |
| | | |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePolling(() => { |
| | | sections.forEach((section) => { |
| | | fetchSectionData(section) |
| | | }) |
| | | }) |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | |
| | | import PanelHeader from './PanelHeader.vue' |
| | | import { unqualifiedProductProcessingAnalysis } from '@/api/viewIndex.js' |
| | | import { useChartBackground } from '@/hooks/useChartBackground.js' |
| | | import { usePolling } from '@/hooks/usePolling.js' |
| | | |
| | | const pieWrapperRef = ref(null) |
| | | const pieBackgroundRef = ref(null) |
| | |
| | | } |
| | | |
| | | onMounted(() => { |
| | | loadData() |
| | | initBackground() |
| | | }) |
| | | |
| | | onBeforeUnmount(() => { |
| | | cleanupBackground() |
| | | }) |
| | | |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePolling(loadData) |
| | | </script> |
| | | |
| | | <style scoped> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted } from 'vue' |
| | | import { ref } from 'vue' |
| | | import { unqualifiedProductRanking } from '@/api/viewIndex.js' |
| | | import PanelHeader from './PanelHeader.vue' |
| | | import { usePolling } from '@/hooks/usePolling.js' |
| | | |
| | | const panelList = ref([]) |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | fetchData() |
| | | }) |
| | | // å¯å¨è½®è¯¢ï¼æ¯åéå·æ°ä¸æ¬¡æ°æ® |
| | | usePolling(fetchData) |
| | | </script> |
| | | |
| | | <style scoped> |