perf(证书流水线): 添加批量更新证书申请参数功能

实现批量更新证书申请参数功能,包括前端界面和后端处理逻辑
- 添加批量修改证书申请参数的按钮和对话框
- 实现后端批量更新证书申请参数的接口和服务
- 添加相关测试用例验证功能正确性
This commit is contained in:
xiaojunnuo
2026-05-07 22:54:29 +08:00
parent b75c625ddc
commit 63be1c1cbd
7 changed files with 375 additions and 0 deletions
@@ -110,6 +110,14 @@ export async function BatchUpdateNotificaiton(pipelineIds: number[], notificatio
});
}
export async function BatchUpdateCertApplyOptions(pipelineIds: number[], options: any): Promise<void> {
return await request({
url: apiPrefix + "/batchUpdateCertApplyOptions",
method: "post",
data: { ids: pipelineIds, options },
});
}
export async function BatchUpdateProject(pipelineIds: number[], toProjectId: number): Promise<void> {
return await request({
url: apiPrefix + "/batchTransfer",
@@ -0,0 +1,106 @@
<template>
<fs-button icon="ph:certificate" class="need-plus" type="link" text="修改证书申请参数" @click="openFormDialog"></fs-button>
</template>
<script setup lang="ts">
import { useFormWrapper } from "@fast-crud/fast-crud";
import { cloneDeep } from "lodash-es";
import * as api from "../api";
import { useSettingStore } from "/@/store/settings";
import { usePluginStore } from "/@/store/plugin";
import { useReference } from "/@/use/use-refrence";
const props = defineProps<{
selectedRowKeys: any[];
}>();
const emit = defineEmits<{
change: any;
}>();
const batchUpdateFields = ["renewDays", "privateKeyType"];
function hasFormValue(form: any, field: string) {
return form[field] != null && form[field] !== "";
}
function buildBatchUpdateOptions(form: any) {
const options: any = {};
for (const field of batchUpdateFields) {
if (hasFormValue(form, field)) {
options[field] = form[field];
}
}
return options;
}
async function batchUpdateRequest(form: any) {
const options = buildBatchUpdateOptions(form);
await api.BatchUpdateCertApplyOptions(props.selectedRowKeys, options);
emit("change");
}
const { openCrudFormDialog } = useFormWrapper();
const settingStore = useSettingStore();
const pluginStore = usePluginStore();
function createInputColumn(inputDefine: any) {
const form = cloneDeep(inputDefine);
useReference(form);
delete form.value;
delete form.rules;
form.required = false;
if (form.component) {
form.component.allowClear = true;
}
return {
title: inputDefine.title,
form,
};
}
function createColumns(inputDefines: any) {
const columns: any = {};
for (const field of batchUpdateFields) {
columns[field] = createInputColumn(inputDefines[field]);
}
return columns;
}
function hasAnyBatchUpdateValue(form: any) {
return batchUpdateFields.some(field => hasFormValue(form, field));
}
async function openFormDialog() {
settingStore.checkPlus();
const certApplyPlugin: any = await pluginStore.getPluginDefine("CertApply");
const certApplyInput = certApplyPlugin?.input || {};
const crudOptions: any = {
columns: createColumns(certApplyInput),
form: {
mode: "edit",
//@ts-ignore
async doSubmit({ form }) {
if (!hasAnyBatchUpdateValue(form)) {
throw new Error("请至少选择一个要修改的参数");
}
await batchUpdateRequest(form);
},
col: {
span: 22,
},
labelCol: {
style: {
width: "120px",
},
},
wrapper: {
title: "批量修改证书申请参数",
width: 620,
},
},
} as any;
await openCrudFormDialog({ crudOptions });
}
</script>
@@ -40,6 +40,7 @@
<fs-button v-if="hasActionPermission('write')" icon="ion:trash-outline" class="color-red" type="link" :text="t('certd.batchDelete')" @click="batchDelete"></fs-button>
<batch-rerun :selected-row-keys="selectedRowKeys" @change="batchFinished"></batch-rerun>
<change-group v-if="hasActionPermission('write')" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-group>
<change-cert-apply-options v-if="hasActionPermission('write')" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-cert-apply-options>
<change-notification v-if="hasActionPermission('write')" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-notification>
<change-trigger v-if="hasActionPermission('write')" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-trigger>
<change-project v-if="hasActionPermission('write') && settingStore.isEnterprise" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-project>
@@ -57,6 +58,7 @@ import { computed, onActivated, onMounted, provide, ref } from "vue";
import { dict, useFs } from "@fast-crud/fast-crud";
import createCrudOptions from "./crud";
import ChangeGroup from "./components/change-group.vue";
import ChangeCertApplyOptions from "./components/change-cert-apply-options.vue";
import ChangeTrigger from "./components/change-trigger.vue";
import ChangeProject from "./components/change-project.vue";