Browse Source

Merge branch 'master' of dd.tall.wiki:ccsens_fe/corrosion

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

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

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

24
src/views/month-data.vue

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

10
src/views/statistical-history.vue

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

14
src/views/statistical-realtime.vue

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

Loading…
Cancel
Save