Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 补充操作类型、对象 #2006

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/pages/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -641,5 +641,30 @@
"修改用户邮箱": "Modify User Email",
"修改用户电话号码": "Modify User Phone Number",
"删除租户用户": "Delete Tenant User",
"删除协同租户用户": "Delete Collaborative Tenant User"
"删除协同租户用户": "Delete Collaborative Tenant User",
"数据源部门": "Data Source Department",
"租户部门": "Tenant Department",
"租户": "Tenant",
"虚拟用户": "Virtual User",
"创建数据源部门": "Create Data Source Department",
"创建部门-父部门关系": "Create Department-Parent Department Relationship",
"修改数据源部门": "Modify Data Source Department",
"修改部门-父部门关系": "Modify Department-Parent Department Relationship",
"删除数据源部门": "Delete Data Source Department",
"删除部门-父部门关系": "Delete Department-Parent Department Relationship",
"创建租户部门": "Create Tenant Department",
"创建协同租户部门": "Create Collaborative Tenant Department",
"修改租户部门": "Modify Tenant Department",
"删除租户部门": "Delete Tenant Department",
"删除协同租户部门": "Delete Collaborative Tenant Department",
"创建租户": "Create Tenant",
"创建租户实名管理员": "Create Tenant Real-name Manager",
"修改租户信息": "Modify Tenant Information",
"修改租户状态": "Modify Tenant Status",
"修改租户账户有效期配置": "Modify Tenant Account Validity Period Configuration",
"删除租户": "Delete Tenant",
"删除租户实名管理员": "Delete Tenant Real-name Manager",
"创建虚拟用户": "Create Virtual User",
"修改虚拟用户": "Modify Virtual User",
"删除虚拟用户": "Delete Virtual User"
}
27 changes: 26 additions & 1 deletion src/pages/src/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -641,5 +641,30 @@
"修改用户邮箱": "修改用户邮箱",
"修改用户电话号码": "修改用户电话号码",
"删除租户用户": "删除租户用户",
"删除协同租户用户": "删除协同租户用户"
"删除协同租户用户": "删除协同租户用户",
"数据源部门": "数据源部门",
"租户部门": "租户部门",
"租户": "租户",
"虚拟用户": "虚拟用户",
"创建数据源部门": "创建数据源部门",
"创建部门-父部门关系": "创建部门-父部门关系",
"修改数据源部门": "修改数据源部门",
"修改部门-父部门关系": "修改部门-父部门关系",
"删除数据源部门": "删除数据源部门",
"删除部门-父部门关系": "删除部门-父部门关系",
"创建租户部门": "创建租户部门",
"创建协同租户部门": "创建协同租户部门",
"修改租户部门": "修改租户部门",
"删除租户部门": "删除租户部门",
"删除协同租户部门": "删除协同租户部门",
"创建租户": "创建租户",
"创建租户实名管理员": "创建租户实名管理员",
"修改租户信息": "修改租户信息",
"修改租户状态": "修改租户状态",
"修改租户账户有效期配置": "修改租户账户有效期配置",
"删除租户": "删除租户",
"删除租户实名管理员": "删除租户实名管理员",
"创建虚拟用户": "创建虚拟用户",
"修改虚拟用户": "修改虚拟用户",
"删除虚拟用户": "删除虚拟用户"
}
92 changes: 59 additions & 33 deletions src/pages/src/views/operations-history/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/>
</bk-form-item>
<bk-form-item class="inline-block ml-[20px]" :label="$t('操作类型')">
<bk-select class="items-select" v-model="formData.operation" @change="handleOperationChange">
<bk-select class="items-select" v-model="formData.operation">
<bk-option
v-for="item in curOperationOptions"
:key="item.key"
Expand All @@ -35,7 +35,7 @@
</bk-select>
</bk-form-item>
<bk-form-item class="inline-block ml-[20px]" :label="$t('操作对象')">
<bk-select class="items-select" v-model="formData.object_type" @change="handleOperationTypeChange">
<bk-select class="items-select" v-model="formData.object_type">
<bk-option
v-for="item in curOperationType"
:key="item.key"
Expand All @@ -54,7 +54,7 @@
class="w-[88px] h-[32px]"
theme="primary"
:loading="isLoading"
@click="initAudit"
@click="() => handleFetchAudit('search')"
>
{{ $t('查询') }}
</bk-button>
Expand Down Expand Up @@ -107,6 +107,7 @@
@page-limit-change="pageLimitChange"
@page-value-change="pageCurrentChange"
:show-overflow-tooltip="true"
:max-height="505"
>
<bk-table-column :label="$t('操作人')" prop="creator" width="100">
<template #default="{ row }">
Expand Down Expand Up @@ -141,7 +142,7 @@

<script setup lang="ts">
import dayjs from 'dayjs';
import { computed, onMounted, reactive, ref } from 'vue';
import { computed, onMounted, reactive, ref, watch } from 'vue';

import { getCurrentOperationOptions, operationType } from './operations';

