perf: Update user orgs roles (#3828)

Co-authored-by: Bai <baijiangjie@gmail.com>
This commit is contained in:
fit2bot
2024-04-09 15:44:07 +08:00
committed by GitHub
parent b08e6de527
commit 8a60ad774f
6 changed files with 37 additions and 8 deletions

View File

@@ -68,7 +68,16 @@ export default {
return [this.$t('common.tree.Loading') + '...']
}
const getItem = this.formatterArgs.getItem || (item => item.name)
let data = this.data.map(item => getItem(item)) || []
let data = []
if (Array.isArray(this.data)) {
data = this.data.map(item => getItem(item)) || []
} else {
// object {key: [value]}
data = Object.entries(this.data).map(([key, value]) => {
const item = { key: key, value: value }
return getItem(item)
}) || []
}
data = data.filter(Boolean)
return data
},
@@ -80,7 +89,14 @@ export default {
if (this.formatterArgs.async) {
this.amount = this.cellValue
} else {
this.amount = (this.cellValue?.filter(value => !this.cellValueToRemove.includes(value)) || []).length
let cellValue = []
if (Array.isArray(this.cellValue)) {
cellValue = this.cellValue
} else {
// object {key: [value]}
cellValue = Object.keys(this.cellValue)
}
this.amount = (cellValue?.filter(value => !this.cellValueToRemove.includes(value)) || []).length
}
},
methods: {

View File

@@ -1996,7 +1996,7 @@
"UpdateNodeAssetHardwareInfo": "Update node asset hardware information"
},
"users": {
"OrgRoleRelations": "Organizations",
"OrgsAndRoles": "Organizations and roles",
"LunaSettingUpdate": "Luna setting",
"KokoSettingUpdate": "Koko setting",
"UserSetting": "User setting",

View File

@@ -1987,7 +1987,7 @@
"UpdateNodeAssetHardwareInfo": "ノード資産ハードウェア情報の更新"
},
"users": {
"OrgRoleRelations": "しょぞくそしき",
"OrgsAndRoles": "そしきとやくわり",
"LunaSettingUpdate": "Luna 設定更新",
"KokoSettingUpdate": "Koko 設定更新",
"UserSetting": "個人設定",

View File

@@ -1981,7 +1981,7 @@
"PasskeyAddDisableInfo": "你的认证来源是 {source}, 不支持添加 Passkey"
},
"users": {
"OrgRoleRelations": "所属组织",
"OrgsAndRoles": "组织与角色",
"LunaSettingUpdate": "Luna 配置设置",
"KokoSettingUpdate": "Koko 配置设置",
"UserSetting": "偏好设置",

View File

@@ -196,7 +196,7 @@ export default {
}
},
{
key: this.$t('users.OrgRoleRelations'),
key: this.$t('users.OrgsAndRoles'),
has: this.$store.getters.currentOrgIsRoot,
formatter: (item, val) => {
const doms = []
@@ -207,8 +207,8 @@ export default {
if (key.length >= allowKeyMaxLength) {
prettyKey = key.substring(0, allowKeyMaxLength - 3) + '...'
}
const domKey = <el-tag size='mini' type='success'>{prettyKey}</el-tag>
doms.push(domKey)
const item = prettyKey + ': ' + value.join(',')
doms.push([item, <br/>])
})
return <div>{doms}</div>
}

View File

@@ -96,6 +96,19 @@ export default {
return this.$store.getters.hasValidLicense && !this.currentOrgIsRoot
}
},
orgs_roles: {
columnKey: 'orgs_roles',
has: () => {
return this.$store.getters.currentOrgIsRoot
},
formatter: AmountFormatter,
filters: [],
formatterArgs: {
getItem(item) {
return item.key + ': ' + item.value.join(',')
}
}
},
phone: {
formatter: (row) => {
const phoneObj = row.phone