From 2e8f41d5d0d3cda52aadf40a391106ef19ac00fd Mon Sep 17 00:00:00 2001 From: copper Date: Mon, 4 Jan 2021 17:15:44 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E8=B0=83=E6=95=B4moment=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=8C=96=E9=97=AE=E9=A2=98=202.=20=E5=8A=9F=E8=83=BD=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E4=B8=8E=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 6 +- src/components/Login.vue | 18 +- src/components/Main.vue | 83 ++++- src/components/admin/Index.vue | 9 +- src/components/admin/forms/RuleDetail.vue | 165 +++++++++ src/components/admin/tables/DeviceTable.vue | 2 +- src/components/admin/tables/RulesTable.vue | 177 ++++++++++ src/components/analysis/Index.vue | 122 ++++++- src/components/charts/BaseIndexChart.vue | 139 ++++++++ src/components/charts/TempChart.vue | 0 src/components/logs/DayLimit.vue | 115 +++++++ src/components/logs/DayLogs.vue | 81 +++++ src/components/logs/Index.vue | 13 - src/components/map/Index.vue | 115 ++++++- src/components/map/RightTable.vue | 59 ++++ src/components/search/Index.vue | 363 +++++++++++++++----- src/components/search/LurMean.vue | 127 +++++++ src/components/search/LurSTS.vue | 121 +++++++ src/components/search/Means.vue | 217 ++++++++++++ src/components/search/QaDay.vue | 124 +++++++ src/components/search/QaSTS.vue | 170 +++++++++ src/components/search/YLSTS.vue | 133 +++++++ src/components/utils/moment.zh_cn.js | 115 +++++++ src/utils/http.js | 35 +- src/utils/router.js | 8 +- src/utils/store.js | 9 +- src/utils/water.js | 7 +- vue.config.js | 13 +- 28 files changed, 2398 insertions(+), 148 deletions(-) create mode 100644 src/components/admin/forms/RuleDetail.vue create mode 100644 src/components/admin/tables/RulesTable.vue create mode 100644 src/components/charts/BaseIndexChart.vue create mode 100644 src/components/charts/TempChart.vue create mode 100644 src/components/logs/DayLimit.vue create mode 100644 src/components/logs/DayLogs.vue delete mode 100644 src/components/logs/Index.vue create mode 100644 src/components/map/RightTable.vue create mode 100644 src/components/search/LurMean.vue create mode 100644 src/components/search/LurSTS.vue create mode 100644 src/components/search/Means.vue create mode 100644 src/components/search/QaDay.vue create mode 100644 src/components/search/QaSTS.vue create mode 100644 src/components/search/YLSTS.vue create mode 100644 src/components/utils/moment.zh_cn.js diff --git a/public/index.html b/public/index.html index d2a4288..9d43d2b 100644 --- a/public/index.html +++ b/public/index.html @@ -16,18 +16,22 @@ We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue. +
+ + + - + \ No newline at end of file diff --git a/src/components/Login.vue b/src/components/Login.vue index 6f80423..357a601 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -16,14 +16,14 @@ >

- CVEO水质监测平台 + 湖北富瑞尔科技有限公司水质监测平台

- 当前版本: 1.0.2 + 当前版本: 1.1.0

- 后台版本: 1.0.0 + 后台版本: 1.1.0

版本记录: @@ -39,6 +39,11 @@

2020-12-7: 1.0.2版本,修复字体背景遮挡问题 +

+

+ 2021-1-4: + 1.1.0版本,添加分时数据查询功能,提供表格与图表两种方式,对数据时间范围进行限制 + 后台进行调整,对分时数据时间范围进行限制

