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 @@