fix: 订阅管理修改

This commit is contained in:
100011797 2023-06-21 11:16:43 +08:00
parent 71ffdc13fe
commit 02b2ce66a9
10 changed files with 198 additions and 93 deletions

View File

@ -7,6 +7,9 @@ export const getList_api = (data: any): any => server.post(`/notifications/_quer
// 修改记录状态
export const changeStatus_api = (type: '_read' | '_unread', data: string[]): any => server.post(`/notifications/${type}`, data)
export const changeAllStatus = (type: '_read' | '_unread', data: string[]): any => server.post(`/notifications/${type}/provider`, data)
// 查询告警记录详情
export const getDetail = (id: string): any => server.get(`/alarm/record/${id}`)

View File

@ -5,7 +5,7 @@
:columns="columns"
target="category"
style="padding: 0"
@search="(params:any)=>queryParams = {...params}"
@search="queryParams"
/>
<j-pro-table
@ -18,7 +18,9 @@
:defaultParams="defaultParams"
>
<template #headerTitle>
<j-button @click="onAllRead" type="primary">全部已读</j-button>
<j-popconfirm title="确认全部已读?" @confirm="onAllRead">
<j-button type="primary">全部已读</j-button>
</j-popconfirm>
</template>
<template #topicProvider="slotProps">
{{ slotProps.topicName }}
@ -89,12 +91,13 @@ import PermissionButton from '@/components/PermissionButton/index.vue';
import {
getList_api,
changeStatus_api,
changeAllStatus
} from '@/api/account/notificationRecord';
import dayjs from 'dayjs';
import { message } from 'ant-design-vue';
import { useUserInfo } from '@/store/userInfo';
import { useRouterParams } from '@/utils/hooks/useParams';
import { getTypeList_api } from '@/api/account/notificationSubscription';
import { onlyMessage } from '@/utils/comm';
const user = useUserInfo();
@ -229,7 +232,7 @@ const changeStatus = (row: any) => {
const type = row.state.value === 'read' ? '_unread' : '_read';
changeStatus_api(type, [row.id]).then((resp: any) => {
if (resp.status === 200) {
message.success('操作成功!');
onlyMessage('操作成功!');
refresh();
user.updateAlarm();
}
@ -242,8 +245,12 @@ watchEffect(() => {
}
})
const onAllRead = () => {
const onAllRead = async () => {
const resp = await changeAllStatus('_read', getType.value)
if(resp.status === 200){
onlyMessage('操作成功!')
refresh()
}
}
onMounted(() => {

View File

@ -1372,6 +1372,7 @@
v-if="routeQuery.view !== 'true'"
@click="clickSave"
type="primary"
:loading="loading"
>
保存
</j-button>
@ -1418,7 +1419,9 @@ const menuStory = useMenuStore();
const deptPermission = 'system/Department';
const rolePermission = 'system/Role';
const typeOptions = ref<any[]>([])
const typeOptions = ref<any[]>([]);
const loading = ref<boolean>(false);
//
const initForm: formType = {
@ -1755,6 +1758,7 @@ function clickSave() {
}));
}
loading.value = true
const request = routeQuery.id
? updateApp_api(routeQuery.id as string, params)
: addApp_api(params);
@ -1772,7 +1776,9 @@ function clickSave() {
menuStory.jumpPage('system/Apply');
}
}
});
}).finally(() => {
loading.value = false
})
});
}
function getErrorNum(

View File

@ -11,7 +11,6 @@
</template>
<script lang="ts" setup>
import { onlyMessage } from '@/utils/comm';
import { PropType } from 'vue';
import Role from '../Role/index.vue';

View File

@ -97,7 +97,7 @@ const handleSearch = async () => {
.map((item: string) => {
return (resp?.result || []).find((i: any) => i?.id === item)?.name
})
?.join(',');
?.join(',') || '未配置权限'
}
}
};

View File

@ -100,7 +100,10 @@
<div class="child-item-right-auth">
<j-tooltip :title="!update ? '暂无权限,请联系管理员' : ''">
<j-button :disabled="!update" type="text" @click="onAuth">
<div class="child-item-right-auth-btn" :class="{ active: auth.length }">
<div
class="child-item-right-auth-btn"
:class="{ active: auth.length }"
>
<AIcon type="UserOutlined" />
<span>权限控制</span>
</div>
@ -143,8 +146,10 @@ import {
editChannelConfig,
updateChannelConfig,
} from '@/api/system/noticeRule';
import { Modal } from 'jetlinks-ui-components';
import { Modal, Checkbox } from 'jetlinks-ui-components';
import { usePermissionStore } from '@/store/permission';
import { LocalStore } from '@/utils/comm';
import { useUserInfo } from '@/store/userInfo';
const props = defineProps({
data: {
@ -165,6 +170,7 @@ const auth = ref<string[]>([]);
const loading = ref<boolean>(false);
const permission = usePermissionStore();
const user = useUserInfo();
const action = permission.hasPermission('system/NoticeRule:action');
const add = permission.hasPermission('system/NoticeRule:add');
@ -224,74 +230,116 @@ const onAuthSave = (_data: string[]) => {
});
};
const onSwitchChange = (e: boolean) => {
Modal.confirm({
title: e
? '开启后默认平台所有用户都能接收到该通知'
: '关闭后平台所有用户都不能接收到该通知',
cancelText: '取消',
okText: e ? '确认开启' : '确认关闭',
onOk() {
if (e) {
// enable
if (
props.data.id &&
props.data.channels?.length &&
props.data.channels.find(
(item: any) => item.channelProvider === 'inside-mail',
)
) {
actionChannelConfig(props.data.id, 'enable').then(
(resp) => {
if (resp.status === 200) {
onlyMessage('操作成功!');
emits('refresh');
}
},
);
} else {
const obj = {
...props.data,
state: 'enabled',
channels: [
{
name: '站内信',
channelProvider: 'inside-mail',
grant: {},
},
],
};
saveChannelConfig([obj]).then((resp) => {
if (resp.status === 200) {
onlyMessage('操作成功!', 'success');
emits('refresh');
}
});
const onAction = (e: boolean) => {
if (e) {
// enable
if (
props.data.id &&
props.data.channels?.length &&
props.data.channels.find(
(item: any) => item.channelProvider === 'inside-mail',
)
) {
actionChannelConfig(props.data.id, 'enable').then((resp) => {
if (resp.status === 200) {
onlyMessage('操作成功!');
emits('refresh');
}
} else {
actionChannelConfig(props.data.id, 'disable').then((resp) => {
if (resp.status === 200) {
onlyMessage('操作成功!');
emits('refresh');
}
});
});
} else {
const obj = {
...props.data,
state: 'enabled',
channels: [
{
name: '站内信',
channelProvider: 'inside-mail',
grant: {},
},
],
};
saveChannelConfig([obj]).then((resp) => {
if (resp.status === 200) {
onlyMessage('操作成功!', 'success');
emits('refresh');
}
});
}
} else {
actionChannelConfig(props.data.id, 'disable').then((resp) => {
if (resp.status === 200) {
onlyMessage('操作成功!');
emits('refresh');
}
},
onCancel() {},
});
});
}
};
const onSwitchChange = (e: boolean) => {
const _value = LocalStore.get(user.userInfos?.username) || {};
let _checked: boolean = e ? _value?.open : _value?.close;
if (_checked) {
onAction(e);
} else {
Modal.confirm({
title: e
? '开启后默认平台所有用户都能接收到该通知'
: '关闭后平台所有用户都不能接收到该通知',
cancelText: '取消',
okText: e ? '确认开启' : '确认关闭',
content: h(
'div',
{
style: {
display: 'flex',
justifyContent: 'flex-end',
marginTop: '20px',
},
},
[
h(
Checkbox,
{
onChange: (_e: any) => {
LocalStore.set(
user.userInfos?.username,
e
? {
..._value,
open: _e.target?.checked,
}
: {
..._value,
close: _e.target?.checked,
},
);
},
},
'不再提示',
),
],
),
onOk() {
onAction(e);
},
onCancel() {},
});
}
};
const onSave = (_data: any) => {
loading.value = true
updateChannelConfig(props.data.id, [_data]).then((resp) => {
if (resp.status === 200) {
onlyMessage('操作成功!', 'success');
visible.value = false;
emits('refresh');
}
}).finally(() => {
loading.value = false
})
loading.value = true;
updateChannelConfig(props.data.id, [_data])
.then((resp) => {
if (resp.status === 200) {
onlyMessage('操作成功!', 'success');
visible.value = false;
emits('refresh');
}
})
.finally(() => {
loading.value = false;
});
};
</script>

View File

@ -86,6 +86,7 @@ const onSearch = (e: any) => {
//
const cancelSelect = () => {
_selectedRowKeys.value = [];
emit('update:modelValue', []);
};
const onSelect = (record: any, selected: boolean) => {

View File

@ -159,11 +159,11 @@ const handleClick = (dt: any) => {
if (_selectedRowKeys.value.includes(dt.id)) {
_selectedRowKeys.value = [];
emit('update:value', undefined);
emit('change', { provider: undefined });
emit('change', { provider: undefined, value: undefined });
} else {
_selectedRowKeys.value = [dt.id];
emit('update:value', dt.id);
emit('change', { provider: dt?.provider });
emit('change', { provider: dt?.provider, value: dt.id });
}
};

View File

@ -138,12 +138,12 @@ const handleClick = (dt: any) => {
if (_selectedRowKeys.value.includes(dt.id)) {
_selectedRowKeys.value = [];
emit('update:value', undefined);
emit('change', { templateName: undefined });
emit('change', { templateName: undefined, value: undefined });
emit('update:detail', undefined);
} else {
_selectedRowKeys.value = [dt.id];
emit('update:value', dt.id);
emit('change', { templateName: dt?.name });
emit('change', { templateName: dt?.name, value: dt?.id });
emit('update:detail', dt);
}
};

View File

@ -12,20 +12,23 @@
<div style="margin: 20px">
<template v-if="current === 0">
<NotifyWay
v-model:value="formModel.channelProvider"
v-model:name="formModel.name"
:value="formModel.channelProvider"
:name="formModel.name"
@change="onWayChange"
/>
</template>
<template v-if="current === 1">
<NotifyConfig
v-model:value="formModel.channelConfiguration.notifierId"
:value="formModel.channelConfiguration.notifierId"
:notifyType="formModel.channelProvider"
@change="onConfigChange"
/>
</template>
<template v-if="current === 2">
<NotifyTemplate
v-model:value="formModel.channelConfiguration.templateId"
:value="formModel.channelConfiguration.templateId"
:notifierId="formModel.channelConfiguration.notifierId"
@change="onTemplateChange"
/>
</template>
<template v-if="current === 3">
@ -52,7 +55,13 @@
v-if="current !== stepList.length - 1"
>下一步</j-button
>
<j-button :loading="loading" type="primary" @click="onSave" v-else>确认</j-button>
<j-button
:loading="loading"
type="primary"
@click="onSave"
v-else
>确认</j-button
>
</j-space>
</template>
</j-modal>
@ -89,8 +98,8 @@ const props = defineProps({
},
loading: {
type: Boolean,
default: false
}
default: false,
},
});
const stepList = [
@ -128,11 +137,13 @@ const _variableDefinitions = computed(() => {
const handleVariable = (obj: any) => {
const arr = ['user', 'org'];
const _array = variable.value.filter((item: any) => {
const _type = item.expands?.businessType || item.type || '';
return arr.includes(_type);
}).map((i: any) => i?.id);
const _variable = variableMap.get(formModel.channelProvider)
const _array = variable.value
.filter((item: any) => {
const _type = item.expands?.businessType || item.type || '';
return arr.includes(_type);
})
.map((i: any) => i?.id);
const _variable = variableMap.get(formModel.channelProvider);
const _obj = {};
[...new Set([..._array, _variable]).values()].map((item: string) => {
_obj[item] = {
@ -153,7 +164,9 @@ const handleVariable = (obj: any) => {
};
const jumpStep = async (val: number) => {
if (val === 1) {
if (val === 0) {
current.value = val;
} else if (val === 1) {
if (formModel.channelProvider) {
current.value = val;
} else {
@ -197,6 +210,34 @@ const jumpStep = async (val: number) => {
}
};
const onWayChange = (obj: any) => {
//
if (formModel.channelProvider !== obj.value) {
formModel.channelConfiguration.notifierId = '';
formModel.channelConfiguration.templateId = '';
formModel.channelConfiguration.variables = {};
}
formModel.channelProvider = obj?.value;
formModel.name = obj?.label;
};
const onConfigChange = (obj: any) => {
//
if (formModel.channelConfiguration?.notifierId !== obj?.value) {
formModel.channelConfiguration.templateId = '';
formModel.channelConfiguration.variables = {};
}
formModel.channelConfiguration.notifierId = obj?.value;
};
const onTemplateChange = (obj: any) => {
//
if (formModel.channelConfiguration?.templateId !== obj?.value) {
formModel.channelConfiguration.variables = {};
}
formModel.channelConfiguration.templateId = obj?.value
};
watchEffect(() => {
Object.assign(formModel, props.data);
});