Skip to content

Commit

Permalink
fix: 跨租户协同交互优化 TencentBlueKing#1684
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 7497
  • Loading branch information
yuri0528 committed May 10, 2024
1 parent 8d0c3bb commit 6829de2
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 28 deletions.
19 changes: 9 additions & 10 deletions src/pages/src/views/setting/cross-tenant-collaboration/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,31 @@
type="unborder-card"
>
<bk-tab-panel
v-for="(item, index) in panels"
:key="index"
v-for="item in panels"
:key="item.name"
:name="item.name"
:label="item.label"
>
<MyShare v-if="active === 'local'" />
<OtherShare v-else />
<component :is="item.component" :active="active"></component>
</bk-tab-panel>
</bk-tab>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import MyShare from './my-share/index.vue';
import OtherShare from './other-share/index.vue';
import { defineAsyncComponent, ref } from 'vue';
import { t } from '@/language/index';
import { useMainViewStore } from '@/store';
const MyShare = defineAsyncComponent(() => import('./my-share/index.vue'));
const OtherShare = defineAsyncComponent(() => import('./other-share/index.vue'));
const store = useMainViewStore();
store.customBreadcrumbs = false;
const panels = [
{ name: 'local', label: t('我分享的') },
{ name: 'other', label: t('其他租户分享的') },
{ name: 'local', label: t('我分享的'), component: MyShare },
{ name: 'other', label: t('其他租户分享的'), component: OtherShare },
];
const active = ref('local');
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

<script setup lang="ts">
import { bkTooltips as vBkTooltips, InfoBox, Message } from 'bkui-vue';
import { computed, inject, onMounted, reactive, ref, watch } from 'vue';
import { computed, defineProps, inject, reactive, ref, watch, watchEffect } from 'vue';
import OperationDetails from './OperationDetails.vue';
import ViewDetails from './ViewDetails.vue';
Expand All @@ -114,6 +114,13 @@ const store = useMainViewStore();
store.customBreadcrumbs = false;
const userStore = useUser();
const props = defineProps({
active: {
type: String,
default: '',
},
});
const tableMaxHeight = useTableMaxHeight(202);
const editLeaveBefore = inject('editLeaveBefore');
const isLoading = ref(false);
Expand All @@ -123,10 +130,6 @@ const isDataError = ref(false);
const isSearchEmpty = ref(false);
const search = ref('');
onMounted(() => {
fetchToStrategies();
});
// 获取协同策略列表
const fetchToStrategies = async () => {
try {
Expand All @@ -146,6 +149,12 @@ const fetchToStrategies = async () => {
}
};
watchEffect(() => {
if (props.active === 'local') {
fetchToStrategies();
}
});
const statusFilters = [
{ text: t('启用'), value: 'enabled' },
{ text: t('停用'), value: 'disabled' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ const handleSave = async () => {
},
};
await props.config.type === 'view' ? putFromStrategies(params) : putFromStrategiesConfirm(params);
props.config.type === 'view' ? await putFromStrategies(params) : await putFromStrategiesConfirm(params);
Message({ theme: 'success', message: t('更新成功') });
emit('updateList');
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<div v-bkloading="{ loading: isLoading, zIndex: 9 }" class="user-info-wrapper user-scroll-y">
<div
v-bkloading="{ loading: isLoading, zIndex: 9 }"
:class="['user-info-wrapper user-scroll-y', { 'has-alert': userStore.showAlert }]">
<!-- 一期不做 -->
<!-- <header>
<bk-button text theme="primary" @click="handleUpdateRecord">
Expand Down Expand Up @@ -206,19 +208,27 @@
</template>

<script setup lang="ts">
import { inject, onMounted, reactive, ref } from 'vue';
import { defineProps, inject, reactive, ref, watchEffect } from 'vue';
import OperationDetails from './OperationDetails.vue';
import Empty from '@/components/Empty.vue';
import { useTableMaxHeight } from '@/hooks';
import { getFromStrategies, putFromStrategiesStatus } from '@/http';
import { t } from '@/language/index';
import { useMainViewStore } from '@/store';
import { useMainViewStore, useUser } from '@/store';
import { dataSourceStatus } from '@/utils';
const store = useMainViewStore();
store.customBreadcrumbs = false;
const userStore = useUser();
const props = defineProps({
active: {
type: String,
default: '',
},
});
const tableMaxHeight = useTableMaxHeight(238);
const editLeaveBefore = inject('editLeaveBefore');
Expand All @@ -245,27 +255,37 @@ const detailsConfig = reactive({
type: '',
});
onMounted(() => {
fetchFromStrategies();
});
const fetchFromStrategies = async () => {
try {
isLoading.value = true;
isDataEmpty.value = false;
isDataError.value = false;
const res = await getFromStrategies();
tableData.value = res?.data;
if (tableData.value.length === 0) {
isDataEmpty.value = true;
}
tableData.value = res.data?.sort(a => (a.target_status === 'unconfirmed' ? -1 : 1));
const table = document.querySelector('.user-info-table');
const rows = table.querySelectorAll('.hover-highlight');
rows.forEach((row) => {
const statusCell = row.cells[1];
if (statusCell.textContent.trim() === t('待确认')) {
row.classList.add('unconfirmed');
}
});
isDataEmpty.value = tableData.value.length === 0;
} catch (error) {
isDataError.value = true;
} finally {
isLoading.value = false;
}
};
watchEffect(() => {
if (props.active === 'other') {
fetchFromStrategies();
}
});
const handleFilter = ({ checked }) => {
if (checked.length === 0) return isDataEmpty.value = false;
isDataEmpty.value = !tableData.value.some(item => checked.includes(item.status));
Expand Down Expand Up @@ -328,6 +348,10 @@ const updateList = () => {
</script>

<style lang="less" scoped>
.has-alert {
height: calc(100vh - 180px) !important;
}
.user-info-wrapper {
width: 100%;
height: calc(100vh - 140px);
Expand All @@ -348,6 +372,10 @@ const updateList = () => {
}
:deep(.user-info-table) {
.unconfirmed td {
background-color: #F2FCF5;
}
.bk-table-head {
table thead th {
text-align: center;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/src/views/tenant/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ const fetchTenantsList = () => {
const rows = getRows();
for (const i of rows) {
i.style.background = '#DCFFE2';
i.style.background = '#F2FCF5';
}
} else {
state.list = res.data.sort((a, b) => a.name.localeCompare(b.name, 'zh-Hans-CN'));
Expand Down

0 comments on commit 6829de2

Please sign in to comment.