|
@@ -11,8 +11,10 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div id='page-header-data-menu' class='data-menu'>
|
|
|
- <el-select v-model='selectedProjectId' placeholder='请选择'>
|
|
|
- <el-option v-for='item in projects' :key='item.id' :label='item.name' :value='item.id'></el-option>
|
|
|
+ <el-select v-model='selectedProjectId' placeholder='请选择' filterable>
|
|
|
+ <el-option-group v-for="group in projectGropList" :key="group.label" :label="group.label">
|
|
|
+ <el-option v-for='item in group.options' :key='item.id' :label='item.name' :value='item.id'></el-option>
|
|
|
+ </el-option-group>
|
|
|
</el-select>
|
|
|
</div>
|
|
|
<div id='page-header-user-menu' class='user-menu'>
|
|
@@ -40,6 +42,7 @@
|
|
|
<script>
|
|
|
import frameworkApi from '@/api/framework'
|
|
|
import { mapGetters, mapMutations } from 'vuex'
|
|
|
+import getFirstLetter from '@/utils/getFirstLetter'
|
|
|
import MessageSever from '../components/messagesever/index'
|
|
|
import lStorage from '@/utils/localStorage'
|
|
|
export default {
|
|
@@ -51,7 +54,38 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapGetters('layout', ['sidebarClosed', 'userInfo', 'projects', 'projectId'])
|
|
|
+ ...mapGetters('layout', ['sidebarClosed', 'userInfo', 'projects', 'projectId']),
|
|
|
+ projectGropList () {
|
|
|
+ const cacheInfo = lStorage.get('historyInfo')?lStorage.get('historyInfo'):{}
|
|
|
+ let options = [{
|
|
|
+ label: '最近使用',
|
|
|
+ options: []
|
|
|
+ }]
|
|
|
+ const projectHistory = cacheInfo[this.userInfo.userName] || []
|
|
|
+ options[0].options = projectHistory.map(projectId => {
|
|
|
+ let obj = this.projects.find(project => {
|
|
|
+ return project.id === projectId
|
|
|
+ })
|
|
|
+ return obj?obj:[]
|
|
|
+ })
|
|
|
+
|
|
|
+ let helpObj = {}
|
|
|
+ this.projects.forEach(p => {
|
|
|
+ const label = getFirstLetter((p.name || p.id).slice(0, 1))
|
|
|
+ if (helpObj[label]) {
|
|
|
+ helpObj[label].push(p)
|
|
|
+ } else {
|
|
|
+ helpObj[label] = [p]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const arr = Object.keys(helpObj).sort().map(label => {
|
|
|
+ return {
|
|
|
+ label: label,
|
|
|
+ options: helpObj[label]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return [...(options[0].options.length > 0 ? options : []), ...arr]
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
selectedProjectId(n, o) {
|
|
@@ -76,12 +110,12 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- let cacheInfo = lStorage.get('cacheInfo')?lStorage.get('cacheInfo'):{}
|
|
|
+ let cacheInfo = lStorage.get('historyInfo')?lStorage.get('historyInfo'):{}
|
|
|
if(cacheInfo[this.userInfo.userName] &&
|
|
|
- cacheInfo[this.userInfo.userName].projectId &&
|
|
|
- this.projects.some((item) => {return item.id == cacheInfo[this.userInfo.userName].projectId})
|
|
|
+ cacheInfo[this.userInfo.userName][0] &&
|
|
|
+ this.projects.some((item) => {return item.id == cacheInfo[this.userInfo.userName][0]})
|
|
|
){
|
|
|
- this.selectedProjectId = cacheInfo[this.userInfo.userName].projectId
|
|
|
+ this.selectedProjectId = cacheInfo[this.userInfo.userName][0]
|
|
|
} else {
|
|
|
this.selectedProjectId = this.projectId
|
|
|
}
|