From e1332212c8750b10741ecbc5577f59973b0c55ff Mon Sep 17 00:00:00 2001 From: xubinbin0303 Date: Sun, 29 Jun 2025 20:32:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(system):=20=E6=B7=BB=E5=8A=A0=20webhook=20?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 webhook API 和相关接口 - 实现 webhook 列表页面,包括搜索、添加、编辑和删除功能 - 添加 webhook 表单组件,用于创建和更新 webhook 信息 - 在字典工具中添加新的字典类型:WEBHOOK_TYPE 和 ON_OFF - 优化日期格式化函数,增加对空值的处理 --- src/api/system/webhook/index.ts | 50 +++++ src/utils/dict.ts | 4 +- src/utils/formatTime.ts | 4 + src/views/system/webhook/WebhookForm.vue | 132 +++++++++++ src/views/system/webhook/index.vue | 275 +++++++++++++++++++++++ 5 files changed, 464 insertions(+), 1 deletion(-) create mode 100644 src/api/system/webhook/index.ts create mode 100644 src/views/system/webhook/WebhookForm.vue create mode 100644 src/views/system/webhook/index.vue diff --git a/src/api/system/webhook/index.ts b/src/api/system/webhook/index.ts new file mode 100644 index 000000000..0402638c0 --- /dev/null +++ b/src/api/system/webhook/index.ts @@ -0,0 +1,50 @@ +import request from '@/config/axios' +import type { Dayjs } from 'dayjs'; + +/** webhook信息 */ +export interface Webhook { + id: number; // ID + bizName?: string; // 群名称 + accessToken?: string; // 通证 + secret?: string; // 加签密钥 + type?: number; // 类型(0:钉钉,1:企微,2:飞书) + status?: number; // 状态(0正常 1关闭) + } + +// webhook API +export const WebhookApi = { + // 查询webhook分页 + getWebhookPage: async (params: any) => { + return await request.get({ url: `/system/webhook/page`, params }) + }, + + // 查询webhook详情 + getWebhook: async (id: number) => { + return await request.get({ url: `/system/webhook/get?id=` + id }) + }, + + // 新增webhook + createWebhook: async (data: Webhook) => { + return await request.post({ url: `/system/webhook/create`, data }) + }, + + // 修改webhook + updateWebhook: async (data: Webhook) => { + return await request.put({ url: `/system/webhook/update`, data }) + }, + + // 删除webhook + deleteWebhook: async (id: number) => { + return await request.delete({ url: `/system/webhook/delete?id=` + id }) + }, + + /** 批量删除webhook */ + deleteWebhookList: async (ids: number[]) => { + return await request.delete({ url: `/system/webhook/delete-list?ids=${ids.join(',')}` }) + }, + + // 导出webhook Excel + exportWebhook: async (params) => { + return await request.download({ url: `/system/webhook/export-excel`, params }) + } +} \ No newline at end of file diff --git a/src/utils/dict.ts b/src/utils/dict.ts index 947f9f31a..862a9abc9 100644 --- a/src/utils/dict.ts +++ b/src/utils/dict.ts @@ -244,5 +244,7 @@ export enum DICT_TYPE { IOT_PLUGIN_STATUS = 'iot_plugin_status', // IOT 插件状态 IOT_PLUGIN_TYPE = 'iot_plugin_type', // IOT 插件类型 IOT_DATA_BRIDGE_DIRECTION_ENUM = 'iot_data_bridge_direction_enum', // 桥梁方向 - IOT_DATA_BRIDGE_TYPE_ENUM = 'iot_data_bridge_type_enum' // 桥梁类型 + IOT_DATA_BRIDGE_TYPE_ENUM = 'iot_data_bridge_type_enum', // 桥梁类型 + WEBHOOK_TYPE = 'webhook_type', + ON_OFF = 'on_off' } diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index 99eb428c3..3b54e15ec 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -198,6 +198,10 @@ export function formatPast2(ms: number): string { * @param cellValue 字段值 */ export function dateFormatter(_row: any, _column: TableColumnCtx, cellValue: any): string { + if (!cellValue) { + console.warn('dateFormatter received falsy value:', cellValue) + return 'N/A' // 或者返回 '--' + } return cellValue ? formatDate(cellValue) : '' } diff --git a/src/views/system/webhook/WebhookForm.vue b/src/views/system/webhook/WebhookForm.vue new file mode 100644 index 000000000..5e86a5ca0 --- /dev/null +++ b/src/views/system/webhook/WebhookForm.vue @@ -0,0 +1,132 @@ + + diff --git a/src/views/system/webhook/index.vue b/src/views/system/webhook/index.vue new file mode 100644 index 000000000..f3156701c --- /dev/null +++ b/src/views/system/webhook/index.vue @@ -0,0 +1,275 @@ + + +