8 changed files with 942 additions and 159 deletions
File diff suppressed because it is too large
@ -0,0 +1,51 @@ |
|||||
|
<template> |
||||
|
<div id="container"></div> |
||||
|
</template> |
||||
|
|
||||
|
<script setup> |
||||
|
import { onMounted, computed } from 'vue'; |
||||
|
import { Bar } from '@antv/g2plot'; |
||||
|
import { useStore } from 'vuex'; |
||||
|
|
||||
|
let timer = null; |
||||
|
const store = useStore(); |
||||
|
const token = computed(() => store.getters['user/token']); |
||||
|
const electricData = computed(() => store.state.statistics.electricData); |
||||
|
|
||||
|
// 获取积分电量数据 |
||||
|
const getElectricData = async () => { |
||||
|
if (token) { |
||||
|
await store.dispatch('statistics/getElectricData'); |
||||
|
timer && clearTimeout(timer); |
||||
|
timer = null; |
||||
|
} else { |
||||
|
timer = setTimeout(() => { |
||||
|
getElectricData(); |
||||
|
}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
// 设置表格高度 |
||||
|
onMounted(async () => { |
||||
|
await getElectricData(); |
||||
|
const bar = new Bar('container', { |
||||
|
title: '积分电量', |
||||
|
data: electricData.value, |
||||
|
xField: 'value', |
||||
|
yField: 'year', |
||||
|
// legend: { |
||||
|
// position: 'top-left', |
||||
|
// }, |
||||
|
slider: { |
||||
|
start: 0.1, |
||||
|
end: 0.2, |
||||
|
}, |
||||
|
meta: { |
||||
|
value: { alias: '积分电量' }, |
||||
|
year: { alias: '年月' }, |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
bar.render(); |
||||
|
}); |
||||
|
</script> |
@ -0,0 +1,78 @@ |
|||||
|
import { getIntegralElectric, getTotalCorrosion, getMoistTime } from 'apis/index'; |
||||
|
|
||||
|
export default { |
||||
|
namespaced: true, |
||||
|
|
||||
|
state: { |
||||
|
electricData: null, |
||||
|
corrosionData: null, |
||||
|
moistTimeData: null, |
||||
|
}, |
||||
|
|
||||
|
getters: {}, |
||||
|
|
||||
|
mutations: { |
||||
|
/** |
||||
|
* 设置积分电量数据 |
||||
|
* @param {*} state |
||||
|
* @param {array} data |
||||
|
*/ |
||||
|
setElectricData(state, data) { |
||||
|
console.log('data: ', data); |
||||
|
state.electricData = data; |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 设置月累计腐蚀的数据 |
||||
|
* @param {*} state |
||||
|
* @param {*} data |
||||
|
*/ |
||||
|
setCorrosionData(state, data) { |
||||
|
state.corrosionData = data; |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 设置月累计湿润时间图的数据 |
||||
|
* @param {*} state |
||||
|
* @param {*} data |
||||
|
*/ |
||||
|
setMoistTimeData(state, data) { |
||||
|
state.moistTimeData = data; |
||||
|
}, |
||||
|
}, |
||||
|
|
||||
|
actions: { |
||||
|
// 获取积分电量数据
|
||||
|
async getElectricData({ commit }) { |
||||
|
try { |
||||
|
const data = await getIntegralElectric(); |
||||
|
commit('setElectricData', data || null); |
||||
|
return data; |
||||
|
} catch (error) { |
||||
|
throw new Error(error); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
// 获取月累计腐蚀数据
|
||||
|
async getCorrosionData({ commit }) { |
||||
|
try { |
||||
|
const data = await getTotalCorrosion(); |
||||
|
commit('setCorrosionData', data || null); |
||||
|
return data; |
||||
|
} catch (error) { |
||||
|
throw new Error(error); |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
// 获取月累计湿润时间图数据
|
||||
|
async getMoistTimeData({ commit }) { |
||||
|
try { |
||||
|
const data = await getMoistTime(); |
||||
|
commit('setMoistTimeData', data || null); |
||||
|
return data; |
||||
|
} catch (error) { |
||||
|
throw new Error(error); |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
}; |
@ -0,0 +1,9 @@ |
|||||
|
<template> |
||||
|
<SearchBar /> |
||||
|
<IntegralElectric /> |
||||
|
</template> |
||||
|
|
||||
|
<script setup> |
||||
|
import SearchBar from 'components/search-bar.vue'; |
||||
|
import IntegralElectric from 'components/integral-electric.vue'; |
||||
|
</script> |
Loading…
Reference in new issue