mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: 支持批量修改通知和定时
This commit is contained in:
@@ -84,6 +84,23 @@ export async function BatchUpdateGroup(pipelineIds: number[], groupId: number):
|
||||
});
|
||||
}
|
||||
|
||||
export async function BatchUpdateTrigger(pipelineIds: number[], trigger: any): Promise<void> {
|
||||
return await request({
|
||||
url: apiPrefix + "/batchUpdateTrigger",
|
||||
method: "post",
|
||||
data: { ids: pipelineIds, trigger },
|
||||
});
|
||||
}
|
||||
|
||||
export async function BatchUpdateNotificaiton(pipelineIds: number[], notification: any): Promise<void> {
|
||||
return await request({
|
||||
url: apiPrefix + "/batchUpdateNotification",
|
||||
method: "post",
|
||||
data: { ids: pipelineIds, notification },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export async function BatchDelete(pipelineIds: number[]): Promise<void> {
|
||||
return await request({
|
||||
url: apiPrefix + "/batchDelete",
|
||||
@@ -99,6 +116,8 @@ export async function BatchRerun(pipelineIds: number[]): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function GetFiles(pipelineId: number) {
|
||||
return await request({
|
||||
url: historyApiPrefix + "/files",
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<fs-button icon="mdi:format-list-group" type="link" text="修改通知" @click="openFormDialog"></fs-button>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import * as api from "../api";
|
||||
import { useFormWrapper } from "@fast-crud/fast-crud";
|
||||
import NotificationSelector from "/@/views/certd/notification/notification-selector/index.vue";
|
||||
import { ref } from "vue";
|
||||
|
||||
const props = defineProps<{
|
||||
selectedRowKeys: any[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
change: any;
|
||||
}>();
|
||||
async function batchUpdateRequest(form: any) {
|
||||
/**
|
||||
* type: NotificationType;
|
||||
* when: NotificationWhen[];
|
||||
* options?: EmailOptions;
|
||||
* notificationId: number;
|
||||
* title: string;
|
||||
*/
|
||||
await api.BatchUpdateNotificaiton(props.selectedRowKeys, {
|
||||
type: "other",
|
||||
title: form.title || "通知",
|
||||
when: form.when,
|
||||
notificationId: form.notificationId,
|
||||
});
|
||||
emit("change");
|
||||
}
|
||||
|
||||
const { openCrudFormDialog } = useFormWrapper();
|
||||
|
||||
async function openFormDialog() {
|
||||
const crudOptions: any = {
|
||||
columns: {
|
||||
when: {
|
||||
title: "触发时机",
|
||||
form: {
|
||||
value: ["error", "turnToSuccess"],
|
||||
component: {
|
||||
name: "a-select",
|
||||
vModel: "value",
|
||||
mode: "multiple",
|
||||
options: [
|
||||
{ value: "start", label: "开始时" },
|
||||
{ value: "success", label: "成功时" },
|
||||
{ value: "turnToSuccess", label: "失败转成功时" },
|
||||
{ value: "error", label: "失败时" },
|
||||
],
|
||||
},
|
||||
helper: `建议仅选择'失败时'和'失败转成功'两种即可`,
|
||||
rules: [{ required: true, message: "此项必填" }],
|
||||
},
|
||||
},
|
||||
notificationId: {
|
||||
title: "通知配置",
|
||||
form: {
|
||||
component: {
|
||||
name: NotificationSelector,
|
||||
on: {
|
||||
selectedChange({ form, $event }: any) {
|
||||
form.title = $event?.name || "通知";
|
||||
},
|
||||
},
|
||||
},
|
||||
helper: "请选择通知方式",
|
||||
rules: [{ required: true, message: "此项必填" }],
|
||||
},
|
||||
},
|
||||
},
|
||||
form: {
|
||||
mode: "edit",
|
||||
//@ts-ignore
|
||||
async doSubmit({ form }) {
|
||||
await batchUpdateRequest(form);
|
||||
},
|
||||
col: {
|
||||
span: 22,
|
||||
},
|
||||
labelCol: {
|
||||
style: {
|
||||
width: "100px",
|
||||
},
|
||||
},
|
||||
wrapper: {
|
||||
title: "批量修改通知",
|
||||
width: 600,
|
||||
},
|
||||
},
|
||||
} as any;
|
||||
await openCrudFormDialog({ crudOptions });
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,62 @@
|
||||
<template>
|
||||
<fs-button icon="mdi:format-list-group" type="link" text="修改定时" @click="openFormDialog"></fs-button>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import * as api from "../api";
|
||||
import { useFormWrapper } from "@fast-crud/fast-crud";
|
||||
|
||||
const props = defineProps<{
|
||||
selectedRowKeys: any[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
change: any;
|
||||
}>();
|
||||
async function batchUpdateRequest(form: any) {
|
||||
await api.BatchUpdateTrigger(props.selectedRowKeys, {
|
||||
title: "定时触发",
|
||||
type: "timer",
|
||||
props: form.props,
|
||||
});
|
||||
emit("change");
|
||||
}
|
||||
|
||||
const { openCrudFormDialog } = useFormWrapper();
|
||||
|
||||
async function openFormDialog() {
|
||||
const crudOptions: any = {
|
||||
columns: {
|
||||
"props.cron": {
|
||||
title: "定时",
|
||||
form: {
|
||||
component: {
|
||||
name: "cron-editor",
|
||||
vModel: "modelValue",
|
||||
},
|
||||
rules: [{ required: true, message: "请选择定时Cron" }],
|
||||
},
|
||||
},
|
||||
},
|
||||
form: {
|
||||
mode: "edit",
|
||||
//@ts-ignore
|
||||
async doSubmit({ form }) {
|
||||
await batchUpdateRequest(form);
|
||||
},
|
||||
col: {
|
||||
span: 22,
|
||||
},
|
||||
labelCol: {
|
||||
style: {
|
||||
width: "100px",
|
||||
},
|
||||
},
|
||||
wrapper: {
|
||||
title: "批量修改定时",
|
||||
width: 600,
|
||||
},
|
||||
},
|
||||
} as any;
|
||||
await openCrudFormDialog({ crudOptions });
|
||||
}
|
||||
</script>
|
||||
@@ -7,9 +7,11 @@
|
||||
<div v-if="selectedRowKeys.length > 0" class="batch-actions">
|
||||
<div class="batch-actions-inner">
|
||||
<span> 已选择 {{ selectedRowKeys.length }} 项 </span>
|
||||
<fs-button icon="ion:trash-outline" class="color-green" type="link" text="批量删除" @click="batchDelete"></fs-button>
|
||||
<change-group class="color-green" :selected-row-keys="selectedRowKeys" @change="groupChanged"></change-group>
|
||||
<fs-button icon="ion:trash-outline" class="color-red" type="link" text="批量删除" @click="batchDelete"></fs-button>
|
||||
<fs-button icon="icon-park-outline:replay-music" class="need-plus" type="link" text="强制重新运行" @click="batchRerun"></fs-button>
|
||||
<change-group class="color-green" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-group>
|
||||
<change-notification class="color-green" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-notification>
|
||||
<change-trigger class="color-green" :selected-row-keys="selectedRowKeys" @change="batchFinished"></change-trigger>
|
||||
</div>
|
||||
</div>
|
||||
<template #actionbar-right> </template>
|
||||
@@ -26,8 +28,10 @@ import { dict, useFs } from "@fast-crud/fast-crud";
|
||||
import createCrudOptions from "./crud";
|
||||
import PiCertdForm from "./certd-form/index.vue";
|
||||
import ChangeGroup from "./components/change-group.vue";
|
||||
import ChangeTrigger from "./components/change-trigger.vue";
|
||||
import { Modal, notification } from "ant-design-vue";
|
||||
import * as api from "./api";
|
||||
import ChangeNotification from "/@/views/certd/pipeline/components/change-notification.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "PipelineManager",
|
||||
@@ -55,7 +59,7 @@ onActivated(async () => {
|
||||
await crudExpose.doRefresh();
|
||||
});
|
||||
|
||||
function groupChanged() {
|
||||
function batchFinished() {
|
||||
crudExpose.doRefresh();
|
||||
selectedRowKeys.value = [];
|
||||
}
|
||||
|
||||
+24
-24
@@ -24,17 +24,17 @@
|
||||
disabled: !editMode,
|
||||
options: [
|
||||
{ value: 'email', label: '邮件' },
|
||||
{ value: 'other', label: '其他通知方式' }
|
||||
]
|
||||
{ value: 'other', label: '其他通知方式' },
|
||||
],
|
||||
},
|
||||
rules: [{ required: true, message: '此项必填' }]
|
||||
rules: [{ required: true, message: '此项必填' }],
|
||||
}"
|
||||
/>
|
||||
<fs-form-item
|
||||
v-model="currentNotification.when"
|
||||
:item="{
|
||||
title: '触发时机',
|
||||
key: 'type',
|
||||
key: 'when',
|
||||
value: ['error'],
|
||||
component: {
|
||||
name: 'a-select',
|
||||
@@ -45,11 +45,11 @@
|
||||
{ value: 'start', label: '开始时' },
|
||||
{ value: 'success', label: '成功时' },
|
||||
{ value: 'turnToSuccess', label: '失败转成功时' },
|
||||
{ value: 'error', label: '失败时' }
|
||||
]
|
||||
{ value: 'error', label: '失败时' },
|
||||
],
|
||||
},
|
||||
helper: `建议仅选择'失败时'和'失败转成功'两种即可`,
|
||||
rules: [{ required: true, message: '此项必填' }]
|
||||
rules: [{ required: true, message: '此项必填' }],
|
||||
}"
|
||||
/>
|
||||
<pi-notification-form-email v-if="currentNotification.type === 'email'" ref="optionsRef" v-model:options="currentNotification.options"></pi-notification-form-email>
|
||||
@@ -59,14 +59,14 @@
|
||||
v-model="currentNotification.notificationId"
|
||||
:item="{
|
||||
title: '通知配置',
|
||||
key: 'type',
|
||||
key: 'notificationId',
|
||||
component: {
|
||||
disabled: !editMode,
|
||||
name: NotificationSelector,
|
||||
onSelectedChange
|
||||
onSelectedChange,
|
||||
},
|
||||
helper: '请选择通知方式',
|
||||
rules: [{ required: true, message: '此项必填' }]
|
||||
rules: [{ required: true, message: '此项必填' }],
|
||||
}"
|
||||
/>
|
||||
</a-form>
|
||||
@@ -96,8 +96,8 @@ export default {
|
||||
props: {
|
||||
editMode: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
emits: ["update"],
|
||||
setup(props: any, context: any) {
|
||||
@@ -118,23 +118,23 @@ export default {
|
||||
{
|
||||
type: "string",
|
||||
required: true,
|
||||
message: "请选择类型"
|
||||
}
|
||||
message: "请选择类型",
|
||||
},
|
||||
],
|
||||
when: [
|
||||
{
|
||||
type: "string",
|
||||
required: true,
|
||||
message: "请选择通知时机"
|
||||
}
|
||||
message: "请选择通知时机",
|
||||
},
|
||||
],
|
||||
notificationId: [
|
||||
{
|
||||
type: "number",
|
||||
required: true,
|
||||
message: "请选择通知配置"
|
||||
}
|
||||
]
|
||||
message: "请选择通知配置",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const notificationDrawerShow = () => {
|
||||
@@ -195,7 +195,7 @@ export default {
|
||||
async onOk() {
|
||||
callback.value("delete");
|
||||
notificationDrawerClose();
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -222,21 +222,21 @@ export default {
|
||||
notificationDelete,
|
||||
rules,
|
||||
blankFn,
|
||||
optionsRef
|
||||
optionsRef,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...useNotificationForm(),
|
||||
labelCol: { span: 6 },
|
||||
wrapperCol: { span: 16 }
|
||||
wrapperCol: { span: 16 },
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
NotificationSelector() {
|
||||
return NotificationSelector;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
+19
-26
@@ -1,12 +1,5 @@
|
||||
<template>
|
||||
<a-drawer
|
||||
v-model:open="triggerDrawerVisible"
|
||||
placement="right"
|
||||
:closable="true"
|
||||
width="650px"
|
||||
class="pi-trigger-form"
|
||||
@after-open-change="triggerDrawerOnAfterVisibleChange"
|
||||
>
|
||||
<a-drawer v-model:open="triggerDrawerVisible" placement="right" :closable="true" width="650px" class="pi-trigger-form" @after-open-change="triggerDrawerOnAfterVisibleChange">
|
||||
<template #title>
|
||||
<div>
|
||||
编辑触发器
|
||||
@@ -26,9 +19,9 @@
|
||||
component: {
|
||||
name: 'a-input',
|
||||
vModel: 'value',
|
||||
disabled: !editMode
|
||||
disabled: !editMode,
|
||||
},
|
||||
rules: [{ required: true, message: '此项必填' }]
|
||||
rules: [{ required: true, message: '此项必填' }],
|
||||
}"
|
||||
/>
|
||||
|
||||
@@ -42,9 +35,9 @@
|
||||
name: 'a-select',
|
||||
vModel: 'value',
|
||||
disabled: !editMode,
|
||||
options: [{ value: 'timer', label: '定时' }]
|
||||
options: [{ value: 'timer', label: '定时' }],
|
||||
},
|
||||
rules: [{ required: true, message: '此项必填' }]
|
||||
rules: [{ required: true, message: '此项必填' }],
|
||||
}"
|
||||
/>
|
||||
|
||||
@@ -56,10 +49,10 @@
|
||||
component: {
|
||||
disabled: !editMode,
|
||||
name: 'cron-editor',
|
||||
vModel: 'modelValue'
|
||||
vModel: 'modelValue',
|
||||
},
|
||||
helper: '点击上面的按钮,选择每天几点定时执行。\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行',
|
||||
rules: [{ required: true, message: '此项必填' }]
|
||||
rules: [{ required: true, message: '此项必填' }],
|
||||
}"
|
||||
/>
|
||||
</a-form>
|
||||
@@ -84,8 +77,8 @@ export default {
|
||||
props: {
|
||||
editMode: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
emits: ["update"],
|
||||
setup(props, context) {
|
||||
@@ -105,9 +98,9 @@ export default {
|
||||
{
|
||||
type: "string",
|
||||
required: true,
|
||||
message: "请输入名称"
|
||||
}
|
||||
]
|
||||
message: "请输入名称",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const triggerDrawerShow = () => {
|
||||
@@ -117,7 +110,7 @@ export default {
|
||||
triggerDrawerVisible.value = false;
|
||||
};
|
||||
|
||||
const triggerDrawerOnAfterVisibleChange = (val) => {
|
||||
const triggerDrawerOnAfterVisibleChange = val => {
|
||||
console.log("triggerDrawerOnAfterVisibleChange", val);
|
||||
};
|
||||
|
||||
@@ -128,7 +121,7 @@ export default {
|
||||
triggerDrawerShow();
|
||||
};
|
||||
|
||||
const triggerAdd = (emit) => {
|
||||
const triggerAdd = emit => {
|
||||
mode.value = "add";
|
||||
const trigger = { id: nanoid(), title: "定时触发", type: "timer", props: {} };
|
||||
triggerOpen(trigger, emit);
|
||||
@@ -144,7 +137,7 @@ export default {
|
||||
triggerOpen(trigger, emit);
|
||||
};
|
||||
|
||||
const triggerSave = async (e) => {
|
||||
const triggerSave = async e => {
|
||||
console.log("currentTriggerSave", currentTrigger.value);
|
||||
try {
|
||||
await triggerFormRef.value.validate();
|
||||
@@ -164,7 +157,7 @@ export default {
|
||||
async onOk() {
|
||||
callback.value("delete");
|
||||
triggerDrawerClose();
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -185,16 +178,16 @@ export default {
|
||||
triggerSave,
|
||||
triggerDelete,
|
||||
rules,
|
||||
blankFn
|
||||
blankFn,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...useTriggerForm(),
|
||||
labelCol: { span: 6 },
|
||||
wrapperCol: { span: 16 }
|
||||
wrapperCol: { span: 16 },
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user