From 6a2c76366373acfaecea72ede6746690ea6e67ce Mon Sep 17 00:00:00 2001 From: opensnail <598092184@qq.com> Date: Thu, 18 Apr 2024 23:33:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(sj=5F1.0.0):=20=E5=AE=8C=E6=88=90=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipient/modules/dingding-form.vue | 30 ++++++++-- .../notify/recipient/modules/email-form.vue | 24 +++++++- .../notify/recipient/modules/lark-form.vue | 24 +++++++- .../notify-recipient-operate-drawer.vue | 58 +++++++++---------- .../recipient/modules/qiye-wecht-form.vue | 24 +++++++- 5 files changed, 114 insertions(+), 46 deletions(-) diff --git a/src/views/notify/recipient/modules/dingding-form.vue b/src/views/notify/recipient/modules/dingding-form.vue index b6b16f7..bd148fd 100644 --- a/src/views/notify/recipient/modules/dingding-form.vue +++ b/src/views/notify/recipient/modules/dingding-form.vue @@ -9,6 +9,7 @@ defineOptions({ interface Emits { (e: 'fetchAdd', model: Api.NotifyRecipient.NotifyRecipient): void; + (e: 'fetchUpdate', model: Api.NotifyRecipient.NotifyRecipient): void; } const emit = defineEmits(); @@ -33,12 +34,11 @@ function createDefaultModel(): Model { }; } -type RuleKey = Extract; +type RuleKey = Extract; const rules: Record = { recipientName: defaultRequiredRule, notifyType: defaultRequiredRule, - description: defaultRequiredRule, webhookUrl: defaultRequiredRule, ats: defaultRequiredRule }; @@ -49,13 +49,31 @@ const buildNotifyAttribute = (webhookUrl: string, ats: string[]) => { async function save() { await validate(); - const { id, recipientName, notifyType, webhookUrl, ats, description } = model; + const { recipientName, notifyType, webhookUrl, ats, description } = model; const notifyAttribute = buildNotifyAttribute(webhookUrl, ats); - emit('fetchAdd', { id, recipientName, notifyType, notifyAttribute, description }); + emit('fetchAdd', { recipientName, notifyType, notifyAttribute, description }); } +async function update() { + await validate(); + const { id, recipientName, notifyType, webhookUrl, ats, description } = model; + const notifyAttribute = buildNotifyAttribute(webhookUrl, ats); + emit('fetchUpdate', { id, recipientName, notifyType, notifyAttribute, description }); +} + +const showData = (rowData: Api.NotifyRecipient.NotifyRecipient) => { + if (rowData.notifyAttribute) { + const notifyAttribute = JSON.parse(rowData.notifyAttribute); + Object.assign(model, rowData); + Object.assign(model, notifyAttribute); + } +}; + defineExpose({ - save + save, + createDefaultModel, + showData, + update }); @@ -89,8 +107,8 @@ defineExpose({ v-model:value="model.description" type="textarea" :placeholder="$t('page.notifyRecipient.form.description')" - round clearable + round /> diff --git a/src/views/notify/recipient/modules/email-form.vue b/src/views/notify/recipient/modules/email-form.vue index 71b34fa..d518c51 100644 --- a/src/views/notify/recipient/modules/email-form.vue +++ b/src/views/notify/recipient/modules/email-form.vue @@ -9,6 +9,7 @@ defineOptions({ interface Emits { (e: 'fetchAdd', model: Api.NotifyRecipient.NotifyRecipient): void; + (e: 'fetchUpdate', model: Api.NotifyRecipient.NotifyRecipient): void; } const emit = defineEmits(); @@ -29,12 +30,11 @@ function createDefaultModel(): Model { }; } -type RuleKey = Extract; +type RuleKey = Extract; const rules: Record = { recipientName: defaultRequiredRule, notifyType: defaultRequiredRule, - description: defaultRequiredRule, tos: defaultRequiredRule }; @@ -49,8 +49,26 @@ async function save() { emit('fetchAdd', { id, recipientName, notifyType, notifyAttribute, description }); } +const showData = (rowData: Api.NotifyRecipient.NotifyRecipient) => { + if (rowData.notifyAttribute) { + const notifyAttribute = JSON.parse(rowData.notifyAttribute); + Object.assign(model, rowData); + Object.assign(model, notifyAttribute); + } +}; + +async function update() { + await validate(); + const { id, recipientName, notifyType, tos, description } = model; + const notifyAttribute = buildNotifyAttribute(tos); + emit('fetchUpdate', { id, recipientName, notifyType, notifyAttribute, description }); +} + defineExpose({ - save + save, + showData, + createDefaultModel, + update }); diff --git a/src/views/notify/recipient/modules/lark-form.vue b/src/views/notify/recipient/modules/lark-form.vue index e934fcf..d30c135 100644 --- a/src/views/notify/recipient/modules/lark-form.vue +++ b/src/views/notify/recipient/modules/lark-form.vue @@ -9,6 +9,7 @@ defineOptions({ interface Emits { (e: 'fetchAdd', model: Api.NotifyRecipient.NotifyRecipient): void; + (e: 'fetchUpdate', model: Api.NotifyRecipient.NotifyRecipient): void; } const emit = defineEmits(); @@ -33,12 +34,11 @@ function createDefaultModel(): Model { }; } -type RuleKey = Extract; +type RuleKey = Extract; const rules: Record = { recipientName: defaultRequiredRule, notifyType: defaultRequiredRule, - description: defaultRequiredRule, webhookUrl: defaultRequiredRule, ats: defaultRequiredRule }; @@ -54,8 +54,26 @@ async function save() { emit('fetchAdd', { id, recipientName, notifyType, notifyAttribute, description }); } +async function update() { + await validate(); + const { id, recipientName, notifyType, webhookUrl, ats, description } = model; + const notifyAttribute = buildNotifyAttribute(webhookUrl, ats); + emit('fetchUpdate', { id, recipientName, notifyType, notifyAttribute, description }); +} + +const showData = (rowData: Api.NotifyRecipient.NotifyRecipient) => { + if (rowData.notifyAttribute) { + const notifyAttribute = JSON.parse(rowData.notifyAttribute); + Object.assign(model, rowData); + Object.assign(model, notifyAttribute); + } +}; + defineExpose({ - save + save, + showData, + createDefaultModel, + update }); diff --git a/src/views/notify/recipient/modules/notify-recipient-operate-drawer.vue b/src/views/notify/recipient/modules/notify-recipient-operate-drawer.vue index abc88ad..0764f96 100644 --- a/src/views/notify/recipient/modules/notify-recipient-operate-drawer.vue +++ b/src/views/notify/recipient/modules/notify-recipient-operate-drawer.vue @@ -1,9 +1,9 @@