fix: 代理

This commit is contained in:
luo
2026-09-12 11:27:50 +08:00
parent d3d257cdf8
commit 2308d82d0f
44 changed files with 5470 additions and 200 deletions

View File

@@ -31,7 +31,7 @@
:total="pagination.total"
:marginTop="10"
:actions="getActions"
:actionsWidth="180"
:actionsWidth="160"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
>
@@ -48,13 +48,6 @@
destroy-on-close
@closed="clearSensitiveForm"
>
<ElAlert
title="支付凭证仅用于本次写入,页面不会回显、缓存或记录凭证内容。"
type="warning"
:closable="false"
show-icon
/>
<ElForm ref="formRef" :model="form" :rules="formRules" label-width="120px">
<ElFormItem label="商户名称" prop="name">
<ElInput v-model="form.name" maxlength="100" placeholder="请输入商户名称" />
@@ -117,12 +110,12 @@
</ElFormItem>
<template v-if="showCredentialEditor">
<ElDivider content-position="left">写入支付凭证</ElDivider>
<ElAlert
title="凭证值以密码方式输入,提交后立即清空。"
type="info"
:closable="false"
show-icon
/>
<div class="credential-tip">
必填字段:{{ credentialFieldSpec.required.join('、') || '-' }}
<template v-if="credentialFieldSpec.optional.length">
;可选字段:{{ credentialFieldSpec.optional.join('、') }}
</template>
</div>
<div class="credential-list">
<div
v-for="(entry, index) in form.credentials"
@@ -170,37 +163,12 @@
</ElButton>
</template>
</ElDrawer>
<ElDrawer v-model="detailDrawerVisible" title="支付商户详情" size="560px">
<ElDescriptions v-if="detail" :column="1" border>
<ElDescriptionsItem label="商户名称">{{ detail.name }}</ElDescriptionsItem>
<ElDescriptionsItem label="支付方式">{{
getPaymentMethodLabel(detail.payment_method)
}}</ElDescriptionsItem>
<ElDescriptionsItem label="服务商类型">{{
getPaymentProviderLabel(detail.provider_type)
}}</ElDescriptionsItem>
<ElDescriptionsItem label="商户标识">{{ detail.merchant_identity }}</ElDescriptionsItem>
<ElDescriptionsItem label="启停状态">{{
detail.enabled ? '启用' : '停用'
}}</ElDescriptionsItem>
<ElDescriptionsItem label="支付凭证">{{
Number(detail.credential_version) > 0 ? '已配置' : '未配置'
}}</ElDescriptionsItem>
<ElDescriptionsItem label="凭证版本">{{
detail.credential_version || '-'
}}</ElDescriptionsItem>
<ElDescriptionsItem label="备注">{{ detail.remark || '-' }}</ElDescriptionsItem>
<ElDescriptionsItem label="更新时间">{{
formatDateTime(detail.updated_at)
}}</ElDescriptionsItem>
</ElDescriptions>
</ElDrawer>
</div>
</template>
<script setup lang="ts">
import { computed, h, onMounted, onUnmounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { Delete, Plus } from '@element-plus/icons-vue'
import { ElButton, ElMessage, ElMessageBox, ElTag } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
@@ -211,8 +179,10 @@
import {
PAYMENT_METHOD_OPTIONS,
PAYMENT_PROVIDER_OPTIONS,
buildPaymentCredentials,
getPaymentMethodLabel,
getPaymentProviderLabel,
getPaymentCredentialFieldSpec,
type PaymentCredentialEntry,
type PaymentCredentials,
type PaymentMerchant,
@@ -221,6 +191,7 @@
type PaymentMerchantProviderType,
type PaymentMerchantQueryParams
} from '@/types/api/paymentMerchantPools'
import { RoutesAlias } from '@/router/routesAlias'
import { formatDateTime } from '@/utils/business/format'
defineOptions({ name: 'PaymentMerchantManagement' })
@@ -228,8 +199,20 @@
type FilterVo = string | number | undefined | null | unknown[]
const { isPlatformAccount } = usePermission()
const router = useRouter()
const canManage = computed(() => isPlatformAccount.value)
const handleNameClick = (row: PaymentMerchant) => {
if (!canManage.value) {
ElMessage.warning('您没有查看支付商户详情的权限')
return
}
router.push({
path: `${RoutesAlias.PaymentMerchantPoolsDetail}/${row.id}`
})
}
// 列表查询
const searchForm = reactive<Record<string, FilterVo>>({
page: 1,
@@ -273,7 +256,24 @@
]
const columnOptions = [
{ label: '商户名称', prop: 'name', minWidth: 180 },
{
label: '商户名称',
prop: 'name',
minWidth: 180,
showOverflowTooltip: true,
formatter: (row: PaymentMerchant) =>
h(
'span',
{
style: 'color: var(--el-color-primary); cursor: pointer; text-decoration: underline;',
onClick: (event: MouseEvent) => {
event.stopPropagation()
handleNameClick(row)
}
},
row.name
)
},
{
label: '支付方式',
prop: 'payment_method',
@@ -388,6 +388,7 @@
const formRef = ref<FormInstance>()
const showCredentialEditor = ref(false)
const credentialError = ref('')
const credentialTemplateKeys = ref<string[]>([])
const initialFormState = () => ({
id: 0,
@@ -409,6 +410,9 @@
const credentialConfigured = computed(() => Number(form.credential_version) > 0)
// 当前服务商组合下的凭证必填/可选字段枚举
const credentialFieldSpec = computed(() => getPaymentCredentialFieldSpec(form.provider_type))
const formRules = reactive<FormRules>({
name: [
{ required: true, message: '请输入商户名称', trigger: 'blur' },
@@ -429,6 +433,7 @@
form.credentials = []
showCredentialEditor.value = false
credentialError.value = ''
credentialTemplateKeys.value = []
}
const clearSensitiveForm = () => {
@@ -439,25 +444,13 @@
}
const buildCredentialPayload = (): PaymentCredentials | null => {
const credentials: Record<string, string> = {}
for (const entry of form.credentials) {
const key = entry.key.trim()
if (!key) {
credentialError.value = '请填写凭证字段名'
return null
}
if (!entry.value) {
credentialError.value = `请填写凭证字段 ${key} 的值`
return null
}
if (Object.prototype.hasOwnProperty.call(credentials, key)) {
credentialError.value = `凭证字段 ${key} 重复`
return null
}
credentials[key] = entry.value
}
if (form.credentials.length === 0) {
credentialError.value = '请至少添加一个凭证字段'
const { credentials, error } = buildPaymentCredentials(
form.provider_type,
form.merchant_identity,
form.credentials
)
if (!credentials) {
credentialError.value = error
return null
}
credentialError.value = ''
@@ -467,6 +460,7 @@
const showCreateDrawer = () => {
if (!canManage.value) return
Object.assign(form, initialFormState())
credentialTemplateKeys.value = []
formDrawerVisible.value = true
formMode.value = 'create'
showCredentialEditor.value = true
@@ -476,8 +470,16 @@
const startCredentialReplacement = () => {
if (!canManage.value) return
form.credentials = []
if (credentialTemplateKeys.value.length > 0) {
form.credentials = credentialTemplateKeys.value.map((key) => ({
localId: generateLocalId(),
key,
value: ''
}))
} else {
addCredential()
}
showCredentialEditor.value = true
addCredential()
}
const addCredential = () => {
@@ -531,6 +533,7 @@
ElMessage.success('支付凭证更新成功')
}
formDrawerVisible.value = false
clearSensitiveForm()
await loadMerchants()
} catch (error) {
console.error('提交支付商户失败:', error)
@@ -549,6 +552,7 @@
})
ElMessage.success('支付商户已更新')
formDrawerVisible.value = false
clearSensitiveForm()
await loadMerchants()
} catch (error) {
console.error('更新支付商户失败:', error)
@@ -557,23 +561,9 @@
}
}
// 详情 / 启停 / 删除
const detailDrawerVisible = ref(false)
const detail = ref<PaymentMerchant | null>(null)
// 启停 / 删除
const tableRef = ref()
const showDetail = async (id: number) => {
try {
const res = await PaymentMerchantPoolsService.getPaymentMerchantById(id)
if (res.code === 0) {
detail.value = res.data
detailDrawerVisible.value = true
}
} catch (error) {
console.error('加载支付商户详情失败:', error)
}
}
const openEditDrawer = async (id: number) => {
if (!canManage.value) return
try {
@@ -648,11 +638,6 @@
}
const getActions = (row: PaymentMerchant) => [
{
label: '详情',
type: 'primary' as const,
handler: () => showDetail(row.id)
},
{
label: '编辑',
type: 'primary' as const,
@@ -682,7 +667,6 @@
onUnmounted(() => {
resetSensitiveForm()
merchants.value = []
detail.value = null
})
</script>
@@ -708,6 +692,14 @@
color: var(--el-text-color-secondary);
}
.credential-tip {
margin-bottom: 8px;
font-size: 12px;
line-height: 20px;
color: var(--el-text-color-secondary);
word-break: break-all;
}
.field-error {
margin-top: 8px;
font-size: 12px;

View File

@@ -202,48 +202,12 @@
</ElButton>
</template>
</ElDrawer>
<ElDrawer v-model="detailDrawerVisible" title="商户池详情" size="640px">
<ElDescriptions v-if="detail" :column="1" border>
<ElDescriptionsItem label="商户池名称">{{ detail.name }}</ElDescriptionsItem>
<ElDescriptionsItem label="支付方式">{{
getPaymentMethodLabel(detail.payment_method)
}}</ElDescriptionsItem>
<ElDescriptionsItem label="成员数量">{{ detail.member_ids.length }}</ElDescriptionsItem>
<ElDescriptionsItem label="轮询策略">{{
getPaymentPoolStrategyLabel(detail.strategy)
}}</ElDescriptionsItem>
<ElDescriptionsItem
v-if="detail.strategy === 'amount' || detail.strategy === 'count'"
label="统计周期"
>
{{ getPaymentStatisticCycleLabel(detail.statistic_cycle) }}
</ElDescriptionsItem>
<ElDescriptionsItem v-if="detail.strategy === 'amount'" label="金额阈值">
{{ (Number(detail.threshold_amount) / 100).toFixed(2) }} 元
</ElDescriptionsItem>
<ElDescriptionsItem v-if="detail.strategy === 'count'" label="笔数阈值">
{{ detail.threshold_count }}
</ElDescriptionsItem>
<ElDescriptionsItem v-if="detail.strategy === 'time'" label="时间周期">
{{ detail.time_period_value }}
{{ getPaymentTimePeriodUnitLabel(detail.time_period_unit) }}
</ElDescriptionsItem>
<ElDescriptionsItem label="启停状态">
{{ detail.enabled ? '启用' : '停用' }}
</ElDescriptionsItem>
<ElDescriptionsItem label="路由世代">v{{ detail.routing_epoch }}</ElDescriptionsItem>
<ElDescriptionsItem label="备注">{{ detail.remark || '-' }}</ElDescriptionsItem>
<ElDescriptionsItem label="更新时间">{{
formatDateTime(detail.updated_at)
}}</ElDescriptionsItem>
</ElDescriptions>
</ElDrawer>
</div>
</template>
<script setup lang="ts">
import { computed, h, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
import { computed, h, onMounted, onUnmounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { Delete, Plus, Rank } from '@element-plus/icons-vue'
import { VueDraggable } from 'vue-draggable-plus'
import { ElButton, ElMessage, ElMessageBox, ElTag } from 'element-plus'
@@ -269,14 +233,25 @@
type PaymentPoolStrategy
} from '@/types/api/paymentMerchantPools'
import { formatDateTime } from '@/utils/business/format'
import { RoutesAlias } from '@/router/routesAlias'
defineOptions({ name: 'PaymentMerchantPoolManagement' })
type FilterVo = string | number | undefined | null | unknown[]
const { isPlatformAccount } = usePermission()
const router = useRouter()
const canManage = computed(() => isPlatformAccount.value)
const handleNameClick = (row: PaymentMerchantPool) => {
if (!canManage.value) {
ElMessage.warning('您没有查看商户池详情的权限')
return
}
router.push({ path: `${RoutesAlias.PaymentMerchantPoolDetail}/${row.id}` })
}
const searchForm = reactive<Record<string, FilterVo>>({
page: 1,
page_size: 10,
@@ -301,7 +276,24 @@
]
const columnOptions = [
{ label: '商户池名称', prop: 'name', minWidth: 180 },
{
label: '商户池名称',
prop: 'name',
minWidth: 180,
showOverflowTooltip: true,
formatter: (row: PaymentMerchantPool) =>
h(
'span',
{
style: 'color: var(--el-color-primary); cursor: pointer; text-decoration: underline;',
onClick: (event: MouseEvent) => {
event.stopPropagation()
handleNameClick(row)
}
},
row.name
)
},
{
label: '支付方式',
prop: 'payment_method',
@@ -445,7 +437,7 @@
)
const getMemberName = (id: number) =>
availableMerchants.value.find((m) => m.id === id)?.name || `#${id}`
availableMerchants.value.find((m) => m.id === id)?.name || '未知商户'
// 表单
type FormMode = 'create' | 'edit'
@@ -475,16 +467,13 @@
const form = reactive(initialFormState())
const orderedMemberIds = ref<number[]>([])
watch(
() => form.member_ids,
(val) => {
orderedMemberIds.value = [...val]
},
{ immediate: true, deep: true }
)
watch(orderedMemberIds, (val) => {
form.member_ids = [...val]
// 成员顺序以 form.member_ids 为单一数据源:VueDraggable 的 v-model 直接写回该数组,
// 避免双向 watch 互相赋值导致的递归更新。
const orderedMemberIds = computed<number[]>({
get: () => form.member_ids,
set: (val) => {
form.member_ids = [...val]
}
})
const formRules = reactive<FormRules>({
@@ -611,7 +600,6 @@
const handlePaymentMethodChange = (value: PaymentMerchantMethod) => {
form.payment_method = value
form.member_ids = []
orderedMemberIds.value = []
availableMerchants.value = []
memberError.value = ''
loadAvailableMerchants(value)
@@ -688,7 +676,6 @@
const showCreateDrawer = async () => {
if (!canManage.value) return
Object.assign(form, initialFormState())
orderedMemberIds.value = []
formDrawerVisible.value = true
formMode.value = 'create'
await loadAvailableMerchants(form.payment_method)
@@ -712,14 +699,12 @@
time_period_started_at: pool.time_period_started_at || '',
remark: pool.remark || ''
})
orderedMemberIds.value = [...pool.member_ids]
formDrawerVisible.value = true
formMode.value = 'edit'
}
const resetForm = () => {
Object.assign(form, initialFormState())
orderedMemberIds.value = []
memberError.value = ''
pendingMemberId.value = undefined
formRef.value?.clearValidate()
@@ -753,23 +738,8 @@
}
}
// 详情
const detailDrawerVisible = ref(false)
const detail = ref<PaymentMerchantPool | null>(null)
const tableRef = ref()
const showDetail = async (id: number) => {
try {
const res = await PaymentMerchantPoolsService.getPaymentMerchantPoolById(id)
if (res.code === 0) {
detail.value = res.data
detailDrawerVisible.value = true
}
} catch (error) {
console.error('加载商户池详情失败:', error)
}
}
const toggleEnabled = async (pool: PaymentMerchantPool) => {
if (!canManage.value) return
const target = !pool.enabled
@@ -795,11 +765,6 @@
}
const getActions = (row: PaymentMerchantPool) => [
{
label: '详情',
type: 'primary' as const,
handler: () => showDetail(row.id)
},
{
label: '编辑',
type: 'primary' as const,
@@ -822,9 +787,7 @@
onUnmounted(() => {
pools.value = []
detail.value = null
availableMerchants.value = []
orderedMemberIds.value = []
})
</script>

View File

@@ -0,0 +1,297 @@
<template>
<div class="payment-merchant-detail-page">
<ElCard shadow="never">
<div class="detail-header">
<ElButton @click="handleBack">
<template #icon>
<ElIcon><ArrowLeft /></ElIcon>
</template>
返回
</ElButton>
<h2 class="detail-title">{{ pageTitle }}</h2>
</div>
<DetailPage v-if="detailData" :sections="detailSections" :data="detailData" />
<div v-if="loading" class="loading-container">
<ElIcon class="is-loading"><Loading /></ElIcon>
<span>加载中...</span>
</div>
</ElCard>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElButton, ElCard, ElIcon } from 'element-plus'
import { ArrowLeft, Loading } from '@element-plus/icons-vue'
import DetailPage from '@/components/common/DetailPage.vue'
import type { DetailField, DetailSection } from '@/components/common/DetailPage.vue'
import { PaymentMerchantPoolsService } from '@/api/modules'
import type { PaymentMerchantDetail } from '@/types/api'
import { formatDateTime } from '@/utils/business/format'
import { getPaymentMethodLabel, getPaymentProviderLabel } from '@/types/api/paymentMerchantPools'
defineOptions({ name: 'PaymentMerchantPoolsDetail' })
const route = useRoute()
const router = useRouter()
const loading = ref(false)
const detailData = ref<PaymentMerchantDetail | null>(null)
const merchantId = computed(() => Number(route.params.id))
const pageTitle = computed(() => `支付商户详情 #${merchantId.value}`)
const formatText = (value: string | number | boolean | undefined | null): string => {
if (value === undefined || value === null || value === '') return '-'
return String(value)
}
const formatBoolean = (value: boolean): string => (value ? '是' : '否')
const formatCredentialStatus = (value: string | number | boolean | undefined | null): string => {
if (value === '已配置') return '已配置'
if (value === true || value === 1) return '已配置'
return '未配置'
}
const baseSection: DetailSection = {
title: '基本信息',
fields: [
{ label: '商户ID', prop: 'id' },
{ label: '商户名称', prop: 'name' },
{
label: '支付方式',
formatter: (_, data) => getPaymentMethodLabel(data.payment_method)
},
{
label: '服务商类型',
formatter: (_, data) => getPaymentProviderLabel(data.provider_type)
},
{ label: '商户标识', prop: 'merchant_identity' },
{
label: '启停状态',
formatter: (_, data) => (data.enabled ? '启用' : '停用')
},
{
label: '凭证状态',
formatter: (_, data) =>
Number(data.credential_version) > 0 ? '已配置' : '未配置'
},
{ label: '凭证版本', prop: 'credential_version' },
{
label: '备注',
prop: 'remark',
formatter: (value) => formatText(value),
fullWidth: true
},
{
label: '创建时间',
prop: 'created_at',
formatter: (value) => formatDateTime(value)
},
{
label: '更新时间',
prop: 'updated_at',
formatter: (value) => formatDateTime(value)
}
]
}
const alipayFields: DetailField[] = [
{
label: '支付宝AppID',
prop: 'credentials.ali_app_id',
formatter: (value) => formatText(value)
},
{
label: '支付过期分钟数',
prop: 'credentials.ali_pay_expire_minutes',
formatter: (value) => formatText(value)
},
{
label: '生产环境',
prop: 'credentials.ali_production',
formatter: (value) => formatBoolean(value)
},
{
label: '异步通知地址',
prop: 'credentials.ali_notify_url',
formatter: (value) => formatText(value),
fullWidth: true
},
{
label: '同步跳转地址',
prop: 'credentials.ali_return_url',
formatter: (value) => formatText(value),
fullWidth: true
},
{
label: '应用私钥',
prop: 'credentials.ali_private_key',
formatter: (value) => formatCredentialStatus(value)
},
{
label: '支付宝公钥',
prop: 'credentials.ali_public_key',
formatter: (value) => formatCredentialStatus(value)
}
]
const wechatPayFields: DetailField[] = [
{
label: '微信商户号',
prop: 'credentials.wx_mch_id',
formatter: (value) => formatText(value)
},
{
label: '证书序列号',
prop: 'credentials.wx_serial_no',
formatter: (value) => formatText(value)
},
{
label: '支付回调地址',
prop: 'credentials.wx_notify_url',
formatter: (value) => formatText(value),
fullWidth: true
},
{
label: 'APIv2密钥',
prop: 'credentials.wx_api_v2_key',
formatter: (value) => formatCredentialStatus(value)
},
{
label: 'APIv3密钥',
prop: 'credentials.wx_api_v3_key',
formatter: (value) => formatCredentialStatus(value)
},
{
label: '支付证书',
prop: 'credentials.wx_cert_content',
formatter: (value) => formatCredentialStatus(value)
},
{
label: '支付密钥',
prop: 'credentials.wx_key_content',
formatter: (value) => formatCredentialStatus(value)
}
]
const fuiouFields: DetailField[] = [
{
label: '富友API地址',
prop: 'credentials.fy_api_url',
formatter: (value) => formatText(value),
fullWidth: true
},
{
label: '富友机构号',
prop: 'credentials.fy_ins_cd',
formatter: (value) => formatText(value)
},
{
label: '富友商户号',
prop: 'credentials.fy_mchnt_cd',
formatter: (value) => formatText(value)
},
{
label: '富友终端号',
prop: 'credentials.fy_term_id',
formatter: (value) => formatText(value)
},
{
label: '支付回调地址',
prop: 'credentials.fy_notify_url',
formatter: (value) => formatText(value)
},
{
label: '富友私钥',
prop: 'credentials.fy_private_key',
formatter: (value) => formatCredentialStatus(value)
},
{
label: '富友公钥',
prop: 'credentials.fy_public_key',
formatter: (value) => formatCredentialStatus(value)
}
]
const credentialSections = computed<DetailSection[]>(() => {
if (!detailData.value) return []
const providerType = detailData.value.provider_type
if (providerType === 'alipay') {
return [{ title: '支付宝配置', fields: alipayFields }]
}
if (providerType === 'wechat' || providerType === 'wechat_v2') {
return [{ title: '微信支付配置', fields: wechatPayFields }]
}
if (providerType === 'fuiou') {
return [{ title: '富友支付配置', fields: fuiouFields }]
}
return []
})
const detailSections = computed<DetailSection[]>(() => [baseSection, ...credentialSections.value])
const handleBack = () => {
router.back()
}
const fetchDetail = async () => {
loading.value = true
try {
const res = await PaymentMerchantPoolsService.getPaymentMerchantDetailById(merchantId.value)
if (res.code === 0) {
detailData.value = res.data
}
} catch (error) {
console.error('加载支付商户详情失败:', error)
} finally {
loading.value = false
}
}
onMounted(() => {
fetchDetail()
})
</script>
<style scoped lang="scss">
.payment-merchant-detail-page {
padding: 20px;
}
.detail-header {
display: flex;
gap: 16px;
align-items: center;
padding-bottom: 16px;
.detail-title {
margin: 0;
font-size: 20px;
font-weight: 600;
color: var(--el-text-color-primary);
}
}
.loading-container {
display: flex;
flex-direction: column;
gap: 12px;
align-items: center;
justify-content: center;
padding: 60px 20px;
color: var(--el-text-color-secondary);
.el-icon {
font-size: 32px;
}
}
</style>

View File

@@ -0,0 +1,243 @@
<template>
<div class="payment-merchant-pool-detail-page">
<ElCard shadow="never">
<div class="detail-header">
<ElButton @click="handleBack">
<template #icon>
<ElIcon><ArrowLeft /></ElIcon>
</template>
返回
</ElButton>
<h2 class="detail-title">商户池详情</h2>
</div>
<DetailPage v-if="detailData" :sections="detailSections" :data="detailData" />
<div v-if="loading" class="loading-container">
<ElIcon class="is-loading"><Loading /></ElIcon>
<span>加载中...</span>
</div>
</ElCard>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElButton, ElCard, ElIcon } from 'element-plus'
import { ArrowLeft, Loading } from '@element-plus/icons-vue'
import DetailPage from '@/components/common/DetailPage.vue'
import type { DetailField, DetailSection } from '@/components/common/DetailPage.vue'
import { PaymentMerchantPoolsService } from '@/api/modules'
import type {
PaymentMerchantMethod,
PaymentMerchantPool,
PaymentMerchantPoolMemberOption
} from '@/types/api'
import {
getPaymentMethodLabel,
getPaymentPoolStrategyLabel,
getPaymentStatisticCycleLabel,
getPaymentTimePeriodUnitLabel
} from '@/types/api/paymentMerchantPools'
import { formatDateTime } from '@/utils/business/format'
defineOptions({ name: 'PaymentMerchantPoolDetail' })
const route = useRoute()
const router = useRouter()
const loading = ref(false)
const detailData = ref<PaymentMerchantPool | null>(null)
const memberMerchants = ref<PaymentMerchantPoolMemberOption[]>([])
const poolId = computed(() => Number(route.params.id))
const loadMemberMerchants = async (paymentMethod: PaymentMerchantMethod) => {
try {
const res = await PaymentMerchantPoolsService.getPaymentMerchants({
page: 1,
page_size: 100,
payment_method: paymentMethod
})
if (res.code === 0) {
memberMerchants.value = (res.data?.items || []).map((item) => ({
id: item.id,
name: item.name,
payment_method: item.payment_method,
enabled: item.enabled
}))
}
} catch (error) {
console.error('加载商户池成员商户失败:', error)
}
}
// 成员只展示商户名称,不展示 member_ids 原始 ID
const memberNamesText = computed(() => {
const memberIds = detailData.value?.member_ids || []
if (memberIds.length === 0) return '-'
return memberIds
.map(
(memberId) => memberMerchants.value.find((item) => item.id === memberId)?.name || '未知商户'
)
.join('、')
})
const formatText = (value: string | number | undefined | null): string => {
if (value === undefined || value === null || value === '') return '-'
return String(value)
}
const baseSection: DetailSection = {
title: '基本信息',
fields: [
{ label: '商户池名称', prop: 'name' },
{
label: '支付方式',
formatter: (_, data) => getPaymentMethodLabel(data.payment_method)
},
{
label: '启停状态',
formatter: (_, data) => (data.enabled ? '启用' : '停用')
},
{
label: '成员数量',
formatter: (_, data) => `${(data.member_ids || []).length} 个`
},
{
label: '成员商户',
formatter: () => memberNamesText.value,
fullWidth: true
},
{
label: '备注',
prop: 'remark',
formatter: (value) => formatText(value),
fullWidth: true
}
]
}
const rotationFields = computed<DetailField[]>(() => {
const data = detailData.value
if (!data) return []
const fields: DetailField[] = [
{
label: '轮询策略',
formatter: (_, row) => getPaymentPoolStrategyLabel(row.strategy)
}
]
if (data.strategy === 'amount') {
fields.push({
label: '统计周期',
formatter: (_, row) => getPaymentStatisticCycleLabel(row.statistic_cycle)
})
fields.push({
label: '金额阈值',
formatter: (_, row) => `${(Number(row.threshold_amount) / 100).toFixed(2)} 元`
})
} else if (data.strategy === 'count') {
fields.push({
label: '统计周期',
formatter: (_, row) => getPaymentStatisticCycleLabel(row.statistic_cycle)
})
fields.push({ label: '笔数阈值', formatter: (_, row) => `${row.threshold_count} 笔` })
} else if (data.strategy === 'time') {
fields.push({
label: '时间周期',
formatter: (_, row) =>
`${row.time_period_value} ${getPaymentTimePeriodUnitLabel(row.time_period_unit)}`
})
fields.push({
label: '时间起点',
formatter: (_, row) => formatDateTime(row.time_period_started_at)
})
}
return fields
})
const runtimeFields = computed<DetailField[]>(() => {
const data = detailData.value
if (!data) return []
const fields: DetailField[] = [
{ label: '路由世代', formatter: (_, row) => `v${row.routing_epoch}` }
]
if (data.created_at) {
fields.push({ label: '创建时间', formatter: (_, row) => formatDateTime(row.created_at) })
}
if (data.updated_at) {
fields.push({ label: '更新时间', formatter: (_, row) => formatDateTime(row.updated_at) })
}
return fields
})
const detailSections = computed<DetailSection[]>(() => [
baseSection,
{ title: '轮询配置', fields: rotationFields.value },
{ title: '运行状态', fields: runtimeFields.value }
])
const handleBack = () => {
router.back()
}
const fetchDetail = async () => {
loading.value = true
try {
const res = await PaymentMerchantPoolsService.getPaymentMerchantPoolById(poolId.value)
if (res.code === 0) {
detailData.value = res.data
await loadMemberMerchants(res.data.payment_method)
}
} catch (error) {
console.error('加载商户池详情失败:', error)
} finally {
loading.value = false
}
}
onMounted(() => {
fetchDetail()
})
</script>
<style scoped lang="scss">
.payment-merchant-pool-detail-page {
padding: 20px;
}
.detail-header {
display: flex;
gap: 16px;
align-items: center;
padding-bottom: 16px;
.detail-title {
margin: 0;
font-size: 20px;
font-weight: 600;
color: var(--el-text-color-primary);
}
}
.loading-container {
display: flex;
flex-direction: column;
gap: 12px;
align-items: center;
justify-content: center;
padding: 60px 20px;
color: var(--el-text-color-secondary);
.el-icon {
font-size: 32px;
}
}
</style>

View File

@@ -68,7 +68,7 @@
v-for="item in currentConfig?.enum_values"
:key="item"
:value="item"
:label="item"
:label="formatEnumLabel(item)"
/>
</ElSelect>
<ElInput
@@ -105,7 +105,7 @@
</template>
<script setup lang="ts">
import { computed, h, onMounted, reactive, ref } from 'vue'
import { computed, h, onMounted, reactive, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage, ElTag } from 'element-plus'
import { SystemConfigService } from '@/api/modules'
@@ -131,7 +131,21 @@
{ label: 'C 端支付方式配置', value: 'c2b.payment' }
]
const searchForm = reactive<{ module?: SystemConfigModule }>({ module: undefined })
const configEnumLabels: Record<string, string> = {
wechat_only: '仅微信支付',
alipay_only: '仅支付宝支付',
both: '同时支持微信与支付宝'
}
const formatEnumLabel = (value: string) => configEnumLabels[value] || value
const isSystemConfigModule = (value: unknown): value is SystemConfigModule =>
moduleOptions.some((item) => item.value === value)
const queryModule = String(route.query.module || '')
const searchForm = reactive<{ module?: SystemConfigModule }>({
module: isSystemConfigModule(queryModule) ? queryModule : undefined
})
const searchFormItems: SearchFormItem[] = [
{
label: '配置模块',
@@ -252,6 +266,9 @@
const methods = parsePaymentMethods(config.value)
return methods.length ? methods.map((method) => paymentMethodLabels[method]).join('、') : '-'
}
if (config.enum_values?.length) {
return formatEnumLabel(config.value) || '-'
}
return config.value || '-'
}
@@ -392,10 +409,16 @@
loadConfigs()
}
// 菜单跳转可能只变更 query(同一组件实例复用),需要跟随 module 变化重新筛选
watch(
() => route.query.module,
(value) => {
const module = String(value || '')
searchForm.module = isSystemConfigModule(module) ? module : undefined
pagination.page = 1
loadConfigs()
}
)
onMounted(loadConfigs)
</script>
<style scoped lang="scss">
.system-configs-page {
}
</style>

View File

@@ -64,6 +64,7 @@
>
<ElOption label="退款审批" value="refund_approval" />
<ElOption label="线下代充值审批" value="offline_recharge_approval" />
<ElOption label="员工代收款审批" value="employee_collection_approval" />
</ElSelect>
</ElFormItem>
</ElCol>