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 */
|
/** edit notify status */
|
||||||
export function fetchUpdateNotifyStatus(id: string, status: Api.Common.EnableStatusNumber) {
|
export function fetchUpdateNotifyStatus(id: string, status: Api.Common.EnableStatusNumber) {
|
||||||
return request<boolean>({
|
return request<boolean>({
|
||||||
@ -69,3 +78,12 @@ export function fetchEditNotifyRecipient(data: Api.NotifyRecipient.NotifyRecipie
|
|||||||
data
|
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 { NButton, NPopconfirm, NTag } from 'naive-ui';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useBoolean } from '@sa/hooks';
|
import { useBoolean } from '@sa/hooks';
|
||||||
import { fetchGetNotifyRecipientPageList } from '@/service/api';
|
import { fetchDeleteNotifyRecipient, fetchGetNotifyRecipientPageList } 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 { alarmTypeRecord } from '@/constants/business';
|
import { alarmTypeRecord } from '@/constants/business';
|
||||||
|
import { tagColor } from '@/utils/common';
|
||||||
import NotifyRecipientOperateDrawer from './modules/notify-recipient-operate-drawer.vue';
|
import NotifyRecipientOperateDrawer from './modules/notify-recipient-operate-drawer.vue';
|
||||||
import NotifyRecipientSearch from './modules/notify-recipient-search.vue';
|
import NotifyRecipientSearch from './modules/notify-recipient-search.vue';
|
||||||
import NotifyRecipientDetailDrawer from './modules/notify-recipient-detail-drawer.vue';
|
import NotifyRecipientDetailDrawer from './modules/notify-recipient-detail-drawer.vue';
|
||||||
@ -65,7 +66,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
|||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
render: row => {
|
render: row => {
|
||||||
const label = $t(alarmTypeRecord[row.notifyType!]);
|
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,
|
editingData,
|
||||||
handleAdd,
|
handleAdd,
|
||||||
handleEdit,
|
handleEdit,
|
||||||
checkedRowKeys,
|
checkedRowKeys
|
||||||
onBatchDeleted,
|
|
||||||
onDeleted
|
|
||||||
// closeDrawer
|
// closeDrawer
|
||||||
} = useTableOperate(data, getData);
|
} = useTableOperate(data, getData);
|
||||||
|
|
||||||
async function handleBatchDelete() {
|
async function handleBatchDelete() {
|
||||||
// request
|
const { error } = await fetchDeleteNotifyRecipient(checkedRowKeys.value);
|
||||||
console.log(checkedRowKeys.value);
|
if (!error) {
|
||||||
|
window.$message?.success($t('common.deleteSuccess'));
|
||||||
onBatchDeleted();
|
getData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDelete(id: string) {
|
async function handleDelete(id: string) {
|
||||||
// request
|
// request
|
||||||
console.log(id);
|
const { error } = await fetchDeleteNotifyRecipient([id]);
|
||||||
|
if (!error) {
|
||||||
onDeleted();
|
window.$message?.success($t('common.deleteSuccess'));
|
||||||
|
getData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit(id: string) {
|
function edit(id: string) {
|
||||||
|
@ -36,7 +36,7 @@ function createDefaultModel(): Model {
|
|||||||
notifyType: 1,
|
notifyType: 1,
|
||||||
webhookUrl,
|
webhookUrl,
|
||||||
ats,
|
ats,
|
||||||
description: ''
|
description: props.value.description
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ interface Props {
|
|||||||
value: Api.NotifyRecipient.NotifyRecipient;
|
value: Api.NotifyRecipient.NotifyRecipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void;
|
(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());
|
const model: Model = reactive(createDefaultModel());
|
||||||
|
|
||||||
function createDefaultModel(): Model {
|
function createDefaultModel(): Model {
|
||||||
|
const { tos } = JSON.parse(props.value.notifyAttribute!) as { tos: string[] };
|
||||||
return {
|
return {
|
||||||
id: '',
|
id: props.value.id,
|
||||||
recipientName: '',
|
recipientName: props.value.recipientName,
|
||||||
notifyType: 2,
|
notifyType: 2,
|
||||||
tos: [],
|
tos,
|
||||||
description: ''
|
description: props.value.description
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ interface Props {
|
|||||||
value: Api.NotifyRecipient.NotifyRecipient;
|
value: Api.NotifyRecipient.NotifyRecipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void;
|
(e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void;
|
||||||
@ -29,13 +29,15 @@ type Model = Pick<
|
|||||||
const model: Model = reactive(createDefaultModel());
|
const model: Model = reactive(createDefaultModel());
|
||||||
|
|
||||||
function createDefaultModel(): Model {
|
function createDefaultModel(): Model {
|
||||||
|
const { webhookUrl, ats } = JSON.parse(props.value.notifyAttribute!) as { webhookUrl: string; ats: string[] };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: '',
|
id: props.value.id,
|
||||||
recipientName: '',
|
recipientName: props.value.recipientName,
|
||||||
notifyType: 4,
|
notifyType: 4,
|
||||||
webhookUrl: '',
|
webhookUrl,
|
||||||
ats: [],
|
ats,
|
||||||
description: ''
|
description: props.value.description
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,11 +64,13 @@ function createDefaultModel(): Model {
|
|||||||
function handleUpdateModelWhenEdit() {
|
function handleUpdateModelWhenEdit() {
|
||||||
if (props.operateType === 'add') {
|
if (props.operateType === 'add') {
|
||||||
model.value = createDefaultModel();
|
model.value = createDefaultModel();
|
||||||
|
notifyTabPane.value = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.operateType === 'edit' && props.rowData) {
|
if (props.operateType === 'edit' && props.rowData) {
|
||||||
model.value = 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';
|
import { $t } from '@/locales';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'WecomForm'
|
name: 'WeComForm'
|
||||||
});
|
});
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value: Api.NotifyRecipient.NotifyRecipient;
|
value: Api.NotifyRecipient.NotifyRecipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void;
|
(e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void;
|
||||||
@ -29,13 +29,14 @@ type Model = Pick<
|
|||||||
const model: Model = reactive(createDefaultModel());
|
const model: Model = reactive(createDefaultModel());
|
||||||
|
|
||||||
function createDefaultModel(): Model {
|
function createDefaultModel(): Model {
|
||||||
|
const { webhookUrl, ats } = JSON.parse(props.value.notifyAttribute!) as { webhookUrl: string; ats: string[] };
|
||||||
return {
|
return {
|
||||||
id: '',
|
id: props.value.id,
|
||||||
recipientName: '',
|
recipientName: props.value.recipientName,
|
||||||
notifyType: 3,
|
notifyType: 3,
|
||||||
webhookUrl: '',
|
webhookUrl,
|
||||||
ats: [],
|
ats,
|
||||||
description: ''
|
description: props.value.description
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import { NButton, NPopconfirm, NTag } from 'naive-ui';
|
import { NButton, NPopconfirm, NTag } from 'naive-ui';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useBoolean } from '@sa/hooks';
|
import { useBoolean } from '@sa/hooks';
|
||||||
import { fetchGetNotifyConfigList, fetchUpdateNotifyStatus } from '@/service/api';
|
import { fetchBatchDeleteNotify, 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';
|
||||||
@ -173,21 +173,25 @@ const {
|
|||||||
editingData,
|
editingData,
|
||||||
handleAdd,
|
handleAdd,
|
||||||
handleEdit,
|
handleEdit,
|
||||||
checkedRowKeys,
|
checkedRowKeys
|
||||||
onBatchDeleted,
|
|
||||||
onDeleted
|
|
||||||
// closeDrawer
|
// closeDrawer
|
||||||
} = useTableOperate(data, getData);
|
} = useTableOperate(data, getData);
|
||||||
|
|
||||||
async function handleBatchDelete() {
|
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
|
// request
|
||||||
console.log(id);
|
const { error } = await fetchBatchDeleteNotify([id]);
|
||||||
|
if (!error) {
|
||||||
onDeleted();
|
window.$message?.success($t('common.deleteSuccess'));
|
||||||
|
getData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit(id: string) {
|
function edit(id: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user