Skip to content

Commit

Permalink
feat: 协同数据更新记录 TencentBlueKing#1684
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 7721
  • Loading branch information
yuri0528 committed May 13, 2024
1 parent 625a9fd commit b7c53e1
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 41 deletions.
6 changes: 6 additions & 0 deletions src/pages/src/http/settingFiles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import http from './fetch';
import type {
CollaborationSyncRecordsParams,
FromStrategiesConfirmParams,
NewCustomFieldsParams,
NewToStrategiesParams,
Expand Down Expand Up @@ -136,3 +137,8 @@ export const putFromStrategiesConfirm = (params: FromStrategiesConfirmParams) =>
* 跨租户协同-编辑协同策略
*/
export const putFromStrategies = (params: FromStrategiesConfirmParams) => http.put(`/api/v1/web/collaboration/from-strategies/${params.id}/`, params);

/**
* 跨租户协同-数据更新记录
*/
export const getCollaborationSyncRecords = (params: CollaborationSyncRecordsParams) => http.get('/api/v1/web/collaboration/sync-records/', params);
8 changes: 8 additions & 0 deletions src/pages/src/http/types/settingFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,11 @@ export interface FromStrategiesConfirmParams {
}[],
},
}

/**
* 跨租户协同-数据更新记录
*/
export interface CollaborationSyncRecordsParams {
page?: number,
pageSize?: number,
}
4 changes: 1 addition & 3 deletions src/pages/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
"确认删除该组织?": "Delete this organization?",
"删除该组织同时会删除其下用户与子组织,请谨慎操作": "Deleting this organization will also delete its users and sub-organizations. Please proceed with caution",
"新增": "Add",
"配置数据源": "Configure data source",
"配置数据源": "Configure Data Source",
"查看组织架构": "View organizational structure",
"选择数据源类型": "Select data source type",
"支持多种类、多平台异构数据源快速接入,助力全方位分析": "Supports fast access to heterogeneous data sources of multiple types and platforms to facilitate all-round analysis",
Expand Down Expand Up @@ -432,7 +432,6 @@
"是否重置数据源?": "Reset the data source?",
"数据源重置成功": "Data source reset successfully",
"导入成功": "Import Successful",
"查看组织架构": "View organizational",
"关闭": "Close",
"更新": "Update",
"立即同步": "Synchronize Now",
Expand All @@ -443,7 +442,6 @@
"本地": "Local",
"暂未配置数据源": "Data source not configured",
"需要先配置数据源后才可进行登录配置,当前支持使用以下方式进行登录": "You need to configure a data source before setting up login configurations, currently supports the following methods for logging in",
"配置数据源": "Configure Data Source",
"仅对本地数据源启用": "Enable only for local data source",
"登录详情": "Login Details",
"配置成功": "Configuration Successful",
Expand Down
2 changes: 0 additions & 2 deletions src/pages/src/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@
"是否重置数据源?": "是否重置数据源?",
"数据源重置成功": "数据源重置成功",
"导入成功": "导入成功",
"查看组织架构": "查看组织架构",
"关闭": "关闭",
"更新": "更新",
"立即同步": "立即同步",
Expand All @@ -443,7 +442,6 @@
"本地": "本地",
"暂未配置数据源": "暂未配置数据源",
"需要先配置数据源后才可进行登录配置,当前支持使用以下方式进行登录": "需要先配置数据源后才可进行登录配置,当前支持使用以下方式进行登录",
"配置数据源": "配置数据源",
"仅对本地数据源启用": "仅对本地数据源启用",
"登录详情": "登录详情",
"配置成功": "配置成功",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
<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">
<header>
<bk-button text theme="primary" @click="showUpdateRecord">
<i class="user-icon icon-lishijilu" />
{{ $t('数据更新记录') }}
</bk-button>
</header> -->
</header>
<bk-table
class="user-info-table"
:data="tableData"
Expand Down Expand Up @@ -92,20 +91,25 @@
:is-show="dialogConfig.isShow"
@closed="dialogConfig.isShow = false">
<bk-table
v-bkloading="{ loading: dialogConfig.loading, zIndex: 9 }"
class="update-record-table"
:data="dialogConfig.list"
:border="['outer']"
show-overflow-tooltip
remote-pagination
:pagination="pagination"
@page-limit-change="pageLimitChange"
@page-value-change="pageCurrentChange"
>
<template #empty>
<Empty
:is-data-empty="dialogConfig.isDataEmpty"
:is-data-error="dialogConfig.isDataError"
@handle-update="fetchDataUpdateRecord"
@handle-update="fetchUpdateRecord"
/>
</template>
<bk-table-column type="expand" width="60"></bk-table-column>
<template #expandRow="row">
<!-- <bk-table-column type="expand" width="60"></bk-table-column> -->
<!-- <template #expandRow="row">
<div class="expand-wrapper">
<div class="expand-item">
<span class="w-[60px] text-[#EA3636]">{{ $t('删除') }}:</span>
Expand Down Expand Up @@ -171,35 +175,31 @@
</div>
</div>
</div>
</template>
<bk-table-column prop="updated_at" :label="$t('时间')" width="160">
<template #default="{ row }">
<span>{{ row.updated_at }}</span>
</template>
</bk-table-column>
<bk-table-column prop="source_tenant" :label="$t('源租户')"></bk-table-column>
</template> -->
<bk-table-column prop="start_at" :label="$t('时间')" width="160"></bk-table-column>
<bk-table-column prop="source_tenant_name" :label="$t('源租户')"></bk-table-column>
<bk-table-column :label="$t('更新内容')" width="480">
<template #default="{ row }">
<bk-tag theme="danger">
{{ $t('删除') }}:
<i class="bk-sq-icon icon-personal-user" />
<span>{{ row.delete?.users?.length }}</span>
<span>{{ row.content?.delete?.user }}</span>
<i class="bk-sq-icon icon-file-close" />
<span>{{ row.delete?.departments?.length }}</span>
<span>{{ row.content?.delete?.department }}</span>
</bk-tag>
<bk-tag theme="warning">
{{ $t('变更') }}:
<i class="bk-sq-icon icon-personal-user" />
<span>{{ row.change?.users?.length }}</span>
<span>{{ row.content?.update?.user }}</span>
<i class="bk-sq-icon icon-file-close" />
<span>{{ row.change?.departments?.length }}</span>
<span>{{ row.content?.update?.department }}</span>
</bk-tag>
<bk-tag theme="success">
{{ $t('新增') }}:
<i class="bk-sq-icon icon-personal-user" />
<span>{{ row.add?.users?.length }}</span>
<span>{{ row.content?.create?.user }}</span>
<i class="bk-sq-icon icon-file-close" />
<span>{{ row.add?.departments?.length }}</span>
<span>{{ row.content?.create?.department }}</span>
</bk-tag>
</template>
</bk-table-column>
Expand All @@ -215,7 +215,7 @@ import OperationDetails from './OperationDetails.vue';
import Empty from '@/components/Empty.vue';
import { useTableMaxHeight } from '@/hooks';
import { getFromStrategies, putFromStrategiesStatus } from '@/http';
import { getCollaborationSyncRecords, getFromStrategies, putFromStrategiesStatus } from '@/http';
import { t } from '@/language/index';
import { useMainViewStore, useUser } from '@/store';
import { dataSourceStatus } from '@/utils';
Expand Down Expand Up @@ -296,23 +296,62 @@ const dialogConfig = reactive({
list: [],
isDataEmpty: false,
isDataError: false,
loading: false,
});
// 一期不做
// const handleUpdateRecord = async () => {
// try {
// dialogConfig.isShow = true;
// dialogConfig.isDataEmpty = false;
// dialogConfig.isDataError = false;
// setTimeout(() => {
// dialogConfig.list = [];
// }, 1000);
// } catch (error) {
// dialogConfig.isDataError = true;
// } finally {
// dialogConfig.isShow = false;
// }
// };
const pagination = reactive({
current: 1,
count: 0,
limit: 10,
});
// 数据更新记录
const showUpdateRecord = () => {
dialogConfig.isShow = true;
fetchUpdateRecord();
};
const fetchUpdateRecord = async () => {
try {
dialogConfig.loading = true;
dialogConfig.isDataEmpty = false;
dialogConfig.isDataError = false;
const res = await getCollaborationSyncRecords({
page: pagination.current,
pageSize: pagination.limit,
});
const { count, results } = res.data;
pagination.count = count;
dialogConfig.isDataEmpty = count === 0;
dialogConfig.list = results;
dialogConfig.list?.forEach((item) => {
const { department, user } = item.summary;
item.content = {
create: { department: department.create, user: user.create },
delete: { department: department.delete, user: user.delete },
update: { department: department.update, user: user.update },
};
});
} catch (error) {
dialogConfig.isDataError = true;
} finally {
dialogConfig.loading = false;
}
};
const pageLimitChange = (limit: number) => {
pagination.limit = limit;
pagination.current = 1;
fetchUpdateRecord();
};
const pageCurrentChange = (current: number) => {
pagination.current = current;
fetchUpdateRecord();
};
const handleDetails = (item, type) => {
detailsConfig.isShow = true;
Expand Down Expand Up @@ -485,6 +524,11 @@ const updateList = () => {
}
.update-record-table {
:deep(.bk-table-footer) {
padding: 0 15px;
background: #fff;
}
.expand-wrapper {
max-height: 300px;
overflow-y: auto;
Expand Down
1 change: 1 addition & 0 deletions src/pages/src/views/setting/data-source/ConfigList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ const confirmImportUsers = async () => {
if (res.data.data.status === 'success') {
importDialog.isShow = false;
InfoBox({
width: 450,
infoType: 'success',
title: t('导入成功'),
confirmText: t('查看组织架构'),
Expand Down

0 comments on commit b7c53e1

Please sign in to comment.