From 817226e1d5506196da8a9d6214b497bc00e1fc37 Mon Sep 17 00:00:00 2001 From: JiangQiming <291854119@qq.com> Date: Sun, 29 Jan 2023 18:44:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=9A=E7=9F=A5=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/notice/Template/Debug/index.vue | 201 +++++++++++ src/views/notice/Template/Log/index.vue | 156 +++++++++ src/views/notice/Template/index.vue | 407 +++++++++++++++++++++- 3 files changed, 749 insertions(+), 15 deletions(-) create mode 100644 src/views/notice/Template/Debug/index.vue create mode 100644 src/views/notice/Template/Log/index.vue diff --git a/src/views/notice/Template/Debug/index.vue b/src/views/notice/Template/Debug/index.vue new file mode 100644 index 00000000..4da9e494 --- /dev/null +++ b/src/views/notice/Template/Debug/index.vue @@ -0,0 +1,201 @@ + + + + + + + {{ item.name }} + + + + + + + + {{ record[column.dataIndex] }} + + + + + + + + + + + + + + diff --git a/src/views/notice/Template/Log/index.vue b/src/views/notice/Template/Log/index.vue new file mode 100644 index 00000000..2be0156c --- /dev/null +++ b/src/views/notice/Template/Log/index.vue @@ -0,0 +1,156 @@ + + + + + + + {{ moment(slotProps.notifyTime).format('YYYY-MM-DD HH:mm:ss') }} + + + + + + + + + + + + + + + + + diff --git a/src/views/notice/Template/index.vue b/src/views/notice/Template/index.vue index 3201947b..5f2313fd 100644 --- a/src/views/notice/Template/index.vue +++ b/src/views/notice/Template/index.vue @@ -1,22 +1,399 @@ - - 通知模板 + + + + + + + + + + 新增 + + + 导入 + + + 导出 + + + + + + + + + + + + + {{ slotProps.name }} + + + + + 通知方式 + + + {{ getMethodTxt(slotProps.type) }} + + + + + 说明 + + {{ slotProps.description }} + + + + + + + + + + + {{ item.text }} + + + + + + + + + {{ item.text }} + + + + + + + + + + + + + + + + + + + + + + + + + - +/** + * 根据通知方式展示对应logo + */ +const getLogo = (type: string, provider: string) => { + return MSG_TYPE[type].find((f: any) => f.value === provider)?.logo; +}; +/** + * 通知方式字段展示对应文字 + */ +const getMethodTxt = (type: string) => { + return NOTICE_METHOD.find((f) => f.value === type)?.label; +}; + +/** + * 新增 + */ +const handleAdd = () => { + router.push(`/notice/Config/detail/:id`); +}; + +/** + * 导入 + */ +const beforeUpload = (file: any) => { + console.log('file: ', file); + const reader = new FileReader(); + reader.readAsText(file); + reader.onload = async (result) => { + const text = result.target?.result; + console.log('text: ', text); + if (!file.type.includes('json')) { + message.error('请上传json格式文件'); + return false; + } + try { + const data = JSON.parse(text || '{}'); + const { success } = await ConfigApi.update(data); + if (success) { + message.success('操作成功'); + configRef.value.reload(); + } + return true; + } catch { + // message.error('请上传json格式文件'); + } + return true; + }; + return false; +}; + +/** + * 导出 + */ +const handleExport = () => { + downloadObject(configRef.value.dataSource, `通知配置`); +}; + +/** + * 查看 + */ +const handleView = (id: string) => { + message.warn(id + '暂未开发'); +}; + +const syncVis = ref(false); +const debugVis = ref(false); +const logVis = ref(false); +const currentConfig = ref>>(); +const getActions = ( + data: Partial>, + type: 'card' | 'table', +): ActionsType[] => { + if (!data) return []; + const actions = [ + { + key: 'edit', + text: '编辑', + tooltip: { + title: '编辑', + }, + icon: 'EditOutlined', + onClick: () => { + // visible.value = true; + // current.value = data; + router.push(`/notice/Config/detail/${data.id}`); + }, + }, + { + key: 'debug', + text: '调试', + tooltip: { + title: '调试', + }, + icon: 'BugOutlined', + onClick: () => { + debugVis.value = true; + currentConfig.value = data; + }, + }, + { + key: 'debug', + text: '通知记录', + tooltip: { + title: '通知记录', + }, + icon: 'BarsOutlined', + onClick: () => { + logVis.value = true; + currentConfig.value = data; + }, + }, + { + key: 'debug', + text: '导出', + tooltip: { + title: '导出', + }, + icon: 'ArrowDownOutlined', + onClick: () => { + downloadObject(data, `通知配置`); + }, + }, + { + key: 'delete', + text: '删除', + popConfirm: { + title: '确认删除?', + onConfirm: async () => { + const resp = await ConfigApi.del(data.id); + if (resp.status === 200) { + message.success('操作成功!'); + configRef.value?.reload(); + } else { + message.error('操作失败!'); + } + }, + }, + icon: 'DeleteOutlined', + }, + ]; + return actions; +}; + +