feat: 支持企业级管理模式,项目管理,细分权限

This commit is contained in:
xiaojunnuo
2026-02-10 01:57:11 +08:00
parent d1a8dd7817
commit 37340838b6
35 changed files with 559 additions and 135 deletions
@@ -3,6 +3,8 @@ import { ref } from "vue";
import { getCommonColumnDefine } from "/@/views/certd/access/common";
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
import { useI18n } from "/src/locales";
import { useProjectStore } from "/@/store/project";
import { projectDict } from "../../../dicts";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
@@ -44,6 +46,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
context.typeRef = typeRef;
const commonColumnsDefine = getCommonColumnDefine(crudExpose, typeRef, api);
commonColumnsDefine.type.form.component.disabled = true;
const projectStore = useProjectStore();
return {
typeRef,
crudOptions: {
@@ -58,6 +61,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
search: {
show: true,
initialForm: {
...projectStore.getSearchForm(),
},
},
form: {
wrapper: {
@@ -141,6 +147,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
},
...commonColumnsDefine,
projectId: {
title: t("certd.fields.projectName"),
type: "dict-select",
dict: projectDict,
},
},
},
};
@@ -3,6 +3,8 @@ import { useI18n } from "/src/locales";
import { ref } from "vue";
import { getCommonColumnDefine } from "/@/views/certd/access/common";
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
import { projectDict } from "../dicts";
import { useProjectStore } from "/@/store/project";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
@@ -29,6 +31,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
const typeRef = ref();
const commonColumnsDefine = getCommonColumnDefine(crudExpose, typeRef, api);
const projectStore = useProjectStore();
return {
crudOptions: {
request: {
@@ -42,6 +45,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
confirmMessage: "授权如果已经被使用,可能会导致流水线无法正常运行,请谨慎操作",
},
},
search: {
initialForm: {
...projectStore.getSearchForm(),
},
},
rowHandle: {
width: 200,
buttons: {
@@ -115,6 +123,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
},
...commonColumnsDefine,
projectId: {
title: t("certd.fields.projectName"),
type: "dict-select",
dict: projectDict,
},
},
},
};
@@ -6,6 +6,8 @@ import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, Edi
import { useUserStore } from "/@/store/user";
import { useSettingStore } from "/@/store/settings";
import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status";
import { projectDict } from "../dicts";
import { useProjectStore } from "/@/store/project";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const router = useRouter();
@@ -32,6 +34,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
const projectStore = useProjectStore();
return {
crudOptions: {
settings: {
@@ -64,6 +68,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
},
search: {
initialForm: {
...projectStore.getSearchForm(),
},
formItem: {
labelCol: {
style: {
@@ -195,17 +202,10 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
align: "center",
},
},
createTime: {
title: t("certd.fields.createTime"),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
projectId: {
title: t("certd.fields.projectName"),
type: "dict-select",
dict: projectDict,
},
updateTime: {
title: t("certd.fields.updateTime"),
@@ -10,6 +10,8 @@ import { notification } from "ant-design-vue";
import CertView from "/@/views/certd/pipeline/cert-view.vue";
import { useCertUpload } from "/@/views/certd/pipeline/cert-upload/use";
import { useSettingStore } from "/@/store/settings";
import { useProjectStore } from "/@/store/project";
import { projectDict } from "../../dicts";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
@@ -36,7 +38,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
const router = useRouter();
const settingStore = useSettingStore();
const projectStore = useProjectStore();
const model = useModal();
const viewCert = async (row: any) => {
const cert = await api.GetCert(row.id);
@@ -63,6 +65,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
const expireStatus = route?.query?.expireStatus as string;
const searchInitForm = {
expiresLeft: expireStatus,
...projectStore.getSearchForm(),
};
return {
crudOptions: {
@@ -344,6 +347,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
},
},
projectId: {
title: t("certd.fields.projectName"),
type: "dict-select",
dict: projectDict,
},
},
},
};
@@ -13,6 +13,8 @@ import { useSiteImport } from "/@/views/certd/monitor/site/use";
import { ref } from "vue";
import GroupSelector from "../../basic/group/group-selector.vue";
import { createGroupDictRef } from "../../basic/group/api";
import { useProjectStore } from "/@/store/project";
import { projectDict } from "../../dicts";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const api = siteInfoApi;
@@ -105,6 +107,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
return searchFrom.groupId;
}
}
const projectStore = useProjectStore();
return {
id: "siteMonitorCrud",
crudOptions: {
@@ -289,6 +293,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
// name: "disabled",
// show: true,
// },
search: {
initialForm: {
...projectStore.getSearchForm(),
},
},
columns: {
id: {
title: "ID",
@@ -800,6 +809,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
},
},
projectId: {
title: t("certd.fields.projectName"),
type: "dict-select",
dict: projectDict,
},
},
},
};
@@ -5,6 +5,8 @@ import { forEach, get, merge, set } from "lodash-es";
import { Modal } from "ant-design-vue";
import { mitter } from "/@/utils/util.mitt";
import { useI18n } from "/src/locales";
import { useProjectStore } from "/@/store/project";
import { projectDict } from "../dicts";
export function notificationProvide(api: any) {
provide("notificationApi", api);
@@ -26,6 +28,8 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
},
};
const projectStore = useProjectStore();
provide("getCurrentPluginDefine", () => {
return currentDefine;
});
@@ -247,5 +251,10 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
},
},
} as ColumnCompositionProps,
projectId: {
title: t("certd.fields.projectName"),
type: "dict-select",
dict: projectDict,
},
};
}
@@ -2,6 +2,7 @@ import { ref } from "vue";
import { getCommonColumnDefine } from "./common";
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
import { createNotificationApi } from "/@/views/certd/notification/api";
import { useProjectStore } from "/@/store/project";
const api = createNotificationApi();
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
@@ -26,6 +27,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
const typeRef = ref();
const commonColumnsDefine = getCommonColumnDefine(crudExpose, typeRef, api);
const projectStore = useProjectStore();
return {
crudOptions: {
request: {
@@ -34,6 +36,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
editRequest,
delRequest,
},
search: {
initialForm: {
...projectStore.getSearchForm(),
},
},
form: {
labelCol: {
//固定label宽度
@@ -2,6 +2,7 @@
import { ref } from "vue";
import { getCommonColumnDefine } from "../../common";
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
import { useProjectStore } from "/@/store/project";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { crudBinding } = crudExpose;
@@ -29,6 +30,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
return res;
};
const projectStore = useProjectStore();
const selectedRowKey = ref([props.modelValue]);
const onSelectChange = (changed: any) => {
@@ -54,6 +56,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
search: {
show: false,
initialForm: {
...projectStore.getSearchForm(),
},
},
form: {
labelCol: {
@@ -3,6 +3,8 @@ import { useI18n } from "/src/locales";
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
import { OPEN_API_DOC, openkeyApi } from "./api";
import { useModal } from "/@/use/use-modal";
import { useProjectStore } from "/@/store/project";
import { projectDict } from "../../dicts";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
@@ -26,6 +28,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
const res = await api.AddObj(form);
return res;
};
const projectStore = useProjectStore();
const model = useModal();
return {
crudOptions: {
@@ -37,6 +40,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
search: {
show: false,
initialForm: {
...projectStore.getSearchForm(),
},
},
form: {
labelCol: {
@@ -163,6 +169,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
sorter: true,
},
},
projectId: {
title: t("certd.fields.projectName"),
type: "dict-select",
dict: projectDict,
},
createTime: {
title: t("certd.fields.createTime"),
type: "datetime",
@@ -15,6 +15,7 @@ import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status";
import { useCertViewer } from "/@/views/certd/pipeline/use";
import { useI18n } from "/src/locales";
import { projectDict } from "../dicts";
import { useProjectStore } from "/@/store/project";
export default function ({ crudExpose, context: { selectedRowKeys, openCertApplyDialog } }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const router = useRouter();
@@ -67,6 +68,8 @@ export default function ({ crudExpose, context: { selectedRowKeys, openCertApply
const userStore = useUserStore();
const settingStore = useSettingStore();
const projectStore = useProjectStore();
const DEFAULT_WILL_EXPIRE_DAYS = settingStore.sysPublic.defaultWillExpireDays || settingStore.sysPublic.defaultCertRenewDays || 15;
function onDialogOpen(opt: any) {
@@ -148,7 +151,9 @@ export default function ({ crudExpose, context: { selectedRowKeys, openCertApply
},
},
search: {
col: { span: 3 },
initialForm: {
...projectStore.getSearchForm(),
},
},
form: {
afterSubmit({ form, res, mode }) {
@@ -631,7 +636,7 @@ export default function ({ crudExpose, context: { selectedRowKeys, openCertApply
},
projectId: {
title: t("certd.fields.projectName"),
type: "number",
type: "dict-select",
dict: projectDict,
},
updateTime: {
@@ -1,6 +1,8 @@
import { useI18n } from "/src/locales";
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
import { pipelineGroupApi } from "./api";
import { useProjectStore } from "/@/store/project";
import { projectDict } from "../../dicts";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
@@ -25,6 +27,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
return res;
};
const projectStore = useProjectStore();
return {
crudOptions: {
settings: {
@@ -44,6 +48,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
editRequest,
delRequest,
},
search: {
initialForm: {
...projectStore.getSearchForm(),
},
},
form: {
labelCol: {
//固定label宽度
@@ -127,6 +136,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
width: 400,
},
},
projectId: {
title: t("certd.fields.projectName"),
type: "dict-select",
dict: projectDict,
},
},
},
};
@@ -6,6 +6,8 @@ import createCrudOptionsPipeline from "../crud";
import * as pipelineApi from "../api";
import { useTemplate } from "/@/views/certd/pipeline/template/use";
import { useI18n } from "/@/locales";
import { useProjectStore } from "/@/store/project";
import { projectDict } from "../../dicts";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const api = templateApi;
const { t } = useI18n();
@@ -28,6 +30,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
const res = await api.AddObj(form);
return res;
};
const projectStore = useProjectStore();
const { openCrudFormDialog } = useFormWrapper();
const router = useRouter();
@@ -48,6 +52,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
router.push({ path: "/certd/pipeline/template/edit", query: { templateId: res.id, editMode: "true" } });
},
},
search: {
initialForm: {
...projectStore.getSearchForm(),
},
},
form: {
labelCol: {
//固定label宽度
@@ -232,6 +241,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
},
},
projectId: {
title: t("certd.fields.projectName"),
type: "dict-select",
dict: projectDict,
},
},
},
};
@@ -0,0 +1,11 @@
import { dict } from "@fast-crud/fast-crud";
export const userDict = dict({
url: "/sys/authority/user/getSimpleUsers",
value: "id",
onReady: ({ dict }) => {
for (const item of dict.data) {
item.label = item.nickName || item.username || item.phoneCode + item.mobile;
}
},
});
@@ -6,6 +6,7 @@ import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq,
import { useUserStore } from "/@/store/user";
import { useSettingStore } from "/@/store/settings";
import { Modal } from "ant-design-vue";
import { userDict } from "../dicts";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const router = useRouter();
@@ -80,17 +81,12 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
form: {
component: {},
helper: t("certd.ent.projectNameHelper"),
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 200,
cellRender({ row }) {
return (
<router-link to={`/sys/enterprise/project/detail`} query={{ projectId: row.id }}>
{row.name}
</router-link>
);
return <router-link to={{ path: `/sys/enterprise/project/detail`, query: { projectId: row.id } }}>{row.name}</router-link>;
},
},
},
@@ -125,6 +121,14 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
},
},
adminId: {
title: t("certd.fields.adminId"),
type: "dict-select",
dict: userDict,
column: {
width: 160,
},
},
createTime: {
title: t("certd.createTime"),
type: "datetime",
@@ -6,6 +6,7 @@ import * as api from "./api";
import { useSettingStore } from "/@/store/settings";
import { useUserStore } from "/@/store/user";
import { useI18n } from "/src/locales";
import { userDict } from "../../dicts";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const router = useRouter();
@@ -27,6 +28,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
return res;
};
const projectId = context.projectId;
const userStore = useUserStore();
const settingStore = useSettingStore();
const selectedRowKeys: Ref<any[]> = ref([]);
@@ -60,6 +63,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
minWidth: 200,
fixed: "right",
},
search: {
initialForm: {
projectId,
},
},
columns: {
id: {
title: "ID",
@@ -79,6 +87,10 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
show: false,
},
form: {
value: projectId,
show: false,
},
editForm: {
show: false,
},
column: {
@@ -87,23 +99,18 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
},
userId: {
title: "用户ID",
title: "用户",
type: "dict-select",
dict: dict({
url: "/sys/authority/user/getSimpleUsers",
value: "id",
label: "nickName",
labelBuilder: (item: any) => item.nickName || item.username || item.phoneCode + item.mobile,
}),
dict: userDict,
search: {
show: false,
show: true,
},
form: {
form: {},
editForm: {
show: false,
},
column: {
width: 200,
show: false,
},
},
permission: {
@@ -111,9 +118,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
type: "dict-select",
dict: dict({
data: [
{ label: t("certd.read"), value: "read", color: "cyan" },
{ label: t("certd.write"), value: "write", color: "blue" },
{ label: t("certd.admin"), value: "admin", color: "green" },
{ label: t("certd.ent.permission.read"), value: "read", color: "cyan" },
{ label: t("certd.ent.permission.write"), value: "write", color: "blue" },
{ label: t("certd.ent.permission.admin"), value: "admin", color: "green" },
],
}),
search: {
@@ -1,10 +1,10 @@
<template>
<fs-page class="page-project-member">
<fs-page class="page-project-detail">
<template #header>
<div class="title">
{{ t("certd.projectMemberManager") }}
{{ t("certd.ent.projectDetailManager") }}
<span class="sub">
{{ t("certd.projectMemberDescription") }}
{{ t("certd.ent.projectDetailDescription") }}
</span>
</div>
</template>
@@ -30,7 +30,7 @@ import { useRoute } from "vue-router";
const { t } = useI18n();
defineOptions({
name: "ProjectMemberManager",
name: "ProjectDetail",
});
const route = useRoute();
@@ -29,7 +29,7 @@
<a-tab-pane key="network" :tab="t('certd.sys.setting.networkSetting')">
<SettingNetwork v-if="activeKey === 'network'" />
</a-tab-pane>
<a-tab-pane key="mode" :tab="t('certd.adminMode')">
<a-tab-pane key="mode" :tab="t('certd.sys.setting.adminModeSetting')">
<SettingMode v-if="activeKey === 'mode'" />
</a-tab-pane>
</a-tabs>
@@ -1,7 +1,7 @@
<template>
<div class="sys-settings-form sys-settings-mode">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish">
<a-form-item :label="t('certd.adminMode')" :name="['public', 'adminMode']">
<a-form-item :label="t('certd.sys.setting.adminMode')" :name="['public', 'adminMode']">
<fs-dict-radio v-model:value="formState.public.adminMode" :dict="adminModeDict" />
</a-form-item>
@@ -30,11 +30,11 @@ defineOptions({
const adminModeDict = dict({
data: [
{
label: t("certd.adminMode.enterpriseMode"),
label: t("certd.sys.setting.enterpriseMode"),
value: "enterprise",
},
{
label: t("certd.adminMode.saasMode"),
label: t("certd.sys.setting.saasMode"),
value: "saas",
},
],