Skip to content

Commit

Permalink
refactor: 解决code conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
neronkl committed Sep 5, 2023
2 parents 0e03153 + 5bfa5e5 commit 3ffbceb
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 15 deletions.
6 changes: 5 additions & 1 deletion src/pages/src/http/dataSourceFiles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import http from './fetch';
import type {
DataSourceUsersParams,
DataSourceUsersResult,
NewDataSourceUserParams,
PutDataSourceUserParams,
Expand All @@ -8,7 +9,10 @@ import type {
/**
* 数据源用户信息列表
*/
export const getDataSourceUsers = (id: string, username: string): Promise<DataSourceUsersResult> => http.get(`/api/v1/web/data-sources/${id}/users/?username=${username}`);
export const getDataSourceUsers = (params: DataSourceUsersParams): Promise<DataSourceUsersResult> => {
const { id, username, page, pageSize } = params;
return http.get(`/api/v1/web/data-sources/${id}/users/?username=${username}&page=${page}&page_size=${pageSize}`);
};

/**
* 新建数据源用户
Expand Down
10 changes: 10 additions & 0 deletions src/pages/src/http/types/dataSourceFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@ export interface PutDataSourceUserParams {
department_ids?: [],
leader_ids?: [],
}

/**
* 数据源用户信息列表参数
*/
export interface DataSourceUsersParams {
id: string,
username: string,
page: number,
pageSize: number,
}
41 changes: 40 additions & 1 deletion src/pages/src/views/data-source/local-details/UserInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
class="user-info-table"
:data="users"
:border="['outer']"
remote-pagination
:pagination="pagination"
show-overflow-tooltip
@page-limit-change="pageLimitChange"
@page-value-change="pageCurrentChange"
>
<template #empty>
<Empty
Expand Down Expand Up @@ -138,8 +142,12 @@ defineProps({
type: Boolean,
default: false,
},
pagination: {
type: Object,
default: () => ({}),
},
});
const emit = defineEmits(['updateUsers']);
const emit = defineEmits(['updateUsers', 'updatePageLimit', 'updatePageCurrent']);
const editLeaveBefore = inject('editLeaveBefore');
const searchVal = ref('');
const detailsConfig = reactive({
Expand Down Expand Up @@ -251,6 +259,13 @@ const handleClear = () => {
searchVal.value = '';
emit('updateUsers', searchVal.value);
};
const pageLimitChange = (limit) => {
emit('updatePageLimit', limit);
};
const pageCurrentChange = (current) => {
emit('updatePageCurrent', current);
};
</script>

<style lang="less" scoped>
Expand All @@ -269,6 +284,30 @@ const handleClear = () => {
width: 320px;
}
}
:deep(.user-info-table) {
.bk-table-head {
table thead th {
text-align: center;
}
.table-head-settings {
border-right: none;
}
}
.bk-table-footer {
padding: 0 15px;
background: #fff;
}
.account-status-icon {
width: 16px;
height: 16px;
margin-right: 5px;
vertical-align: middle;
}
}
}
.details-edit-wrapper {
Expand Down
48 changes: 35 additions & 13 deletions src/pages/src/views/data-source/local-details/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
:is-data-empty="state.isDataEmpty"
:is-empty-search="state.isEmptySearch"
:is-data-error="state.isDataError"
@updateUsers="updateUsers" />
:pagination="state.pagination"
@updateUsers="updateUsers"
@updatePageLimit="updatePageLimit"
@updatePageCurrent="updatePageCurrent" />
<PswInfo v-else />
</bk-tab-panel>
</bk-tab>
Expand Down Expand Up @@ -73,20 +76,32 @@ const state = reactive({
isDataError: false,
// 表格请求结果为空
isDataEmpty: false,
pagination: {
current: 1,
count: 0,
limit: 10,
},
});
const getUsers = async (value?: string) => {
const params = reactive({
id: currentId.value,
username: '',
page: 1,
pageSize: 10,
});
const getUsers = async () => {
try {
state.isLoading = true;
state.isDataEmpty = false;
state.isEmptySearch = false;
state.isDataError = false;
value = value ? value : '';
const res = await getDataSourceUsers(currentId.value, value);
if (res.data.length === 0) {
value === '' ? state.isDataEmpty = true : state.isEmptySearch = true;
const res = await getDataSourceUsers(params);
if (res.data.count === 0) {
params.username === '' ? state.isDataEmpty = true : state.isEmptySearch = true;
}
state.users = res.data;
state.pagination.count = res.data.count;
state.users = res.data.results;
state.isLoading = false;
} catch (error) {
state.isDataError = true;
Expand All @@ -97,7 +112,19 @@ const getUsers = async (value?: string) => {
getUsers();
const updateUsers = (value: string) => {
getUsers(value);
params.username = value;
getUsers();
};
const updatePageLimit = (limit) => {
state.pagination.limit = limit;
params.pageSize = limit;
getUsers();
};
const updatePageCurrent = (current) => {
state.pagination.current = current;
params.page = current;
getUsers();
};
</script>

Expand All @@ -106,8 +133,3 @@ const updateUsers = (value: string) => {
box-shadow: none;
}
</style>
<style lang="less">
.congfig {
display: flex;
}
</style>

0 comments on commit 3ffbceb

Please sign in to comment.