mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
perf: 优化证书申请成功通知发送方式
This commit is contained in:
@@ -43,6 +43,21 @@ export function createApi() {
|
||||
});
|
||||
},
|
||||
|
||||
async SetDefault(id: number) {
|
||||
return await request({
|
||||
url: apiPrefix + "/setDefault",
|
||||
method: "post",
|
||||
params: { id }
|
||||
});
|
||||
},
|
||||
|
||||
async GetDefaultId() {
|
||||
return await request({
|
||||
url: apiPrefix + "/getDefaultId",
|
||||
method: "post"
|
||||
});
|
||||
},
|
||||
|
||||
async GetSimpleInfo(id: number) {
|
||||
return await request({
|
||||
url: apiPrefix + "/simpleInfo",
|
||||
|
||||
@@ -2,6 +2,8 @@ import { ColumnCompositionProps, compute, dict } from "@fast-crud/fast-crud";
|
||||
import { computed, provide, ref, toRef } from "vue";
|
||||
import { useReference } from "/@/use/use-refrence";
|
||||
import { forEach, get, merge, set } from "lodash-es";
|
||||
import { Modal } from "ant-design-vue";
|
||||
import * as api from "/@/views/sys/cname/provider/api";
|
||||
|
||||
export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
|
||||
provide("notificationApi", api);
|
||||
@@ -141,6 +143,47 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
|
||||
width: 200
|
||||
}
|
||||
},
|
||||
isDefault: {
|
||||
title: "是否默认",
|
||||
type: "dict-switch",
|
||||
dict: dict({
|
||||
data: [
|
||||
{ label: "是", value: true, color: "success" },
|
||||
{ label: "否", value: false, color: "default" }
|
||||
]
|
||||
}),
|
||||
form: {
|
||||
value: false,
|
||||
rules: [{ required: true, message: "请选择是否默认" }],
|
||||
order: 999
|
||||
},
|
||||
column: {
|
||||
align: "center",
|
||||
width: 100,
|
||||
component: {
|
||||
name: "a-switch",
|
||||
vModel: "checked",
|
||||
disabled: compute(({ value }) => {
|
||||
return value === true;
|
||||
}),
|
||||
on: {
|
||||
change({ row }) {
|
||||
Modal.confirm({
|
||||
title: "提示",
|
||||
content: "确定设置为默认通知?",
|
||||
onOk: async () => {
|
||||
await api.SetDefault(row.id);
|
||||
await crudExpose.doRefresh();
|
||||
},
|
||||
onCancel: async () => {
|
||||
await crudExpose.doRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} as ColumnCompositionProps,
|
||||
test: {
|
||||
title: "测试",
|
||||
form: {
|
||||
@@ -151,7 +194,7 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
|
||||
name: "api-test",
|
||||
action: "TestRequest"
|
||||
},
|
||||
order: 999,
|
||||
order: 990,
|
||||
col: {
|
||||
span: 24
|
||||
}
|
||||
|
||||
+14
-1
@@ -7,7 +7,7 @@
|
||||
<span v-else class="mlr-5 text-gray">{{ placeholder }}</span>
|
||||
<a-button class="ml-5" :disabled="disabled" :size="size" @click="chooseForm.open">选择</a-button>
|
||||
<a-form-item-rest v-if="chooseForm.show">
|
||||
<a-modal v-model:open="chooseForm.show" title="选择通知渠道" width="900px" @ok="chooseForm.ok">
|
||||
<a-modal v-model:open="chooseForm.show" title="选择通知渠道" width="905px" @ok="chooseForm.ok">
|
||||
<div style="height: 400px; position: relative">
|
||||
<cert-notification-modal v-model="selectedId"></cert-notification-modal>
|
||||
</div>
|
||||
@@ -45,6 +45,10 @@ export default defineComponent({
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
useDefault: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
emits: ["update:modelValue", "selectedChange", "change"],
|
||||
@@ -60,6 +64,15 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
async function loadDefault() {
|
||||
const defId = await api.GetDefaultId();
|
||||
if (defId) {
|
||||
await emitValue(defId);
|
||||
}
|
||||
}
|
||||
|
||||
loadDefault();
|
||||
|
||||
function clear() {
|
||||
if (props.disabled) {
|
||||
return;
|
||||
|
||||
+1
-4
@@ -56,9 +56,6 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
show: false
|
||||
},
|
||||
form: {
|
||||
wrapper: {
|
||||
width: "1050px"
|
||||
},
|
||||
labelCol: {
|
||||
//固定label宽度
|
||||
span: null,
|
||||
@@ -72,7 +69,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
},
|
||||
table: {
|
||||
scroll: {
|
||||
x: 800
|
||||
x: 700
|
||||
},
|
||||
rowSelection: {
|
||||
type: "radio",
|
||||
|
||||
@@ -109,7 +109,8 @@ export default function (certPluginGroup: PluginGroup, formWrapperRef: any): Cre
|
||||
form: {
|
||||
component: {
|
||||
name: NotificationSelector,
|
||||
vModel: "modelValue"
|
||||
vModel: "modelValue",
|
||||
useDefault: true
|
||||
},
|
||||
order: 101,
|
||||
helper: "建议设置,任务执行失败实时提醒"
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// @ts-ignore
|
||||
import { request } from "/@/api/service";
|
||||
import { SysPrivateSetting, SysPublicSetting } from "/@/api/modules/api.basic";
|
||||
const apiPrefix = "/user/settings";
|
||||
export type UserSettings = {
|
||||
defaultNotification?: number;
|
||||
defaultCron?: string;
|
||||
};
|
||||
|
||||
export async function UserSettingsGet() {
|
||||
const res = await request({
|
||||
url: apiPrefix + "/getDefault",
|
||||
method: "post"
|
||||
});
|
||||
if (!res) {
|
||||
return {};
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function UserSettingsSave(setting: any) {
|
||||
return await request({
|
||||
url: apiPrefix + "/saveDefault",
|
||||
method: "post",
|
||||
data: setting
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<fs-page class="page-user-settings">
|
||||
<template #header>
|
||||
<div class="title">设置</div>
|
||||
</template>
|
||||
<div class="user-settings-form settings-form">
|
||||
<a-form
|
||||
:model="formState"
|
||||
name="basic"
|
||||
:label-col="{ span: 8 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
autocomplete="off"
|
||||
@finish="onFinish"
|
||||
@finish-failed="onFinishFailed"
|
||||
>
|
||||
<a-form-item label="默认定时设置" name="defaultCron">
|
||||
<notification-selector v-model="formState.defaultCron" />
|
||||
<div class="helper">创建流水线时默认使用此定时时间</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
|
||||
<a-button :loading="saveLoading" type="primary" html-type="submit">保存</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</fs-page>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { reactive, ref } from "vue";
|
||||
import * as api from "./api";
|
||||
import { UserSettings } from "./api";
|
||||
import { notification } from "ant-design-vue";
|
||||
import { merge } from "lodash-es";
|
||||
import NotificationSelector from "/@/views/certd/notification/notification-selector/index.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "UserSettings"
|
||||
});
|
||||
|
||||
const formState = reactive<Partial<UserSettings>>({});
|
||||
|
||||
async function loadUserSettings() {
|
||||
const data: any = await api.UserSettingsGet();
|
||||
merge(formState, data);
|
||||
}
|
||||
|
||||
const saveLoading = ref(false);
|
||||
loadUserSettings();
|
||||
const onFinish = async (form: any) => {
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
await api.UserSettingsSave(form);
|
||||
notification.success({
|
||||
message: "保存成功"
|
||||
});
|
||||
} finally {
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onFinishFailed = (errorInfo: any) => {
|
||||
// console.log("Failed:", errorInfo);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.page-user-settings {
|
||||
.user-settings-form {
|
||||
width: 500px;
|
||||
margin: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user