feat(系统设置): 组织与项目数量&代码结构调整

This commit is contained in:
RubyLiu 2023-08-23 14:30:04 +08:00 committed by 刘瑞斌
parent 7bb1602c5c
commit dbbac51244
14 changed files with 58 additions and 23 deletions

View File

@ -1,5 +1,5 @@
import MSR from '@/api/http/index'; import MSR from '@/api/http/index';
import * as orgUrl from '@/api/requrls/setting/system/organizationAndProject'; import * as orgUrl from '@/api/requrls/setting/organizationAndProject';
import { TableQueryParams } from '@/models/common'; import { TableQueryParams } from '@/models/common';
import { AddUserToOrgOrProjectParams } from '@/models/setting/systemOrg'; import { AddUserToOrgOrProjectParams } from '@/models/setting/systemOrg';
import { import {
@ -91,3 +91,8 @@ export function createOrUpdateProject(data: CreateOrUpdateSystemProjectParams) {
export function getAllUser() { export function getAllUser() {
return MSR.get({ url: orgUrl.getOrgOrProjectAdminUrl }); return MSR.get({ url: orgUrl.getOrgOrProjectAdminUrl });
} }
// 获取项目和组织的总数
export function getOrgAndProjectCount() {
return MSR.get({ url: orgUrl.getOrgAndProjectCountUrl });
}

View File

@ -52,3 +52,6 @@ export const getEnableProjectUrl = '/system/project/enable/';
export const getDisableProjectUrl = '/system/project/disable/'; export const getDisableProjectUrl = '/system/project/disable/';
// 获取组织或项目的管理员 // 获取组织或项目的管理员
export const getOrgOrProjectAdminUrl = '/system/project/user-list'; export const getOrgOrProjectAdminUrl = '/system/project/user-list';
// 获取项目和组织的总数
export const getOrgAndProjectCountUrl = '/system/organization/total';

View File

@ -23,7 +23,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { ref, onMounted, watch } from 'vue'; import { ref, onMounted, watch } from 'vue';
import { getUserByOrganizationOrProject, getAllUser } from '@/api/modules/setting/system/organizationAndProject'; import { getUserByOrganizationOrProject, getAllUser } from '@/api/modules/setting/organizationAndProject';
export interface MsUserSelectorProps { export interface MsUserSelectorProps {
value: string[]; value: string[];
@ -100,3 +100,4 @@
} }
); );
</script> </script>
@/api/modules/setting/organizationAndProject

View File

@ -53,7 +53,7 @@
import { reactive, ref, watchEffect, computed } from 'vue'; import { reactive, ref, watchEffect, computed } from 'vue';
import type { FormInstance, ValidatedError } from '@arco-design/web-vue'; import type { FormInstance, ValidatedError } from '@arco-design/web-vue';
import MsUserSelector from '@/components/business/ms-user-selector/index.vue'; import MsUserSelector from '@/components/business/ms-user-selector/index.vue';
import { createOrUpdateOrg } from '@/api/modules/setting/system/organizationAndProject'; import { createOrUpdateOrg } from '@/api/modules/setting/organizationAndProject';
import { Message } from '@arco-design/web-vue'; import { Message } from '@arco-design/web-vue';
import { CreateOrUpdateSystemOrgParams } from '@/models/setting/system/orgAndProject'; import { CreateOrUpdateSystemOrgParams } from '@/models/setting/system/orgAndProject';
@ -119,3 +119,4 @@
}); });
const isEdit = computed(() => !!props.currentOrganization?.id); const isEdit = computed(() => !!props.currentOrganization?.id);
</script> </script>
@/api/modules/setting/organizationAndProject

View File

