Skip to content

Commit

Permalink
feat: 自定义收藏夹
Browse files Browse the repository at this point in the history
  • Loading branch information
liufei20151013 committed Mar 11, 2024
1 parent 6e7b41c commit 9d9d5c6
Show file tree
Hide file tree
Showing 10 changed files with 3,768 additions and 3,053 deletions.
85 changes: 85 additions & 0 deletions src/components/Apps/FavoriteAssetDialog/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>
<GenericUpdateFormDialog
v-if="visible"
:selected-rows="selectedRows"
:form-setting="formSetting"
:visible="visible"
v-on="$listeners"
/>
</template>

<script>
import { GenericUpdateFormDialog } from '@/layout/components'
import getFields from '../fields'
export default {
name: 'FavoriteAssetDialog',
components: {
GenericUpdateFormDialog
},
props: {
permType: {
type: String,
default: 'asset'
},
visible: {
type: Boolean,
default: false
},
selectedRows: {
type: Array,
default: () => ([])
}
},
data() {
return {
formSetting: {
url: '',
hasSaveContinue: false,
initial: {},
fields: [],
fieldsMeta: {}
}
}
},
created() {
this.init()
},
methods: {
init() {
let url
const fieldsManager = getFields.bind(this)()
const fields = [
'users', 'user_groups', 'accounts',
'actions', 'is_active', 'date_start', 'date_expired'
]
const fieldsMeta = {
users: fieldsManager.users,
user_groups: fieldsManager.user_groups,
accounts: fieldsManager.accounts,
date_start: fieldsManager.date_start,
date_expired: fieldsManager.date_expired,
is_active: fieldsManager.is_active,
actions: {
label: this.$t('common.Action')
}
}
if (this.permType !== 'asset') {
url = '/api/v1/perms/application-permissions/'
fields.splice(2, 0, 'applications')
Object.assign(fieldsMeta, { applications: fieldsManager.applications })
} else {
url = '/api/v1/perms/asset-permissions/'
fields.splice(2, 0, ...['assets', 'nodes'])
Object.assign(fieldsMeta, {
assets: fieldsManager.assets,
nodes: fieldsManager.nodes
})
}
this.$data.formSetting.url = url
this.$data.formSetting.fields = fields
this.$data.formSetting.fieldsMeta = fieldsMeta
}
}
}
</script>
8 changes: 7 additions & 1 deletion src/i18n/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,10 @@
"WebUpdate": "Update asset - Web",
"DatabaseUpdate": "Update asset - Database",
"GPTCreate": "Create asset - GPT",
"AppletHostDomainHelpText": "These domains are in System Organization"
"AppletHostDomainHelpText": "These domains are in System Organization",
"CollectingAsset": "Collecting asset",
"FavoriteNode": "Favorite node",
"TestFavoriteNodeErrorMsg": "Please select favourites"
},
"audits": {
"ChangeField": "Change field",
Expand Down Expand Up @@ -1392,6 +1395,9 @@
"LoginLog": "Login logs",
"MyApps": "My Apps",
"MyAssets": "My assets",
"MyFavoriteNodes": "My favorite nodes",
"FavoriteNodeCreate": "FavoriteNode create",
"FavoriteNodeUpdate": "FavoriteNode update",
"OperateLog": "Operation logs",
"PasswordChangeLog": "Password change logs",
"Perms": "Permissions",
Expand Down
8 changes: 7 additions & 1 deletion src/i18n/langs/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,10 @@
"WebUpdate": "資産の更新 - Web",
"DatabaseUpdate": "資産の更新 - データベース",
"GPTCreate": "資産の作成 - GPT",
"AppletHostDomainHelpText": "これらのドメインはシステム組織にあります"
"AppletHostDomainHelpText": "これらのドメインはシステム組織にあります",
"CollectingAsset": "資産の収集",
"FavoriteNode": "お気に入りフォルダ",
"TestFavoriteNodeErrorMsg": "お気に入りを選択してください"
},
"audits": {
"ChangeField": "フィールドを変更します",
Expand Down Expand Up @@ -1397,6 +1400,9 @@
"LoginLog": "ログインログ",
"MyApps": "私の応用",
"MyAssets": "マイ資産",
"MyFavoriteNodes": "のお気に入り",
"FavoriteNodeCreate": "お気に入りを作る",
"FavoriteNodeUpdate": "お気に入りを更新",
"OperateLog": "操作ログ",
"PasswordChangeLog": "パスワード変更ログ",
"Perms": "権限管理",
Expand Down
8 changes: 7 additions & 1 deletion src/i18n/langs/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@
"NoSQLProtocol": "非关系数据库",
"OtherProtocol": "其它协议",
"PasswordOrToken": "密码 / 令牌",
"AppletHostDomainHelpText": "这里的网域属于 System 组织"
"AppletHostDomainHelpText": "这里的网域属于 System 组织",
"CollectingAsset": "收藏资产",
"FavoriteNode": "收藏夹",
"TestFavoriteNodeErrorMsg": "请选择收藏夹"
},
"audits": {
"ChangeField": "变更字段",
Expand Down Expand Up @@ -1425,6 +1428,9 @@
"LoginLog": "登录日志",
"MyApps": "我的应用",
"MyAssets": "我的资产",
"MyFavoriteNodes": "我的收藏夹",
"FavoriteNodeCreate": "创建收藏夹",
"FavoriteNodeUpdate": "更新收藏夹",
"OperateLog": "操作日志",
"PasswordChangeLog": "改密日志",
"Perms": "权限管理",
Expand Down
42 changes: 41 additions & 1 deletion src/router/workbench/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,47 @@ export default {
permissions: ['perms.view_myassets']
}
},

