Browse Source

统计图参数调整

master
song 4 years ago
parent
commit
c78090da56
  1. 4
      src/components/data-search-bar.vue
  2. 4
      src/components/search-bar-data.vue
  3. 24
      src/views/month-data.vue
  4. 10
      src/views/statistical-history.vue
  5. 14
      src/views/statistical-realtime.vue

4
src/components/data-search-bar.vue

@ -53,8 +53,8 @@ const onSubmit = () => {
searchDeviceForm.value.validate(() => {
const { deviceId, date } = { ...searchDevice };
if (date) {
const start = dayjs(date[0]).format('X');
const end = dayjs(date[1]).format('X');
const start = dayjs(date[0]).valueOf();
const end = dayjs(date[1]).valueOf();
const daterange = [start, end];
emit('search', { deviceId, date: daterange });
} else {

4
src/components/search-bar-data.vue

@ -55,8 +55,8 @@ const onSubmit = () => {
searchDeviceForm.value.validate(() => {
const { deviceId, date } = searchDevice;
if (date) {
const start = dayjs(date[0]).format('X');
const end = dayjs(date[1]).format('X');
const start = dayjs(date[0]).valueOf();
const end = dayjs(date[1]).valueOf();
const daterange = [start, end];
emit('search', { deviceId, date: daterange });
} else {

24
src/views/month-data.vue

@ -1,5 +1,5 @@
<template>
<DataSearchBar @search="getDate" />
<DataSearchBar @search="onSearch" />
<IntegralElectric ref="child1" class="mt-4" />
<TotalCorrosion ref="child2" class="mt-4" />
<MoistTime ref="child3" class="mt-4" />
@ -17,6 +17,8 @@ const child1 = ref(null);
const child2 = ref(null);
const child3 = ref(null);
const search = ref({});
const page = ref({ page: 2, size: 10 });
let timer = null;
const store = useStore();
const token = computed(() => store.getters['user/token']);
@ -25,21 +27,22 @@ const corrosionData = computed(() => store.state.statistics.corrosionData);
const moistTimeData = computed(() => store.state.statistics.moistTimeData);
const currentDeviceId = computed(() => store.state.device.currentDeviceId); // id
//
/**
* 获取月累计数据
* @param {*} deviceId // id
* @param {*} date //
* @param {*} sort // 1 -> -1->
*/
const getDate = async options => {
const getDate = async () => {
try {
if (token) {
const options = { ...search.value };
const date = options && options.date ? options.date : [];
const params = {
deviceId: currentDeviceId.value,
date: options && options.date && options.date.length ? options.date : [],
sort: 1,
search: { deviceId: currentDeviceId.value, date },
page: { page: page.value.page, size: page.value.size },
};
await store.dispatch('statistics/getMonthsDate', params);
timer && clearTimeout(timer);
timer = null;
@ -58,4 +61,13 @@ const getDate = async options => {
};
getDate();
/**
* 监听search信息
* @param {object} payload search组件emit的数据
*/
const onSearch = payload => {
search.value = { ...payload };
getDate();
};
</script>

10
src/views/statistical-history.vue

@ -11,6 +11,7 @@ import { useStore } from 'vuex';
const childRef = ref(null);
const page = ref({ page: 2, size: 10 });
let timer = null;
const store = useStore();
const token = computed(() => store.getters['user/token']);
@ -31,13 +32,10 @@ const getDate = async () => {
try {
if (token) {
const options = { ...search.value };
const date = options && options.date ? options.date : [];
const params = {
deviceId: currentDeviceId.value,
date: options && options.date && options.date.length ? options.date : [],
sort: 1,
page: 1,
size: 10,
type: 0,
search: { deviceId: currentDeviceId.value, date },
page: { page: page.value.page, size: page.value.size },
};
await store.dispatch('statistics/getRealtimeData', params);
timer && clearTimeout(timer);

14
src/views/statistical-realtime.vue

@ -12,6 +12,7 @@ import dayjs from 'dayjs';
const childRef = ref(null);
const page = ref({ page: 2, size: 10 });
let timer = null;
let apiTimer = null;
const store = useStore();
@ -32,16 +33,11 @@ const getDate = async () => {
try {
if (token) {
const startTime = new Date(new Date(new Date().toLocaleDateString()).getTime());
const start = dayjs(startTime).format('X');
const end = dayjs(new Date()).format('X');
const start = dayjs(startTime).valueOf();
const end = dayjs(new Date()).valueOf();
const params = {
deviceId: currentDeviceId.value,
date: [start, end],
sort: 1,
page: 1,
size: 10,
type: 0,
search: { deviceId: currentDeviceId.value, date: [start, end] },
page: { page: page.value.page, size: page.value.size },
};
await store.dispatch('statistics/getRealtimeData', params);
timer && clearTimeout(timer);

Loading…
Cancel
Save