feat(frontend): polish organization space UI and share-to-space panels
Redesign share-to-space settings for knowledge bases and agents with member-style search, add popup, and table list; simplify the org picker dropdown. Also refresh organization settings join-request review with table layout and approval popup.
This commit is contained in:
@@ -1,130 +1,117 @@
|
||||
<template>
|
||||
<div class="section-content">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">{{ $t('organization.share.title') }}</h3>
|
||||
<p class="section-desc">{{ $t('organization.share.agentShareDesc') }}</p>
|
||||
</div>
|
||||
<!-- 共享范围说明:当传入 agent 时展示,仅提示 + 变更同步说明,不列具体开关 -->
|
||||
<div v-if="agent?.config" class="share-scope-block">
|
||||
<h4 class="share-scope-title">{{ $t('agent.shareScope.title') }}</h4>
|
||||
<p class="share-scope-desc">{{ $t('agent.shareScope.desc') }}</p>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<div class="share-form">
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('organization.share.selectOrg') }}</label>
|
||||
<div class="share-input-row">
|
||||
<t-select
|
||||
v-model="selectedOrgId"
|
||||
:placeholder="$t('organization.share.selectOrgPlaceholder')"
|
||||
:loading="loadingOrgs"
|
||||
class="org-select org-select-dropdown"
|
||||
:popup-props="{ overlayClassName: 'org-select-dropdown-popup' }"
|
||||
>
|
||||
<t-option
|
||||
v-for="org in availableOrganizations"
|
||||
:key="org.id"
|
||||
:value="org.id"
|
||||
:label="org.name"
|
||||
>
|
||||
<div class="org-option-content">
|
||||
<div class="org-option-icon-wrap">
|
||||
<SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" />
|
||||
</div>
|
||||
<div class="org-option-body">
|
||||
<div class="org-option-header">
|
||||
<span class="org-option-name">{{ org.name }}</span>
|
||||
<t-tag v-if="org.is_owner" theme="primary" size="small" variant="light">
|
||||
{{ $t('organization.owner') }}
|
||||
</t-tag>
|
||||
<t-tag v-else-if="org.my_role" :theme="org.my_role === 'admin' ? 'warning' : 'default'" size="small" variant="light">
|
||||
{{ $t(`organization.role.${org.my_role}`) }}
|
||||
</t-tag>
|
||||
</div>
|
||||
<div class="org-option-meta">
|
||||
<span class="org-meta-tag">
|
||||
<t-icon name="user" class="org-meta-icon org-meta-icon-user" />
|
||||
{{ org.member_count ?? 0 }}
|
||||
</span>
|
||||
<span class="org-meta-tag">
|
||||
<img src="@/assets/img/zhishiku.svg" class="org-meta-icon org-meta-icon-kb" alt="" aria-hidden="true" />
|
||||
{{ org.share_count ?? 0 }}
|
||||
</span>
|
||||
<span class="org-meta-tag">
|
||||
<img src="@/assets/img/agent.svg" class="org-meta-icon org-meta-icon-agent" alt="" aria-hidden="true" />
|
||||
{{ org.agent_share_count ?? 0 }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<t-button
|
||||
theme="primary"
|
||||
:loading="submitting"
|
||||
:disabled="!selectedOrgId"
|
||||
@click="handleShare"
|
||||
>
|
||||
{{ $t('knowledgeEditor.share.addShare') }}
|
||||
</t-button>
|
||||
</div>
|
||||
<div class="share-to-space-panel">
|
||||
<div class="share-panel-header">
|
||||
<div class="share-panel-header-row">
|
||||
<div class="share-panel-titlewrap">
|
||||
<h2 class="share-panel-title">{{ $t('organization.share.title') }}</h2>
|
||||
<t-popup placement="bottom-start" trigger="hover" overlay-class-name="share-hint-popup-overlay"
|
||||
:overlay-inner-style="shareHintPopupInnerStyle">
|
||||
<button type="button" class="share-hint-trigger-btn" :aria-label="$t('agent.shareScope.title')"
|
||||
:title="$t('agent.shareScope.title')">
|
||||
<t-icon name="info-circle" size="16px" />
|
||||
</button>
|
||||
<template #content>
|
||||
<div class="share-hint-popover">
|
||||
<p class="share-hint-title">{{ $t('agent.shareScope.title') }}</p>
|
||||
<p class="share-hint-desc">{{ $t('organization.share.agentShareDesc') }}</p>
|
||||
<p v-if="agent?.config" class="share-hint-desc">{{ $t('agent.shareScope.desc') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</t-popup>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shares-section">
|
||||
<div class="shares-header">
|
||||
<span class="shares-title">{{ $t('organization.share.sharedTo') }}</span>
|
||||
<span class="shares-count">{{ shares.length }}</span>
|
||||
<p class="share-panel-desc">{{ $t('organization.share.agentShareDesc') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="share-panel-list-wrap">
|
||||
<div class="share-panel-list-header">
|
||||
<div class="share-panel-titlewrap">
|
||||
<span class="share-panel-list-title">{{ $t('organization.share.sharedTo') }}</span>
|
||||
<span class="share-panel-count-badge">{{ filteredShares.length }}</span>
|
||||
</div>
|
||||
<div v-if="loadingShares" class="shares-loading">
|
||||
<t-loading size="small" />
|
||||
<span>{{ $t('common.loading') }}</span>
|
||||
</div>
|
||||
<div v-else-if="shares.length === 0" class="shares-empty">
|
||||
<t-icon name="share" class="empty-icon" />
|
||||
<span>{{ $t('organization.share.noShares') }}</span>
|
||||
</div>
|
||||
<div v-else class="shares-list">
|
||||
<div v-for="share in shares" :key="share.id" class="share-item">
|
||||
<div class="share-info">
|
||||
<div class="share-info-top">
|
||||
<div class="share-org">
|
||||
<SpaceAvatar
|
||||
:name="share.organization_name || ''"
|
||||
:avatar="orgStore.organizations.find(o => o.id === share.organization_id)?.avatar"
|
||||
size="small"
|
||||
/>
|
||||
<span class="org-name">{{ share.organization_name }}</span>
|
||||
<div class="share-panel-actions">
|
||||
<div class="share-panel-search">
|
||||
<t-input v-model="searchQuery" size="small" :placeholder="$t('organization.share.searchPlaceholder')"
|
||||
clearable>
|
||||
<template #prefix-icon>
|
||||
<t-icon name="search" />
|
||||
</template>
|
||||
</t-input>
|
||||
</div>
|
||||
<t-popup v-model="addPopupVisible" trigger="click" placement="bottom-end" destroy-on-close
|
||||
overlay-class-name="share-add-popup-overlay">
|
||||
<t-button theme="primary" variant="outline" shape="square" size="small" class="share-panel-add-btn"
|
||||
:title="$t('knowledgeEditor.share.addShare')" :aria-label="$t('knowledgeEditor.share.addShare')">
|
||||
<template #icon><t-icon name="add" /></template>
|
||||
</t-button>
|
||||
<template #content>
|
||||
<div class="share-add-popup-inner" @click.stop>
|
||||
<div class="member-invite-popup-title">{{ $t('organization.share.addShareDialogTitle') }}</div>
|
||||
<div class="org-upgrade-fields">
|
||||
<div class="org-upgrade-field org-upgrade-field--last">
|
||||
<label class="org-upgrade-field-label">{{ $t('organization.share.selectOrg') }}</label>
|
||||
<ShareToSpaceOrgSelect v-model="selectedOrgId" :organizations="availableOrganizations"
|
||||
:loading="loadingOrgs" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="invite-popup-footer">
|
||||
<t-button variant="outline" :disabled="submitting" @click="addPopupVisible = false">
|
||||
{{ $t('common.cancel') }}
|
||||
</t-button>
|
||||
<t-button theme="primary" :loading="submitting" :disabled="!selectedOrgId" @click="handleShare">
|
||||
{{ $t('knowledgeEditor.share.addShare') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="share-item-meta">
|
||||
<span class="org-meta-tag">
|
||||
<t-icon name="user" class="org-meta-icon org-meta-icon-user" />
|
||||
{{ getOrgForShare(share.organization_id)?.member_count ?? 0 }}
|
||||
</span>
|
||||
<span class="org-meta-tag">
|
||||
<img src="@/assets/img/zhishiku.svg" class="org-meta-icon org-meta-icon-kb" alt="" aria-hidden="true" />
|
||||
{{ getOrgForShare(share.organization_id)?.share_count ?? 0 }}
|
||||
</span>
|
||||
<t-tooltip :content="$t('organization.share.spaceAgentShareCountTip')" placement="top">
|
||||
<span class="org-meta-tag">
|
||||
<img src="@/assets/img/agent.svg" class="org-meta-icon org-meta-icon-agent" alt="" aria-hidden="true" />
|
||||
{{ getOrgForShare(share.organization_id)?.agent_share_count ?? 0 }}
|
||||
</span>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</t-popup>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loadingShares && shares.length === 0" class="share-panel-loading">
|
||||
<t-loading size="small" />
|
||||
<span>{{ $t('organization.share.loading') }}</span>
|
||||
</div>
|
||||
<div v-else-if="filteredShares.length === 0" class="share-panel-empty">
|
||||
<t-empty :description="searchQuery.trim()
|
||||
? $t('organization.share.emptySearch', { q: searchQuery })
|
||||
: $t('organization.share.noShares')" />
|
||||
</div>
|
||||
<div v-else class="share-panel-table-shell">
|
||||
<t-table row-key="id" :data="filteredShares" :columns="shareColumns" size="medium" hover stripe
|
||||
:loading="loadingShares">
|
||||
<template #space="{ row }">
|
||||
<div class="share-space-cell">
|
||||
<span class="share-space-name">
|
||||
<SpaceAvatar :name="row.organization_name || ''"
|
||||
:avatar="getOrgForShare(row.organization_id)?.avatar" size="small" />
|
||||
<span class="share-space-name-text">{{ row.organization_name }}</span>
|
||||
</span>
|
||||
<span v-if="row.shared_by_username" class="share-space-meta">
|
||||
{{ $t('organization.share.sharedFrom') }} {{ row.shared_by_username }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="share-actions">
|
||||
<t-popconfirm
|
||||
:content="$t('knowledgeEditor.share.unshareConfirm', { name: share.organization_name })"
|
||||
@confirm="handleUnshare(share)"
|
||||
>
|
||||
<t-button variant="text" theme="danger" size="small">
|
||||
<t-icon name="delete" />
|
||||
</t-button>
|
||||
</template>
|
||||
<template #permission>
|
||||
<t-tag size="small" theme="default" variant="light">
|
||||
{{ $t('organization.share.permissionReadonly') }}
|
||||
</t-tag>
|
||||
</template>
|
||||
<template #created_at="{ row }">{{ formatShareDate(row.created_at) }}</template>
|
||||
<template #actions="{ row }">
|
||||
<div class="share-table-actions">
|
||||
<t-popconfirm :content="$t('knowledgeEditor.share.unshareConfirm', { name: row.organization_name })"
|
||||
:confirm-btn="{ content: $t('common.confirm'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: $t('common.cancel') }" placement="left" @confirm="handleUnshare(row)">
|
||||
<t-tooltip :content="$t('organization.share.unshareAction')" placement="top">
|
||||
<t-button theme="danger" shape="square" variant="text" size="small" @click.stop>
|
||||
<template #icon><t-icon name="delete" /></template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
</t-popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</t-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -139,6 +126,7 @@ import { shareAgent, listAgentShares, removeAgentShare } from '@/api/organizatio
|
||||
import type { AgentShareResponse } from '@/api/organization'
|
||||
import type { CustomAgent } from '@/api/agent'
|
||||
import SpaceAvatar from '@/components/SpaceAvatar.vue'
|
||||
import ShareToSpaceOrgSelect from '@/components/ShareToSpaceOrgSelect.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const orgStore = useOrganizationStore()
|
||||
@@ -149,15 +137,25 @@ function getOrgForShare(organizationId: string) {
|
||||
|
||||
interface Props {
|
||||
agentId: string
|
||||
/** 当前智能体(用于展示共享范围说明) */
|
||||
agent?: CustomAgent | null
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const shareHintPopupInnerStyle = {
|
||||
boxSizing: 'border-box' as const,
|
||||
padding: '0',
|
||||
width: 'min(400px, calc(100vw - 24px))',
|
||||
maxWidth: 'min(400px, calc(100vw - 24px))',
|
||||
maxHeight: 'min(280px, 65vh)',
|
||||
overflow: 'hidden',
|
||||
}
|
||||
|
||||
const loadingOrgs = ref(false)
|
||||
const loadingShares = ref(false)
|
||||
const submitting = ref(false)
|
||||
const addPopupVisible = ref(false)
|
||||
const searchQuery = ref('')
|
||||
const selectedOrgId = ref('')
|
||||
const shares = ref<(AgentShareResponse & { organization_name?: string })[]>([])
|
||||
|
||||
@@ -170,6 +168,29 @@ const availableOrganizations = computed(() => {
|
||||
)
|
||||
})
|
||||
|
||||
const filteredShares = computed(() => {
|
||||
const query = searchQuery.value.trim().toLowerCase()
|
||||
if (!query) return shares.value
|
||||
return shares.value.filter((share) => {
|
||||
const haystack = [share.organization_name, share.shared_by_username].filter(Boolean).join(' ').toLowerCase()
|
||||
return haystack.includes(query)
|
||||
})
|
||||
})
|
||||
|
||||
const shareColumns = computed(() => [
|
||||
{ colKey: 'space', title: t('organization.share.columns.space'), ellipsis: true, minWidth: 180 },
|
||||
{ colKey: 'permission', title: t('organization.share.columns.permission'), width: 96 },
|
||||
{ colKey: 'created_at', title: t('organization.share.columns.sharedAt'), width: 154 },
|
||||
{ colKey: 'actions', title: t('organization.share.columns.operations'), width: 72, align: 'left' },
|
||||
])
|
||||
|
||||
function formatShareDate(dateStr?: string) {
|
||||
if (!dateStr) return '—'
|
||||
const date = new Date(dateStr)
|
||||
if (Number.isNaN(date.getTime())) return dateStr
|
||||
return date.toLocaleDateString(undefined, { year: 'numeric', month: '2-digit', day: '2-digit' })
|
||||
}
|
||||
|
||||
async function loadOrganizations() {
|
||||
loadingOrgs.value = true
|
||||
try {
|
||||
@@ -185,7 +206,7 @@ async function loadShares() {
|
||||
try {
|
||||
const result = await listAgentShares(props.agentId)
|
||||
if (result.success && result.data) {
|
||||
const sharesData = (result.data as any).shares || result.data
|
||||
const sharesData = (result.data as { shares?: AgentShareResponse[] }).shares || result.data
|
||||
const sharesList = Array.isArray(sharesData) ? sharesData : []
|
||||
shares.value = sharesList.map((share: AgentShareResponse) => ({
|
||||
...share,
|
||||
@@ -210,12 +231,14 @@ async function handleShare() {
|
||||
if (result.success) {
|
||||
MessagePlugin.success(t('organization.share.shareSuccess'))
|
||||
selectedOrgId.value = ''
|
||||
addPopupVisible.value = false
|
||||
await loadShares()
|
||||
} else {
|
||||
MessagePlugin.error(result.message || t('organization.share.shareFailed'))
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || t('organization.share.shareFailed'))
|
||||
} catch (e: unknown) {
|
||||
const message = e instanceof Error ? e.message : t('organization.share.shareFailed')
|
||||
MessagePlugin.error(message)
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
@@ -230,8 +253,9 @@ async function handleUnshare(share: AgentShareResponse) {
|
||||
} else {
|
||||
MessagePlugin.error(result.message || t('organization.share.unshareFailed'))
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || t('organization.share.unshareFailed'))
|
||||
} catch (e: unknown) {
|
||||
const message = e instanceof Error ? e.message : t('organization.share.unshareFailed')
|
||||
MessagePlugin.error(message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,280 +271,9 @@ defineExpose({ loadShares })
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.section-content { .section-header { margin-bottom: 20px; } .section-title { margin: 0 0 8px 0; font-size: 16px; font-weight: 600; } .section-desc { margin: 0; font-size: 14px; color: var(--td-text-color-disabled); } }
|
||||
.share-form { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--td-component-stroke); }
|
||||
.form-item {
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
.share-input-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
.org-select { flex: 1; min-width: 240px; }
|
||||
}
|
||||
.shares-section { margin-bottom: 24px; }
|
||||
.shares-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
.shares-title {
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
.shares-count {
|
||||
padding: 2px 8px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 10px;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-disabled);
|
||||
}
|
||||
}
|
||||
.shares-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 32px;
|
||||
color: var(--td-text-color-disabled);
|
||||
font-size: 14px;
|
||||
}
|
||||
.shares-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 40px 20px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 8px;
|
||||
color: var(--td-text-color-disabled);
|
||||
.empty-icon { font-size: 32px; opacity: 0.5; }
|
||||
}
|
||||
.shares-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.share-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 8px;
|
||||
transition: background 0.2s ease, border-color 0.2s ease;
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-color: var(--td-component-stroke);
|
||||
}
|
||||
}
|
||||
.share-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.share-info-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.share-org {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
.org-name {
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
}
|
||||
.share-item-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
.org-meta-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 2px 6px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.org-meta-icon {
|
||||
flex-shrink: 0;
|
||||
vertical-align: middle;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
.org-meta-icon-user {
|
||||
font-size: 12px;
|
||||
}
|
||||
.org-meta-icon-kb {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.org-meta-icon-agent {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
}
|
||||
.share-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
.permission-change-select { width: 100px; }
|
||||
}
|
||||
|
||||
.share-scope-block {
|
||||
margin-bottom: 24px;
|
||||
padding: 16px;
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-success-color-focus);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.share-scope-title {
|
||||
margin: 0 0 6px 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
.share-scope-desc {
|
||||
margin: 0 0 12px 0;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
// 与知识库设置中空间下拉一致的选项样式
|
||||
:deep(.t-select-option) {
|
||||
height: auto;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
border-radius: 4px;
|
||||
margin: 1px 6px;
|
||||
transition: background 0.15s ease;
|
||||
}
|
||||
:deep(.t-select-option:hover),
|
||||
:deep(.t-select-option.t-is-selected) {
|
||||
background: var(--td-brand-color-light);
|
||||
}
|
||||
:deep(.t-select-option__content) {
|
||||
width: 100%;
|
||||
}
|
||||
.org-option-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0;
|
||||
min-width: 260px;
|
||||
width: 100%;
|
||||
}
|
||||
.org-option-icon-wrap {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.org-option-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.org-option-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.org-option-name {
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.org-option-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
|
||||
.org-meta-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 0px 4px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.org-meta-icon {
|
||||
flex-shrink: 0;
|
||||
vertical-align: middle;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.org-meta-icon-user {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.org-meta-icon-kb {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.org-meta-icon-agent {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
}
|
||||
@import '@/components/share-to-space-panel.less';
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.org-select-dropdown-popup.t-select__dropdown {
|
||||
padding: 4px 0;
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
border-radius: 6px;
|
||||
box-shadow: var(--td-shadow-2);
|
||||
}
|
||||
.org-select-dropdown-popup .t-select-option {
|
||||
height: auto;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
border-radius: 4px;
|
||||
margin: 1px 6px;
|
||||
}
|
||||
.org-select-dropdown-popup .t-select-option__content {
|
||||
width: 100%;
|
||||
}
|
||||
// Dark mode: invert black SVG icons loaded via <img> tag, match text opacity
|
||||
html[theme-mode="dark"] .org-meta-icon-kb,
|
||||
html[theme-mode="dark"] .org-meta-icon-agent {
|
||||
filter: invert(1);
|
||||
opacity: 0.55;
|
||||
}
|
||||
@import '@/components/share-to-space-panel.overlay.less';
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<t-select
|
||||
:model-value="modelValue"
|
||||
:placeholder="placeholder || $t('organization.share.selectOrgPlaceholder')"
|
||||
:loading="loading"
|
||||
class="share-org-select"
|
||||
:popup-props="orgSelectPopupProps"
|
||||
@update:model-value="$emit('update:modelValue', $event)"
|
||||
@popup-visible-change="handlePopupVisibleChange"
|
||||
>
|
||||
<t-option
|
||||
v-for="org in organizations"
|
||||
:key="org.id"
|
||||
:value="org.id"
|
||||
:label="org.name"
|
||||
>
|
||||
<div class="share-org-option">
|
||||
<SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" />
|
||||
<span class="share-org-option-name">{{ org.name }}</span>
|
||||
<span v-if="roleLabel(org)" class="share-org-option-role">{{ roleLabel(org) }}</span>
|
||||
</div>
|
||||
</t-option>
|
||||
</t-select>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { Organization } from '@/api/organization'
|
||||
import SpaceAvatar from '@/components/SpaceAvatar.vue'
|
||||
|
||||
defineProps<{
|
||||
modelValue: string
|
||||
organizations: Organization[]
|
||||
loading?: boolean
|
||||
placeholder?: string
|
||||
}>()
|
||||
|
||||
defineEmits<{
|
||||
'update:modelValue': [value: string]
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const orgSelectPopupProps = {
|
||||
attach: 'body' as const,
|
||||
overlayClassName: 'share-org-select-popup',
|
||||
zIndex: 3060,
|
||||
}
|
||||
|
||||
function handlePopupVisibleChange(visible: boolean) {
|
||||
if (!visible) return
|
||||
requestAnimationFrame(() => {
|
||||
document.querySelectorAll('.share-org-select-popup .t-select-option[title]').forEach((el) => {
|
||||
el.removeAttribute('title')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function roleLabel(org: Organization) {
|
||||
if (org.is_owner) return t('organization.owner')
|
||||
if (org.my_role) return t(`organization.role.${org.my_role}`)
|
||||
return ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.share-org-select {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,214 @@
|
||||
.share-to-space-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.share-panel-header {
|
||||
.share-panel-header-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.share-panel-titlewrap {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.share-panel-title {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.share-panel-desc {
|
||||
margin: 8px 0 0;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.share-hint-trigger-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--td-text-color-secondary);
|
||||
cursor: pointer;
|
||||
line-height: 0;
|
||||
transition: background-color 0.2s ease, color 0.2s ease;
|
||||
|
||||
:deep(.t-icon) {
|
||||
display: block;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--td-brand-color-focus);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
.share-panel-list-wrap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.share-panel-list-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
.share-panel-titlewrap {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.share-panel-list-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.share-panel-count-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 22px;
|
||||
height: 20px;
|
||||
padding: 0 7px;
|
||||
border-radius: 10px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.share-panel-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.share-panel-search {
|
||||
flex: 0 0 14rem;
|
||||
width: 14rem;
|
||||
min-width: 0;
|
||||
|
||||
:deep(.t-input) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.share-panel-add-btn {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.share-panel-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 20px 0 8px;
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.share-panel-empty {
|
||||
padding: 8px 0 16px;
|
||||
}
|
||||
|
||||
.share-panel-table-shell {
|
||||
overflow-x: auto;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
background: var(--td-bg-color-container);
|
||||
|
||||
:deep(thead th) {
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
:deep(.t-table td),
|
||||
:deep(.t-table th) {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.share-space-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
padding: 2px 0;
|
||||
}
|
||||
|
||||
.share-space-name {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.share-space-name-text {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.share-space-meta {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.share-permission-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.share-permission-select {
|
||||
width: 100%;
|
||||
max-width: 120px;
|
||||
}
|
||||
|
||||
:deep(.share-permission-select.t-select) {
|
||||
width: 100%;
|
||||
max-width: 120px;
|
||||
}
|
||||
|
||||
.share-table-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
/* 共享到空间添加弹层(对齐空间设置里的添加成员 / 权限升级 popup) */
|
||||
.share-add-popup-overlay {
|
||||
z-index: 3050 !important;
|
||||
|
||||
.t-popup__content {
|
||||
padding: 16px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
box-shadow: var(--td-shadow-2), 0 8px 24px rgba(15, 23, 42, 0.08);
|
||||
}
|
||||
|
||||
.share-add-popup-inner {
|
||||
width: min(360px, calc(100vw - 32px));
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.member-invite-popup-title {
|
||||
margin: 0 0 10px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.add-member-tip {
|
||||
margin: 0 0 12px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.org-upgrade-fields {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.org-upgrade-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
|
||||
&--last {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.org-upgrade-field-label {
|
||||
display: block;
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.org-upgrade-field .t-select,
|
||||
.org-upgrade-field .share-org-select {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.member-form-hint {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.invite-popup-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
margin-top: 16px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
}
|
||||
|
||||
/* 空间选择下拉(挂到 body,避免嵌套在共享 popup 内产生双层阴影) */
|
||||
.share-org-select-popup {
|
||||
z-index: 3060 !important;
|
||||
|
||||
.t-popup__content {
|
||||
padding: 4px !important;
|
||||
border-radius: 8px !important;
|
||||
border: 1px solid var(--td-component-stroke) !important;
|
||||
background: var(--td-bg-color-container) !important;
|
||||
box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1) !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.t-select__dropdown {
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
background: transparent !important;
|
||||
max-height: min(280px, 40vh);
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.t-select-option {
|
||||
height: 36px !important;
|
||||
min-height: 36px;
|
||||
align-items: center;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
border-radius: 6px !important;
|
||||
transition: background-color 0.15s ease;
|
||||
|
||||
&:hover,
|
||||
&.t-is-hover {
|
||||
background: var(--td-bg-color-secondarycontainer) !important;
|
||||
}
|
||||
|
||||
&.t-is-selected {
|
||||
background: transparent !important;
|
||||
font-weight: 500;
|
||||
|
||||
.share-org-option-name {
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.t-select-option__content {
|
||||
width: 100%;
|
||||
padding: 0 10px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.share-org-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.share-org-option-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.share-org-option-role {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
}
|
||||
|
||||
/* 共享说明提示弹出层(t-popup 挂到 body,须全局样式) */
|
||||
.share-hint-popup-overlay {
|
||||
z-index: 3050 !important;
|
||||
|
||||
.t-popup__content {
|
||||
padding: 0 !important;
|
||||
border-radius: 12px !important;
|
||||
background: var(--td-bg-color-container) !important;
|
||||
border: 0.5px solid var(--td-component-stroke) !important;
|
||||
box-shadow:
|
||||
0 0 0 0.5px rgba(0, 0, 0, 0.03),
|
||||
0 2px 4px rgba(0, 0, 0, 0.04),
|
||||
0 8px 24px rgba(0, 0, 0, 0.1) !important;
|
||||
backdrop-filter: blur(20px) saturate(180%) !important;
|
||||
-webkit-backdrop-filter: blur(20px) saturate(180%) !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.share-hint-popover {
|
||||
padding: 14px 16px;
|
||||
|
||||
.share-hint-title {
|
||||
margin: 0 0 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.share-hint-desc {
|
||||
margin: 0 0 8px;
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2860,6 +2860,7 @@ export default {
|
||||
},
|
||||
share: {
|
||||
description: 'Share the knowledge base with spaces so members can access and use it',
|
||||
hintTitle: 'Sharing notes',
|
||||
addShare: 'Share',
|
||||
unshareConfirm: 'Are you sure you want to unshare from "{name}"?',
|
||||
tip1: 'After sharing, space members will access this knowledge base based on the assigned permissions',
|
||||
@@ -5184,6 +5185,24 @@ export default {
|
||||
operations: 'Actions',
|
||||
},
|
||||
},
|
||||
joinRequests: {
|
||||
listTitle: 'Pending requests',
|
||||
searchPlaceholder: 'Search applicants…',
|
||||
loading: 'Loading requests…',
|
||||
emptySearch: 'No requests matching "{q}"',
|
||||
typeJoin: 'Join',
|
||||
typeUpgrade: 'Upgrade',
|
||||
rejectConfirm: 'Reject this request?',
|
||||
approveTitle: 'Approve request',
|
||||
approveDesc: 'Assign a role for "{name}" after approval',
|
||||
columns: {
|
||||
applicant: 'Applicant',
|
||||
type: 'Type',
|
||||
requestedRole: 'Requested role',
|
||||
message: 'Note',
|
||||
appliedAt: 'Applied',
|
||||
},
|
||||
},
|
||||
sharedResources: {
|
||||
kbListTitle: 'Shared knowledge bases',
|
||||
agentListTitle: 'Shared agents',
|
||||
@@ -5367,6 +5386,17 @@ export default {
|
||||
unshareFailed: 'Failed to cancel share',
|
||||
sharedTo: 'Shared to',
|
||||
noShares: 'Not shared to any space yet',
|
||||
searchPlaceholder: 'Search spaces…',
|
||||
loading: 'Loading…',
|
||||
emptySearch: 'No spaces matching "{q}"',
|
||||
addShareDialogTitle: 'Share to space',
|
||||
unshareAction: 'Remove share',
|
||||
columns: {
|
||||
space: 'Space',
|
||||
permission: 'Permission',
|
||||
sharedAt: 'Shared',
|
||||
operations: 'Actions',
|
||||
},
|
||||
sharedKnowledgeBase: 'Shared Knowledge Base',
|
||||
shareToSpace: 'Share to space',
|
||||
shareModelToSpace: 'Share "{name}" to space',
|
||||
|
||||
@@ -4099,6 +4099,7 @@ export default {
|
||||
share: {
|
||||
description:
|
||||
"스페이스 구성원이 접근하고 사용할 수 있도록 지식베이스를 스페이스에 공유합니다.",
|
||||
hintTitle: "공유 안내",
|
||||
addShare: "공유",
|
||||
unshareConfirm: '"{name}" 공유를 취소하시겠습니까?',
|
||||
tip1: "공유 후 스페이스 구성원은 설정된 권한에 따라 이 지식베이스에 액세스하게 됩니다.",
|
||||
@@ -5193,6 +5194,24 @@ export default {
|
||||
operations: "작업",
|
||||
},
|
||||
},
|
||||
joinRequests: {
|
||||
listTitle: "대기 중인 신청",
|
||||
searchPlaceholder: "신청자 검색…",
|
||||
loading: "신청 로딩 중…",
|
||||
emptySearch: "「{q}」와(과) 일치하는 신청이 없습니다",
|
||||
typeJoin: "가입",
|
||||
typeUpgrade: "업그레이드",
|
||||
rejectConfirm: "이 신청을 거절하시겠습니까?",
|
||||
approveTitle: "신청 승인",
|
||||
approveDesc: "승인 후 「{name}」에게 부여할 역할",
|
||||
columns: {
|
||||
applicant: "신청자",
|
||||
type: "유형",
|
||||
requestedRole: "신청 역할",
|
||||
message: "신청 사유",
|
||||
appliedAt: "신청 시간",
|
||||
},
|
||||
},
|
||||
sharedResources: {
|
||||
kbListTitle: "공유 지식베이스",
|
||||
agentListTitle: "공유 에이전트",
|
||||
@@ -5396,6 +5415,17 @@ export default {
|
||||
unshareFailed: "공유를 취소하지 못했습니다.",
|
||||
sharedTo: "공유된 스페이스",
|
||||
noShares: "아직 어떤 스페이스에도 공유되지 않았습니다.",
|
||||
searchPlaceholder: "스페이스 검색…",
|
||||
loading: "로딩 중…",
|
||||
emptySearch: "「{q}」와(과) 일치하는 스페이스가 없습니다",
|
||||
addShareDialogTitle: "스페이스에 공유",
|
||||
unshareAction: "공유 해제",
|
||||
columns: {
|
||||
space: "스페이스",
|
||||
permission: "권한",
|
||||
sharedAt: "공유 시간",
|
||||
operations: "작업",
|
||||
},
|
||||
sharedKnowledgeBase: "공유 지식베이스",
|
||||
sharedFrom: "출처",
|
||||
sharedBadge: "공유",
|
||||
|
||||
@@ -3902,6 +3902,7 @@ export default {
|
||||
},
|
||||
share: {
|
||||
description: 'Share the knowledge base with spaces so members can access and use it',
|
||||
hintTitle: 'Sharing notes',
|
||||
addShare: 'Share',
|
||||
unshareConfirm: 'Are you sure you want to unshare from "{name}"?',
|
||||
tip1: 'After sharing, space members will access this knowledge base based on the assigned permissions',
|
||||
@@ -5827,6 +5828,24 @@ export default {
|
||||
operations: 'Actions',
|
||||
},
|
||||
},
|
||||
joinRequests: {
|
||||
listTitle: 'Pending requests',
|
||||
searchPlaceholder: 'Search applicants…',
|
||||
loading: 'Loading requests…',
|
||||
emptySearch: 'No requests matching "{q}"',
|
||||
typeJoin: 'Join',
|
||||
typeUpgrade: 'Upgrade',
|
||||
rejectConfirm: 'Reject this request?',
|
||||
approveTitle: 'Approve request',
|
||||
approveDesc: 'Assign a role for "{name}" after approval',
|
||||
columns: {
|
||||
applicant: 'Applicant',
|
||||
type: 'Type',
|
||||
requestedRole: 'Requested role',
|
||||
message: 'Note',
|
||||
appliedAt: 'Applied',
|
||||
},
|
||||
},
|
||||
sharedResources: {
|
||||
kbListTitle: 'Shared knowledge bases',
|
||||
agentListTitle: 'Shared agents',
|
||||
@@ -6016,6 +6035,17 @@ export default {
|
||||
unshareFailed: 'Failed to cancel share',
|
||||
sharedTo: 'Shared to',
|
||||
noShares: 'Not shared to any space yet',
|
||||
searchPlaceholder: 'Search spaces…',
|
||||
loading: 'Loading…',
|
||||
emptySearch: 'No spaces matching "{q}"',
|
||||
addShareDialogTitle: 'Share to space',
|
||||
unshareAction: 'Remove share',
|
||||
columns: {
|
||||
space: 'Space',
|
||||
permission: 'Permission',
|
||||
sharedAt: 'Shared',
|
||||
operations: 'Actions',
|
||||
},
|
||||
sharedKnowledgeBase: 'Shared Knowledge Base',
|
||||
sharedFrom: 'From',
|
||||
sharedBadge: 'Shared',
|
||||
|
||||
@@ -4156,6 +4156,7 @@ export default {
|
||||
},
|
||||
share: {
|
||||
description: "将知识库共享给空间,让空间成员可以访问和使用",
|
||||
hintTitle: "共享说明",
|
||||
addShare: "共享",
|
||||
unshareConfirm: "确定要取消对「{name}」的共享吗?",
|
||||
tip1: "共享后,空间成员将根据设定的权限访问此知识库",
|
||||
@@ -5238,6 +5239,24 @@ export default {
|
||||
operations: "操作",
|
||||
},
|
||||
},
|
||||
joinRequests: {
|
||||
listTitle: "待审核申请",
|
||||
searchPlaceholder: "搜索申请人…",
|
||||
loading: "加载申请中…",
|
||||
emptySearch: "未找到匹配「{q}」的申请",
|
||||
typeJoin: "加入",
|
||||
typeUpgrade: "升级",
|
||||
rejectConfirm: "确认拒绝该申请?",
|
||||
approveTitle: "通过申请",
|
||||
approveDesc: "为「{name}」分配加入后的角色",
|
||||
columns: {
|
||||
applicant: "申请人",
|
||||
type: "类型",
|
||||
requestedRole: "申请角色",
|
||||
message: "申请说明",
|
||||
appliedAt: "申请时间",
|
||||
},
|
||||
},
|
||||
sharedResources: {
|
||||
kbListTitle: "共享知识库",
|
||||
agentListTitle: "共享智能体",
|
||||
@@ -5427,6 +5446,17 @@ export default {
|
||||
unshareFailed: "取消共享失败",
|
||||
sharedTo: "已共享到",
|
||||
noShares: "尚未共享到任何空间",
|
||||
searchPlaceholder: "搜索空间…",
|
||||
loading: "加载中…",
|
||||
emptySearch: "未找到匹配「{q}」的空间",
|
||||
addShareDialogTitle: "共享到空间",
|
||||
unshareAction: "取消共享",
|
||||
columns: {
|
||||
space: "空间",
|
||||
permission: "权限",
|
||||
sharedAt: "共享时间",
|
||||
operations: "操作",
|
||||
},
|
||||
sharedKnowledgeBase: "共享知识库",
|
||||
sharedFrom: "来自",
|
||||
sharedBadge: "共享",
|
||||
|
||||
@@ -1,164 +1,137 @@
|
||||
<template>
|
||||
<div class="section-content">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">{{ $t('organization.share.title') }}</h3>
|
||||
<p class="section-desc">{{ $t('knowledgeEditor.share.description') }}</p>
|
||||
<div class="share-to-space-panel">
|
||||
<div class="share-panel-header">
|
||||
<div class="share-panel-header-row">
|
||||
<div class="share-panel-titlewrap">
|
||||
<h2 class="share-panel-title">{{ $t('organization.share.title') }}</h2>
|
||||
<t-popup placement="bottom-start" trigger="hover" overlay-class-name="share-hint-popup-overlay"
|
||||
:overlay-inner-style="shareHintPopupInnerStyle">
|
||||
<button type="button" class="share-hint-trigger-btn" :aria-label="$t('knowledgeEditor.share.hintTitle')"
|
||||
:title="$t('knowledgeEditor.share.hintTitle')">
|
||||
<t-icon name="info-circle" size="16px" />
|
||||
</button>
|
||||
<template #content>
|
||||
<div class="share-hint-popover">
|
||||
<p class="share-hint-title">{{ $t('knowledgeEditor.share.hintTitle') }}</p>
|
||||
<p class="share-hint-desc">{{ $t('knowledgeEditor.share.tip1') }}</p>
|
||||
<p class="share-hint-desc">{{ $t('knowledgeEditor.share.tip2') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</t-popup>
|
||||
</div>
|
||||
</div>
|
||||
<p class="share-panel-desc">{{ $t('knowledgeEditor.share.description') }}</p>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<!-- 共享表单:仅 KB creator 或空间 Admin+ 可见,其他角色看到的是只读列表。 -->
|
||||
<div v-if="canShare" class="share-form">
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('organization.share.selectOrg') }}</label>
|
||||
<div class="share-input-row">
|
||||
<t-select
|
||||
v-model="selectedOrgId"
|
||||
:placeholder="$t('organization.share.selectOrgPlaceholder')"
|
||||
:loading="loadingOrgs"
|
||||
class="org-select org-select-dropdown"
|
||||
:popup-props="{ overlayClassName: 'org-select-dropdown-popup' }"
|
||||
>
|
||||
<t-option
|
||||
v-for="org in availableOrganizations"
|
||||
:key="org.id"
|
||||
:value="org.id"
|
||||
:label="org.name"
|
||||
>
|
||||
<div class="org-option-content">
|
||||
<div class="org-option-icon-wrap">
|
||||
<SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" />
|
||||
|
||||
<div class="share-panel-list-wrap">
|
||||
<div class="share-panel-list-header">
|
||||
<div class="share-panel-titlewrap">
|
||||
<span class="share-panel-list-title">{{ $t('organization.share.sharedTo') }}</span>
|
||||
<span class="share-panel-count-badge">{{ filteredShares.length }}</span>
|
||||
</div>
|
||||
<div class="share-panel-actions">
|
||||
<div class="share-panel-search">
|
||||
<t-input v-model="searchQuery" size="small" :placeholder="$t('organization.share.searchPlaceholder')"
|
||||
clearable>
|
||||
<template #prefix-icon>
|
||||
<t-icon name="search" />
|
||||
</template>
|
||||
</t-input>
|
||||
</div>
|
||||
<t-popup v-if="canShare" v-model="addPopupVisible" trigger="click" placement="bottom-end" destroy-on-close
|
||||
overlay-class-name="share-add-popup-overlay">
|
||||
<t-button theme="primary" variant="outline" shape="square" size="small" class="share-panel-add-btn"
|
||||
:title="$t('knowledgeEditor.share.addShare')" :aria-label="$t('knowledgeEditor.share.addShare')">
|
||||
<template #icon><t-icon name="add" /></template>
|
||||
</t-button>
|
||||
<template #content>
|
||||
<div class="share-add-popup-inner" @click.stop>
|
||||
<div class="member-invite-popup-title">{{ $t('organization.share.addShareDialogTitle') }}</div>
|
||||
<div class="org-upgrade-fields">
|
||||
<div class="org-upgrade-field">
|
||||
<label class="org-upgrade-field-label">{{ $t('organization.share.selectOrg') }}</label>
|
||||
<ShareToSpaceOrgSelect v-model="selectedOrgId" :organizations="availableOrganizations"
|
||||
:loading="loadingOrgs" />
|
||||
</div>
|
||||
<div class="org-option-body">
|
||||
<div class="org-option-header">
|
||||
<span class="org-option-name">{{ org.name }}</span>
|
||||
<t-tag v-if="org.is_owner" theme="primary" size="small" variant="light">
|
||||
{{ $t('organization.owner') }}
|
||||
</t-tag>
|
||||
<t-tag v-else-if="org.my_role" :theme="org.my_role === 'admin' ? 'warning' : 'default'" size="small" variant="light">
|
||||
{{ $t(`organization.role.${org.my_role}`) }}
|
||||
</t-tag>
|
||||
</div>
|
||||
<div class="org-option-meta">
|
||||
<span class="org-meta-tag">
|
||||
<t-icon name="user" class="org-meta-icon org-meta-icon-user" />
|
||||
{{ org.member_count ?? 0 }}
|
||||
</span>
|
||||
<span class="org-meta-tag">
|
||||
<img src="@/assets/img/zhishiku.svg" class="org-meta-icon org-meta-icon-kb" alt="" aria-hidden="true" />
|
||||
{{ org.share_count ?? 0 }}
|
||||
</span>
|
||||
<span class="org-meta-tag">
|
||||
<img src="@/assets/img/agent.svg" class="org-meta-icon org-meta-icon-agent" alt="" aria-hidden="true" />
|
||||
{{ org.agent_share_count ?? 0 }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="org-upgrade-field org-upgrade-field--last">
|
||||
<label class="org-upgrade-field-label">{{ $t('organization.share.permission') }}</label>
|
||||
<t-select v-model="selectedPermission" size="medium">
|
||||
<t-option value="viewer" :label="$t('organization.share.permissionReadonly')" />
|
||||
<t-option value="editor" :label="$t('organization.share.permissionEditable')" />
|
||||
</t-select>
|
||||
<p class="member-form-hint">{{ $t('organization.share.permissionTip') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<t-select
|
||||
v-model="selectedPermission"
|
||||
class="permission-select"
|
||||
>
|
||||
<t-option value="viewer" :label="$t('organization.share.permissionReadonly')" />
|
||||
<t-option value="editor" :label="$t('organization.share.permissionEditable')" />
|
||||
</t-select>
|
||||
<t-button
|
||||
theme="primary"
|
||||
:loading="submitting"
|
||||
:disabled="!selectedOrgId"
|
||||
@click="handleShare"
|
||||
>
|
||||
{{ $t('knowledgeEditor.share.addShare') }}
|
||||
</t-button>
|
||||
</div>
|
||||
<p class="form-tip">{{ $t('organization.share.permissionTip') }}</p>
|
||||
<div class="invite-popup-footer">
|
||||
<t-button variant="outline" :disabled="submitting" @click="addPopupVisible = false">
|
||||
{{ $t('common.cancel') }}
|
||||
</t-button>
|
||||
<t-button theme="primary" :loading="submitting" :disabled="!selectedOrgId" @click="handleShare">
|
||||
{{ $t('knowledgeEditor.share.addShare') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</t-popup>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 已共享列表 -->
|
||||
<div class="shares-section">
|
||||
<div class="shares-header">
|
||||
<span class="shares-title">{{ $t('organization.share.sharedTo') }}</span>
|
||||
<span class="shares-count">{{ shares.length }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="loadingShares" class="shares-loading">
|
||||
<t-loading size="small" />
|
||||
<span>{{ $t('common.loading') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-else-if="shares.length === 0" class="shares-empty">
|
||||
<t-icon name="share" class="empty-icon" />
|
||||
<span>{{ $t('organization.share.noShares') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-else class="shares-list">
|
||||
<div v-for="share in shares" :key="share.id" class="share-item">
|
||||
<div class="share-info">
|
||||
<div class="share-info-top">
|
||||
<div class="share-org">
|
||||
<SpaceAvatar
|
||||
:name="share.organization_name || ''"
|
||||
:avatar="orgStore.organizations.find(o => o.id === share.organization_id)?.avatar"
|
||||
size="small"
|
||||
/>
|
||||
<span class="org-name">{{ share.organization_name }}</span>
|
||||
</div>
|
||||
<t-tag
|
||||
:theme="share.permission === 'editor' ? 'warning' : 'default'"
|
||||
size="small"
|
||||
variant="light"
|
||||
>
|
||||
{{ share.permission === 'editor' ? $t('organization.share.permissionEditable') : $t('organization.share.permissionReadonly') }}
|
||||
</t-tag>
|
||||
</div>
|
||||
<div class="share-item-meta">
|
||||
<span class="org-meta-tag">
|
||||
<t-icon name="user" class="org-meta-icon org-meta-icon-user" />
|
||||
{{ getOrgForShare(share.organization_id)?.member_count ?? 0 }}
|
||||
</span>
|
||||
<span class="org-meta-tag">
|
||||
<img src="@/assets/img/zhishiku.svg" class="org-meta-icon org-meta-icon-kb" alt="" aria-hidden="true" />
|
||||
{{ getOrgForShare(share.organization_id)?.share_count ?? 0 }}
|
||||
</span>
|
||||
<span class="org-meta-tag">
|
||||
<img src="@/assets/img/agent.svg" class="org-meta-icon org-meta-icon-agent" alt="" aria-hidden="true" />
|
||||
{{ getOrgForShare(share.organization_id)?.agent_share_count ?? 0 }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="loadingShares && shares.length === 0" class="share-panel-loading">
|
||||
<t-loading size="small" />
|
||||
<span>{{ $t('organization.share.loading') }}</span>
|
||||
</div>
|
||||
<div v-else-if="filteredShares.length === 0" class="share-panel-empty">
|
||||
<t-empty :description="searchQuery.trim()
|
||||
? $t('organization.share.emptySearch', { q: searchQuery })
|
||||
: $t('organization.share.noShares')" />
|
||||
</div>
|
||||
<div v-else class="share-panel-table-shell">
|
||||
<t-table row-key="id" :data="filteredShares" :columns="shareColumns" size="medium" hover stripe
|
||||
:loading="loadingShares">
|
||||
<template #space="{ row }">
|
||||
<div class="share-space-cell">
|
||||
<span class="share-space-name">
|
||||
<SpaceAvatar :name="row.organization_name || ''"
|
||||
:avatar="getOrgForShare(row.organization_id)?.avatar" size="small" />
|
||||
<span class="share-space-name-text">{{ row.organization_name }}</span>
|
||||
</span>
|
||||
<span v-if="row.shared_by_username" class="share-space-meta">
|
||||
{{ $t('organization.share.sharedFrom') }} {{ row.shared_by_username }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="canShare" class="share-actions">
|
||||
<t-select
|
||||
:value="share.permission"
|
||||
size="small"
|
||||
class="permission-change-select"
|
||||
@change="(val: string) => handleUpdatePermission(share, val)"
|
||||
>
|
||||
</template>
|
||||
<template #permission="{ row }">
|
||||
<div class="share-permission-cell">
|
||||
<t-select v-if="canShare" :value="row.permission" size="small" class="share-permission-select"
|
||||
@change="(val: string) => handleUpdatePermission(row, val)">
|
||||
<t-option value="viewer" :label="$t('organization.share.permissionReadonly')" />
|
||||
<t-option value="editor" :label="$t('organization.share.permissionEditable')" />
|
||||
</t-select>
|
||||
<t-popconfirm
|
||||
:content="$t('knowledgeEditor.share.unshareConfirm', { name: share.organization_name })"
|
||||
@confirm="handleUnshare(share)"
|
||||
>
|
||||
<t-button variant="text" theme="danger" size="small">
|
||||
<t-icon name="delete" />
|
||||
</t-button>
|
||||
<t-tag v-else size="small"
|
||||
:theme="row.permission === 'editor' || row.permission === 'admin' ? 'warning' : 'default'"
|
||||
variant="light">
|
||||
{{ permissionLabel(row.permission) }}
|
||||
</t-tag>
|
||||
</div>
|
||||
</template>
|
||||
<template #created_at="{ row }">{{ formatShareDate(row.created_at) }}</template>
|
||||
<template #actions="{ row }">
|
||||
<div v-if="canShare" class="share-table-actions">
|
||||
<t-popconfirm :content="$t('knowledgeEditor.share.unshareConfirm', { name: row.organization_name })"
|
||||
:confirm-btn="{ content: $t('common.confirm'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: $t('common.cancel') }" placement="left" @confirm="handleUnshare(row)">
|
||||
<t-tooltip :content="$t('organization.share.unshareAction')" placement="top">
|
||||
<t-button theme="danger" shape="square" variant="text" size="small" @click.stop>
|
||||
<template #icon><t-icon name="delete" /></template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
</t-popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 提示信息 -->
|
||||
<div class="share-tips">
|
||||
<t-icon name="info-circle" class="tip-icon" />
|
||||
<div class="tip-content">
|
||||
<p>{{ $t('knowledgeEditor.share.tip1') }}</p>
|
||||
<p>{{ $t('knowledgeEditor.share.tip2') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</t-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -170,6 +143,7 @@ import { useOrganizationStore } from '@/stores/organization'
|
||||
import { shareKnowledgeBase, listKBShares, removeShare, updateSharePermission } from '@/api/organization'
|
||||
import type { KnowledgeBaseShare } from '@/api/organization'
|
||||
import SpaceAvatar from '@/components/SpaceAvatar.vue'
|
||||
import ShareToSpaceOrgSelect from '@/components/ShareToSpaceOrgSelect.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const orgStore = useOrganizationStore()
|
||||
@@ -180,9 +154,6 @@ function getOrgForShare(organizationId: string) {
|
||||
|
||||
interface Props {
|
||||
kbId: string
|
||||
// 后端 POST/PUT/DELETE /knowledge-bases/:id/shares 受 OwnedKBOrAdmin
|
||||
// 守卫:仅 KB creator 或空间 Admin+ 能改动共享。父组件根据 KB.creator_id
|
||||
// 计算后传入,缺省 false 表示只读。
|
||||
canShare?: boolean
|
||||
}
|
||||
|
||||
@@ -190,14 +161,24 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
canShare: false,
|
||||
})
|
||||
|
||||
const shareHintPopupInnerStyle = {
|
||||
boxSizing: 'border-box' as const,
|
||||
padding: '0',
|
||||
width: 'min(400px, calc(100vw - 24px))',
|
||||
maxWidth: 'min(400px, calc(100vw - 24px))',
|
||||
maxHeight: 'min(280px, 65vh)',
|
||||
overflow: 'hidden',
|
||||
}
|
||||
|
||||
const loadingOrgs = ref(false)
|
||||
const loadingShares = ref(false)
|
||||
const submitting = ref(false)
|
||||
const addPopupVisible = ref(false)
|
||||
const searchQuery = ref('')
|
||||
const selectedOrgId = ref('')
|
||||
const selectedPermission = ref<'viewer' | 'editor'>('viewer')
|
||||
const shares = ref<(KnowledgeBaseShare & { organization_name?: string })[]>([])
|
||||
|
||||
// Only show organizations where user can share (editor or admin); exclude viewer-only orgs and already shared
|
||||
const availableOrganizations = computed(() => {
|
||||
const sharedOrgIds = new Set(shares.value.map(s => s.organization_id))
|
||||
return orgStore.organizations.filter(
|
||||
@@ -207,7 +188,45 @@ const availableOrganizations = computed(() => {
|
||||
)
|
||||
})
|
||||
|
||||
// Load organizations
|
||||
const filteredShares = computed(() => {
|
||||
const query = searchQuery.value.trim().toLowerCase()
|
||||
if (!query) return shares.value
|
||||
return shares.value.filter((share) => {
|
||||
const haystack = [
|
||||
share.organization_name,
|
||||
share.shared_by_username,
|
||||
permissionLabel(share.permission),
|
||||
].filter(Boolean).join(' ').toLowerCase()
|
||||
return haystack.includes(query)
|
||||
})
|
||||
})
|
||||
|
||||
const shareColumns = computed(() => {
|
||||
const cols = [
|
||||
{ colKey: 'space', title: t('organization.share.columns.space'), ellipsis: true, minWidth: 180 },
|
||||
{ colKey: 'permission', title: t('organization.share.columns.permission'), width: 132 },
|
||||
{ colKey: 'created_at', title: t('organization.share.columns.sharedAt'), width: 154 },
|
||||
]
|
||||
if (props.canShare) {
|
||||
cols.push({ colKey: 'actions', title: t('organization.share.columns.operations'), width: 72, align: 'left' } as typeof cols[number])
|
||||
}
|
||||
return cols
|
||||
})
|
||||
|
||||
function permissionLabel(permission: string) {
|
||||
if (permission === 'editor' || permission === 'admin') {
|
||||
return t('organization.share.permissionEditable')
|
||||
}
|
||||
return t('organization.share.permissionReadonly')
|
||||
}
|
||||
|
||||
function formatShareDate(dateStr?: string) {
|
||||
if (!dateStr) return '—'
|
||||
const date = new Date(dateStr)
|
||||
if (Number.isNaN(date.getTime())) return dateStr
|
||||
return date.toLocaleDateString(undefined, { year: 'numeric', month: '2-digit', day: '2-digit' })
|
||||
}
|
||||
|
||||
async function loadOrganizations() {
|
||||
loadingOrgs.value = true
|
||||
try {
|
||||
@@ -217,15 +236,13 @@ async function loadOrganizations() {
|
||||
}
|
||||
}
|
||||
|
||||
// Load shares
|
||||
async function loadShares() {
|
||||
if (!props.kbId) return
|
||||
loadingShares.value = true
|
||||
try {
|
||||
const result = await listKBShares(props.kbId)
|
||||
if (result.success && result.data) {
|
||||
// result.data is ListSharesResponse with shares array
|
||||
const sharesData = (result.data as any).shares || result.data
|
||||
const sharesData = (result.data as { shares?: KnowledgeBaseShare[] }).shares || result.data
|
||||
const sharesList = Array.isArray(sharesData) ? sharesData : []
|
||||
shares.value = sharesList.map((share: KnowledgeBaseShare) => ({
|
||||
...share,
|
||||
@@ -239,7 +256,6 @@ async function loadShares() {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle share
|
||||
async function handleShare() {
|
||||
if (!selectedOrgId.value) return
|
||||
|
||||
@@ -253,18 +269,19 @@ async function handleShare() {
|
||||
MessagePlugin.success(t('organization.share.shareSuccess'))
|
||||
selectedOrgId.value = ''
|
||||
selectedPermission.value = 'viewer'
|
||||
addPopupVisible.value = false
|
||||
await loadShares()
|
||||
} else {
|
||||
MessagePlugin.error(result.message || t('organization.share.shareFailed'))
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || t('organization.share.shareFailed'))
|
||||
} catch (e: unknown) {
|
||||
const message = e instanceof Error ? e.message : t('organization.share.shareFailed')
|
||||
MessagePlugin.error(message)
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Handle update permission
|
||||
async function handleUpdatePermission(share: KnowledgeBaseShare, newPermission: string) {
|
||||
if (share.permission === newPermission) return
|
||||
|
||||
@@ -278,12 +295,12 @@ async function handleUpdatePermission(share: KnowledgeBaseShare, newPermission:
|
||||
} else {
|
||||
MessagePlugin.error(result.message || t('organization.roleUpdateFailed'))
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || t('organization.roleUpdateFailed'))
|
||||
} catch (e: unknown) {
|
||||
const message = e instanceof Error ? e.message : t('organization.roleUpdateFailed')
|
||||
MessagePlugin.error(message)
|
||||
}
|
||||
}
|
||||
|
||||
// Handle unshare
|
||||
async function handleUnshare(share: KnowledgeBaseShare) {
|
||||
try {
|
||||
const result = await removeShare(props.kbId, share.id)
|
||||
@@ -293,12 +310,12 @@ async function handleUnshare(share: KnowledgeBaseShare) {
|
||||
} else {
|
||||
MessagePlugin.error(result.message || t('organization.share.unshareFailed'))
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || t('organization.share.unshareFailed'))
|
||||
} catch (e: unknown) {
|
||||
const message = e instanceof Error ? e.message : t('organization.share.unshareFailed')
|
||||
MessagePlugin.error(message)
|
||||
}
|
||||
}
|
||||
|
||||
// Watch for kbId changes
|
||||
watch(() => props.kbId, async (newKbId) => {
|
||||
if (newKbId) {
|
||||
await Promise.all([loadOrganizations(), loadShares()])
|
||||
@@ -307,366 +324,9 @@ watch(() => props.kbId, async (newKbId) => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.section-content {
|
||||
.section-header {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin: 0 0 6px 0;
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.section-desc {
|
||||
margin: 0;
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
line-height: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
.share-form {
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 24px;
|
||||
border-bottom: 1px solid var(--td-bg-color-secondarycontainer);
|
||||
}
|
||||
|
||||
.form-item {
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.form-tip {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
line-height: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.share-input-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.org-select {
|
||||
flex: 1;
|
||||
min-width: 240px;
|
||||
}
|
||||
|
||||
.permission-select {
|
||||
width: 120px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.shares-section {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.shares-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.shares-title {
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.shares-count {
|
||||
padding: 2px 8px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 10px;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
}
|
||||
|
||||
.shares-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 32px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.shares-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 40px 20px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 8px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
|
||||
.empty-icon {
|
||||
font-size: 32px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.shares-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.share-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 14px 16px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border: 1px solid var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 8px;
|
||||
transition: background 0.2s ease, border-color 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-color: var(--td-component-stroke);
|
||||
}
|
||||
}
|
||||
|
||||
.share-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.share-info-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.share-org {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.org-name {
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.share-item-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
.org-meta-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 2px 6px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.org-meta-icon {
|
||||
flex-shrink: 0;
|
||||
vertical-align: middle;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.org-meta-icon-user {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.org-meta-icon-kb {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.org-meta-icon-agent {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
}
|
||||
|
||||
.share-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
.permission-change-select {
|
||||
width: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
.share-tips {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
background: var(--td-brand-color-light);
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--td-brand-color-focus);
|
||||
|
||||
.tip-icon {
|
||||
flex-shrink: 0;
|
||||
font-size: 16px;
|
||||
color: var(--td-brand-color);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.tip-content {
|
||||
flex: 1;
|
||||
|
||||
p {
|
||||
margin: 0 0 4px 0;
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
line-height: 20px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Custom option styles for organization select (compact)
|
||||
:deep(.t-select-option) {
|
||||
height: auto;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
border-radius: 4px;
|
||||
margin: 1px 6px;
|
||||
transition: background 0.15s ease;
|
||||
}
|
||||
|
||||
:deep(.t-select-option:hover),
|
||||
:deep(.t-select-option.t-is-selected) {
|
||||
background: var(--td-brand-color-light);
|
||||
}
|
||||
|
||||
:deep(.t-select-option__content) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.org-option-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0;
|
||||
min-width: 260px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.org-option-icon-wrap {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.org-option-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.org-option-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 2px;
|
||||
|
||||
.org-option-name {
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.org-option-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-family: var(--app-font-family);
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
.org-meta-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 0px 4px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.org-meta-icon {
|
||||
flex-shrink: 0;
|
||||
vertical-align: middle;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.org-meta-icon-user {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.org-meta-icon-kb {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.org-meta-icon-agent {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
}
|
||||
@import '@/components/share-to-space-panel.less';
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
// Global styles for organization select dropdown (compact)
|
||||
.org-select-dropdown-popup.t-select__dropdown {
|
||||
padding: 4px 0;
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
border-radius: 6px;
|
||||
box-shadow: var(--td-shadow-2);
|
||||
}
|
||||
|
||||
.org-select-dropdown-popup .t-select-option {
|
||||
height: auto;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
border-radius: 4px;
|
||||
margin: 1px 6px;
|
||||
}
|
||||
|
||||
.org-select-dropdown-popup .t-select-option__content {
|
||||
width: 100%;
|
||||
}
|
||||
@import '@/components/share-to-space-panel.overlay.less';
|
||||
</style>
|
||||
|
||||
@@ -507,57 +507,117 @@
|
||||
<p class="section-description">{{ $t('organization.settings.joinRequestsDesc') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="settings-group">
|
||||
<t-loading :loading="joinRequestsLoading">
|
||||
<div v-if="joinRequests.length === 0 && !joinRequestsLoading" class="empty-join-requests">
|
||||
<div class="empty-icon">
|
||||
<t-icon name="check-circle" size="48px" />
|
||||
</div>
|
||||
<p class="empty-text">{{ $t('organization.settings.noPendingRequests') }}</p>
|
||||
<div class="members-list-wrap join-requests-wrap">
|
||||
<div class="members-list-header">
|
||||
<div class="members-list-titlewrap">
|
||||
<span class="members-list-title">{{ $t('organization.joinRequests.listTitle') }}</span>
|
||||
<span class="members-list-count-badge">{{ filteredJoinRequests.length }}</span>
|
||||
</div>
|
||||
<div v-else class="join-requests-list">
|
||||
<div v-for="req in joinRequests" :key="req.id" class="join-request-item">
|
||||
<div class="request-user">
|
||||
<div class="request-avatar">
|
||||
<t-icon name="user" size="20px" />
|
||||
</div>
|
||||
<div class="request-info">
|
||||
<span class="request-name">
|
||||
{{ req.username || req.email || req.user_id }}
|
||||
<t-tag v-if="req.request_type === 'upgrade'" size="small" theme="warning"
|
||||
class="request-type-tag">
|
||||
{{ $t('organization.upgrade.upgradeRequest') }}
|
||||
</t-tag>
|
||||
</span>
|
||||
<span class="request-email">{{ req.email }}</span>
|
||||
<p v-if="req.message" class="request-message">{{ req.message }}</p>
|
||||
<span v-if="req.request_type === 'upgrade' && req.prev_role" class="request-prev-role">
|
||||
{{ $t('organization.upgrade.currentRole') }}:{{ roleLabel(req.prev_role) }} → {{
|
||||
roleLabel(req.requested_role) }}
|
||||
</span>
|
||||
<span v-else class="request-requested-role">{{ $t('organization.invite.requestRole') }}:{{
|
||||
roleLabel(req.requested_role) }}</span>
|
||||
<span class="request-time">{{ formatDate(req.created_at) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="request-actions">
|
||||
<div class="request-assign-role">
|
||||
<span class="request-assign-label">{{ $t('organization.settings.assignRole') }}</span>
|
||||
<t-select v-model="assignRoleMap[req.id]" class="request-role-select"
|
||||
:options="orgRoleOptions" size="small" />
|
||||
</div>
|
||||
<t-button theme="primary" size="small" :loading="reviewingRequestId === req.id"
|
||||
@click="handleApproveRequest(req)">
|
||||
{{ $t('organization.settings.approve') }}
|
||||
</t-button>
|
||||
<t-button theme="default" variant="outline" size="small"
|
||||
:loading="reviewingRequestId === req.id" @click="handleRejectRequest(req)">
|
||||
{{ $t('organization.settings.reject') }}
|
||||
</t-button>
|
||||
</div>
|
||||
<div class="members-list-actions">
|
||||
<div class="members-list-search">
|
||||
<t-input v-model="joinRequestSearchQuery" size="small"
|
||||
:placeholder="$t('organization.joinRequests.searchPlaceholder')" clearable>
|
||||
<template #prefix-icon>
|
||||
<t-icon name="search" />
|
||||
</template>
|
||||
</t-input>
|
||||
</div>
|
||||
</div>
|
||||
</t-loading>
|
||||
</div>
|
||||
|
||||
<div v-if="joinRequestsLoading && joinRequests.length === 0" class="loading-inline">
|
||||
<t-loading size="small" />
|
||||
<span>{{ $t('organization.joinRequests.loading') }}</span>
|
||||
</div>
|
||||
<div v-else-if="filteredJoinRequests.length === 0" class="empty-state">
|
||||
<t-empty :description="joinRequestSearchQuery.trim()
|
||||
? $t('organization.joinRequests.emptySearch', { q: joinRequestSearchQuery })
|
||||
: $t('organization.settings.noPendingRequests')" />
|
||||
</div>
|
||||
<div v-else class="data-table-shell join-requests-table">
|
||||
<t-table row-key="id" :data="filteredJoinRequests" :columns="joinRequestColumns" size="medium"
|
||||
hover stripe :loading="joinRequestsLoading">
|
||||
<template #applicant="{ row }">
|
||||
<div class="member-cell">
|
||||
<span class="member-name">{{ joinRequestApplicantLabel(row) }}</span>
|
||||
<span v-if="joinRequestApplicantSecondary(row)" class="member-email">
|
||||
{{ joinRequestApplicantSecondary(row) }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #request_type="{ row }">
|
||||
<t-tag size="small" :theme="row.request_type === 'upgrade' ? 'warning' : 'primary'"
|
||||
variant="light">
|
||||
{{ row.request_type === 'upgrade'
|
||||
? $t('organization.joinRequests.typeUpgrade')
|
||||
: $t('organization.joinRequests.typeJoin') }}
|
||||
</t-tag>
|
||||
</template>
|
||||
<template #requested_role="{ row }">
|
||||
<span v-if="row.request_type === 'upgrade' && row.prev_role" class="join-request-role-change">
|
||||
{{ roleLabel(row.prev_role) }}
|
||||
<t-icon name="arrow-right" size="12px" />
|
||||
{{ roleLabel(row.requested_role) }}
|
||||
</span>
|
||||
<t-tag v-else size="small" :theme="getRoleTheme(row.requested_role)" variant="light">
|
||||
{{ roleLabel(row.requested_role) }}
|
||||
</t-tag>
|
||||
</template>
|
||||
<template #message="{ row }">
|
||||
<span class="join-request-message" :title="row.message || undefined">
|
||||
{{ row.message || '—' }}
|
||||
</span>
|
||||
</template>
|
||||
<template #created_at="{ row }">{{ formatDate(row.created_at) }}</template>
|
||||
<template #actions="{ row }">
|
||||
<div class="join-request-actions">
|
||||
<t-popup :visible="approvePopupRequestId === row.id"
|
||||
placement="left-start" destroy-on-close overlay-class-name="org-approve-request-popup-overlay"
|
||||
@visible-change="(visible) => handleApprovePopupVisibleChange(visible, row)">
|
||||
<t-tooltip :content="$t('organization.settings.approve')" placement="top">
|
||||
<t-button theme="primary" variant="text" shape="square" size="small"
|
||||
:loading="reviewingRequestId === row.id" @click.stop="openApprovePopup(row)">
|
||||
<template #icon><t-icon name="check" /></template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
<template #content>
|
||||
<div class="org-approve-request-popup-inner" @click.stop>
|
||||
<div class="member-invite-popup-title">{{ $t('organization.joinRequests.approveTitle') }}</div>
|
||||
<p class="add-member-tip">
|
||||
{{ $t('organization.joinRequests.approveDesc', { name: joinRequestApplicantLabel(row) }) }}
|
||||
</p>
|
||||
<div class="org-upgrade-field org-upgrade-field--last">
|
||||
<label class="org-upgrade-field-label">{{ $t('organization.settings.assignRole') }}</label>
|
||||
<t-select v-model="approveAssignRole" size="medium" :options="orgRoleOptions" />
|
||||
</div>
|
||||
<div class="invite-popup-footer">
|
||||
<t-button variant="outline" :disabled="reviewingRequestId === row.id"
|
||||
@click="closeApprovePopup">
|
||||
{{ $t('common.cancel') }}
|
||||
</t-button>
|
||||
<t-button theme="primary" :loading="reviewingRequestId === row.id"
|
||||
@click="confirmApproveRequest(row)">
|
||||
{{ $t('organization.settings.approve') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</t-popup>
|
||||
<t-popconfirm :content="$t('organization.joinRequests.rejectConfirm')"
|
||||
:confirm-btn="{ content: $t('organization.settings.reject'), theme: 'danger' }"
|
||||
:cancel-btn="{ content: $t('common.cancel') }" placement="left"
|
||||
@confirm="handleRejectRequest(row)">
|
||||
<t-tooltip :content="$t('organization.settings.reject')" placement="top">
|
||||
<t-button theme="danger" variant="text" shape="square" size="small"
|
||||
:loading="reviewingRequestId === row.id" @click.stop>
|
||||
<template #icon><t-icon name="close" /></template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
</t-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</t-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -820,6 +880,7 @@ const sharedKnowledgeBases = ref<KnowledgeBaseShare[]>([])
|
||||
const sharedAgents = ref<AgentShareResponse[]>([])
|
||||
const joinRequests = ref<JoinRequestResponse[]>([])
|
||||
const joinRequestsLoading = ref(false)
|
||||
const joinRequestSearchQuery = ref('')
|
||||
const reviewingRequestId = ref<string | null>(null)
|
||||
const sharesLoading = ref(false)
|
||||
const membersLoading = ref(false)
|
||||
@@ -1094,6 +1155,18 @@ function sharePermissionLabel(permission: string): string {
|
||||
return t('organization.share.permissionReadonly')
|
||||
}
|
||||
|
||||
const joinRequestColumns = computed(() => {
|
||||
const cols = [
|
||||
{ colKey: 'applicant', title: t('organization.joinRequests.columns.applicant'), ellipsis: true, minWidth: 160 },
|
||||
{ colKey: 'request_type', title: t('organization.joinRequests.columns.type'), width: 88 },
|
||||
{ colKey: 'requested_role', title: t('organization.joinRequests.columns.requestedRole'), width: 140 },
|
||||
{ colKey: 'message', title: t('organization.joinRequests.columns.message'), ellipsis: true, minWidth: 120 },
|
||||
{ colKey: 'created_at', title: t('organization.joinRequests.columns.appliedAt'), width: 154 },
|
||||
{ colKey: 'actions', title: t('organization.members.columns.operations'), width: 88, align: 'left' },
|
||||
]
|
||||
return cols
|
||||
})
|
||||
|
||||
const sharedKbColumns = computed(() => {
|
||||
const cols = [
|
||||
{ colKey: 'name', title: t('organization.sharedResources.columns.name'), ellipsis: true, minWidth: 180 },
|
||||
@@ -1160,6 +1233,28 @@ const filteredMembers = computed(() => {
|
||||
)
|
||||
})
|
||||
|
||||
const filteredJoinRequests = computed(() => {
|
||||
const query = joinRequestSearchQuery.value.trim().toLowerCase()
|
||||
if (!query) return joinRequests.value
|
||||
return joinRequests.value.filter((req) => {
|
||||
const haystack = [req.username, req.email, req.user_id, req.message]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
.toLowerCase()
|
||||
return haystack.includes(query)
|
||||
})
|
||||
})
|
||||
|
||||
function joinRequestApplicantLabel(req: JoinRequestResponse): string {
|
||||
return req.username || req.email || req.user_id
|
||||
}
|
||||
|
||||
function joinRequestApplicantSecondary(req: JoinRequestResponse): string {
|
||||
const primary = joinRequestApplicantLabel(req)
|
||||
if (req.email && req.email !== primary) return req.email
|
||||
return ''
|
||||
}
|
||||
|
||||
// 成员行的主标题:优先展示「空间名」,回退到代表用户名 / 空间 ID。Plan 3
|
||||
// 之后每一行成员都对应一个空间,UI 必须先于代表用户呈现空间身份,
|
||||
// 否则用户会误以为这是按"人"加进来的。
|
||||
@@ -1292,7 +1387,32 @@ const orgRoleOptions = [
|
||||
{ label: t('organization.role.editor'), value: 'editor' },
|
||||
{ label: t('organization.role.admin'), value: 'admin' },
|
||||
]
|
||||
const assignRoleMap = ref<Record<string, 'viewer' | 'editor' | 'admin'>>({})
|
||||
const approvePopupRequestId = ref<string | null>(null)
|
||||
const approveAssignRole = ref<'viewer' | 'editor' | 'admin'>('viewer')
|
||||
|
||||
function normalizeJoinRequestRole(role: string): 'viewer' | 'editor' | 'admin' {
|
||||
if (role === 'admin' || role === 'editor' || role === 'viewer') return role
|
||||
return 'viewer'
|
||||
}
|
||||
|
||||
function openApprovePopup(req: JoinRequestResponse) {
|
||||
approvePopupRequestId.value = req.id
|
||||
approveAssignRole.value = normalizeJoinRequestRole(req.requested_role)
|
||||
}
|
||||
|
||||
function closeApprovePopup() {
|
||||
approvePopupRequestId.value = null
|
||||
}
|
||||
|
||||
function handleApprovePopupVisibleChange(visible: boolean, req: JoinRequestResponse) {
|
||||
if (visible) {
|
||||
openApprovePopup(req)
|
||||
return
|
||||
}
|
||||
if (approvePopupRequestId.value === req.id) {
|
||||
closeApprovePopup()
|
||||
}
|
||||
}
|
||||
|
||||
function roleLabel(role: string) {
|
||||
if (role === 'admin') return t('organization.role.admin')
|
||||
@@ -1307,11 +1427,6 @@ const fetchJoinRequests = async () => {
|
||||
const res = await listJoinRequests(props.orgId)
|
||||
if (res.success && res.data) {
|
||||
joinRequests.value = res.data.requests || []
|
||||
assignRoleMap.value = {}
|
||||
joinRequests.value.forEach((r) => {
|
||||
const rRole = (r.requested_role === 'admin' || r.requested_role === 'editor' || r.requested_role === 'viewer') ? r.requested_role : 'viewer'
|
||||
assignRoleMap.value[r.id] = rRole
|
||||
})
|
||||
} else {
|
||||
joinRequests.value = []
|
||||
}
|
||||
@@ -1334,21 +1449,27 @@ const refreshOrganizationAfterReview = async () => {
|
||||
])
|
||||
}
|
||||
|
||||
const handleApproveRequest = async (req: JoinRequestResponse) => {
|
||||
if (!props.orgId) return
|
||||
const confirmApproveRequest = async (req: JoinRequestResponse) => {
|
||||
const success = await handleApproveRequest(req, approveAssignRole.value)
|
||||
if (success) closeApprovePopup()
|
||||
}
|
||||
|
||||
const handleApproveRequest = async (req: JoinRequestResponse, assignRole: 'viewer' | 'editor' | 'admin'): Promise<boolean> => {
|
||||
if (!props.orgId) return false
|
||||
reviewingRequestId.value = req.id
|
||||
const assignRole = assignRoleMap.value[req.id] ?? (req.requested_role === 'admin' || req.requested_role === 'editor' ? req.requested_role : 'viewer')
|
||||
try {
|
||||
const res = await reviewJoinRequest(props.orgId, req.id, { approved: true, role: assignRole })
|
||||
if (res.success) {
|
||||
MessagePlugin.success(t('organization.settings.approveSuccess'))
|
||||
joinRequests.value = joinRequests.value.filter(r => r.id !== req.id)
|
||||
await refreshOrganizationAfterReview()
|
||||
} else {
|
||||
MessagePlugin.error(res.message || t('organization.settings.reviewFailed'))
|
||||
return true
|
||||
}
|
||||
MessagePlugin.error(res.message || t('organization.settings.reviewFailed'))
|
||||
return false
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('organization.settings.reviewFailed'))
|
||||
return false
|
||||
} finally {
|
||||
reviewingRequestId.value = null
|
||||
}
|
||||
@@ -1738,6 +1859,8 @@ watch(() => props.visible, (newVal) => {
|
||||
if (newVal) {
|
||||
currentSection.value = 'basic'
|
||||
memberSearchQuery.value = ''
|
||||
joinRequestSearchQuery.value = ''
|
||||
approvePopupRequestId.value = null
|
||||
joinRequests.value = []
|
||||
if (props.mode === 'create') {
|
||||
// 创建模式:重置表单
|
||||
@@ -2876,139 +2999,35 @@ watch(addMemberPopupVisible, (visible) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Join requests
|
||||
.empty-join-requests {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 48px 20px;
|
||||
|
||||
.empty-icon {
|
||||
color: var(--td-brand-color);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 14px;
|
||||
// Join requests table
|
||||
.join-requests-wrap {
|
||||
.join-request-message {
|
||||
display: block;
|
||||
max-width: 220px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.join-requests-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
|
||||
.join-request-item {
|
||||
display: flex;
|
||||
.join-request-role-change {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 12px 16px;
|
||||
background: var(--td-bg-color-container);
|
||||
border-radius: 8px;
|
||||
transition: background 0.2s;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
}
|
||||
|
||||
.request-user {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.request-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: var(--td-brand-color-light);
|
||||
color: var(--td-brand-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.t-icon {
|
||||
flex-shrink: 0;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
}
|
||||
|
||||
.request-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
|
||||
.request-name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
|
||||
.request-type-tag {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.request-email {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.request-prev-role {
|
||||
font-size: 12px;
|
||||
color: var(--td-warning-color);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.request-message {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 4px 0 0;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.request-requested-role {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.request-time {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
margin-top: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.request-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.request-assign-role {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.request-assign-label {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.request-role-select {
|
||||
min-width: 100px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.join-request-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3292,7 +3311,8 @@ watch(addMemberPopupVisible, (visible) => {
|
||||
|
||||
/* 添加成员 / 权限升级弹出层(与空间成员管理邀请弹层一致) */
|
||||
.org-add-member-popup-overlay,
|
||||
.org-upgrade-popup-overlay {
|
||||
.org-upgrade-popup-overlay,
|
||||
.org-approve-request-popup-overlay {
|
||||
z-index: 3050 !important;
|
||||
|
||||
.t-popup__content {
|
||||
@@ -3303,8 +3323,10 @@ watch(addMemberPopupVisible, (visible) => {
|
||||
}
|
||||
}
|
||||
|
||||
.org-upgrade-popup-overlay {
|
||||
.org-upgrade-popup-inner {
|
||||
.org-upgrade-popup-overlay,
|
||||
.org-approve-request-popup-overlay {
|
||||
.org-upgrade-popup-inner,
|
||||
.org-approve-request-popup-inner {
|
||||
width: min(360px, calc(100vw - 32px));
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
@@ -3404,7 +3426,8 @@ watch(addMemberPopupVisible, (visible) => {
|
||||
}
|
||||
}
|
||||
|
||||
.org-upgrade-field .t-textarea {
|
||||
.org-upgrade-field .t-textarea,
|
||||
.org-upgrade-field .t-select {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user