{
path: '/workbench/favorite_nodes',
name: 'MyFavoriteNodes',
component: empty,
redirect: '',
meta: {
icon: 'assets',
title: i18n.t('route.MyFavoriteNodes')
},
children: [
{
path: '',
name: 'FavoriteNodeList',
component: () => import('@/views/myFavoriteNodes/index'),
meta: {
title: i18n.t('route.MyFavoriteNodes'),
permissions: ['assets.view_favoritenode']
}
},
{
path: ':id/update',
name: 'FavoriteNodeUpdate',
component: () => import('@/views/myFavoriteNodes/FavoriteNodeCreateUpdate'),
hidden: true,
meta: {
title: i18n.t('route.FavoriteNodeUpdate'),
permissions: ['assets.change_favoritenode']
}
},
{
path: 'create',
name: 'FavoriteNodeCreate',
component: () => import('@/views/myFavoriteNodes/FavoriteNodeCreateUpdate'),
hidden: true,
meta: {
title: i18n.t('route.FavoriteNodeCreate'),
permissions: ['assets.add_favoritenode']
}
}
]
},
{
path: `external-luna`,
component: empty,
Expand Down
27 changes: 27 additions & 0 deletions src/views/myFavoriteNodes/FavoriteNodeCreateUpdate.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<GenericCreateUpdatePage :fields="fields" :initial="initial" :url="url" />
</template>

<script>
import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage'
export default {
name: 'FavoriteNodeCreateUpdate',
components: {
GenericCreateUpdatePage
},
data() {
return {
initial: {},
fields: [
[this.$t('common.Basic'), ['name']]
],
url: '/api/v1/assets/favorite-nodes/'
}
}
}
</script>

<style>
</style>
34 changes: 34 additions & 0 deletions src/views/myFavoriteNodes/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<GenericListPage :header-actions="headerActions" :table-config="tableConfig" />
</template>

<script>
import { GenericListPage } from '@/layout/components'
export default {
components: {
GenericListPage
},
data() {
return {
tableConfig: {
url: '/api/v1/assets/favorite-nodes/',
columns: ['name', 'actions'],
columnsShow: {
min: ['name', 'actions'],
default: ['name', 'actions']
}
},
headerActions: {
hasExport: false,
hasImport: false,
createRoute: 'FavoriteNodeCreate'
}
}
}
}
</script>

<style>
</style>
110 changes: 110 additions & 0 deletions src/views/myassets/components/FavoriteAssetDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<template>
<Dialog
v-if="iVisible"
:destroy-on-close="true"
:show-cancel="false"
:show-confirm="false"
:title="$tc('assets.CollectingAsset')"
:visible.sync="iVisible"
top="35vh"
width="40%"
>
<el-row :gutter="20">
<el-col :md="4" :sm="24">
<div style="line-height: 34px">{{ $t('assets.FavoriteNode') }}</div>
</el-col>
<el-col :md="14" :sm="24">
<select v-model="favoriteNodeId" class="el-input__inner">
<option value="" disabled selected hidden>请选择</option>
<option v-for="(item, index) in favoriteNodes" :key="index" :value="item.id">{{ item.name }}</option>
</select>
</el-col>
<el-col :md="4" :sm="24">
<el-button
:loading="loading"
size="mini"
style="line-height:20px "
type="primary"
@click="dialogConfirm"
>
{{ this.$t('common.Confirm') }}
</el-button>
</el-col>
</el-row>
</Dialog>
</template>

<script>
import Dialog from '@/components/Dialog/index.vue'
export default {
name: 'FavoriteAssetDialog',
components: {
Dialog
},
props: {
visible: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: false
},
cell: {
type: String,
default: ''
},
allFavorites: {
type: Array,
default: () => []
}
},
data() {
return {
favoriteNodeId: '',
favoriteNodes: []
}
},
computed: {
iVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
}
},
mounted() {
this.getAllFavoriteNodes()
},
methods: {
getAllFavoriteNodes() {
this.$axios.get('/api/v1/assets/favorite-nodes/').then(resp => {
this.favoriteNodes = resp
})
},
dialogConfirm() {
console.log(this.cell)
console.log(this.favoriteNodeId)
if (this.favoriteNodeId === '') {
return this.$message.error(this.$tc('assets.TestFavoriteNodeErrorMsg'))
}
const data = { asset: this.cell, favoriteNode: this.favoriteNodeId }
const url = '/api/v1/assets/favorite-assets/'
this.$axios.post(url, data).then((res) => {
this.favoriteNodeId = ''
this.allFavorites.push({ asset: this.cell })
this.$message.success(this.$i18n.t('common.CollectionSucceed'))
}).finally(() => {
this.iVisible = false
})
}
}
}
</script>

<style lang="scss" scoped>
</style>

Loading

0 comments on commit 9d9d5c6

Please sign in to comment.