Skip to content

Commit

Permalink
Merge branch 'TencentBlueKing:main' into tenant-yzygyin
Browse files Browse the repository at this point in the history
  • Loading branch information
yzygyin authored Apr 29, 2024
2 parents 9e3b66d + 20c37c5 commit fe4454e
Show file tree
Hide file tree
Showing 38 changed files with 9,321 additions and 7,958 deletions.
6 changes: 3 additions & 3 deletions src/pages/bk.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ module.exports = {
open: true,
replaceStatic: true,
outputAssetsDirName: '',
https: true,

// webpack config 配置
configureWebpack() {
return {
devServer: {
setupMiddlewares: mockServer,
https: true,
proxy: {
proxy: [{
'/api': {
target: process.env.BK_AJAX_BASE_URL,
changeOrigin: true,
secure: false,
},
},
}],
client: {
overlay: false,
},
Expand Down
8 changes: 4 additions & 4 deletions src/pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
"vue-router": "^4.1.6"
},
"devDependencies": {
"@blueking/babel-preset-bk": "^2.1.0-beta7",
"@blueking/cli-service-webpack": "0.0.0-beta.109",
"@blueking/eslint-config-bk": "2.1.0-beta.12",
"@blueking/stylelint-config-bk": "^2.1.0-beta.9",
"@blueking/babel-preset-bk": "^2.1.0-beta.11",
"@blueking/cli-service-webpack": "^0.0.1",
"@blueking/eslint-config-bk": "^2.1.0-beta.22",
"@blueking/stylelint-config-bk": "^2.1.0-beta.10",
"@types/node": "^20.5.1",
"enhanced-resolve": "^5.10.0",
"eslint-plugin-import": "^2.28.1",
Expand Down
9 changes: 8 additions & 1 deletion src/pages/src/components/layouts/MainBreadcrumbs.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="main-breadcrumbs">
<div :class="['main-breadcrumbs', { 'hidden-box-shadow': hiddenBoxShadow }]">
<slot>
<i
v-if="showBack"
Expand Down Expand Up @@ -31,6 +31,9 @@ const current = computed(() => store.breadCrumbsTitle || route.meta.navName);
* back control
*/
const showBack = computed(() => route.meta.showBack);
const hiddenBoxShadow = computed(() => route.meta.hiddenBoxShadow);
const handleBack = () => {
const { back } = window.history.state;
if (back) {
Expand Down Expand Up @@ -75,4 +78,8 @@ const handleBack = () => {
margin-right: 4px;
}
}
.hidden-box-shadow {
box-shadow: none !important;
}
</style>
26 changes: 21 additions & 5 deletions src/pages/src/components/layouts/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
class="main-container__view user-scroll-y user-scroll-x"
:class="[{
'pd-24': mainViewStore.hasPadding,
'has-breadcrumbs': !mainViewStore.customBreadcrumbs
'has-breadcrumbs': !mainViewStore.customBreadcrumbs,
'has-alert': userStore.showAlert,
'overflow-hidden': hiddenBoxShadow,
}]">
<RouterView />
</div>
Expand All @@ -23,18 +25,22 @@
</div>
</template>

<script setup lang="ts">
<script setup lang="ts"> import { computed } from 'vue';
import MainBreadcrumbs from './MainBreadcrumbs.vue';
import { useMainViewStore, useMenu } from '@/store';
import { useRoute } from 'vue-router';
import { useMainViewStore, useMenu, useUser } from '@/store';
const menuStore = useMenu();
const mainViewStore = useMainViewStore();
const userStore = useUser();
const route = useRoute();
const hiddenBoxShadow = computed(() => route.meta.hiddenBoxShadow);
</script>

<style lang="less">
.main-container {
display: flex;
height: calc(100vh - 52px);
}
.main-container-content {
Expand All @@ -50,10 +56,20 @@ const mainViewStore = useMainViewStore();
background-color: #f5f7fa;
&.has-breadcrumbs {
height: calc(100% - 52px);
height: calc(100vh - 104px);
}
}
.has-alert {
&.has-breadcrumbs {
height: calc(100vh - 144px);
}
}
.overflow-hidden {
overflow: hidden;
}
.main-menu {
position: relative;
z-index: 101;
Expand Down
67 changes: 36 additions & 31 deletions src/pages/src/hooks/useOrganizationAside.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { ref, watch } from 'vue';
import { ref } from 'vue';

import { getDepartmentsList } from '@/http/organizationFiles';
import useAppStore from '@/store/app';
Expand Down Expand Up @@ -43,25 +43,26 @@ export default function useOrganizationAside(currentTenant: any) {
};
};


const findNode = (item: IOrg, id: number) => {
if (item.id === id) {
return item;
}
if (item.children) {
for (const child of item.children) {
const result = findNode(child, id);
if (result) {
return result;
}
}
}
return null;
};

/**
* 添加子组织
*/
const addNode = (id, node) => {
const findNode = (item: IOrg, id: number) => {
if (item.id === id) {
return item;
}
if (item.children) {
for (const child of item.children) {
const result = findNode(child, id);
if (result) {
return result;
}
}
}
return null;
};

for (const item of treeData.value) {
const current = findNode(item, id);
if (current) {
Expand All @@ -75,25 +76,28 @@ export default function useOrganizationAside(currentTenant: any) {
};

/**
* 重命名
* @param node
* 删除组织
*/
const updateNode = (node: IOrg) => {
const findNode = (item: IOrg, id: number) => {
if (item.id === id) {
return item;
const deleteDept = (id, list) => {
for (let i = 0; i < list.length; i++) {
if (list[i].id === id) {
list.splice(i, 1);
break;
}
if (item.children) {
for (const child of item.children) {
const result = findNode(child, id);
if (result) {
return result;
}
}
if (list[i].children) {
deleteDept(id, list[i].children);
}
return null;
};
}
};
const deleteNode = (id) => {
deleteDept(id, treeData.value);
};

/**
* 重命名
* @param node
*/
const updateNode = (node: IOrg) => {
for (const item of treeData.value) {
const current = findNode(item, node.id);
if (current) {
Expand All @@ -108,6 +112,7 @@ export default function useOrganizationAside(currentTenant: any) {
getRemoteData,
getPrefixIcon,
addNode,
deleteNode,
updateNode,
};
};
28 changes: 22 additions & 6 deletions src/pages/src/http/organizationFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export const putTenantOrganizationDetails = (id: string, params: UpdateTenantPar
*/
export const getTenantDepartments = (id: string) => http.get(`/api/v1/web/tenant-organization/departments/${id}/children/`);

/**
* 租户下部门单个用户详情
*/
export const getTenantOrganizationUsers = (id: string) => http.get(`/api/v1/web/tenant-organization/users/${id}/`);

/**
* 租户下部门下用户列表
Expand Down Expand Up @@ -62,16 +58,36 @@ export const getCurrentTenant = () => http.get(`${prefix}/current-tenant/`);
export const getDepartmentsList = (deptId: number, id: string) => http.get(`${prefix}/tenants/${id}/departments/`, { parent_department_id: deptId });

/**
* 创建租户部门
* 创建租户组织
*/
export const addDepartment = (id: string, params: any) => http.post(`${prefix}/tenants/${id}/departments/`, params);

/**
* 更新租户部门
* 删除租户组织
*/
export const deleteDepartment = (id: string) => http.delete(`${prefix}/tenants/departments/${id}/`);

/**
* 更新租户组织
*/
export const updateDepartment = (id: string, params: any) => http.put(`${prefix}/tenants/departments/${id}/`, params);

/**
* 获取当前租户的协作租户信息
*/
export const getCollaboration = () => http.get(`${prefix}/collaborative-tenants/`);

/**
* 搜索组织
*/
export const searchOrganization = (params: any) => http.get(`${prefix}/tenants/departments/`, params);

/**
* 搜索用户
*/
export const searchUser = (params: any) => http.get(`${prefix}/tenants/users/`, params);

/**
* 租户下部门单个用户详情
*/
export const getOrganizationUsers = (id: string) => http.get(`${prefix}/tenants/users/${id}/`);
6 changes: 6 additions & 0 deletions src/pages/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,11 @@
"重命名": "Rename",
"协同租户": "Collaboration Tenant",
"协同配置": "Collaboration Configuration",
"用户": "User",
"暂无搜索结果": "No search results",
"已停用": "Disabled",
"删除组织": "Delete organization",
"确认删除该组织?": "Delete this organization?",
"删除该组织同时会删除其下用户与子组织,请谨慎操作": "Deleting this organization will also delete its users and sub-organizations. Please proceed with caution",
"新增": "Add"
}
6 changes: 6 additions & 0 deletions src/pages/src/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,11 @@
"重命名": "重命名",
"协同租户": "协同租户",
"协同配置": "协同配置",
"用户": "用户",
"暂无搜索结果": "暂无搜索结果",
"已停用": "已停用",
"删除组织": "删除组织",
"确认删除该组织?": "确认删除该组织?",
"删除该组织同时会删除其下用户与子组织,请谨慎操作": "删除该组织同时会删除其下用户与子组织,请谨慎操作",
"新增": "新增"
}
1 change: 1 addition & 0 deletions src/pages/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default createRouter({
routeParentName: 'setting',
navName: t('跨租户协同'),
isMenu: true,
hiddenBoxShadow: true,
},
component: () => import('@/views/setting/cross-tenant-collaboration/index.vue'),
},
Expand Down
1 change: 1 addition & 0 deletions src/pages/src/router/router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ declare module 'vue-router' {
navName?: string, // 设置面包屑 name
isMenu?: boolean, // 判断是否为 bk-menu 导航,若是则不显示返回按钮
showBack?: boolean, // 用于判断是否显示面包屑返回按钮
hiddenBoxShadow?: boolean, // 是否隐藏 box-shadow
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/pages/src/store/app.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { defineStore } from 'pinia';
import { computed, ref } from 'vue';
import { ref } from 'vue';


export default defineStore('app', () => {
const currentOrg = ref({});

const isSearchTree = ref(false);

const reloadIndex = ref(1);

return {
currentOrg,
isSearchTree,
reloadIndex,
};
});
4 changes: 4 additions & 0 deletions src/pages/src/store/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ export const useUser = defineStore('user', {
username: '',
avatar_url: '',
},
showAlert: false, // 消息通知显示状态
}),
actions: {
setUser(user: IUser) {
this.user = user;
},
setShowAlert(status: boolean) {
this.showAlert = status;
},
},
});
Loading

0 comments on commit fe4454e

Please sign in to comment.