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