@ -85,7 +85,7 @@
import { reactive, ref, watchEffect, computed } from 'vue'; import { reactive, ref, watchEffect, computed } from 'vue';
import type { FormInstance, ValidatedError } from '@arco-design/web-vue'; import type { FormInstance, ValidatedError } from '@arco-design/web-vue';
import MsUserSelector from '@/components/business/ms-user-selector/index.vue'; import MsUserSelector from '@/components/business/ms-user-selector/index.vue';
import { createOrUpdateProject, getSystemOrgOption } from '@/api/modules/setting/system/organizationAndProject'; import { createOrUpdateProject, getSystemOrgOption } from '@/api/modules/setting/organizationAndProject';
import { Message } from '@arco-design/web-vue'; import { Message } from '@arco-design/web-vue';
import MsIcon from '@/components/pure/ms-icon-font/index.vue'; import MsIcon from '@/components/pure/ms-icon-font/index.vue';
import { CreateOrUpdateSystemProjectParams, SystemOrgOption } from '@/models/setting/system/orgAndProject'; import { CreateOrUpdateSystemProjectParams, SystemOrgOption } from '@/models/setting/system/orgAndProject';
@ -184,3 +184,4 @@
} }
}); });
</script> </script>
@/api/modules/setting/organizationAndProject

View File

@ -33,7 +33,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { reactive, ref, watchEffect, onUnmounted } from 'vue'; import { reactive, ref, watchEffect, onUnmounted } from 'vue';
import { addUserToOrgOrProject } from '@/api/modules/setting/system/organizationAndProject'; import { addUserToOrgOrProject } from '@/api/modules/setting/organizationAndProject';
import { Message, type FormInstance, type ValidatedError } from '@arco-design/web-vue'; import { Message, type FormInstance, type ValidatedError } from '@arco-design/web-vue';
import MsUserSelector from '@/components/business/ms-user-selector/index.vue'; import MsUserSelector from '@/components/business/ms-user-selector/index.vue';
@ -101,3 +101,4 @@
color: var(--color-text-4); color: var(--color-text-4);
} }
</style> </style>
@/api/modules/setting/organizationAndProject

View File

@ -24,7 +24,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { postProjectTableByOrgId } from '@/api/modules/setting/system/organizationAndProject'; import { postProjectTableByOrgId } from '@/api/modules/setting/organizationAndProject';
import { MsTableColumn } from '@/components/pure/ms-table/type'; import { MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
@ -104,3 +104,4 @@
} }
); );
</script> </script>
@/api/modules/setting/organizationAndProject

View File

@ -61,7 +61,7 @@
deleteOrg, deleteOrg,
enableOrDisableOrg, enableOrDisableOrg,
revokeDeleteOrg, revokeDeleteOrg,
} from '@/api/modules/setting/system/organizationAndProject'; } from '@/api/modules/setting/organizationAndProject';
import { TableKeyEnum } from '@/enums/tableEnum'; import { TableKeyEnum } from '@/enums/tableEnum';
import { MsTableColumn } from '@/components/pure/ms-table/type'; import { MsTableColumn } from '@/components/pure/ms-table/type';
import MsTableMoreAction from '@/components/pure/ms-table-more-action/index.vue'; import MsTableMoreAction from '@/components/pure/ms-table-more-action/index.vue';
@ -285,3 +285,4 @@
cursor: pointer; cursor: pointer;
} }
</style> </style>
@/api/modules/setting/organizationAndProject

View File

@ -56,7 +56,7 @@
deleteProject, deleteProject,
enableOrDisableProject, enableOrDisableProject,
revokeDeleteProject, revokeDeleteProject,
} from '@/api/modules/setting/system/organizationAndProject'; } from '@/api/modules/setting/organizationAndProject';
import { TableKeyEnum } from '@/enums/tableEnum'; import { TableKeyEnum } from '@/enums/tableEnum';
import { MsTableColumn } from '@/components/pure/ms-table/type'; import { MsTableColumn } from '@/components/pure/ms-table/type';
import MsTableMoreAction from '@/components/pure/ms-table-more-action/index.vue'; import MsTableMoreAction from '@/components/pure/ms-table-more-action/index.vue';
@ -278,3 +278,4 @@
cursor: pointer; cursor: pointer;
} }
</style> </style>
@/api/modules/setting/organizationAndProject

View File