Expand Down Expand Up @@ -172,13 +173,30 @@ const isFold = reactive({
const formRef = ref();
const isLoading = ref(false);
const tableData = ref([]);
const formData = reactive({

interface SearchParams {
creator: string,
operation: string,
object_type: string,
object_name: string,
created_at: string,
}

const formData = reactive<SearchParams>({
creator: '', // 操作人
operation: '', // 操作类型
object_type: '', // 操作对象
object_name: '', // 操作实例
created_at: '', // 操作时间
});
const curSearchParams: SearchParams = {
creator: '', // 操作人
operation: '', // 操作类型
object_type: '', // 操作对象
object_name: '', // 操作实例
created_at: '', // 操作时间
};

const pagination = reactive({
current: 1,
count: 0,
Expand Down Expand Up @@ -214,18 +232,24 @@ const fetchRealUsers = (value: string) => {
});
};


// 获取audit数据
const initAudit = async () => {
const handleFetchAudit = async (type = '') => {
try {
isLoading.value = true;
if (type === 'search') {
pagination.count = 0;
pagination.current = 1;
curSearchParams.operation = formData.operation;
curSearchParams.object_type = formData.object_type;
curSearchParams.object_name = formData.object_name;
curSearchParams.creator = formData.creator;
curSearchParams.created_at = formData.created_at ? dayjs(formData.created_at).format('YYYY-MM-DD HH:mm:ss') : '';
}
const params = {
page: pagination.current,
pageSize: pagination.limit,
operation: formData.operation,
object_type: formData.object_type,
object_name: formData.object_name,
creator: formData.creator,
created_at: formData.created_at ? dayjs(formData.created_at).format('YYYY-MM-DD HH:mm:ss') : '',
...curSearchParams,
};
const res = await getAudit(params);
pagination.count = res.data?.count;
Expand All @@ -240,13 +264,13 @@ const initAudit = async () => {
// pageSize更改回调方法
const pageLimitChange = (pageSize: number) => {
pagination.limit = pageSize;
initAudit();
handleFetchAudit();
};

// page更改回调方法
const pageCurrentChange = (page: number) => {
pagination.current = page;
initAudit();
handleFetchAudit();
};

// 折叠button处理
Expand Down Expand Up @@ -281,9 +305,9 @@ const curOperationOptions = computed(() => {
return operationOptions;
});

// 基于relyKey筛选后的操作对象
// 基于relyKey筛选后的操作对象,操作对象选项不完全被relyKey限制,除非操作类型有数据
const curOperationType = computed(() => {
if (relyKey.value) {
if (relyKey.value && formData.operation !== '') {
return operationType.filter((type: {key: string, label: string}) => type.key === relyKey.value);
}
return operationType;
Expand All @@ -301,30 +325,32 @@ const getOperationLabel = (key: string) => {
return curOperation ? curOperation.label : '--';
};

// 操作类型选择回调方法
const handleOperationChange = (value: string) => {
const curRelyKey = (curOperationOptions.value.find(option => option.key === value))?.relyKey;
if (curRelyKey) {
// 更新relyKey
relyKey.value = curRelyKey;
// 同步操作对象数据
formData.object_type = curRelyKey;
} else if (formData.object_type === '') {
// 若操作对象此时未选择,可以清空relyKey
relyKey.value = null;
// 监听操作类型,若操作对象此时未选择,可以清空relyKey
watch(() => formData.operation, (value) => {
if (value === '' && formData.object_type === '') {
relyKey.value = '';
} else {
const curRelyKey = (curOperationOptions.value.find(option => option.key === value))?.relyKey;
if (curRelyKey) {
// 更新relyKey
relyKey.value = curRelyKey;
// 同步操作对象数据
formData.object_type = curRelyKey;
}
}
};
});

// 操作对象选择回调方法
const handleOperationTypeChange = (value: string) => {
if (formData.operation === '') {
// 若操作类型此时未选择,可以清空relyKey
// 监听操作对象,若操作类型此时未选择,可以清空relyKey
watch(() => formData.object_type, (value) => {
if (value === '' && formData.operation === '') {
relyKey.value = '';
} else if (value) {
relyKey.value = value;
}
};
});

onMounted(() => {
initAudit();
handleFetchAudit();
initCreator();
});

Expand Down
51 changes: 51 additions & 0 deletions src/pages/src/views/operations-history/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,41 @@ export const operationMap = {
delete_tenant_user: t('删除租户用户'),
delete_collaboration_tenant_user: t('删除协同租户用户'),
},
data_source_department: {
create_data_source_department: t('创建数据源部门'),
create_parent_department: t('创建部门-父部门关系'),

modify_data_source_department: t('修改数据源部门'),
modify_parent_department: t('修改部门-父部门关系'),

delete_data_source_department: t('删除数据源部门'),
delete_parent_department: t('删除部门-父部门关系'),
},
tenant_department: {
create_tenant_department: t('创建租户部门'),
create_collaboration_tenant_department: t('创建协同租户部门'),

modify_tenant_department: t('修改租户部门'),
delete_tenant_department: t('删除租户部门'),

delete_collaboration_tenant_department: t('删除协同租户部门'),
},
tenant: {
create_tenant: t('创建租户'),
create_tenant_real_manager: t('创建租户实名管理员'),

modify_tenant: t('修改租户信息'),
modify_tenant_status: t('修改租户状态'),
modify_tenant_account_validity_period_config: t('修改租户账户有效期配置'),

delete_tenant: t('删除租户'),
delete_tenant_real_manager: t('删除租户实名管理员'),
},
virtual_user: {
create_virtual_user: t('创建虚拟用户'),
modify_virtual_user: t('修改虚拟用户'),
delete_virtual_user: t('删除虚拟用户'),
},
};

// eslint-disable-next-line @typescript-eslint/naming-convention
Expand All @@ -61,6 +96,22 @@ export const operationType = [
key: 'tenant_user',
label: t('租户用户'),
},
{
key: 'data_source_department',
label: t('数据源部门'),
},
{
key: 'tenant_department',
label: t('租户部门'),
},
{
key: 'tenant',
label: t('租户'),
},
{
key: 'virtual_user',
label: t('虚拟用户'),
},
];

// 展开operationMap子项,获取操作类型所有下拉项
Expand Down
Loading