diff --git a/alias.config.js b/alias.config.js
new file mode 100644
index 0000000..1252859
--- /dev/null
+++ b/alias.config.js
@@ -0,0 +1,18 @@
+const path = require('path');
+
+const resolve = dir => path.join(__dirname, dir);
+
+module.exports = {
+ resolve: {
+ alias: {
+ '~': __dirname,
+ '@': resolve('src'),
+ views: resolve('src/views'),
+ components: resolve('src/components'),
+ assets: resolve('src/assets'),
+ utils: resolve('src/utils'),
+ store: resolve('src/store'),
+ apis: resolve('src/apis'),
+ },
+ },
+};
diff --git a/rest/设备管理.http b/rest/设备管理.http
new file mode 100644
index 0000000..ceada5e
--- /dev/null
+++ b/rest/设备管理.http
@@ -0,0 +1,4 @@
+### 查询设备列表
+GET https://test.tall.wiki/gateway/corrosion/devices/all?deviceId=&size=50
+Accept: application/json
+
diff --git a/src/apis/index.js b/src/apis/index.js
index 10778ea..3556198 100644
--- a/src/apis/index.js
+++ b/src/apis/index.js
@@ -1,3 +1,5 @@
+// noinspection SpellCheckingInspection
+
import http from 'utils/axios';
const apiUrl = import.meta.env.VITE_API_URL;
@@ -14,7 +16,13 @@ export const getDevices = () => http.get(`${corrosion}/devices`);
export const createDevice = data => http.post(`${corrosion}/devices`, data);
// 获取设备列表 完整信息
-export const getDevicesAll = (params = { deviceId: '', page: 1, size: 50 }) => http.get(`${corrosion}/devices/all`, { params });
+export const getDevicesAll = (
+ params = {
+ deviceId: '',
+ page: 1,
+ size: 50,
+ },
+) => http.get(`${corrosion}/devices/all`, { params });
// 更新设备
export const updateDevice = (deviceId, data) => http.put(`${corrosion}/devices/all/${deviceId}`, data);
@@ -43,8 +51,20 @@ export const createConfigNetwork = data => http.post(`${corrosion}/config/networ
// 提交功能配置参数
export const createConfigFunction = data => http.post(`${corrosion}/config/function`, data);
+// 查上报数据
+export const getDatas = params => http.post(`${corrosion}/datas`, params);
+
+// 导出上报数据
+export const exportDatas = params => http.post(`${corrosion}/export`, params);
+
// 查历史数据
-export const getHistories = params => http.post(`${corrosion}/datas`, params);
+export const getHistory = params => http.post(`${corrosion}/history/datas`, params);
// 导出历史数据
-export const exportHistory = params => http.post(`${corrosion}/export`, params);
+export const exportHistory = params => http.post(`${corrosion}/history/export`, params);
+
+// 发送查询历史记录的指令
+export const sendCommand = params => http.post(`${corrosion}/history`, params);
+
+// 查询下发指令状态
+export const getCommansStatus = params => http.get(`${corrosion}/history`, { params });
diff --git a/src/components/history-data.vue b/src/components/data-report.vue
similarity index 100%
rename from src/components/history-data.vue
rename to src/components/data-report.vue
diff --git a/src/components/search-bar-data.vue b/src/components/search-bar-data.vue
index b3f82e8..7645308 100644
--- a/src/components/search-bar-data.vue
+++ b/src/components/search-bar-data.vue
@@ -1,22 +1,30 @@
-
+
-
+
+
+
+
+
+
+
+
+
查询
@@ -28,19 +36,26 @@
diff --git a/src/config/config.js b/src/config/config.js
index b957275..481aa00 100644
--- a/src/config/config.js
+++ b/src/config/config.js
@@ -1,3 +1,4 @@
+// 网络参数设置
export const networkConfig = {
ip1: '',
port1: '',
@@ -13,6 +14,7 @@ export const networkConfig = {
status: '',
};
+// 功能参数设置
export const functionConfig = {
frequency: {
so2: 0, // SO2采样频率
@@ -41,9 +43,33 @@ export const functionConfig = {
status: '',
};
+// 金属腐蚀类型
export const corrosiveTypes = [
{ value: 'XIN', type: '锌' },
{ value: 'LV', type: '铝' },
{ value: 'TONG', type: '铜' },
{ value: 'GANG', type: '钢' },
];
+
+// 添加设备
+export const deviceData = {
+ deviceId: '', // 设备id
+ deviceFullId: '', // 设备完整id
+ deviceDirection: '', // 设备朝向
+ area: '', // 地区
+ address: '', // 安装地点名称
+ contact: '', // 联系人
+ phone: '', // 联系人电话
+ lon: '', // 经度
+ lat: '', // 纬度
+ head: '', // 负责人
+ installLocation: '', // 安装位置
+ installTime: '', // 安装时间
+ runTime: '', // 正式运行时间
+ linkAddress: '', // 链路地址
+ probNo: '', // 探头编号
+ simple: '', // 试样
+ sim1: '', // sim卡1
+ joint: '', // 主站后台联调情况
+ remark: '', // 备注
+};
diff --git a/src/routers/index.js b/src/routers/index.js
index 1403455..b88eae5 100644
--- a/src/routers/index.js
+++ b/src/routers/index.js
@@ -39,32 +39,59 @@ export const routes = [
component: () => import('@/views/device-create.vue'),
},
{
- path: '/corrosion/data-history',
- name: 'data-history',
+ path: '/corrosion/statistical-realtime',
+ name: 'statistical-realtime',
meta: {
- title: '历史数据查看',
+ title: '实时数据统计',
+ icon: 'el-icon-time',
+ },
+ component: () => import('@/views/statistical-realtime.vue'),
+ },
+ {
+ path: '/corrosion/data-report',
+ name: 'data-report',
+ meta: {
+ title: '上报数据查看',
icon: 'el-icon-document-copy',
},
- component: () => import('@/views/data-history.vue'),
+ component: () => import('@/views/data-report.vue'),
},
{
- path: '/corrosion/statistical-history',
- name: 'statistical-history',
+ path: '/corrosion/statistical-report',
+ name: 'statistical-report',
meta: {
- title: '历史数据统计',
+ title: '上报数据统计',
icon: 'el-icon-data-line',
},
- component: () => import('@/views/statistical-history.vue'),
+ component: () => import('@/views/statistical-report.vue'),
},
{
- path: '/corrosion/statistical-realtime',
- name: 'statistical-realtime',
+ path: '/corrosion/data-history',
+ name: 'data-history',
meta: {
- title: '实时数据统计',
- icon: 'el-icon-time',
+ title: '历史数据查看',
+ icon: 'el-icon-document-copy',
},
- component: () => import('@/views/statistical-realtime.vue'),
+ component: () => import('@/views/data-history.vue'),
},
+ {
+ path: '/corrosion/commands',
+ name: 'commands',
+ meta: {
+ title: '指令下发状态',
+ icon: 'el-icon-document-copy',
+ },
+ component: () => import('@/views/commands.vue'),
+ },
+ // {
+ // path: '/corrosion/statistical-history',
+ // name: 'statistical-history',
+ // meta: {
+ // title: '历史数据统计',
+ // icon: 'el-icon-data-line',
+ // },
+ // component: () => import('@/views/statistical-history.vue'),
+ // },
// {
// path: '/corrosion/months',
// name: 'months',
diff --git a/src/store/statistics.js b/src/store/statistics.js
index 6747efc..995e38d 100644
--- a/src/store/statistics.js
+++ b/src/store/statistics.js
@@ -1,4 +1,4 @@
-import { getHistories, getMonthsDate } from 'apis/index';
+import { getDatas, getMonthsDate } from 'apis/index';
export default {
namespaced: true,
@@ -67,7 +67,7 @@ export default {
// 获取实时数据统计数据
async getRealtimeData({ commit }, params) {
try {
- const data = await getHistories(params);
+ const data = await getDatas(params);
commit('setRealtimeData', data || null);
return data;
} catch (error) {
diff --git a/src/views/commands.vue b/src/views/commands.vue
new file mode 100644
index 0000000..fe93252
--- /dev/null
+++ b/src/views/commands.vue
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+ {{ computeType(scope.row.type) }}
+
+
+
+
+ {{ scope.row.status }}
+
+
+
+
+ {{ formatDate(+scope.row.startTime) }}
+
+
+
+
+ {{ formatDate(+scope.row.endTime) }}
+
+
+
+
+
+
+
diff --git a/src/views/data-history.vue b/src/views/data-history.vue
index 514a1f7..311cbb7 100644
--- a/src/views/data-history.vue
+++ b/src/views/data-history.vue
@@ -2,11 +2,14 @@
import { computed, onMounted, ref } from 'vue';
import { useStore } from 'vuex';
import SearchBar from 'components/search-bar-data.vue';
-import { getHistories } from 'apis/index';
+import { getHistory, sendCommand } from 'apis';
import { ElMessage } from 'element-plus';
const search = ref({});
-const page = ref({ page: 1, size: 50 });
+const page = ref({
+ page: 1,
+ size: 50,
+});
let timer = null;
const store = useStore();
const token = computed(() => store.getters['user/token']);
@@ -30,11 +33,12 @@ const getData = async () => {
const params = {
deviceId: currentDeviceId.value,
date,
+ dataType: options.dataType,
page: page.value.age,
size: page.value.size,
type: 1,
};
- const resData = await getHistories(params);
+ const resData = await getHistory(params);
data.value = resData.data;
page.value = resData.page;
timer && clearTimeout(timer);
@@ -91,43 +95,74 @@ const onPrev = e => {
page.value.page = e - 1;
getData();
};
+
+/**
+ * 发送查询指令
+ * @param {string} dataType ('data', 'event')
+ */
+async function onSend(dataType) {
+ try {
+ const { date, deviceId } = 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('指令发送失败');
+ }
+}
-
+
+
+
+ 发送查询指令(历史数据)
+ 发送查询指令(历史事件)
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+import { computed, onMounted, ref } from 'vue';
+import { useStore } from 'vuex';
+import SearchBar from 'components/search-bar-data.vue';
+import { getDatas } from 'apis/index';
+import { ElMessage } from 'element-plus';
+
+const search = ref({});
+const page = ref({
+ page: 1,
+ size: 50,
+});
+let timer = null;
+const store = useStore();
+const token = computed(() => store.getters['user/token']);
+const currentDeviceId = computed(() => store.state.device.currentDeviceId); // 正在操作的设备的id
+let contentHeight = 600;
+const data = ref(null);
+
+// 获取设备完整信息列表
+const getData = async () => {
+ try {
+ if (token && token.value) {
+ if (!currentDeviceId.value) {
+ return ElMessage.error('请选择站点');
+ }
+
+ const options = { ...search.value };
+ const date = options && options.date ? options.date : [];
+ if (!date || date.length !== 2) {
+ return ElMessage.error('请选择时间 ');
+ }
+ const params = {
+ deviceId: currentDeviceId.value,
+ date,
+ page: page.value.age,
+ size: page.value.size,
+ type: 1,
+ };
+ const resData = await getDatas(params);
+ data.value = resData.data;
+ page.value = resData.page;
+ timer && clearTimeout(timer);
+ timer = null;
+ } else {
+ timer = setTimeout(() => {
+ getData();
+ }, 20);
+ }
+ } catch (error) {
+ ElMessage.error(error.message || '获取数据失败');
+ console.log('error: ', error);
+ }
+};
+
+// getData();
+
+// 设置表格高度
+onMounted(() => {
+ const winHeight = document.documentElement.clientHeight;
+ contentHeight = winHeight - 150;
+});
+
+/**
+ * 监听sear h信息
+ * @param {object} payload search组件emi 的数据
+ */
+const onSearch = payload => {
+ search.value = { ...payload };
+ getData();
+};
+/**
+ * 当前 码变化
+ * 更新page 重新 取数据
+ * @param {number} e 的页码
+ */
+const onCurrentPageChange = e => {
+ page.value.page = e;
+ getData();
+};
+
+const onSizeChange = e => {
+ page.value.size = e;
+ getData();
+};
+
+// 下一页
+const onNext = e => {
+ page.value.page = e + 1;
+ getData();
+};
+
+// 上一页
+const onPrev = e => {
+ page.value.page = e - 1;
+ getData();
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/device-edit.vue b/src/views/device-edit.vue
index 9258b77..d40c05c 100644
--- a/src/views/device-edit.vue
+++ b/src/views/device-edit.vue
@@ -121,30 +121,11 @@