diff --git a/src/components/Login.vue b/src/components/Login.vue
index f23689c..41ed719 100644
--- a/src/components/Login.vue
+++ b/src/components/Login.vue
@@ -134,9 +134,6 @@ export default {
this.form.utel = "";
this.form.upass = "";
this.form.checkcode = "";
- },
- checkDingding() {
-
},
createCode() {
let code = "";
diff --git a/src/components/Main.vue b/src/components/Main.vue
index 797cc59..d3685ae 100644
--- a/src/components/Main.vue
+++ b/src/components/Main.vue
@@ -1,7 +1,14 @@
-
- 标题?
+
+
+
+ 水质监测平台
+
+
+ 登出
+
+
@@ -31,7 +38,9 @@
+
+
@@ -43,14 +52,14 @@ import MapLayout from '@/components/map/Index'
import Search from '@/components/search/Index'
import Logs from '@/components/logs/Index'
import Admin from '@/components/admin/Index'
-
+import { logout } from '@/utils/http'
export default {
components: {
'icon-font':IconFont,
'map-layout':MapLayout,
'search':Search,
// 'logs':Logs,
- // 'admin':Admin
+ 'admin':Admin
},
data() {
return {
@@ -66,6 +75,14 @@ export default {
methods: {
handleMenuClick({item, key, keyPath}) {
this.currentComp = key
+ },
+ logout() {
+ logout()
+ sessionStorage.clear()
+ this.$store.commit('logout')
+ this.$router.push({
+ path: '/login'
+ })
}
}
};
diff --git a/src/components/admin/Index.vue b/src/components/admin/Index.vue
index dd7092b..868ee67 100644
--- a/src/components/admin/Index.vue
+++ b/src/components/admin/Index.vue
@@ -1,13 +1,68 @@
-
+
+
+
+
+
+
+ 传感器
+
+
+
+ 设备
+
+
+
+ 项目
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/admin/tables/DeviceTable.vue b/src/components/admin/tables/DeviceTable.vue
new file mode 100644
index 0000000..9d0e66b
--- /dev/null
+++ b/src/components/admin/tables/DeviceTable.vue
@@ -0,0 +1,115 @@
+
+
+
+
+
+ 是
+
+
+ 否
+
+
+
+
+ {{ project.name}}
+
+
+
+ handleDetail(record)" >查看
+
+ handleDelete(record)" >删除
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/admin/tables/ProjectTable.vue b/src/components/admin/tables/ProjectTable.vue
new file mode 100644
index 0000000..5e0fa29
--- /dev/null
+++ b/src/components/admin/tables/ProjectTable.vue
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+ {{ item.name}}
+
+
+
+
+ {{ item.name}}
+
+
+
+ handleDetail(record)" >查看
+
+ handleDelete(record)" >删除
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/admin/tables/SensorTable.vue b/src/components/admin/tables/SensorTable.vue
new file mode 100644
index 0000000..9a5aa46
--- /dev/null
+++ b/src/components/admin/tables/SensorTable.vue
@@ -0,0 +1,90 @@
+
+
+
+
+ handleDetail(record)" >查看
+
+ handleDelete(record)" >删除
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/utils/http.js b/src/utils/http.js
index 994a292..329ad46 100644
--- a/src/utils/http.js
+++ b/src/utils/http.js
@@ -31,6 +31,7 @@ export async function login(username, passwd, uuid, capthe)
response = await instance.get('current/')
data = await response.data
+ data.token = token
return data
}
diff --git a/src/utils/router.js b/src/utils/router.js
index e8cde89..59d388f 100644
--- a/src/utils/router.js
+++ b/src/utils/router.js
@@ -3,7 +3,7 @@ import Router from 'vue-router'
import Index from '@/components/Main'
import Login from '@/components/Login'
import store from './store'
-
+import { setAuth } from './http'
Vue.use(Router)
const routes = [
@@ -26,15 +26,14 @@ const routes = [
}
]
+
if (sessionStorage.getItem("store")) {
+ console.log(sessionStorage.getItem("store"))
store.replaceState(Object.assign({}, store.state, JSON.parse(sessionStorage.getItem("store"))))
- if (store.state.login) {
- if (store.state.uinfo) {
- setAuth(store.state.uinfo.token);
- }
+ if (store.state.token) {
+ setAuth(store.state.token);
}
}
-
const router = new Router({
base: process.env.BASE_URL,
diff --git a/src/utils/store.js b/src/utils/store.js
index a648cc6..9298e36 100644
--- a/src/utils/store.js
+++ b/src/utils/store.js
@@ -9,7 +9,6 @@ const storeToSession = store => {
if (sessionStorage.getItem('store')){
sessionStorage.removeItem('store')
}
- console.log(store)
sessionStorage.setItem('store', JSON.stringify(state))
})
}
@@ -18,13 +17,17 @@ const store = new Vuex.Store({
state: {
userInfo:null,
phone: document.body.clientWidth < 800,
+ token: '',
login:false,
loginTime:0,
- second: 60 * 60 * 2,
+ second: 60 * 60 * 24,
logs:'',
data:{},
currentComp: 'map',
- cacheData:{}
+ cacheData:{},
+ deviceList:[],
+ projectList:[],
+ sensorList:[]
},
mutations: {
phone(state, o) {
@@ -34,12 +37,22 @@ const store = new Vuex.Store({
state.userInfo = o
state.login = true
state.loginTime = new Date().getTime()
+ state.token = o.token
},
logout(state)
{
state.userInfo=null
state.login = false
},
+ deviceList(state, o) {
+ state.deviceList = o
+ },
+ projectList(state, o) {
+ state.projectList = o
+ },
+ sensorList(state, o) {
+ state.sensorList = o
+ }
},
getters: {
phone(state) {
@@ -97,6 +110,15 @@ const store = new Vuex.Store({
}
}
return false
+ },
+ deviceList(state) {
+ return state.deviceList
+ },
+ projectList(state) {
+ return state.projectList
+ },
+ sensorList(state) {
+ return state.sensorList
}
},
plugins: [storeToSession]
diff --git a/src/utils/utils.js b/src/utils/utils.js
index e69de29..cb64c1d 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -0,0 +1,15 @@
+import { getData } from './http'
+
+function processDevice(store)
+{
+ const { deviceList, projectList, sensorList } = store.state
+
+ let deviceIdName = {}
+ let projectIdName = {}
+ let sensorIdName = {}
+
+ deviceList.forEach(d => deviceIdName[d._id] = d.device_name)
+ projectList.forEach(p => projectIdName[p._id.$oid] = p.name)
+ sensorList.forEach(s => sensorIdName[s._id.$oid] = s.name)
+
+}
\ No newline at end of file