develop #1
@ -66,6 +66,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapGetters
|
||||
} from 'vuex'
|
||||
import DateRangeSelect from './DateRangeSelect.vue'
|
||||
import {
|
||||
getAllSites,
|
||||
@ -156,7 +159,6 @@
|
||||
children: []
|
||||
}
|
||||
],
|
||||
siteList: [],
|
||||
siteId: '', //选择的站点ID
|
||||
baseInfo: {}, //站点基本信息
|
||||
gridList: [{
|
||||
@ -193,6 +195,7 @@
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['belongSite']),
|
||||
siteGirdList() {
|
||||
return this.gridList.filter(i => this.deviceCategoryOptions.includes(i.categoryName))
|
||||
}
|
||||
@ -242,14 +245,18 @@
|
||||
return {
|
||||
text: item.siteName,
|
||||
value: item.siteId,
|
||||
id: item.id
|
||||
id: item.id,
|
||||
disable: !this.belongSite || this.belongSite.length === 0 || this
|
||||
.belongSite.includes('all') ? false : !this.belongSite.includes(item
|
||||
.siteId)
|
||||
}
|
||||
})
|
||||
// 设置默认展示的站点
|
||||
if (data.length > 0) {
|
||||
this.siteId = data[0].siteId
|
||||
this.updateSiteInfo()
|
||||
}
|
||||
this.siteId = this.siteTypeOptions.find(i => i.children && i.children.length > 0)?.children
|
||||
.find(
|
||||
item => !item
|
||||
.disable)?.value || ''
|
||||
this.siteId && this.updateSiteInfo()
|
||||
})
|
||||
},
|
||||
getSiteBaseInfo() {
|
||||
|
||||
@ -4,6 +4,7 @@ const getters = {
|
||||
id: state => state.user.id,
|
||||
name: state => state.user.name,
|
||||
roles: state => state.user.roles,
|
||||
permissions: state => state.user.permissions
|
||||
permissions: state => state.user.permissions,
|
||||
belongSite: state => state.user.belongSite
|
||||
}
|
||||
export default getters
|
||||
@ -1,9 +1,20 @@
|
||||
import config from '@/config'
|
||||
import storage from '@/utils/storage'
|
||||
import constant from '@/utils/constant'
|
||||
import { isHttp, isEmpty } from "@/utils/validate"
|
||||
import { login, logout, getInfo } from '@/api/login'
|
||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
||||
import {
|
||||
isHttp,
|
||||
isEmpty
|
||||
} from "@/utils/validate"
|
||||
import {
|
||||
login,
|
||||
logout,
|
||||
getInfo
|
||||
} from '@/api/login'
|
||||
import {
|
||||
getToken,
|
||||
setToken,
|
||||
removeToken
|
||||
} from '@/utils/auth'
|
||||
import defAva from '@/static/images/profile.jpg'
|
||||
|
||||
const baseUrl = config.baseUrl
|
||||
@ -15,7 +26,8 @@ const user = {
|
||||
name: storage.get(constant.name),
|
||||
avatar: storage.get(constant.avatar),
|
||||
roles: storage.get(constant.roles),
|
||||
permissions: storage.get(constant.permissions)
|
||||
permissions: storage.get(constant.permissions),
|
||||
belongSite: storage.get(constant.belongSite)
|
||||
},
|
||||
|
||||
mutations: {
|
||||
@ -41,12 +53,18 @@ const user = {
|
||||
SET_PERMISSIONS: (state, permissions) => {
|
||||
state.permissions = permissions
|
||||
storage.set(constant.permissions, permissions)
|
||||
},
|
||||
SET_BELONGSITE: (state, belongSite = []) => {
|
||||
state.belongSite = belongSite || []
|
||||
storage.set(constant.belongSite, belongSite || [])
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
// 登录
|
||||
Login({ commit }, userInfo) {
|
||||
Login({
|
||||
commit
|
||||
}, userInfo) {
|
||||
const username = userInfo.username.trim()
|
||||
const password = userInfo.password
|
||||
const code = userInfo.code
|
||||
@ -63,10 +81,14 @@ const user = {
|
||||
},
|
||||
|
||||
// 获取用户信息
|
||||
GetInfo({ commit, state }) {
|
||||
GetInfo({
|
||||
commit,
|
||||
state
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getInfo().then(res => {
|
||||
const user = res.user
|
||||
const belongSite = user?.belongSite ? JSON.parse(user?.belongSite) || [] : []
|
||||
let avatar = user.avatar || ""
|
||||
if (!isHttp(avatar)) {
|
||||
avatar = (isEmpty(avatar)) ? defAva : baseUrl + avatar
|
||||
@ -82,6 +104,7 @@ const user = {
|
||||
commit('SET_ID', userid)
|
||||
commit('SET_NAME', username)
|
||||
commit('SET_AVATAR', avatar)
|
||||
commit('SET_BELONGSITE', belongSite)
|
||||
resolve(res)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
@ -90,7 +113,10 @@ const user = {
|
||||
},
|
||||
|
||||
// 退出系统
|
||||
LogOut({ commit, state }) {
|
||||
LogOut({
|
||||
commit,
|
||||
state
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
logout(state.token).then(() => {
|
||||
commit('SET_TOKEN', '')
|
||||
|
||||
Reference in New Issue
Block a user