mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-28 15:55:24 +00:00
feat: 创建表单分类选择
This commit is contained in:
@@ -12,10 +12,10 @@
|
|||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-collapse v-model="activePlatform" accordion>
|
<el-collapse v-model="activePlatform" accordion>
|
||||||
<el-collapse-item
|
<el-collapse-item
|
||||||
v-for="(ps, category) in sortedPlatforms"
|
v-for="(ps, categoryName) in sortedPlatforms"
|
||||||
:key="category"
|
:key="categoryName"
|
||||||
:title="categoryMapper[category]"
|
:title="categoryMapper[categoryName]"
|
||||||
:name="category"
|
:name="categoryName"
|
||||||
>
|
>
|
||||||
<el-col
|
<el-col
|
||||||
v-for="(platform, index) of ps"
|
v-for="(platform, index) of ps"
|
||||||
@@ -49,6 +49,13 @@ export default {
|
|||||||
visible: {
|
visible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
category: {
|
||||||
|
type: String,
|
||||||
|
Validator: (value) => {
|
||||||
|
return ['all', 'host', 'networking', 'database', 'cloud', 'web'].includes(value)
|
||||||
|
},
|
||||||
|
default: 'all'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -77,7 +84,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
sortedPlatforms() {
|
sortedPlatforms() {
|
||||||
return _.groupBy(this.platforms, (item) => item.category.value)
|
const { category, platforms } = this
|
||||||
|
const filterPlatforms = _.groupBy(platforms, (item) => item.category.value)
|
||||||
|
return category === 'all' ? filterPlatforms : { [category]: filterPlatforms[category] }
|
||||||
},
|
},
|
||||||
categoryMapper() {
|
categoryMapper() {
|
||||||
const mapper = {}
|
const mapper = {}
|
||||||
@@ -87,7 +96,19 @@ export default {
|
|||||||
return mapper
|
return mapper
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
watch: {
|
||||||
|
category: {
|
||||||
|
handler(val) {
|
||||||
|
if (val === 'all') {
|
||||||
|
this.activePlatform = 'host'
|
||||||
|
} else {
|
||||||
|
this.activePlatform = val
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
this.$axios.get('/api/v1/assets/platforms/').then(data => {
|
this.$axios.get('/api/v1/assets/platforms/').then(data => {
|
||||||
this.platforms = data
|
this.platforms = data
|
||||||
})
|
})
|
||||||
@@ -109,7 +130,7 @@ export default {
|
|||||||
cloud: 'CloudCreate',
|
cloud: 'CloudCreate',
|
||||||
remote_app: 'RemoteAppCreate'
|
remote_app: 'RemoteAppCreate'
|
||||||
}
|
}
|
||||||
const route = mapper[platform.category] || 'HostCreate'
|
const route = mapper[platform.category.value] || 'HostCreate'
|
||||||
this.$router.push({ name: route, query: { platform: platform.id }})
|
this.$router.push({ name: route, query: { platform: platform.id }})
|
||||||
this.iVisible = false
|
this.iVisible = false
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
:visible.sync="updateSelectedDialogSetting.visible"
|
:visible.sync="updateSelectedDialogSetting.visible"
|
||||||
v-bind="updateSelectedDialogSetting"
|
v-bind="updateSelectedDialogSetting"
|
||||||
/>
|
/>
|
||||||
<PlatformDialog :visible.sync="showPlatform" />
|
<PlatformDialog :visible.sync="showPlatform" :category="category" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -65,6 +65,7 @@ export default {
|
|||||||
],
|
],
|
||||||
activeMenu: 'all'
|
activeMenu: 'all'
|
||||||
},
|
},
|
||||||
|
category: '',
|
||||||
treeSetting: {
|
treeSetting: {
|
||||||
showMenu: true,
|
showMenu: true,
|
||||||
showRefresh: true,
|
showRefresh: true,
|
||||||
@@ -279,6 +280,8 @@ export default {
|
|||||||
},
|
},
|
||||||
handleTabChange(item) {
|
handleTabChange(item) {
|
||||||
const category = item ? item.name : this.tab.activeMenu
|
const category = item ? item.name : this.tab.activeMenu
|
||||||
|
this.category = category
|
||||||
|
console.log('category: ', category)
|
||||||
this.show = false
|
this.show = false
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let url = '/api/v1/assets/assets/'
|
let url = '/api/v1/assets/assets/'
|
||||||
|
Reference in New Issue
Block a user