@@ -149,12 +154,15 @@ export default { */ let results = [ getData(URL_MAP.DEVICE_LIST), - getData(URL_MAP.SENSOR_LIST) + getData(URL_MAP.SENSOR_LIST), + getData(URL_MAP.PROJECT_LIST), + getData(URL_MAP.RULES_LIST), ] data = await Promise.all(results) this.$store.commit('deviceList', data[0].data) this.$store.commit('sensorList', data[1].data) - + this.$store.commit('projectList', data[2].data) + this.$store.commit('ruleList', data[3].data) let path = decodeURIComponent(this.$route.query.redirect || "/"); this.$router.push({ path: path }); } catch (e) { diff --git a/src/components/Main.vue b/src/components/Main.vue index 51f803c..ae8dc00 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -2,10 +2,20 @@ - + 水质监测平台 - +
+ + + + + + + +
+
- +
数据查询 - 详细数据 + 分时数据 + + + 均值数据 + + + 水质质量日报 + + + 水质指标统计 + + + 水质质量类别统计 + + + 水质指标超标统计 + + + 水质超标处理记录 @@ -46,7 +74,7 @@
- + + + + + + +
diff --git a/src/components/admin/Index.vue b/src/components/admin/Index.vue index e201554..fe97b01 100644 --- a/src/components/admin/Index.vue +++ b/src/components/admin/Index.vue @@ -24,6 +24,11 @@ 人员 + + + + 规则 + @@ -41,12 +46,14 @@ import DeviceTable from './tables/DeviceTable'; import ProjectTable from './tables/ProjectTable'; import UserTable from './tables/UserTable'; import { getData, URL_MAP } from "@/utils/http"; +import RulesTable from './tables/RulesTable'; export default { components: { 'sensor-table':SensorTable, 'device-table':DeviceTable, 'project-table':ProjectTable, - 'user-table':UserTable + 'user-table':UserTable, + 'rules-table':RulesTable }, data() { return { diff --git a/src/components/admin/forms/RuleDetail.vue b/src/components/admin/forms/RuleDetail.vue new file mode 100644 index 0000000..f4a6caa --- /dev/null +++ b/src/components/admin/forms/RuleDetail.vue @@ -0,0 +1,165 @@ + + + + + \ No newline at end of file diff --git a/src/components/admin/tables/DeviceTable.vue b/src/components/admin/tables/DeviceTable.vue index 08b729b..ee29f47 100644 --- a/src/components/admin/tables/DeviceTable.vue +++ b/src/components/admin/tables/DeviceTable.vue @@ -139,7 +139,7 @@ export default { try { if (!this.isCreate) { form["id"] = form["_id"]; - console.log(form) + // console.log(form) let data = await patchJSON(URL_MAP.DEVICE_DETAIL, form); } else { form["id"] = form["_id"]; diff --git a/src/components/admin/tables/RulesTable.vue b/src/components/admin/tables/RulesTable.vue new file mode 100644 index 0000000..885560e --- /dev/null +++ b/src/components/admin/tables/RulesTable.vue @@ -0,0 +1,177 @@ + + + + + \ No newline at end of file diff --git a/src/components/analysis/Index.vue b/src/components/analysis/Index.vue index dd7092b..2d70a16 100644 --- a/src/components/analysis/Index.vue +++ b/src/components/analysis/Index.vue @@ -1,13 +1,129 @@ \ No newline at end of file diff --git a/src/components/charts/BaseIndexChart.vue b/src/components/charts/BaseIndexChart.vue new file mode 100644 index 0000000..b5c78dd --- /dev/null +++ b/src/components/charts/BaseIndexChart.vue @@ -0,0 +1,139 @@ + + + + + \ No newline at end of file diff --git a/src/components/charts/TempChart.vue b/src/components/charts/TempChart.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/components/logs/DayLimit.vue b/src/components/logs/DayLimit.vue new file mode 100644 index 0000000..574c414 --- /dev/null +++ b/src/components/logs/DayLimit.vue @@ -0,0 +1,115 @@ + + + + + \ No newline at end of file diff --git a/src/components/logs/DayLogs.vue b/src/components/logs/DayLogs.vue new file mode 100644 index 0000000..11a05b3 --- /dev/null +++ b/src/components/logs/DayLogs.vue @@ -0,0 +1,81 @@ + + + + + \ No newline at end of file diff --git a/src/components/logs/Index.vue b/src/components/logs/Index.vue deleted file mode 100644 index dd7092b..0000000 --- a/src/components/logs/Index.vue +++ /dev/null @@ -1,13 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/components/map/Index.vue b/src/components/map/Index.vue index 96f072a..5cb1558 100644 --- a/src/components/map/Index.vue +++ b/src/components/map/Index.vue @@ -8,6 +8,56 @@ type="primary" @click="loadBaseData" > +
+ 图例 + + +
+ +
+
+ 水质检测仪 +
+
+
+ + +
+ 正常 +
+
+ +
+ 预警 +
+
+ +
+ 超标 +
+
+ +
+ 离线 +
+
+
+
+
+ +
+
+ +
+
+ + 全选 + pH + 浊度 + 余氯 + 温度 + +
@@ -15,10 +65,12 @@ // import { fromLonLat, toLonLat } from "ol/proj.js"; const { fromLonLat, toLonLat } = ol.proj; import { getData, login, logout, URL_MAP } from "@/utils/http"; +import RightTable from "./RightTable.vue"; let map = null; export default { + components: { RightTable }, data() { return { view: new ol.View({ @@ -28,6 +80,8 @@ export default { waterLayer: "", projection: "", center: fromLonLat([114.3, 30.6]), + waterImg: require("@/assets/water.png"), + rightShow: false, }; }, computed: { @@ -41,7 +95,7 @@ export default { methods: { mapinit() { this.projection = ol.proj.get("EPSG:3857"); - + this.waterLayer = this.getDeviceVectorLayer(); var AMapLayer = new ol.layer.Tile({ // source: new ol.source.XYZ({ @@ -125,4 +179,63 @@ export default { \ No newline at end of file diff --git a/src/components/map/RightTable.vue b/src/components/map/RightTable.vue new file mode 100644 index 0000000..251b274 --- /dev/null +++ b/src/components/map/RightTable.vue @@ -0,0 +1,59 @@ + + + + + \ No newline at end of file diff --git a/src/components/search/Index.vue b/src/components/search/Index.vue index 5355ed6..4525e5a 100644 --- a/src/components/search/Index.vue +++ b/src/components/search/Index.vue @@ -1,131 +1,319 @@ + + \ No newline at end of file diff --git a/src/components/search/LurSTS.vue b/src/components/search/LurSTS.vue new file mode 100644 index 0000000..394bd01 --- /dev/null +++ b/src/components/search/LurSTS.vue @@ -0,0 +1,121 @@ + + + + + \ No newline at end of file diff --git a/src/components/search/Means.vue b/src/components/search/Means.vue new file mode 100644 index 0000000..310990f --- /dev/null +++ b/src/components/search/Means.vue @@ -0,0 +1,217 @@ + + + + + \ No newline at end of file diff --git a/src/components/search/QaDay.vue b/src/components/search/QaDay.vue new file mode 100644 index 0000000..d7f444b --- /dev/null +++ b/src/components/search/QaDay.vue @@ -0,0 +1,124 @@ + + + + + \ No newline at end of file diff --git a/src/components/search/QaSTS.vue b/src/components/search/QaSTS.vue new file mode 100644 index 0000000..72a06e3 --- /dev/null +++ b/src/components/search/QaSTS.vue @@ -0,0 +1,170 @@ + + + + + \ No newline at end of file diff --git a/src/components/search/YLSTS.vue b/src/components/search/YLSTS.vue new file mode 100644 index 0000000..15e7e3c --- /dev/null +++ b/src/components/search/YLSTS.vue @@ -0,0 +1,133 @@ + + + + + \ No newline at end of file diff --git a/src/components/utils/moment.zh_cn.js b/src/components/utils/moment.zh_cn.js new file mode 100644 index 0000000..92e32ac --- /dev/null +++ b/src/components/utils/moment.zh_cn.js @@ -0,0 +1,115 @@ +import Moment from 'moment' +Moment.locale('zh-cn', { + months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split( + '_' + ), + monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split( + '_' + ), + weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), + weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'), + weekdaysMin: '日_一_二_三_四_五_六'.split('_'), + longDateFormat: { + LT: 'HH:mm', + LTS: 'HH:mm:ss', + L: 'YYYY/MM/DD', + LL: 'YYYY年M月D日', + LLL: 'YYYY年M月D日Ah点mm分', + LLLL: 'YYYY年M月D日ddddAh点mm分', + l: 'YYYY/M/D', + ll: 'YYYY年M月D日', + lll: 'YYYY年M月D日 HH:mm', + llll: 'YYYY年M月D日dddd HH:mm', + }, + meridiemParse: /凌晨|早上|上午|中午|下午|晚上/, + meridiemHour: function (hour, meridiem) { + if (hour === 12) { + hour = 0; + } + if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') { + return hour; + } else if (meridiem === '下午' || meridiem === '晚上') { + return hour + 12; + } else { + // '中午' + return hour >= 11 ? hour : hour + 12; + } + }, + meridiem: function (hour, minute, isLower) { + var hm = hour * 100 + minute; + if (hm < 600) { + return '凌晨'; + } else if (hm < 900) { + return '早上'; + } else if (hm < 1130) { + return '上午'; + } else if (hm < 1230) { + return '中午'; + } else if (hm < 1800) { + return '下午'; + } else { + return '晚上'; + } + }, + calendar: { + sameDay: '[今天]LT', + nextDay: '[明天]LT', + nextWeek: function (now) { + if (now.week() !== this.week()) { + return '[下]dddLT'; + } else { + return '[本]dddLT'; + } + }, + lastDay: '[昨天]LT', + lastWeek: function (now) { + if (this.week() !== now.week()) { + return '[上]dddLT'; + } else { + return '[本]dddLT'; + } + }, + sameElse: 'L', + }, + dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/, + ordinal: function (number, period) { + switch (period) { + case 'd': + case 'D': + case 'DDD': + return number + '日'; + case 'M': + return number + '月'; + case 'w': + case 'W': + return number + '周'; + default: + return number; + } + }, + relativeTime: { + future: '%s后', + past: '%s前', + s: '几秒', + ss: '%d 秒', + m: '1 分钟', + mm: '%d 分钟', + h: '1 小时', + hh: '%d 小时', + d: '1 天', + dd: '%d 天', + w: '1 周', + ww: '%d 周', + M: '1 个月', + MM: '%d 个月', + y: '1 年', + yy: '%d 年', + }, + week: { + // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效 + dow: 1, // Monday is the first day of the week. + doy: 4, // The week that contains Jan 4th is the first week of the year. + }, +}); + +export default Moment \ No newline at end of file diff --git a/src/utils/http.js b/src/utils/http.js index 6071b63..b27f7f1 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -1,4 +1,5 @@ import axios from "axios"; +import qs from 'qs' const backendUrl = '/backend/' const geoServerUrl = '/geoserver/' @@ -20,17 +21,18 @@ export const URL_MAP = { CHANGE_PASSWD: 'current/chpass/', RESET_PASSWD: 'passwd/reset/', POSITION_LIST: 'position/', - POSITION_DETAIL: 'position/detail/' + POSITION_DETAIL: 'position/detail/', + RULES_LIST: 'parammanager/', + RULES_DETAIL: 'parammanager/detail/' } -export async function login(username, passwd, uuid, capthe) -{ +export async function login(username, passwd, uuid, capthe) { let response = await instance.post('auth', { - 'username':username, - 'password':passwd, - 'uuid':uuid, - 'captch':capthe + 'username': username, + 'password': passwd, + 'uuid': uuid, + 'captch': capthe }) let data = await response.data let token = data.access_token @@ -46,16 +48,19 @@ export function setAuth(auth) { instance.defaults.headers['Authorization'] = 'JWT ' + auth; } -export async function logout() -{ +export async function logout() { instance.defaults.headers['Authorization'] = '' } export async function getData(url, json) { let response = await instance.get(url, { params: json + , + paramsSerializer: function (params) { + return qs.stringify(params, { arrayFormat: 'repeat' }) + } }) - + let data = await response.data return data } @@ -63,7 +68,7 @@ export async function getData(url, json) { export async function postJSON(url, json) { const headerJSON = { "Content-Type": "application/json" - }; + }; let response = await instance.post(url, JSON.stringify(json), { headers: headerJSON }) let data = await response.data return data @@ -72,7 +77,7 @@ export async function postJSON(url, json) { export async function putJSON(url, json) { const headerJSON = { "Content-Type": "application/json" - }; + }; let response = await instance.put(url, JSON.stringify(json), { headers: headerJSON }) let data = await response.data return data @@ -81,7 +86,7 @@ export async function putJSON(url, json) { export async function patchJSON(url, json) { const headerJSON = { "Content-Type": "application/json" - }; + }; let response = await instance.patch(url, JSON.stringify(json), { headers: headerJSON }) let data = await response.data return data @@ -90,8 +95,8 @@ export async function patchJSON(url, json) { export async function deleteJSON(url, json) { const headerJSON = { "Content-Type": "application/json" - }; - let response = await instance.delete(url, { data:json }) + }; + let response = await instance.delete(url, { data: json }) let data = await response.data return data } \ No newline at end of file diff --git a/src/utils/router.js b/src/utils/router.js index e2b2d42..3adf04b 100644 --- a/src/utils/router.js +++ b/src/utils/router.js @@ -9,6 +9,12 @@ Vue.use(VueRouter) const funcRoutes = [ { path:'map-layout', name:'map-layout', component: ()=>import(/* webpackChunkName: "map-layout" */ '@/components/map/Index' ) }, { path:'detail-search', name:'detail-search', component: ()=>import(/* webpackChunkName: "detail-search" */ '@/components/search/Index' ) }, + { path:'means', name:'means', component: ()=>import(/* webpackChunkName: "means" */ '@/components/search/Means' ) }, + { path:'qa-day', name:'qa-day', component: ()=>import(/* webpackChunkName: "qa-day" */ '@/components/search/QaDay' ) }, + { path:'lur-mean', name:'lur-mean', component: ()=>import(/* webpackChunkName: "lur-mean" */ '@/components/search/LurMean' ) }, + { path:'qa-sts', name:'qa-sts', component: ()=>import(/* webpackChunkName: "qa-sts" */ '@/components/search/QaSTS' ) }, + { path:'lur-sts', name:'lur-sts', component: ()=>import(/* webpackChunkName: "lur-sts" */ '@/components/search/LurSTS' ) }, + { path:'yl-sts', name:'yl-sts', component: ()=>import(/* webpackChunkName: "yl-sts" */ '@/components/search/YLSTS' ) }, { path:'admin', name:'admin', component: ()=>import(/* webpackChunkName: "admin" */ '@/components/admin/Index' ) }, { path:'analysis', name:'analysis', component: ()=>import(/* webpackChunkName: "analysis" */ '@/components/analysis/Index' ) }, ] @@ -65,5 +71,5 @@ router.beforeEach((to, from, next) => { next() } }) - +console.log(router) export default router \ No newline at end of file diff --git a/src/utils/store.js b/src/utils/store.js index d2110cd..8582958 100644 --- a/src/utils/store.js +++ b/src/utils/store.js @@ -27,7 +27,8 @@ const store = new Vuex.Store({ cacheData:{}, deviceList:[], projectList:[], - sensorList:[] + sensorList:[], + ruleList:[] }, mutations: { phone(state, o) { @@ -52,6 +53,9 @@ const store = new Vuex.Store({ }, sensorList(state, o) { state.sensorList = o + }, + ruleList(state, o) { + state.ruleList = o } }, getters: { @@ -120,6 +124,9 @@ const store = new Vuex.Store({ sensorList(state) { return state.sensorList }, + ruleList(state) { + return state.ruleList + }, username(state, getters) { if (getters.isLogin) { diff --git a/src/utils/water.js b/src/utils/water.js index 6d71cf9..1a07820 100644 --- a/src/utils/water.js +++ b/src/utils/water.js @@ -1,3 +1,5 @@ +import Moment from 'com/utils/moment.zh_cn' + export function processWater(water, label){ const waters = [] @@ -8,9 +10,10 @@ export function processWater(water, label){ if(!!w.data) { n[key] = w.data[key] } - } ) - n['time'] = new Date(w.data.collect_time) + n['key'] = w._id.$oid + n['time_str'] = Moment(w.timestamp).format('lll') + n['time'] = Moment(w.timestamp).toDate() waters.push(n) } ) return waters diff --git a/vue.config.js b/vue.config.js index 3d83104..f03e000 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,4 +1,5 @@ const path = require('path') +const { env } = require('process') module.exports = { publicPath: '/', @@ -10,7 +11,8 @@ module.exports = { proxy: { '/backend': { // target: 'http://223.75.53.208:8081', - target: 'http://121.36.155.145:10025/', + // target: 'http://121.36.155.145:10025/', + target: 'http://127.0.0.1:7788/' } } }, @@ -31,7 +33,7 @@ module.exports = { 'com': path.resolve(__dirname, 'src', 'components') } }, - externals: { + externals: true ? { 'vue': 'Vue', 'vuex':'Vuex', 'antd': 'antd', @@ -41,6 +43,13 @@ module.exports = { 'axios': 'axios', 'v-charts':'VCharts', 'ol':'ol' + }: { + 'antd': 'antd', + 'ol':'ol', + 'v-charts':'VCharts', + "moment": "moment", + "md5": "js-md5", + 'axios': 'axios', }, module: {