@ -50,7 +50,7 @@
import { import {
postUserTableByOrgIdOrProjectId, postUserTableByOrgIdOrProjectId,
deleteUserFromOrgOrProject, deleteUserFromOrgOrProject,
} from '@/api/modules/setting/system/organizationAndProject'; } from '@/api/modules/setting/organizationAndProject';
import { MsTableColumn } from '@/components/pure/ms-table/type'; import { MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
@ -161,3 +161,4 @@
} }
); );
</script> </script>
@/api/modules/setting/organizationAndProject

View File

@ -33,13 +33,14 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted, watch, nextTick } from 'vue'; import { ref, watch, nextTick, onBeforeMount } from 'vue';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import MsCard from '@/components/pure/ms-card/index.vue'; import MsCard from '@/components/pure/ms-card/index.vue';
import AddOrganizationModal from './components/addOrganizationModal.vue'; import AddOrganizationModal from './components/addOrganizationModal.vue';
import SystemOrganization from './components/systemOrganization.vue'; import SystemOrganization from './components/systemOrganization.vue';
import SystemProject from './components/systemProject.vue'; import SystemProject from './components/systemProject.vue';
import AddProjectModal from './components/addProjectModal.vue'; import AddProjectModal from './components/addProjectModal.vue';
import { getOrgAndProjectCount } from '@/api/modules/setting/organizationAndProject';
const { t } = useI18n(); const { t } = useI18n();
const currentTable = ref('project'); const currentTable = ref('project');
@ -94,13 +95,27 @@
tableSearch(); tableSearch();
organizationVisible.value = false; organizationVisible.value = false;
}; };
//
const initOrgAndProjectCount = async () => {
try {
const res = await getOrgAndProjectCount();
organizationCount.value = res.organizationTotal;
projectCount.value = res.projectTotal;
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
};
watch( watch(
() => currentTable.value, () => currentTable.value,
() => { () => {
tableSearch(); tableSearch();
} }
); );
onMounted(() => { onBeforeMount(() => {
tableSearch(); tableSearch();
initOrgAndProjectCount();
}); });
</script> </script>

View File

@ -33,7 +33,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { reactive, ref, watchEffect, onUnmounted, onMounted } from 'vue'; import { reactive, ref, watchEffect, onMounted } from 'vue';
import { UserTableItem } from '@/models/setting/usergroup'; import { UserTableItem } from '@/models/setting/usergroup';
import { useUserGroupStore } from '@/store'; import { useUserGroupStore } from '@/store';
import { getUserList, addUserToUserGroup } from '@/api/modules/setting/usergroup'; import { getUserList, addUserToUserGroup } from '@/api/modules/setting/usergroup';
@ -78,30 +78,32 @@
}); });
const handleCancel = () => { const handleCancel = () => {
labelCache.clear();
form.name = [];
emit('cancel'); emit('cancel');
}; };
const handleBeforeOk = () => { const handleBeforeOk = () => {
loading.value = true;
formRef.value?.validate(async (errors: undefined | Record<string, ValidatedError>) => { formRef.value?.validate(async (errors: undefined | Record<string, ValidatedError>) => {
if (errors) { if (errors) {
loading.value = false; return;
return false; }
try {
loading.value = true;
await addUserToUserGroup({ roleId: store.currentId, userIds: form.name });
handleCancel();
} catch (e) {
// eslint-disable-next-line no-console
console.log(e);
} finally {
loading.value = false;
} }
await addUserToUserGroup({ roleId: store.currentId, userIds: form.name });
return true;
}); });
}; };
onMounted(() => { onMounted(() => {
initUserList(); initUserList();
}); });
onUnmounted(() => {
labelCache.clear();
form.name = [];
loading.value = false;
});
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

View File

@ -187,6 +187,7 @@
item.indeterminate = false; item.indeterminate = false;
item.perChecked = allChecked.value ? item.permissions?.map((ele) => ele.id) : []; item.perChecked = allChecked.value ? item.permissions?.map((ele) => ele.id) : [];
}); });
if (!canSave.value) canSave.value = true;
}; };
// //

View File

@ -80,6 +80,7 @@
userVisible.value = true; userVisible.value = true;
}; };
const handleAddUserModalCancel = () => { const handleAddUserModalCancel = () => {
fetchData();
userVisible.value = false; userVisible.value = false;
}; };
watchEffect(() => { watchEffect(() => {