|
|
@ -1,30 +1,11 @@
|
|
|
|
import Vue from 'vue'
|
|
|
|
import Vue from 'vue'
|
|
|
|
import {
|
|
|
|
import { login, getLoginUser, logout } from '@/api/modular/system/loginManage'
|
|
|
|
login,
|
|
|
|
import { sysDictTypeTree } from '@/api/modular/system/dictManage'
|
|
|
|
getLoginUser,
|
|
|
|
import { sysMenuChange } from '@/api/modular/system/menuManage'
|
|
|
|
logout
|
|
|
|
import { ACCESS_TOKEN, ALL_APPS_MENU, DICT_TYPE_TREE_DATA, NOTICE_RECEIVED } from '@/store/mutation-types'
|
|
|
|
} from '@/api/modular/system/loginManage'
|
|
|
|
import { sysFileInfoPreview } from '@/api/modular/system/fileManage'
|
|
|
|
import {
|
|
|
|
import { unReadNotice } from '@/api/modular/system/noticeReceivedManage'
|
|
|
|
sysDictTypeTree
|
|
|
|
import { welcome, dateFormat } from '@/utils/util'
|
|
|
|
} from '@/api/modular/system/dictManage'
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
sysMenuChange
|
|
|
|
|
|
|
|
} from '@/api/modular/system/menuManage'
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
ACCESS_TOKEN,
|
|
|
|
|
|
|
|
ALL_APPS_MENU,
|
|
|
|
|
|
|
|
DICT_TYPE_TREE_DATA,
|
|
|
|
|
|
|
|
NOTICE_RECEIVED
|
|
|
|
|
|
|
|
} from '@/store/mutation-types'
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
sysFileInfoPreview
|
|
|
|
|
|
|
|
} from '@/api/modular/system/fileManage'
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
unReadNotice
|
|
|
|
|
|
|
|
} from '@/api/modular/system/noticeReceivedManage'
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
welcome, dateFormat
|
|
|
|
|
|
|
|
} from '@/utils/util'
|
|
|
|
|
|
|
|
import store from '../index'
|
|
|
|
import store from '../index'
|
|
|
|
import router from '../../router'
|
|
|
|
import router from '../../router'
|
|
|
|
|
|
|
|
|
|
|
@ -47,10 +28,7 @@ const user = {
|
|
|
|
SET_TOKEN: (state, token) => {
|
|
|
|
SET_TOKEN: (state, token) => {
|
|
|
|
state.token = token
|
|
|
|
state.token = token
|
|
|
|
},
|
|
|
|
},
|
|
|
|
SET_NAME: (state, {
|
|
|
|
SET_NAME: (state, { name, welcome }) => {
|
|
|
|
name,
|
|
|
|
|
|
|
|
welcome
|
|
|
|
|
|
|
|
}) => {
|
|
|
|
|
|
|
|
state.name = name
|
|
|
|
state.name = name
|
|
|
|
state.welcome = welcome
|
|
|
|
state.welcome = welcome
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -74,21 +52,25 @@ const user = {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
APPEND_NOTICE: (state, notice) => {
|
|
|
|
APPEND_NOTICE: (state, notice) => {
|
|
|
|
notice.publicTime = dateFormat(notice.publicTime, 'YYYY-mm-dd HH:MM:SS')
|
|
|
|
notice.publicTime = dateFormat(notice.publicTime, 'YYYY-mm-dd HH:MM:SS')
|
|
|
|
let notices = state.notices;
|
|
|
|
let notices = state.notices
|
|
|
|
let temp = notices.rows.filter(m => { return m.value == notice.type })[0]
|
|
|
|
let temp = notices.rows.filter(m => {
|
|
|
|
let other = notices.rows.filter(m => { return m.value != notice.type })
|
|
|
|
return m.value == notice.type
|
|
|
|
temp.noticeData.unshift(notice);
|
|
|
|
})[0]
|
|
|
|
notices.totalRows++;
|
|
|
|
let other = notices.rows.filter(m => {
|
|
|
|
|
|
|
|
return m.value != notice.type
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
temp.noticeData.unshift(notice)
|
|
|
|
|
|
|
|
notices.totalRows++
|
|
|
|
if (temp.noticeData.length > 6) {
|
|
|
|
if (temp.noticeData.length > 6) {
|
|
|
|
temp.noticeData.pop();
|
|
|
|
temp.noticeData.pop()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notices.rows = [];
|
|
|
|
notices.rows = []
|
|
|
|
notices.rows.push(temp);
|
|
|
|
notices.rows.push(temp)
|
|
|
|
notices.rows.push.apply(notices.rows, other);
|
|
|
|
notices.rows.push.apply(notices.rows, other)
|
|
|
|
notices.rows.sort((obj1, obj2) => {
|
|
|
|
notices.rows.sort((obj1, obj2) => {
|
|
|
|
return obj1.index - obj2.index
|
|
|
|
return obj1.index - obj2.index
|
|
|
|
})
|
|
|
|
})
|
|
|
|
state.notices = notices;
|
|
|
|
state.notices = notices
|
|
|
|
},
|
|
|
|
},
|
|
|
|
SET_BOOKINGLIST: (state, list) => {
|
|
|
|
SET_BOOKINGLIST: (state, list) => {
|
|
|
|
state.bookingList = list
|
|
|
|
state.bookingList = list
|
|
|
@ -100,195 +82,197 @@ const user = {
|
|
|
|
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
actions: {
|
|
|
|
// 登录
|
|
|
|
// 登录
|
|
|
|
Login({
|
|
|
|
Login({ commit }, userInfo) {
|
|
|
|
commit
|
|
|
|
|
|
|
|
}, userInfo) {
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
login(userInfo).then(response => {
|
|
|
|
login(userInfo)
|
|
|
|
if (!response.success) {
|
|
|
|
.then(response => {
|
|
|
|
reject(response.message)
|
|
|
|
if (!response.success) {
|
|
|
|
return
|
|
|
|
reject(response.message)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
const result = response.data
|
|
|
|
}
|
|
|
|
Vue.ls.set(ACCESS_TOKEN, result, 7 * 24 * 60 * 60 * 1000)
|
|
|
|
const result = response.data
|
|
|
|
commit('SET_TOKEN', result)
|
|
|
|
Vue.ls.set(ACCESS_TOKEN, result, 7 * 24 * 60 * 60 * 1000)
|
|
|
|
resolve()
|
|
|
|
commit('SET_TOKEN', result)
|
|
|
|
// eslint-disable-next-line handle-callback-err
|
|
|
|
resolve()
|
|
|
|
}).catch(error => {
|
|
|
|
// eslint-disable-next-line handle-callback-err
|
|
|
|
// eslint-disable-next-line prefer-promise-reject-errors
|
|
|
|
})
|
|
|
|
reject('后端未启动或代理错误')
|
|
|
|
.catch(error => {
|
|
|
|
})
|
|
|
|
// eslint-disable-next-line prefer-promise-reject-errors
|
|
|
|
|
|
|
|
reject('后端未启动或代理错误')
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 获取用户信息
|
|
|
|
// 获取用户信息
|
|
|
|
GetInfo({
|
|
|
|
GetInfo({ commit }) {
|
|
|
|
commit
|
|
|
|
|
|
|
|
}) {
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
getLoginUser().then(response => {
|
|
|
|
getLoginUser()
|
|
|
|
if (response.success) {
|
|
|
|
.then(response => {
|
|
|
|
const data = response.data
|
|
|
|
if (response.success) {
|
|
|
|
commit('SET_ADMINTYPE', data.adminType)
|
|
|
|
const data = response.data
|
|
|
|
commit('SET_ROLES', 1)
|
|
|
|
commit('SET_ADMINTYPE', data.adminType)
|
|
|
|
commit('SET_BUTTONS', data.permissions)
|
|
|
|
commit('SET_ROLES', 1)
|
|
|
|
commit('SET_INFO', data)
|
|
|
|
commit('SET_BUTTONS', data.permissions)
|
|
|
|
commit('SET_NAME', {
|
|
|
|
commit('SET_INFO', data)
|
|
|
|
name: data.name,
|
|
|
|
commit('SET_NAME', {
|
|
|
|
welcome: welcome()
|
|
|
|
name: data.name,
|
|
|
|
})
|
|
|
|
welcome: welcome()
|
|
|
|
if (data.avatar != null) {
|
|
|
|
|
|
|
|
sysFileInfoPreview({
|
|
|
|
|
|
|
|
id: data.avatar
|
|
|
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
|
|
|
commit('SET_AVATAR', window.URL.createObjectURL(new Blob([res])))
|
|
|
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
|
|
|
this.$message.error('预览错误:' + err.message)
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
// commit('SET_AVATAR', process.env.VUE_APP_API_BASE_URL + '/sysFileInfo/preview?id=' + data.avatar)
|
|
|
|
if (data.avatar != null) {
|
|
|
|
|
|
|
|
sysFileInfoPreview({
|
|
|
|
|
|
|
|
id: data.avatar
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.then(res => {
|
|
|
|
|
|
|
|
commit('SET_AVATAR', window.URL.createObjectURL(new Blob([res])))
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch(err => {
|
|
|
|
|
|
|
|
this.$message.error('预览错误:' + err.message)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
// commit('SET_AVATAR', process.env.VUE_APP_API_BASE_URL + '/sysFileInfo/preview?id=' + data.avatar)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(data)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
|
|
|
|
reject(new Error(data.message))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resolve(data)
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
.catch(error => {
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
reject(error)
|
|
|
|
reject(new Error(data.message))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
|
|
reject(error)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 登出
|
|
|
|
// 登出
|
|
|
|
Logout({
|
|
|
|
Logout({ commit, state }) {
|
|
|
|
commit,
|
|
|
|
return new Promise(resolve => {
|
|
|
|
state
|
|
|
|
logout(state.token)
|
|
|
|
}) {
|
|
|
|
.then(() => {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
resolve()
|
|
|
|
logout(state.token).then(() => {
|
|
|
|
})
|
|
|
|
resolve()
|
|
|
|
.catch(() => {
|
|
|
|
}).catch(() => {
|
|
|
|
resolve()
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
}).finally(() => {
|
|
|
|
.finally(() => {
|
|
|
|
commit('SET_TOKEN', '')
|
|
|
|
commit('SET_TOKEN', '')
|
|
|
|
commit('SET_ROLES', [])
|
|
|
|
commit('SET_ROLES', [])
|
|
|
|
commit('SET_BUTTONS', [])
|
|
|
|
commit('SET_BUTTONS', [])
|
|
|
|
commit('SET_ADMINTYPE', '')
|
|
|
|
commit('SET_ADMINTYPE', '')
|
|
|
|
commit('SET_INFO', null)
|
|
|
|
commit('SET_INFO', null)
|
|
|
|
Vue.ls.remove(ACCESS_TOKEN)
|
|
|
|
Vue.ls.remove(ACCESS_TOKEN)
|
|
|
|
Vue.ls.remove(ALL_APPS_MENU)
|
|
|
|
Vue.ls.remove(ALL_APPS_MENU)
|
|
|
|
Vue.ls.remove(DICT_TYPE_TREE_DATA)
|
|
|
|
Vue.ls.remove(DICT_TYPE_TREE_DATA)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 加载所有字典数据
|
|
|
|
// 加载所有字典数据
|
|
|
|
dictTypeData() {
|
|
|
|
dictTypeData() {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
sysDictTypeTree().then((data) => {
|
|
|
|
sysDictTypeTree()
|
|
|
|
if (data.success) {
|
|
|
|
.then(data => {
|
|
|
|
const result = data.data
|
|
|
|
if (data.success) {
|
|
|
|
Vue.ls.set(DICT_TYPE_TREE_DATA, result)
|
|
|
|
const result = data.data
|
|
|
|
resolve()
|
|
|
|
Vue.ls.set(DICT_TYPE_TREE_DATA, result)
|
|
|
|
} else {
|
|
|
|
resolve()
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
} else {
|
|
|
|
reject(new Error(data.message))
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
}
|
|
|
|
reject(new Error(data.message))
|
|
|
|
}).catch(error => {
|
|
|
|
}
|
|
|
|
reject(error)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
|
|
|
|
reject(error)
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 切换应用菜单
|
|
|
|
// 切换应用菜单
|
|
|
|
MenuChange({
|
|
|
|
MenuChange({ commit }, application) {
|
|
|
|
commit
|
|
|
|
return new Promise(resolve => {
|
|
|
|
}, application) {
|
|
|
|
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
|
|
|
|
sysMenuChange({
|
|
|
|
sysMenuChange({
|
|
|
|
application: application.code
|
|
|
|
application: application.code
|
|
|
|
}).then((res) => {
|
|
|
|
})
|
|
|
|
const apps = {
|
|
|
|
.then(res => {
|
|
|
|
'code': '',
|
|
|
|
const apps = {
|
|
|
|
'name': '',
|
|
|
|
code: '',
|
|
|
|
'active': '',
|
|
|
|
name: '',
|
|
|
|
'menu': ''
|
|
|
|
active: '',
|
|
|
|
}
|
|
|
|
menu: ''
|
|
|
|
apps.active = true
|
|
|
|
|
|
|
|
apps.menu = res.data
|
|
|
|
|
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
|
|
|
|
const all_app_menu = Vue.ls.get(ALL_APPS_MENU)
|
|
|
|
|
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
|
|
|
|
const new_false_all_app_menu = []
|
|
|
|
|
|
|
|
// 先去除所有默认的,以为此时切换的即将成为前端缓存默认的应用
|
|
|
|
|
|
|
|
all_app_menu.forEach(item => {
|
|
|
|
|
|
|
|
if (item.active) {
|
|
|
|
|
|
|
|
item.active = false
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
new_false_all_app_menu.push(item)
|
|
|
|
apps.active = true
|
|
|
|
|
|
|
|
apps.menu = res.data
|
|
|
|
|
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
|
|
|
|
const all_app_menu = Vue.ls.get(ALL_APPS_MENU)
|
|
|
|
|
|
|
|
// eslint-disable-next-line camelcase
|
|
|
|
|
|
|
|
const new_false_all_app_menu = []
|
|
|
|
|
|
|
|
// 先去除所有默认的,以为此时切换的即将成为前端缓存默认的应用
|
|
|
|
|
|
|
|
all_app_menu.forEach(item => {
|
|
|
|
|
|
|
|
if (item.active) {
|
|
|
|
|
|
|
|
item.active = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
new_false_all_app_menu.push(item)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
// 此时缓存中全部都是不默认的应用
|
|
|
|
|
|
|
|
Vue.ls.set(ALL_APPS_MENU, new_false_all_app_menu)
|
|
|
|
|
|
|
|
apps.name = application.name
|
|
|
|
|
|
|
|
apps.code = application.code
|
|
|
|
|
|
|
|
const applocationR = []
|
|
|
|
|
|
|
|
applocationR.push(apps)
|
|
|
|
|
|
|
|
Vue.ls.set(ALL_APPS_MENU, applocationR)
|
|
|
|
|
|
|
|
resolve(res)
|
|
|
|
|
|
|
|
const antDesignmenus = res.data
|
|
|
|
|
|
|
|
store
|
|
|
|
|
|
|
|
.dispatch('GenerateRoutes', {
|
|
|
|
|
|
|
|
antDesignmenus
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
|
|
router.addRoutes(store.getters.addRouters)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
// 切换应用刷新整体界面,暂且取消
|
|
|
|
|
|
|
|
// window.location.reload()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
// 此时缓存中全部都是不默认的应用
|
|
|
|
.catch(() => {
|
|
|
|
Vue.ls.set(ALL_APPS_MENU, new_false_all_app_menu)
|
|
|
|
resolve()
|
|
|
|
apps.name = application.name
|
|
|
|
|
|
|
|
apps.code = application.code
|
|
|
|
|
|
|
|
const applocationR = []
|
|
|
|
|
|
|
|
applocationR.push(apps)
|
|
|
|
|
|
|
|
Vue.ls.set(ALL_APPS_MENU, applocationR)
|
|
|
|
|
|
|
|
resolve(res)
|
|
|
|
|
|
|
|
const antDesignmenus = res.data
|
|
|
|
|
|
|
|
store.dispatch('GenerateRoutes', {
|
|
|
|
|
|
|
|
antDesignmenus
|
|
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
|
|
router.addRoutes(store.getters.addRouters)
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
// 切换应用刷新整体界面,暂且取消
|
|
|
|
|
|
|
|
// window.location.reload()
|
|
|
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 获取收到的通知
|
|
|
|
// 获取收到的通知
|
|
|
|
getNoticReceiveList({
|
|
|
|
getNoticReceiveList({ commit }) {
|
|
|
|
commit
|
|
|
|
|
|
|
|
}) {
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
unReadNotice({
|
|
|
|
unReadNotice({
|
|
|
|
pageSize: 6
|
|
|
|
pageSize: 6
|
|
|
|
}).then((data) => {
|
|
|
|
|
|
|
|
if (data.success) {
|
|
|
|
|
|
|
|
const result = data.data
|
|
|
|
|
|
|
|
commit('SET_NOTICES', result)
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
|
|
|
|
reject(new Error(data.message))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
|
|
reject(error)
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
.then(data => {
|
|
|
|
|
|
|
|
if (data.success) {
|
|
|
|
|
|
|
|
const result = data.data
|
|
|
|
|
|
|
|
commit('SET_NOTICES', result)
|
|
|
|
|
|
|
|
resolve()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
|
|
|
|
reject(new Error(data.message))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch(error => {
|
|
|
|
|
|
|
|
reject(error)
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 设置订舱列表
|
|
|
|
// 设置订舱列表
|
|
|
|
setBookingList({
|
|
|
|
setBookingList({ commit }, obj) {
|
|
|
|
commit
|
|
|
|
return new Promise(resolve => {
|
|
|
|
}, obj) {
|
|
|
|
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
|
|
|
|
commit('SET_BOOKINGLIST', obj)
|
|
|
|
commit('SET_BOOKINGLIST', obj)
|
|
|
|
resolve()
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 设置需要保存页面
|
|
|
|
// 设置需要保存页面
|
|
|
|
setNeedSavePages({
|
|
|
|
setNeedSavePages({ commit }, obj) {
|
|
|
|
commit
|
|
|
|
return new Promise(resolve => {
|
|
|
|
}, obj) {
|
|
|
|
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
|
|
|
|
commit('SET_NEEDSAVEPAGES', obj)
|
|
|
|
commit('SET_NEEDSAVEPAGES', obj)
|
|
|
|
resolve()
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|