feat 应用消息订阅配置

This commit is contained in:
DaxPay
2024-08-06 19:12:20 +08:00
parent f1b04219cb
commit a3ed9dee62
5 changed files with 179 additions and 14 deletions

View File

@@ -0,0 +1,31 @@
import { defHttp } from '@/utils/http/axios'
import { Result } from '#/axios'
import { BaseEntity } from '#/web'
import { unref } from 'vue'
/**
* 分页
*/
export const findAllByAppId = (appId) => {
return defHttp.get<Result<NotifyConfigResult[]>>({
url: '/merchant/notify/config/findAllByAppId',
params: { appId: unref(appId) },
})
}
export function subscribe(params) {
return defHttp.post<Result<NotifyConfigResult>>({
url: '/merchant/notify/config/subscribe',
data: params,
})
}
export interface NotifyConfigResult extends BaseEntity {
/** 消息通知类型编码 */
code?: string
/** 订阅名称 */
name?: string
/** 是否订阅 */
subscribe?: boolean
/** 描述 */
description?: string
}

View File

@@ -0,0 +1,108 @@
<template>
<basic-drawer
v-bind="$attrs"
width="60%"
title="消息订阅配置"
:open="visible"
:mask-closable="false"
@cancel="handleCancel"
>
<vxe-toolbar ref="xToolbar" custom :refresh="{ queryMethod: queryPage }" />
<div class="h-80vh">
<vxe-table height="auto" ref="xTable" key-field="id" :data="records" :loading="loading">
<vxe-column field="subscribe" title="状态" align="center" :min-width="80">
<template #default="{ row }">
<template v-if="row.subscribe">
<a-badge dot color="green" />
<span style="color: green">已订阅</span>
</template>
<template v-else>
<a-badge dot color="red" />
<span style="color: red">未订阅</span>
</template>
</template>
</vxe-column>
<vxe-column field="code" title="通知类型" :min-width="180" />
<vxe-column field="name" title="订阅名称" :min-width="180" />
<vxe-column field="description" title="描述" :min-width="280" />
<vxe-column fixed="right" :width="80" :showOverflow="false" title="操作">
<template #default="{ row }">
<a-link danger v-if="row.subscribe" @click="subscribeNotify(row.code, false)"
>取消订阅</a-link
>
<a-link v-else @click="subscribeNotify(row.code, true)">订阅</a-link>
</template>
</vxe-column>
</vxe-table>
</div>
</basic-drawer>
</template>
<script lang="ts" setup>
import { nextTick, ref } from 'vue'
import { findAllByAppId, NotifyConfigResult, subscribe } from './MerchantNotifyConfig.api'
import BasicDrawer from '@/components/Drawer/src/BasicDrawer.vue'
import ALink from '@/components/Link/Link.vue'
import { VxeTableInstance, VxeToolbarInstance } from 'vxe-table'
const loading = ref(false)
const visible = ref(false)
const records = ref<NotifyConfigResult[]>([])
const xTable = ref<VxeTableInstance>()
const xToolbar = ref<VxeToolbarInstance>()
const appId = ref<string>('')
nextTick(() => {
xTable.value?.connect(xToolbar.value as VxeToolbarInstance)
})
/**
* 入口
*/
function init(mchAppId: string) {
visible.value = true
appId.value = mchAppId
queryPage()
}
/**
* 查询列表
*/
function queryPage() {
loading.value = true
findAllByAppId(appId).then((res) => {
records.value = res.data
loading.value = false
})
}
/**
* 订阅设置
*/
function subscribeNotify(notifyType, sub) {
loading.value = true
subscribe({
appId: appId.value,
notifyType,
subscribe: sub,
})
.then(() => {})
.finally(() => {
queryPage()
})
}
/**
* 关闭
*/
function handleCancel() {
visible.value = false
}
defineExpose({
init,
})
</script>
<style></style>

View File

