diff --git a/.vscode/settings.json b/.vscode/settings.json index f37bf03..4f31ac9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,4 @@ { - "cSpell.words": [ - "browserslist", - "commitlint", - "unplugin", - "windi", - "windicss" - ] + "cSpell.words": ["browserslist", "commitlint", "unplugin", "windi", "windicss"], + "vue3snippets.enable-compile-vue-file-on-did-save-code": true } diff --git a/package-lock.json b/package-lock.json index d5e0f35..fcc4d61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1815,6 +1815,51 @@ "esutils": "^2.0.2" } }, + "dom-serializer": { + "version": "1.3.2", + "resolved": "https://registry.nlark.com/dom-serializer/download/dom-serializer-1.3.2.tgz?cache=0&sync_timestamp=1621256858583&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdom-serializer%2Fdownload%2Fdom-serializer-1.3.2.tgz", + "integrity": "sha1-YgZDfTLO767HFhgDIwx6ILwbTZE=", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + }, + "dependencies": { + "entities": { + "version": "2.2.0", + "resolved": "https://registry.nlark.com/entities/download/entities-2.2.0.tgz?cache=0&sync_timestamp=1628508126700&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fentities%2Fdownload%2Fentities-2.2.0.tgz", + "integrity": "sha1-CY3JDruD2N/6CJ1VJWs1HTTE2lU=", + "dev": true + } + } + }, + "domelementtype": { + "version": "2.2.0", + "resolved": "https://registry.npm.taobao.org/domelementtype/download/domelementtype-2.2.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdomelementtype%2Fdownload%2Fdomelementtype-2.2.0.tgz", + "integrity": "sha1-mgtsJ4LtahxzI9QiZxg9+b2LHVc=", + "dev": true + }, + "domhandler": { + "version": "4.2.2", + "resolved": "https://registry.nlark.com/domhandler/download/domhandler-4.2.2.tgz?cache=0&sync_timestamp=1630246778110&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdomhandler%2Fdownload%2Fdomhandler-4.2.2.tgz", + "integrity": "sha1-6CXXIdGahrjCAaNSZOImxnjudV8=", + "dev": true, + "requires": { + "domelementtype": "^2.2.0" + } + }, + "domutils": { + "version": "2.8.0", + "resolved": "https://registry.nlark.com/domutils/download/domutils-2.8.0.tgz?cache=0&sync_timestamp=1630106535879&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdomutils%2Fdownload%2Fdomutils-2.8.0.tgz", + "integrity": "sha1-RDfe9dtuLR9dbuhZvZXKfQIEgTU=", + "dev": true, + "requires": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + } + }, "dot-prop": { "version": "5.3.0", "resolved": "https://registry.npm.taobao.org/dot-prop/download/dot-prop-5.3.0.tgz?cache=0&sync_timestamp=1605778235569&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdot-prop%2Fdownload%2Fdot-prop-5.3.0.tgz", @@ -1871,6 +1916,12 @@ "ansi-colors": "^4.1.1" } }, + "entities": { + "version": "3.0.1", + "resolved": "https://registry.nlark.com/entities/download/entities-3.0.1.tgz?cache=0&sync_timestamp=1628508126700&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fentities%2Fdownload%2Fentities-3.0.1.tgz", + "integrity": "sha1-K4h8piWF6W2zkDSC0zbBAGwwAdQ=", + "dev": true + }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npm.taobao.org/error-ex/download/error-ex-1.3.2.tgz", @@ -2163,6 +2214,15 @@ } } }, + "eslint-plugin-html": { + "version": "6.2.0", + "resolved": "https://registry.nlark.com/eslint-plugin-html/download/eslint-plugin-html-6.2.0.tgz?cache=0&sync_timestamp=1632176597928&other_urls=https%3A%2F%2Fregistry.nlark.com%2Feslint-plugin-html%2Fdownload%2Feslint-plugin-html-6.2.0.tgz", + "integrity": "sha1-cVvAC1C70NmW4o+VPCiaXr7GnUM=", + "dev": true, + "requires": { + "htmlparser2": "^7.1.2" + } + }, "eslint-plugin-import": { "version": "2.25.2", "resolved": "https://registry.npmmirror.com/eslint-plugin-import/download/eslint-plugin-import-2.25.2.tgz?cache=0&sync_timestamp=1634079318456&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Feslint-plugin-import%2Fdownload%2Feslint-plugin-import-2.25.2.tgz", @@ -2845,6 +2905,18 @@ "lru-cache": "^6.0.0" } }, + "htmlparser2": { + "version": "7.1.2", + "resolved": "https://registry.nlark.com/htmlparser2/download/htmlparser2-7.1.2.tgz?cache=0&sync_timestamp=1631386311915&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fhtmlparser2%2Fdownload%2Fhtmlparser2-7.1.2.tgz", + "integrity": "sha1-WHkj048DvIngMHbgDLosdHPzf3w=", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.2", + "domutils": "^2.8.0", + "entities": "^3.0.1" + } + }, "human-signals": { "version": "2.1.0", "resolved": "https://registry.nlark.com/human-signals/download/human-signals-2.1.0.tgz", diff --git a/package.json b/package.json index 99d424f..3d78f36 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "cz": "git add . && git cz", "format": "prettier --write ./src", "lint": "eslint ./src --ext .vue,.js,.ts", - "lint-fix": "eslint --fix ./src --ext .vue,.js,.ts", + "fix": "eslint --fix ./src --ext .vue,.js,.ts", "prepare": "husky install" }, "dependencies": { @@ -31,6 +31,7 @@ "eslint": "^7.32.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-config-prettier": "^8.3.0", + "eslint-plugin-html": "^6.2.0", "eslint-plugin-import": "^2.25.2", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-vue": "^7.19.1", diff --git a/src/App.vue b/src/App.vue index 78ed659..dc7d3a1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,15 +1,20 @@ diff --git a/src/components/navbar.vue b/src/components/navbar.vue index 7e66889..62eb903 100644 --- a/src/components/navbar.vue +++ b/src/components/navbar.vue @@ -1,3 +1,23 @@ + + diff --git a/src/components/search-bar-data.vue b/src/components/search-bar-data.vue new file mode 100644 index 0000000..1cfa5b6 --- /dev/null +++ b/src/components/search-bar-data.vue @@ -0,0 +1,59 @@ + + + diff --git a/src/routers/index.js b/src/routers/index.js index 000ada8..c16af7f 100644 --- a/src/routers/index.js +++ b/src/routers/index.js @@ -2,36 +2,35 @@ import { createRouter, createWebHistory } from 'vue-router'; // 还有 createWebHashHistory 和 createMemoryHistory export const routes = [ - { path: '/', redirect: '/test' }, { path: '/network-config', name: 'network-config', - meta: { title: '网络参数配置' }, + meta: { title: '网络参数配置', icon: 'el-icon-setting' }, component: () => import('@/views/network-config.vue'), }, { path: '/function-config', name: 'function-config', - meta: { title: '功能参数配置' }, + meta: { title: '功能参数配置', icon: 'el-icon-set-up' }, component: () => import('@/views/function-config.vue'), }, { path: '/device-create', name: 'device-create', - meta: { title: '设备添加' }, + meta: { title: '设备添加', icon: 'el-icon-plus' }, component: () => import('@/views/device-create.vue'), }, { path: '/devices', name: 'devices', - meta: { title: '设备管理' }, + meta: { title: '设备管理', icon: 'el-icon-box' }, component: () => import('@/views/device-list.vue'), }, { - path: '/monthes', - name: 'monthes', - meta: { title: '月累计数据分析' }, - component: () => import('@/views/month-data.vue'), + path: '/data-history', + name: 'data-history', + meta: { title: '历史数据查看', icon: 'el-icon-data-line' }, + component: () => import('@/views/data-history.vue'), }, { path: '/statistical-realtime', @@ -45,6 +44,12 @@ export const routes = [ meta: { title: '历史数据统计' }, component: () => import('@/views/statistical-history.vue'), }, + { + path: '/months', + name: 'months', + meta: { title: '月累计数据分析', icon: 'el-icon-data-analysis' }, + component: () => import('@/views/month-data.vue'), + }, { path: '/test', name: 'test', diff --git a/src/store/device.js b/src/store/device.js index bdd5466..1966708 100644 --- a/src/store/device.js +++ b/src/store/device.js @@ -4,11 +4,21 @@ const user = { namespaced: true, state: { - devices: [], - devicesAll: null, + devices: [], // 站点列表 设备列表简版 + devicesAll: null, // 设备列表完整版 + currentDeviceId: '', // 当前正在编辑的设备deviceId }, - getters: {}, + getters: { + // 当前正在编辑的设备的完整信息 + current({ devicesAll, currentDeviceId }) { + try { + return devicesAll.data.find(device => device.deviceId === currentDeviceId); + } catch (error) { + return null; + } + }, + }, mutations: { /** @@ -23,11 +33,20 @@ const user = { /** * 设置devicesAll的数据 * @param {*} state - * @param {*} devices + * @param {array} devices */ setDevicesAll(state, devices) { state.devicesAll = devices; }, + + /** + * 设置正则编辑的设备deviceId + * @param {*} state + * @param {string} deviceId + */ + setCurrentDeviceId(state, deviceId) { + state.currentDeviceId = deviceId; + }, }, actions: { diff --git a/src/store/index.js b/src/store/index.js index 7238607..37706ae 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,12 +1,17 @@ import { createStore } from 'vuex'; import device from './device'; -import user from './user'; import statistics from './statistics'; +import user from './user'; export default createStore({ modules: { user, device, statistics }, - state: {}, + state: { menu: { show: true, collapse: false } }, getters: {}, - mutations: {}, + mutations: { + toggleCollapse(state) { + console.log('1'); + state.menu.collapse = !state.menu.collapse; + }, + }, actions: {}, }); diff --git a/src/views/data-history.vue b/src/views/data-history.vue new file mode 100644 index 0000000..f1d9251 --- /dev/null +++ b/src/views/data-history.vue @@ -0,0 +1,122 @@ + + + diff --git a/src/views/device-edit.vue b/src/views/device-edit.vue new file mode 100644 index 0000000..66a1309 --- /dev/null +++ b/src/views/device-edit.vue @@ -0,0 +1,181 @@ + + + diff --git a/src/views/device-list.vue b/src/views/device-list.vue index 97bef5d..35341ce 100644 --- a/src/views/device-list.vue +++ b/src/views/device-list.vue @@ -2,7 +2,7 @@