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 * as orgUrl from '@/api/requrls/setting/system/organizationAndProject';
import * as orgUrl from '@/api/requrls/setting/organizationAndProject';
import { TableQueryParams } from '@/models/common';
import { AddUserToOrgOrProjectParams } from '@/models/setting/systemOrg';
import {
@ -91,3 +91,8 @@ export function createOrUpdateProject(data: CreateOrUpdateSystemProjectParams) {
export function getAllUser() {
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 getOrgOrProjectAdminUrl = '/system/project/user-list';
// 获取项目和组织的总数
export const getOrgAndProjectCountUrl = '/system/organization/total';

View File

@ -23,7 +23,7 @@
<script setup lang="ts">
import { useI18n } from '@/hooks/useI18n';
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 {
value: string[];
@ -100,3 +100,4 @@
}
);
</script>
@/api/modules/setting/organizationAndProject

View File

@ -53,7 +53,7 @@
import { reactive, ref, watchEffect, computed } from 'vue';
import type { FormInstance, ValidatedError } from '@arco-design/web-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 { CreateOrUpdateSystemOrgParams } from '@/models/setting/system/orgAndProject';
@ -119,3 +119,4 @@
});
const isEdit = computed(() => !!props.currentOrganization?.id);
</script>
@/api/modules/setting/organizationAndProject

View File

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

View File

@ -33,7 +33,7 @@
<script lang="ts" setup>
import { useI18n } from '@/hooks/useI18n';
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 MsUserSelector from '@/components/business/ms-user-selector/index.vue';
@ -101,3 +101,4 @@
color: var(--color-text-4);
}
</style>
@/api/modules/setting/organizationAndProject

View File

@ -24,7 +24,7 @@
</template>
<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 useTable from '@/components/pure/ms-table/useTable';
import { useI18n } from '@/hooks/useI18n';
@ -104,3 +104,4 @@
}
);
</script>
@/api/modules/setting/organizationAndProject

View File

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

View File

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

View File

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

View File

@ -33,13 +33,14 @@
</template>
<script lang="ts" setup>
import { ref, onMounted, watch, nextTick } from 'vue';
import { ref, watch, nextTick, onBeforeMount } from 'vue';
import { useI18n } from '@/hooks/useI18n';
import MsCard from '@/components/pure/ms-card/index.vue';
import AddOrganizationModal from './components/addOrganizationModal.vue';
import SystemOrganization from './components/systemOrganization.vue';
import SystemProject from './components/systemProject.vue';
import AddProjectModal from './components/addProjectModal.vue';
import { getOrgAndProjectCount } from '@/api/modules/setting/organizationAndProject';
const { t } = useI18n();
const currentTable = ref('project');
@ -94,13 +95,27 @@
tableSearch();
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(
() => currentTable.value,
() => {
tableSearch();
}
);
onMounted(() => {
onBeforeMount(() => {
tableSearch();
initOrgAndProjectCount();
});
</script>

View File

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

View File

@ -187,6 +187,7 @@
item.indeterminate = false;
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;
};
const handleAddUserModalCancel = () => {
fetchData();
userVisible.value = false;
};
watchEffect(() => {