@@ -47,15 +47,29 @@
</template>
</vxe-column>
<vxe-column field="createTime" title="创建时间" :min-width="120" />
<vxe-column fixed="right" :width="220" :showOverflow="false" title="操作">
<vxe-column fixed="right" :width="180" :showOverflow="false" title="操作">
<template #default="{ row }">
<a-link @click="show(row)">查看</a-link>
<a-divider type="vertical" />
<a-link @click="edit(row)">编辑</a-link>
<a-divider type="vertical" />
<a-link @click="showChannelSetup(row)">通道配置</a-link>
<a-dropdown>
<a> 更多 <Icon icon="ant-design:down-outlined" :size="12" /> </a>
<template #overlay>
<a-menu>
<a-menu-item>
<a-link @click="showChannelSetup(row)">通道配置</a-link>
</a-menu-item>
<a-menu-item>
<a-link @click="showNotifyConfig(row)">订阅配置</a-link>
</a-menu-item>
<a-menu-item>
<a-link danger @click="remove(row)">删除</a-link>
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
<a-divider type="vertical" />
<a-link danger @click="remove(row)">删除</a-link>
</template>
</vxe-column>
</vxe-table>
@@ -70,6 +84,7 @@
/>
<mch-app-edit ref="mchApp" @ok="queryPage" />
<channel-config-list ref="channelSetup" />
<MerchantNotifyConfigList ref="merchantNotifyConfigList" />
</div>
</div>
</template>
@@ -89,6 +104,8 @@
import { dropdown as merchantDropdown } from '@/views/daxpay/admin/merchant/info/Merchant.api'
import { LabeledValue } from 'ant-design-vue/lib/select'
import ChannelConfigList from '@/views/daxpay/admin/merchant/channel/ChannelConfigList.vue'
import MerchantNotifyConfigList from '../../config/notify/MerchantNotifyConfigList.vue'
import Icon from '@/components/Icon/Icon.vue'
// 使用hooks
const {
@@ -120,6 +137,7 @@
const xToolbar = ref<VxeToolbarInstance>()
const mchApp: any = ref()
const channelSetup: any = ref()
const merchantNotifyConfigList: any = ref()
const mchNoOptions = ref<LabeledValue[]>([])
onMounted(() => {
@@ -166,13 +184,21 @@
}
/**
* channelSetup
* 通道配置
*/
function showChannelSetup(record) {
channelSetup.value.init(record.appId)
}
/**
* 通知配置
*/
function showNotifyConfig(record) {
merchantNotifyConfigList.value.init(record.appId)
}
// 删除
/**
* 删除
*/
function remove(record) {
createConfirm({
iconType: 'warning',

View File

@@ -4,7 +4,7 @@
v-bind="$attrs"
title="通知明细列表"
width="60%"
:visible="visible"
:open="visible"
@close="visible = false"
>
<vxe-toolbar ref="xToolbar" custom :refresh="{ queryMethod: queryPage }" />

View File

@@ -22,12 +22,12 @@
<a-menu-item>
<a @click="assignRolesBatch()">角色分配</a>
</a-menu-item>
<!-- <a-menu-item>-->
<!-- <a @click="lockUserConfirmBatch(true)">锁定账号</a>-->
<!-- </a-menu-item>-->
<!-- <a-menu-item>-->
<!-- <a @click="lockUserConfirmBatch(false)">解锁账号</a>-->
<!-- </a-menu-item>-->
<!-- <a-menu-item>-->
<!-- <a @click="lockUserConfirmBatch(true)">锁定账号</a>-->
<!-- </a-menu-item>-->
<!-- <a-menu-item>-->
<!-- <a @click="lockUserConfirmBatch(false)">解锁账号</a>-->
<!-- </a-menu-item>-->
<a-menu-item>
<a @click="resetPwdBatch()">重置密码</a>
</a-menu-item>
@@ -81,10 +81,10 @@
</a-menu-item>
<a-menu-item v-if="[1, 3].includes(row.status)">
<a-link v-if="row.status === 1" @click="lockUserConfirm(row.id, true)"
>封禁账号</a-link
>封禁账号</a-link
>
<a-link v-if="row.status === 3" @click="lockUserConfirm(row.id, false)"
>解锁账号</a-link
>解锁账号</a-link
>
</a-menu-item>
</a-menu>