feat(sj_1.0.0): 完成通知配置

This commit is contained in:
opensnail 2024-04-30 17:50:25 +08:00
parent 3867b49d40
commit f2a03043ab
4 changed files with 117 additions and 7 deletions

View File

@ -25,8 +25,7 @@ const visible = defineModel<boolean>('visible', {
watch( watch(
() => props.rowData, () => props.rowData,
() => { () => {
console.log(props.rowData); const rowData = props.rowData?.notifyAttribute || null;
const rowData = props.rowData?.notifyAttribute;
notifyAttribute.value = JSON.parse(rowData!) || {}; notifyAttribute.value = JSON.parse(rowData!) || {};
}, },
{ immediate: true } { immediate: true }

View File

@ -1,16 +1,22 @@
<script setup lang="tsx"> <script setup lang="tsx">
import { NButton, NPopconfirm, NTag } from 'naive-ui'; import { NButton, NPopconfirm, NTag } from 'naive-ui';
import { ref } from 'vue';
import { fetchGetNotifyConfigList, fetchUpdateNotifyStatus } from '@/service/api'; import { fetchGetNotifyConfigList, fetchUpdateNotifyStatus } from '@/service/api';
import { $t } from '@/locales'; import { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app'; import { useAppStore } from '@/store/modules/app';
import { useTable, useTableOperate } from '@/hooks/common/table'; import { useTable, useTableOperate } from '@/hooks/common/table';
import NotifyConfigOperateDrawer from '@/views/notify/scene/modules/notify-config-operate-drawer.vue'; import NotifyConfigOperateDrawer from '@/views/notify/scene/modules/notify-config-operate-drawer.vue';
import NotifyConfigSearch from '@/views/notify/scene/modules/notify-config-search.vue'; import NotifyConfigSearch from '@/views/notify/scene/modules/notify-config-search.vue';
import NotifyConfigDetailDrawer from '@/views/notify/scene/modules/notify-config-detail-drawer.vue';
import StatusSwitch from '@/components/common/status-switch.vue'; import StatusSwitch from '@/components/common/status-switch.vue';
import { jobNotifyScene, retryNotifyScene } from '@/constants/business'; import { jobNotifyScene, retryNotifyScene, systemTaskType } from '@/constants/business';
import { tagColor } from '@/utils/common'; import { tagColor } from '@/utils/common';
const appStore = useAppStore(); const appStore = useAppStore();
const detailData = ref();
const detailVisible = defineModel<boolean>('detailVisible', {
default: false
});
const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({ const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
apiFn: fetchGetNotifyConfigList, apiFn: fetchGetNotifyConfigList,
@ -35,6 +41,24 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
align: 'center', align: 'center',
width: 64 width: 64
}, },
{
key: 'businessName',
title: $t('page.notifyConfig.businessName'),
align: 'left',
width: 120,
render: row => {
function showDetailDrawer() {
detailData.value = row || null;
detailVisible.value = true;
}
return (
<n-button text tag="a" type="primary" onClick={showDetailDrawer} class="ws-normal">
{row.businessName}
</n-button>
);
}
},
{ {
key: 'groupName', key: 'groupName',
title: $t('page.notifyConfig.groupName'), title: $t('page.notifyConfig.groupName'),
@ -42,10 +66,19 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
width: 120 width: 120
}, },
{ {
key: 'businessName', key: 'systemTaskType',
title: $t('page.notifyConfig.businessName'), title: $t('page.notifyConfig.systemTaskType'),
align: 'left', align: 'left',
width: 120 width: 120,
render: row => {
if (row.systemTaskType === null) {
return null;
}
const label = $t(systemTaskType[row.systemTaskType!]);
return <NTag type={tagColor(row.systemTaskType!)}>{label}</NTag>;
}
}, },
{ {
key: 'notifyStatus', key: 'notifyStatus',
@ -94,6 +127,12 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
align: 'left', align: 'left',
width: 120 width: 120
}, },
{
key: 'createDt',
title: $t('common.createDt'),
align: 'left',
width: 120
},
{ {
key: 'description', key: 'description',
title: $t('page.notifyConfig.description'), title: $t('page.notifyConfig.description'),
@ -192,6 +231,7 @@ function edit(id: string) {
:row-data="editingData" :row-data="editingData"
@submitted="getData" @submitted="getData"
/> />
<NotifyConfigDetailDrawer v-model:visible="detailVisible" :row-data="detailData" />
</NCard> </NCard>
</div> </div>
</template> </template>

View File

@ -0,0 +1,69 @@
<script setup lang="ts">
import { watch } from 'vue';
import { enableStatusNumberRecord, jobNotifyScene, retryNotifyScene, systemTaskType } from '@/constants/business';
import { $t } from '@/locales';
import { tagColor } from '@/utils/common';
defineOptions({
name: 'NotifyConfigDetailDrawer'
});
interface Props {
/** row data */
rowData?: Api.NotifyConfig.NotifyConfig | null;
}
const props = defineProps<Props>();
const visible = defineModel<boolean>('visible', {
default: false
});
watch(
() => props.rowData,
() => {
console.log(props.rowData);
},
{ immediate: true }
);
</script>
<template>
<OperateDrawer v-model="visible" :title="$t('page.groupConfig.detail')">
<NDescriptions label-placement="top" bordered :column="2">
<NDescriptionsItem :label="$t('page.notifyConfig.businessName')" :span="2">
{{ rowData?.businessName }}
</NDescriptionsItem>
<NDescriptionsItem :label="$t('page.groupConfig.groupName')" :span="2">
{{ rowData?.groupName }}
</NDescriptionsItem>
<NDescriptionsItem :label="$t('page.notifyConfig.systemTaskType')" :span="1">
<NTag :type="tagColor(rowData?.systemTaskType!)">{{ $t(systemTaskType[rowData?.systemTaskType!]) }}</NTag>
</NDescriptionsItem>
<NDescriptionsItem :label="$t('page.notifyConfig.notifyStatus')" :span="1">
<NTag :type="tagColor(rowData?.notifyStatus!)">{{ $t(enableStatusNumberRecord[rowData?.notifyStatus!]) }}</NTag>
</NDescriptionsItem>
<NDescriptionsItem v-if="rowData?.systemTaskType === 1" :label="$t('page.notifyConfig.notifyScene')" :span="1">
<NTag :type="tagColor(rowData?.notifyScene!)">
{{ $t(retryNotifyScene[rowData?.notifyScene! as Api.NotifyConfig.RetryNotifyScene]) }}
</NTag>
</NDescriptionsItem>
<NDescriptionsItem v-if="rowData?.systemTaskType === 3" :label="$t('page.notifyConfig.notifyScene')" :span="1">
<NTag :type="tagColor(rowData?.notifyScene!)">
{{ $t(jobNotifyScene[rowData?.notifyScene! as Api.NotifyConfig.JobNotifyScene]) }}
</NTag>
</NDescriptionsItem>
<NDescriptionsItem :label="$t('page.notifyConfig.notifyThreshold')" :span="1">
<NTag :type="tagColor(rowData?.notifyThreshold!)">{{ rowData?.notifyThreshold }}</NTag>
</NDescriptionsItem>
<NDescriptionsItem :label="$t('common.createDt')" :span="2">
{{ rowData?.createDt }}
</NDescriptionsItem>
<NDescriptionsItem :label="$t('page.notifyConfig.description')" :span="2">
{{ rowData?.description }}
</NDescriptionsItem>
</NDescriptions>
</OperateDrawer>
</template>
<style scoped></style>

View File

@ -97,7 +97,7 @@ function createDefaultModel(): Model {
systemTaskType: 1, systemTaskType: 1,
notifyStatus: 1, notifyStatus: 1,
notifyScene: 1, notifyScene: 1,
notifyThreshold: 0, notifyThreshold: 16,
rateLimiterStatus: 0, rateLimiterStatus: 0,
rateLimiterThreshold: 0, rateLimiterThreshold: 0,
description: '' description: ''
@ -316,12 +316,14 @@ watch(visible, () => {
<NFormItem :label="$t('page.notifyConfig.rateLimiterThreshold')" path="rateLimiterThreshold"> <NFormItem :label="$t('page.notifyConfig.rateLimiterThreshold')" path="rateLimiterThreshold">
<NInputNumber <NInputNumber
v-model:value="model.rateLimiterThreshold" v-model:value="model.rateLimiterThreshold"
:min="1"
:placeholder="$t('page.notifyConfig.form.rateLimiterThreshold')" :placeholder="$t('page.notifyConfig.form.rateLimiterThreshold')"
/> />
</NFormItem> </NFormItem>
<NFormItem :label="$t('page.notifyConfig.notifyThreshold')" path="notifyThreshold"> <NFormItem :label="$t('page.notifyConfig.notifyThreshold')" path="notifyThreshold">
<NInputNumber <NInputNumber
v-model:value="model.notifyThreshold" v-model:value="model.notifyThreshold"
:min="1"
:placeholder="$t('page.notifyConfig.form.notifyThreshold')" :placeholder="$t('page.notifyConfig.form.notifyThreshold')"
/> />
</NFormItem> </NFormItem>