From 0a74274c958f389f731080ec76d0a679a9d752b8 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Thu, 18 Nov 2021 16:47:56 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=97=A5=E5=BF=97=E9=87=8D?= =?UTF-8?q?=E6=9E=84=EF=BC=9B=E8=A1=A5=E4=BC=A0=E8=AE=B0=E5=BD=95=E7=AD=89?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/index.js | 9 +- src/components/commands/search-commands.vue | 39 +++--- src/components/history/device.vue | 127 +++++++++--------- src/components/history/history-log-table.vue | 113 ++++++++++++++++ src/components/history/history-log.vue | 35 +++++ src/components/history/local.vue | 111 +++++++-------- src/components/history/search-bar-data.vue | 36 ++--- src/components/history/search-history-log.vue | 77 +++++++++++ src/config/config.js | 8 +- src/config/log.js | 1 + src/utils/overview.js | 6 + src/views/commands.vue | 111 ++++++++++++--- src/views/data-realtime.vue | 11 +- src/views/device-list.vue | 2 +- src/views/history.vue | 4 + 15 files changed, 509 insertions(+), 181 deletions(-) create mode 100644 src/components/history/history-log-table.vue create mode 100644 src/components/history/history-log.vue create mode 100644 src/components/history/search-history-log.vue diff --git a/src/apis/index.js b/src/apis/index.js index 10515ba..eb03322 100644 --- a/src/apis/index.js +++ b/src/apis/index.js @@ -28,7 +28,7 @@ export const getDevicesAll = ( sort: [ { col: 'createdAt', - order: 'ASC', + order: 'DESC', }, ], }, @@ -76,5 +76,8 @@ export const exportHistory = params => http.post(`${corrosion}/history/export`, // 发送查询历史记录的指令 export const sendCommand = params => http.post(`${corrosion}/history`, params); -// 查询下发指令状态 -export const getCommansStatus = params => http.get(`${corrosion}/history`, { params }); +// 补传记录 +export const getSendHistory = params => http.get(`${corrosion}/history`, { params }); + +// 查询平台日志 +export const getLog = params => http.post(`${corrosion}/tpclog/query`, params); diff --git a/src/components/commands/search-commands.vue b/src/components/commands/search-commands.vue index fbcb934..3409043 100644 --- a/src/components/commands/search-commands.vue +++ b/src/components/commands/search-commands.vue @@ -2,7 +2,7 @@ - + - - - - - - - + + + + + + + - - - - - - - + + + + + + + @@ -44,6 +44,15 @@ import { useStore } from 'vuex'; const emit = defineEmits(['search']); const searchDevice = reactive({ deviceId: '', + paging: true, + page: 1, + size: 50, + sort: [ + { + col: 'createdAt', + order: 'DESC', + }, + ], type: '', status: '', }); diff --git a/src/components/history/device.vue b/src/components/history/device.vue index 4c9edca..4f2c9b4 100644 --- a/src/components/history/device.vue +++ b/src/components/history/device.vue @@ -1,3 +1,62 @@ + + - - diff --git a/src/components/history/history-log-table.vue b/src/components/history/history-log-table.vue new file mode 100644 index 0000000..6364af3 --- /dev/null +++ b/src/components/history/history-log-table.vue @@ -0,0 +1,113 @@ + + + diff --git a/src/components/history/history-log.vue b/src/components/history/history-log.vue new file mode 100644 index 0000000..78fb5f7 --- /dev/null +++ b/src/components/history/history-log.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/components/history/local.vue b/src/components/history/local.vue index a63072c..af0d1af 100644 --- a/src/components/history/local.vue +++ b/src/components/history/local.vue @@ -1,3 +1,52 @@ + + - - diff --git a/src/components/history/search-bar-data.vue b/src/components/history/search-bar-data.vue index c1ebd3d..a06f590 100644 --- a/src/components/history/search-bar-data.vue +++ b/src/components/history/search-bar-data.vue @@ -22,8 +22,8 @@ @@ -45,7 +45,6 @@ import { computed, defineEmits, defineProps, reactive, ref, watch } from 'vue'; import { useStore } from 'vuex'; import dayjs from 'dayjs'; import { exportHistory } from 'apis'; -import { ElMessage } from 'element-plus'; const emit = defineEmits(['search']); const searchDevice = reactive({ @@ -114,6 +113,14 @@ async function onExport() { try { loadingExport.value = true; const params = generateParams(); + params.sort = [ + { + col: 'gathered_at', + order: 'DESC', + }, + ]; + params.paging = false; + params.gatheredDateRange = params.date; const resData = await exportHistory(params); loadingExport.value = false; resData && (window.location.href = resData); @@ -122,27 +129,4 @@ async function onExport() { throw new Error(error); } } - -/** - * 发送查询指令 - * @param {string} dataType ('data', 'event') - */ -async function onSend(dataType) { - try { - console.log(dataType); - // const { date, deviceId } = props.search.value; - // const params = { - // deviceId, - // type: dataType, - // }; - // // eslint-disable-next-line prefer-destructuring - // date && date[0] && (params.startTime = date[0]); - // // eslint-disable-next-line prefer-destructuring - // date && date[1] && (params.endTime = date[1]); - // await sendCommand(params); - // ElMessage.success('指令发送成功'); - } catch (e) { - ElMessage.error('指令发送失败'); - } -} diff --git a/src/components/history/search-history-log.vue b/src/components/history/search-history-log.vue new file mode 100644 index 0000000..639c995 --- /dev/null +++ b/src/components/history/search-history-log.vue @@ -0,0 +1,77 @@ + + + diff --git a/src/config/config.js b/src/config/config.js index 6763694..8a91335 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -112,7 +112,7 @@ export const deviceRules = { export const PEND_TYPE = { PENDING: { type: 'primary', - text: '未下发', + text: '待下发', }, FAIL: { type: 'danger', @@ -130,6 +130,12 @@ export const REPORT_TYPE = { POINT: '定时上报', }; +// 下发类型 +export const PENDING_TYPE = { + DATA: { text: '业务上报' }, + EVENT: { text: '事件上报' }, +}; + // 实时查询数据的轮询时间 1分钟 export const REALTIME_DATA_INTERVAL = 60000 * 5; diff --git a/src/config/log.js b/src/config/log.js index e58716f..3932943 100644 --- a/src/config/log.js +++ b/src/config/log.js @@ -82,6 +82,7 @@ export const ASDU_TYPE = { export const INFO_ORDER = { NoOrder: '无序', HasOrder: '有序', + None: '无', }; // 传输原因 diff --git a/src/utils/overview.js b/src/utils/overview.js index 41c3fda..f625507 100644 --- a/src/utils/overview.js +++ b/src/utils/overview.js @@ -57,11 +57,13 @@ export function generateChartOption(count) { value: count.online, name: STATUS_COLOR.ONLINE.text, itemStyle: { color: STATUS_COLOR.ONLINE.color }, + label: { show: count.online }, }, { value: count.offline, name: STATUS_COLOR.OFFLINE.text, itemStyle: { color: STATUS_COLOR.OFFLINE.color }, + label: { show: count.offline }, }, ], }, @@ -96,16 +98,19 @@ export function generateChartOption(count) { value: count.fault, name: STATUS_COLOR.FAULT.text, itemStyle: { color: STATUS_COLOR.FAULT.color }, + label: { show: count.fault }, }, { value: count.warning, name: STATUS_COLOR.WARNING.text, itemStyle: { color: STATUS_COLOR.WARNING.color }, + label: { show: count.warning }, }, { value: count.normal, name: STATUS_COLOR.NORMAL.text, itemStyle: { color: STATUS_COLOR.NORMAL.color }, + label: { show: count.normal }, }, { value: count.offline, @@ -114,6 +119,7 @@ export function generateChartOption(count) { color: STATUS_COLOR.OFFLINE.color, opacity: 0, }, + label: { show: count.offline }, }, ], }, diff --git a/src/views/commands.vue b/src/views/commands.vue index c98b0ed..5708d54 100644 --- a/src/views/commands.vue +++ b/src/views/commands.vue @@ -1,8 +1,13 @@ - + diff --git a/src/views/history.vue b/src/views/history.vue index 9799649..2f07037 100644 --- a/src/views/history.vue +++ b/src/views/history.vue @@ -6,6 +6,9 @@ + + + @@ -13,6 +16,7 @@ import { ref } from 'vue'; import Local from 'components/history/local.vue'; import Device from 'components/history/device.vue'; +import HistoryLog from 'components/history/history-log.vue'; const activeName = ref('local');