Browse Source

refactor: export api fix;日志界面滚动修复

master
wally 4 years ago
parent
commit
fb18f19a84
  1. 2
      src/apis/index.js
  2. 11
      src/components/history/local.vue
  3. 19
      src/components/history/search-bar-data.vue
  4. 14
      src/views/commands.vue

2
src/apis/index.js

@ -71,7 +71,7 @@ export const exportDatas = params => http.post(`${corrosion}/export`, params);
export const getHistory = params => http.post(`${corrosion}/history/datas`, params); export const getHistory = params => http.post(`${corrosion}/history/datas`, params);
// 导出历史数据 // 导出历史数据
export const exportHistory = params => http.post(`${corrosion}/history/export`, params); export const exportHistory = params => http.post(`${corrosion}/export`, params);
// 发送查询历史记录的指令 // 发送查询历史记录的指令
export const sendCommand = params => http.post(`${corrosion}/history`, params); export const sendCommand = params => http.post(`${corrosion}/history`, params);

11
src/components/history/local.vue

@ -48,12 +48,12 @@
</template> </template>
<script setup> <script setup>
import { computed, onMounted, ref } from 'vue';
import { useStore } from 'vuex';
import SearchBar from 'components/history/search-bar-data.vue';
import { getDatas } from 'apis'; import { getDatas } from 'apis';
import { ElMessage } from 'element-plus'; import SearchBar from 'components/history/search-bar-data.vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { ElMessage } from 'element-plus';
import { computed, onMounted, ref } from 'vue';
import { useStore } from 'vuex';
const search = ref({}); const search = ref({});
const page = ref({ const page = ref({
@ -77,6 +77,7 @@ const getData = async () => {
const options = { ...search.value }; const options = { ...search.value };
const date = options && options.date ? options.date : []; const date = options && options.date ? options.date : [];
console.log(date);
if (!date || date.length !== 2) { if (!date || date.length !== 2) {
return ElMessage.error('请选择时间 '); return ElMessage.error('请选择时间 ');
} }
@ -109,8 +110,6 @@ const getData = async () => {
} }
}; };
// getData();
// //
onMounted(() => { onMounted(() => {
const winHeight = document.documentElement.clientHeight; const winHeight = document.documentElement.clientHeight;

19
src/components/history/search-bar-data.vue

@ -41,10 +41,10 @@
</template> </template>
<script setup> <script setup>
import { exportHistory } from 'apis';
import dayjs from 'dayjs';
import { computed, defineEmits, defineProps, reactive, ref, watch } from 'vue'; import { computed, defineEmits, defineProps, reactive, ref, watch } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import dayjs from 'dayjs';
import { exportHistory } from 'apis';
const emit = defineEmits(['search']); const emit = defineEmits(['search']);
const searchDevice = reactive({ const searchDevice = reactive({
@ -65,10 +65,11 @@ defineProps({
// currentDeviceId // currentDeviceId
watch( watch(
() => currentDeviceId.value, [searchDeviceForm, currentDeviceId],
newValue => { ([newForm, newDeviceId]) => {
if (newValue) { if (newDeviceId && newForm) {
searchDevice.deviceId !== newValue && (searchDevice.deviceId = newValue); searchDevice.deviceId !== newDeviceId && (searchDevice.deviceId = newDeviceId);
onSubmit();
} }
}, },
{ immediate: true }, { immediate: true },
@ -99,14 +100,14 @@ function generateParams() {
} }
// //
const onSubmit = () => { function onSubmit() {
searchDeviceForm.value.validate(valid => { searchDeviceForm.value.validate(valid => {
if (valid) { if (valid) {
const params = generateParams(); const params = generateParams();
emit('search', params); emit('search', params);
} }
}); });
}; }
// //
async function onExport() { async function onExport() {
@ -115,7 +116,7 @@ async function onExport() {
const params = generateParams(); const params = generateParams();
params.sort = [ params.sort = [
{ {
col: 'gathered_at', col: 'time',
order: 'DESC', order: 'DESC',
}, },
]; ];

14
src/views/commands.vue

@ -39,7 +39,9 @@
<el-table-column align="center" label="类型标识" min-width="80"> <el-table-column align="center" label="类型标识" min-width="80">
<template #default="scope"> <template #default="scope">
<span v-if="scope.row.asduType && log.ASDU_TYPE[scope.row.asduType]">{{ log.ASDU_TYPE[scope.row.asduType].text }}</span> <span v-if="scope.row.asduType && log.ASDU_TYPE[scope.row.asduType]">
{{ log.ASDU_TYPE[scope.row.asduType].text }}
</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="信息体顺序" min-width="100"> <el-table-column align="center" label="信息体顺序" min-width="100">
@ -82,12 +84,12 @@
</template> </template>
<script setup> <script setup>
import { computed, onMounted, ref } from 'vue'; import { getLog } from 'apis';
import SearchCommands from 'components/commands/search-commands.vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { useStore } from 'vuex';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import SearchCommands from 'components/commands/search-commands.vue'; import { computed, onMounted, ref } from 'vue';
import { getLog } from 'apis'; import { useStore } from 'vuex';
import * as log from '@/config/log'; import * as log from '@/config/log';
const data = ref([]); const data = ref([]);
@ -106,7 +108,7 @@ const currentDeviceId = computed(() => store.state.device.currentDeviceId);
// //
onMounted(() => { onMounted(() => {
const winHeight = document.documentElement.clientHeight; const winHeight = document.documentElement.clientHeight;
contentHeight.value = winHeight - 150; contentHeight.value = winHeight - 250;
onSearch(); onSearch();
}); });

Loading…
Cancel
Save