diff --git a/package-lock.json b/package-lock.json
index 0618fa5..0e7de3e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12,6 +12,7 @@
"@vitejs/plugin-vue": "^1.9.3",
"axios": "^0.23.0",
"dayjs": "^1.10.7",
+ "echarts": "^5.2.2",
"element-plus": "^1.1.0-beta.24",
"lodash": "^4.17.21",
"vite": "^2.6.4",
@@ -2301,6 +2302,21 @@
"ignored": "bin/ignored"
}
},
+ "node_modules/echarts": {
+ "version": "5.2.2",
+ "resolved": "https://registry.npmmirror.com/echarts/download/echarts-5.2.2.tgz",
+ "integrity": "sha1-7DyLKhUcu6cbo8LHz5svIEfOQ3A=",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "tslib": "2.3.0",
+ "zrender": "5.2.1"
+ }
+ },
+ "node_modules/echarts/node_modules/tslib": {
+ "version": "2.3.0",
+ "resolved": "https://registry.nlark.com/tslib/download/tslib-2.3.0.tgz",
+ "integrity": "sha1-gDuM2rPhK6WBpMpByIObuw2ssJ4="
+ },
"node_modules/element-plus": {
"version": "1.1.0-beta.24",
"resolved": "https://registry.npmmirror.com/element-plus/download/element-plus-1.1.0-beta.24.tgz",
@@ -6762,6 +6778,19 @@
"engines": {
"node": ">=10"
}
+ },
+ "node_modules/zrender": {
+ "version": "5.2.1",
+ "resolved": "https://registry.nlark.com/zrender/download/zrender-5.2.1.tgz",
+ "integrity": "sha1-X0u9qRW6bUErCxncJDG+qtBUF7s=",
+ "dependencies": {
+ "tslib": "2.3.0"
+ }
+ },
+ "node_modules/zrender/node_modules/tslib": {
+ "version": "2.3.0",
+ "resolved": "https://registry.nlark.com/tslib/download/tslib-2.3.0.tgz",
+ "integrity": "sha1-gDuM2rPhK6WBpMpByIObuw2ssJ4="
}
},
"dependencies": {
@@ -8638,6 +8667,22 @@
"minimatch": "^3.0.4"
}
},
+ "echarts": {
+ "version": "5.2.2",
+ "resolved": "https://registry.npmmirror.com/echarts/download/echarts-5.2.2.tgz",
+ "integrity": "sha1-7DyLKhUcu6cbo8LHz5svIEfOQ3A=",
+ "requires": {
+ "tslib": "2.3.0",
+ "zrender": "5.2.1"
+ },
+ "dependencies": {
+ "tslib": {
+ "version": "2.3.0",
+ "resolved": "https://registry.nlark.com/tslib/download/tslib-2.3.0.tgz",
+ "integrity": "sha1-gDuM2rPhK6WBpMpByIObuw2ssJ4="
+ }
+ }
+ },
"element-plus": {
"version": "1.1.0-beta.24",
"resolved": "https://registry.npmmirror.com/element-plus/download/element-plus-1.1.0-beta.24.tgz",
@@ -12028,6 +12073,21 @@
"resolved": "https://registry.nlark.com/yocto-queue/download/yocto-queue-0.1.0.tgz",
"integrity": "sha1-ApTrPe4FAo0x7hpfosVWpqrxChs=",
"dev": true
+ },
+ "zrender": {
+ "version": "5.2.1",
+ "resolved": "https://registry.nlark.com/zrender/download/zrender-5.2.1.tgz",
+ "integrity": "sha1-X0u9qRW6bUErCxncJDG+qtBUF7s=",
+ "requires": {
+ "tslib": "2.3.0"
+ },
+ "dependencies": {
+ "tslib": {
+ "version": "2.3.0",
+ "resolved": "https://registry.nlark.com/tslib/download/tslib-2.3.0.tgz",
+ "integrity": "sha1-gDuM2rPhK6WBpMpByIObuw2ssJ4="
+ }
+ }
}
}
}
diff --git a/package.json b/package.json
index d137666..a311c42 100644
--- a/package.json
+++ b/package.json
@@ -18,6 +18,7 @@
"@vitejs/plugin-vue": "^1.9.3",
"axios": "^0.23.0",
"dayjs": "^1.10.7",
+ "echarts": "^5.2.2",
"element-plus": "^1.1.0-beta.24",
"lodash": "^4.17.21",
"vite": "^2.6.4",
diff --git a/src/components/device-select-and-status.vue b/src/components/config/device-select-and-status.vue
similarity index 100%
rename from src/components/device-select-and-status.vue
rename to src/components/config/device-select-and-status.vue
diff --git a/src/components/config/function-config-pending.vue b/src/components/config/function-config-pending.vue
index cef1389..abc50ac 100644
--- a/src/components/config/function-config-pending.vue
+++ b/src/components/config/function-config-pending.vue
@@ -121,14 +121,20 @@
+
+
+
+
+
+
-
+
@@ -155,7 +161,7 @@ import { useStore } from 'vuex';
import { ElMessage } from 'element-plus';
import cloneDeep from 'lodash/cloneDeep';
import isDate from 'lodash/isDate';
-import { createConfigFunction, getConfigFunction } from 'apis';
+import { createConfigFunction, getConfigAppliedFunction } from 'apis';
import Refresh from 'components/refresh.vue';
import { corrosiveTypes, functionConfig } from '@/config/config';
@@ -189,8 +195,7 @@ async function onSearch(deviceId, type = 0) {
deviceId,
type,
};
- const resData = await getConfigFunction(params);
- data.value = resData || functionConfig;
+ const resData = await getConfigAppliedFunction(params);
if (resData && resData.time) {
// 格式化ms为日期格式
resData.time = new Date(+resData.time);
@@ -216,14 +221,17 @@ async function onSearch(deviceId, type = 0) {
resData.report.timePoints[i] = '';
}
}
+ } else {
+ resData.report = [''];
}
}
+ data.value = resData || functionConfig;
}
watch(
currentDeviceId,
newDeviceId => {
- newDeviceId && props.activeName === 'pending' && onSearch(newDeviceId);
+ newDeviceId && props.activeName === 'function' && onSearch(newDeviceId);
},
{ immediate: true },
);
@@ -243,11 +251,19 @@ const onSubmit = () => {
if (param.report.type === 'POINT') {
// 按时间点上报 格式化时间格式
const points = [...param.report.timePoints];
+
for (let i = 0; i < points.length; i++) {
if (points[i]) {
points[i] = formatTime(points[i]);
}
}
+
+ const validated = validateTimePoints(points);
+ if (!validated) {
+ ElMessage.error('上报时间点不能重复');
+ return;
+ }
+
param.report.timePoints = points;
}
await createConfigFunction(param);
@@ -264,4 +280,37 @@ const onReset = () => {
};
// currentDeviceId && onSearch(currentDeviceId.value);
+// 添加时间上报时间点输入框
+function addTimePoints() {
+ const { timePoints } = data.value.report;
+ console.log(data.value.report);
+ if (!timePoints || !timePoints.length) {
+ data.value.report.timePoints = [''];
+ } else {
+ if (timePoints.length >= 6) return;
+ data.value.report.timePoints.push('');
+ }
+}
+
+/**
+ * 验证上报时间点是否重复
+ * @param {array|null} points ["时:分"]
+ * @returns {boolean}
+ */
+function validateTimePoints(points) {
+ if (!points || !points.length) return true;
+ const obj = {};
+ points.forEach(item => {
+ if (obj[item]) {
+ obj[item] += 1;
+ } else {
+ obj[item] = 1;
+ }
+ });
+ // eslint-disable-next-line no-restricted-syntax
+ for (const key in obj) {
+ if (obj[key] > 1) return false;
+ }
+ return true;
+}
diff --git a/src/components/config/network-config-pending.vue b/src/components/config/network-config-pending.vue
index 7688657..a861244 100644
--- a/src/components/config/network-config-pending.vue
+++ b/src/components/config/network-config-pending.vue
@@ -79,7 +79,7 @@
import { computed, defineEmits, defineProps, ref, watch } from 'vue';
import { useStore } from 'vuex';
import { ElMessage } from 'element-plus';
-import { createConfigNetwork, getConfigNetwork } from 'apis';
+import { createConfigNetwork, getConfigAppliedNetwork } from 'apis';
import Refresh from 'components/refresh.vue';
import { networkConfig } from '@/config/config';
@@ -101,7 +101,7 @@ async function onSearch(deviceId, type = 0) {
deviceId,
type,
};
- const resData = await getConfigNetwork(params);
+ const resData = await getConfigAppliedNetwork(params);
data.value = resData || networkConfig;
if (resData && resData.status) {
emit('status', resData.status);
@@ -116,7 +116,7 @@ async function onSearch(deviceId, type = 0) {
watch(
currentDeviceId,
newDeviceId => {
- newDeviceId && props.activeName === 'pending' && onSearch(newDeviceId);
+ newDeviceId && props.activeName === 'network' && onSearch(newDeviceId);
},
{ immediate: true },
);
diff --git a/src/views/data-history.vue b/src/components/history/data-history.vue
similarity index 87%
rename from src/views/data-history.vue
rename to src/components/history/data-history.vue
index 2f88da1..4a02fb6 100644
--- a/src/views/data-history.vue
+++ b/src/components/history/data-history.vue
@@ -1,7 +1,7 @@
-
+
-
+
diff --git a/src/components/search-bar-data.vue b/src/components/history/search-bar-data.vue
similarity index 81%
rename from src/components/search-bar-data.vue
rename to src/components/history/search-bar-data.vue
index 1bbdd34..3523ab6 100644
--- a/src/components/search-bar-data.vue
+++ b/src/components/history/search-bar-data.vue
@@ -1,23 +1,12 @@
-
+
-
-
-
-
-
-
+
@@ -25,6 +14,14 @@
+
+
+
+
+
+
+
+
@@ -33,7 +30,10 @@
- 导出
+
+
+ 导出
+
@@ -47,7 +47,7 @@ import { exportHistory } from 'apis';
const emit = defineEmits(['search']);
const searchDevice = reactive({
deviceId: '',
- date: [dayjs().subtract(7, 'day'), new Date()],
+ date: ['', new Date()],
dataType: 'ReportHistoryData',
});
const searchDeviceForm = ref(null); // form
diff --git a/src/components/statistical/search-bar.vue b/src/components/statistical/search-bar.vue
new file mode 100644
index 0000000..3523ab6
--- /dev/null
+++ b/src/components/statistical/search-bar.vue
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 查询
+
+
+
+
+
+
+ 导出
+
+
+
+
+
+
diff --git a/src/config/config.js b/src/config/config.js
index 9f2d272..608f0a7 100644
--- a/src/config/config.js
+++ b/src/config/config.js
@@ -37,7 +37,7 @@ export const functionConfig = {
corrosiveType4: '', // 金属腐蚀类型
report: {
type: 'CYCLE', // 上报周期类型 0->时间点 1->周期
- timePoints: [0, 0, 0, 0, 0, 0], // 设置时间点
+ timePoints: [''], // 设置时间点
cycle: 240, // 上报周期分钟数
},
status: '',
@@ -45,10 +45,22 @@ export const functionConfig = {
// 金属腐蚀类型
export const corrosiveTypes = [
- { value: 'XIN', type: '锌' },
- { value: 'LV', type: '铝' },
- { value: 'TONG', type: '铜' },
- { value: 'GANG', type: '钢' },
+ {
+ value: 'XIN',
+ type: '锌',
+ },
+ {
+ value: 'LV',
+ type: '铝',
+ },
+ {
+ value: 'TONG',
+ type: '铜',
+ },
+ {
+ value: 'GANG',
+ type: '钢',
+ },
];
// 添加设备
diff --git a/src/hooks/useDeviceCreate.js b/src/hooks/useDeviceCreate.js
index 29bd730..495cd03 100644
--- a/src/hooks/useDeviceCreate.js
+++ b/src/hooks/useDeviceCreate.js
@@ -3,10 +3,6 @@ import { ref } from 'vue';
export default function useDeviceCreate() {
const display = ref(false);
- function toggle() {
- display.value = !display.value;
- }
-
function hide() {
display.value = false;
}
@@ -17,7 +13,6 @@ export default function useDeviceCreate() {
return {
display,
- toggle,
hide,
show,
};
diff --git a/src/routers/index.js b/src/routers/index.js
index 562941f..81953fb 100644
--- a/src/routers/index.js
+++ b/src/routers/index.js
@@ -39,32 +39,23 @@ export const routes = [
component: () => import('@/views/data-realtime.vue'),
},
{
- path: '/corrosion/statistical-realtime',
- name: 'statistical-realtime',
+ path: '/corrosion/history',
+ name: 'history',
meta: {
- title: '实时数据统计',
- icon: 'el-icon-data-analysis',
+ title: '历史数据',
+ icon: 'el-icon-document',
},
- component: () => import('@/views/statistical-realtime.vue'),
+ component: () => import('@/views/history.vue'),
},
{
- path: '/corrosion/statistical-report',
- name: 'statistical-report',
+ path: '/corrosion/statistical',
+ name: 'statistical',
meta: {
- title: '上报数据统计',
+ title: '数据统计',
icon: 'el-icon-data-line',
},
component: () => import('@/views/statistical-report.vue'),
},
- {
- path: '/corrosion/data-history',
- name: 'data-history',
- meta: {
- title: '历史数据',
- icon: 'el-icon-document-copy',
- },
- component: () => import('@/views/data-history.vue'),
- },
{
path: '/corrosion/commands',
name: 'commands',
diff --git a/src/views/config.vue b/src/views/config.vue
index f2ec10c..562b9cc 100644
--- a/src/views/config.vue
+++ b/src/views/config.vue
@@ -1,4 +1,7 @@
+
+
+
@@ -13,6 +16,9 @@
import { ref } from 'vue';
import FunctionConfigPending from 'components/config/function-config-pending.vue';
import NetworkConfigPending from 'components/config/network-config-pending.vue';
+import DeviceSelectAndStatus from 'components/config/device-select-and-status.vue';
+
+const status = ref('');
const activeName = ref('function');
diff --git a/src/views/function-config.vue b/src/views/function-config.vue
index 67fae54..f7d9169 100644
--- a/src/views/function-config.vue
+++ b/src/views/function-config.vue
@@ -14,7 +14,7 @@
diff --git a/src/views/network-config.vue b/src/views/network-config.vue
index f7b416f..18418fd 100644
--- a/src/views/network-config.vue
+++ b/src/views/network-config.vue
@@ -14,7 +14,7 @@