feat(sj_1.0.0): 修复通知人更新问题,添加删除功能
This commit is contained in:
parent
ae847e9f87
commit
add4de0297
@ -27,6 +27,15 @@ export function fetchEditNotify(data: Api.NotifyConfig.NotifyConfig) {
|
||||
});
|
||||
}
|
||||
|
||||
/** delete notify */
|
||||
export function fetchBatchDeleteNotify(data: string[]) {
|
||||
return request<boolean>({
|
||||
url: '/notify-config/ids',
|
||||
method: 'delete',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** edit notify status */
|
||||
export function fetchUpdateNotifyStatus(id: string, status: Api.Common.EnableStatusNumber) {
|
||||
return request<boolean>({
|
||||
@ -69,3 +78,12 @@ export function fetchEditNotifyRecipient(data: Api.NotifyRecipient.NotifyRecipie
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** delete notify recipient */
|
||||
export function fetchDeleteNotifyRecipient(data: string[]) {
|
||||
return request<boolean>({
|
||||
url: '/notify-recipient/ids',
|
||||
method: 'delete',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
@ -2,11 +2,12 @@
|
||||
import { NButton, NPopconfirm, NTag } from 'naive-ui';
|
||||
import { ref } from 'vue';
|
||||
import { useBoolean } from '@sa/hooks';
|
||||
import { fetchGetNotifyRecipientPageList } from '@/service/api';
|
||||
import { fetchDeleteNotifyRecipient, fetchGetNotifyRecipientPageList } from '@/service/api';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import { alarmTypeRecord } from '@/constants/business';
|
||||
import { tagColor } from '@/utils/common';
|
||||
import NotifyRecipientOperateDrawer from './modules/notify-recipient-operate-drawer.vue';
|
||||
import NotifyRecipientSearch from './modules/notify-recipient-search.vue';
|
||||
import NotifyRecipientDetailDrawer from './modules/notify-recipient-detail-drawer.vue';
|
||||
@ -65,7 +66,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
minWidth: 120,
|
||||
render: row => {
|
||||
const label = $t(alarmTypeRecord[row.notifyType!]);
|
||||
return <NTag type="primary">{label}</NTag>;
|
||||
return <NTag type={tagColor(row.notifyType)}>{label}</NTag>;
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -106,24 +107,25 @@ const {
|
||||
editingData,
|
||||
handleAdd,
|
||||
handleEdit,
|
||||
checkedRowKeys,
|
||||
onBatchDeleted,
|
||||
onDeleted
|
||||
checkedRowKeys
|
||||
// closeDrawer
|
||||
} = useTableOperate(data, getData);
|
||||
|
||||
async function handleBatchDelete() {
|
||||
// request
|
||||
console.log(checkedRowKeys.value);
|
||||
|
||||
onBatchDeleted();
|
||||
const { error } = await fetchDeleteNotifyRecipient(checkedRowKeys.value);
|
||||
if (!error) {
|
||||
window.$message?.success($t('common.deleteSuccess'));
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete(id: string) {
|
||||
async function handleDelete(id: string) {
|
||||
// request
|
||||
console.log(id);
|
||||
|
||||
onDeleted();
|
||||
const { error } = await fetchDeleteNotifyRecipient([id]);
|
||||
if (!error) {
|
||||
window.$message?.success($t('common.deleteSuccess'));
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
function edit(id: string) {
|
||||
|
@ -36,7 +36,7 @@ function createDefaultModel(): Model {
|
||||
notifyType: 1,
|
||||
webhookUrl,
|
||||
ats,
|
||||
description: ''
|
||||
description: props.value.description
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ interface Props {
|
||||
value: Api.NotifyRecipient.NotifyRecipient;
|
||||
}
|
||||
|
||||
defineProps<Props>();
|
||||
const props = defineProps<Props>();
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void;
|
||||
@ -26,12 +26,13 @@ type Model = Pick<Api.NotifyRecipient.EmailNotify, 'id' | 'recipientName' | 'not
|
||||
const model: Model = reactive(createDefaultModel());
|
||||
|
||||
function createDefaultModel(): Model {
|
||||
const { tos } = JSON.parse(props.value.notifyAttribute!) as { tos: string[] };
|
||||
return {
|
||||
id: '',
|
||||
recipientName: '',
|
||||
id: props.value.id,
|
||||
recipientName: props.value.recipientName,
|
||||
notifyType: 2,
|
||||
tos: [],
|
||||
description: ''
|
||||
tos,
|
||||
description: props.value.description
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ interface Props {
|
||||
value: Api.NotifyRecipient.NotifyRecipient;
|
||||
}
|
||||
|
||||
defineProps<Props>();
|
||||
const props = defineProps<Props>();
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void;
|
||||
@ -29,13 +29,15 @@ type Model = Pick<
|
||||
const model: Model = reactive(createDefaultModel());
|
||||
|
||||
function createDefaultModel(): Model {
|
||||
const { webhookUrl, ats } = JSON.parse(props.value.notifyAttribute!) as { webhookUrl: string; ats: string[] };
|
||||
|
||||
return {
|
||||
id: '',
|
||||
recipientName: '',
|
||||
id: props.value.id,
|
||||
recipientName: props.value.recipientName,
|
||||
notifyType: 4,
|
||||
webhookUrl: '',
|
||||
ats: [],
|
||||
description: ''
|
||||
webhookUrl,
|
||||
ats,
|
||||
description: props.value.description
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -64,11 +64,13 @@ function createDefaultModel(): Model {
|
||||
function handleUpdateModelWhenEdit() {
|
||||
if (props.operateType === 'add') {
|
||||
model.value = createDefaultModel();
|
||||
notifyTabPane.value = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (props.operateType === 'edit' && props.rowData) {
|
||||
model.value = props.rowData;
|
||||
notifyTabPane.value = props.rowData.notifyType;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,14 +4,14 @@ import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||
import { $t } from '@/locales';
|
||||
|
||||
defineOptions({
|
||||
name: 'WecomForm'
|
||||
name: 'WeComForm'
|
||||
});
|
||||
|
||||
interface Props {
|
||||
value: Api.NotifyRecipient.NotifyRecipient;
|
||||
}
|
||||
|
||||
defineProps<Props>();
|
||||
const props = defineProps<Props>();
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void;
|
||||
@ -29,13 +29,14 @@ type Model = Pick<
|
||||
const model: Model = reactive(createDefaultModel());
|
||||
|
||||
function createDefaultModel(): Model {
|
||||
const { webhookUrl, ats } = JSON.parse(props.value.notifyAttribute!) as { webhookUrl: string; ats: string[] };
|
||||
return {
|
||||
id: '',
|
||||
recipientName: '',
|
||||
id: props.value.id,
|
||||
recipientName: props.value.recipientName,
|
||||
notifyType: 3,
|
||||
webhookUrl: '',
|
||||
ats: [],
|
||||
description: ''
|
||||
webhookUrl,
|
||||
ats,
|
||||
description: props.value.description
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { NButton, NPopconfirm, NTag } from 'naive-ui';
|
||||
import { ref } from 'vue';
|
||||
import { useBoolean } from '@sa/hooks';
|
||||
import { fetchGetNotifyConfigList, fetchUpdateNotifyStatus } from '@/service/api';
|
||||
import { fetchBatchDeleteNotify, fetchGetNotifyConfigList, fetchUpdateNotifyStatus } from '@/service/api';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
@ -173,21 +173,25 @@ const {
|
||||
editingData,
|
||||
handleAdd,
|
||||
handleEdit,
|
||||
checkedRowKeys,
|
||||
onBatchDeleted,
|
||||
onDeleted
|
||||
checkedRowKeys
|
||||
// closeDrawer
|
||||
} = useTableOperate(data, getData);
|
||||
|
||||
async function handleBatchDelete() {
|
||||
onBatchDeleted();
|
||||
const { error } = await fetchBatchDeleteNotify(checkedRowKeys.value);
|
||||
if (!error) {
|
||||
window.$message?.success($t('common.deleteSuccess'));
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete(id: string) {
|
||||
async function handleDelete(id: string) {
|
||||
// request
|
||||
console.log(id);
|
||||
|
||||
onDeleted();
|
||||
const { error } = await fetchBatchDeleteNotify([id]);
|
||||
if (!error) {
|
||||
window.$message?.success($t('common.deleteSuccess'));
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
function edit(id: string) {
|
||||
|
Loading…
Reference in New Issue
Block a user