From 1733be9113ae6a960a1547273d1acb5e5897cb67 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Tue, 2 Nov 2021 11:06:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=BA=E5=AD=97=E7=AC=A6=E4=B8=B2=EF=BC=9B?= =?UTF-8?q?=E6=9B=B4=E6=96=B0devices=EF=BC=9Bexport=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 | 3 ++ src/components/device-select-and-status.vue | 23 +++++++++- src/components/search-bar-data.vue | 48 ++++++++++++++++----- src/store/device.js | 15 +++++++ src/views/data-history.vue | 2 +- src/views/device-create.vue | 3 ++ src/views/device-edit.vue | 1 + src/views/device-list.vue | 11 +---- src/views/function-config.vue | 16 ++++--- src/views/network-config.vue | 14 +++--- 10 files changed, 102 insertions(+), 34 deletions(-) diff --git a/src/apis/index.js b/src/apis/index.js index fb2d03a..ea152d4 100644 --- a/src/apis/index.js +++ b/src/apis/index.js @@ -42,3 +42,6 @@ export const createConfigNetwork = data => http.post(`${corrosion}/config/networ // 提交功能配置参数 export const createConfigFunction = data => http.post(`${corrosion}/config/function`, data); + +// 导出历史数据 +export const exportHistory = params => http.get(`${corrosion}/export`, { params }); diff --git a/src/components/device-select-and-status.vue b/src/components/device-select-and-status.vue index 76853e6..90ee2ba 100644 --- a/src/components/device-select-and-status.vue +++ b/src/components/device-select-and-status.vue @@ -11,7 +11,26 @@ const devices = computed(() => store.state.device.devices); // 设备/站点列 const deviceId = ref(''); // 选中的设备id const currentDeviceId = computed(() => store.state.device.currentDeviceId); // 正在操作的设备的id // const get = computed(() => (props.status.get ? '设置生效' : '等待下发')); -const set = computed(() => (props.status.set ? '设置生效' : '等待下发')); +// const set = computed(() => (props.status.set ? '设置生效' : '等待下发')); + +const statusType = computed(() => { + let type = 'success'; + switch (props.status) { + case 'PENDING': + type = 'primary'; + break; + case 'FAIL': + type = 'danger'; + break; + case 'SUCCESS': + type = 'success'; + break; + default: + type = 'primary'; + break; + } + return type; +}); // 监听currentDeviceId watch( @@ -36,6 +55,6 @@ watch( {{ get }}--> 设置状态: - {{ set }} + {{ props.status || 'PENDING' }} diff --git a/src/components/search-bar-data.vue b/src/components/search-bar-data.vue index 1044113..f68157f 100644 --- a/src/components/search-bar-data.vue +++ b/src/components/search-bar-data.vue @@ -20,13 +20,18 @@ 查询 + + + 导出 + diff --git a/src/store/device.js b/src/store/device.js index 3647c44..09fff3b 100644 --- a/src/store/device.js +++ b/src/store/device.js @@ -1,5 +1,7 @@ import { getDevices, getDevicesAll } from 'apis/index'; +import dayjs from 'dayjs'; + const user = { namespaced: true, @@ -36,6 +38,17 @@ const user = { * @param {object} devices {page, data} */ setDevicesAll(state, devices) { + if (devices && devices.data) { + for (let i = 0; i < devices.data.length; i++) { + const device = devices.data[i]; + if (device.installTime) { + devices.data[i].installTime = dayjs(new Date(+device.installTime)).format('YYYY-MM-DD HH:mm:ss'); + } + if (device.runTime) { + devices.data[i].runTime = dayjs(new Date(+device.runTime)).format('YYYY-MM-DD HH:mm:ss'); + } + } + } state.devicesAll = devices; }, @@ -57,6 +70,8 @@ const user = { for (let i = 0; i < devicesAll.data.length; i++) { const item = devicesAll.data[i]; if (item && item.deviceId === newData.deviceId) { + newData.installTime = dayjs(new Date(+item.installTime)).format('YYYY-MM-DD HH:mm:ss'); + newData.runTime = dayjs(new Date(+item.runTime)).format('YYYY-MM-DD HH:mm:ss'); devicesAll.data[i] = newData; break; } diff --git a/src/views/data-history.vue b/src/views/data-history.vue index fc13646..75c2cec 100644 --- a/src/views/data-history.vue +++ b/src/views/data-history.vue @@ -84,7 +84,7 @@ const onPrev = e => {