This commit is contained in:
@@ -40,8 +40,7 @@ export interface H5PopupConfiguration {
|
|||||||
starts_at: string // 生效开始时间(ISO 8601)
|
starts_at: string // 生效开始时间(ISO 8601)
|
||||||
ends_at: string // 生效结束时间(ISO 8601)
|
ends_at: string // 生效结束时间(ISO 8601)
|
||||||
version: number // 配置版本,每次更新递增;版本参与频率去重,旧版本通知保留原快照
|
version: number // 配置版本,每次更新递增;版本参与频率去重,旧版本通知保留原快照
|
||||||
creator: number // 创建人账号ID
|
creator_name: string // 创建人名称
|
||||||
updater: number // 最近更新人账号ID
|
|
||||||
created_at: string // 创建时间(ISO 8601)
|
created_at: string // 创建时间(ISO 8601)
|
||||||
updated_at: string // 最近更新时间(ISO 8601);启停同样刷新该时间
|
updated_at: string // 最近更新时间(ISO 8601);启停同样刷新该时间
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,6 +307,7 @@ export function buildPaymentCredentials(
|
|||||||
): PaymentCredentialValidationResult {
|
): PaymentCredentialValidationResult {
|
||||||
const spec = getPaymentCredentialFieldSpec(providerType)
|
const spec = getPaymentCredentialFieldSpec(providerType)
|
||||||
const allowedKeys = [...spec.required, ...spec.optional]
|
const allowedKeys = [...spec.required, ...spec.optional]
|
||||||
|
const optionalKeys = new Set(spec.optional)
|
||||||
const credentials: Record<string, PaymentCredentialValue> = {}
|
const credentials: Record<string, PaymentCredentialValue> = {}
|
||||||
|
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
@@ -318,6 +319,7 @@ export function buildPaymentCredentials(
|
|||||||
return { credentials: null, error: `凭证字段 ${key} 不属于当前服务商支持的字段` }
|
return { credentials: null, error: `凭证字段 ${key} 不属于当前服务商支持的字段` }
|
||||||
}
|
}
|
||||||
if (!entry.value) {
|
if (!entry.value) {
|
||||||
|
if (optionalKeys.has(key)) continue
|
||||||
return { credentials: null, error: `请填写凭证字段 ${key} 的值` }
|
return { credentials: null, error: `请填写凭证字段 ${key} 的值` }
|
||||||
}
|
}
|
||||||
if (Object.prototype.hasOwnProperty.call(credentials, key)) {
|
if (Object.prototype.hasOwnProperty.call(credentials, key)) {
|
||||||
|
|||||||
@@ -153,13 +153,12 @@
|
|||||||
formatList(data.card_types, (value) => cardTypeNames[value] || value),
|
formatList(data.card_types, (value) => cardTypeNames[value] || value),
|
||||||
fullWidth: true
|
fullWidth: true
|
||||||
},
|
},
|
||||||
{ label: '创建人', prop: 'creator' },
|
{ label: '创建人', prop: 'creator_name' },
|
||||||
{
|
{
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
formatter: (_value: unknown, data: H5PopupConfiguration) =>
|
formatter: (_value: unknown, data: H5PopupConfiguration) =>
|
||||||
formatDateTime(data.created_at)
|
formatDateTime(data.created_at)
|
||||||
},
|
},
|
||||||
{ label: '最近更新人', prop: 'updater' },
|
|
||||||
{
|
{
|
||||||
label: '最近更新时间',
|
label: '最近更新时间',
|
||||||
formatter: (_value: unknown, data: H5PopupConfiguration) =>
|
formatter: (_value: unknown, data: H5PopupConfiguration) =>
|
||||||
|
|||||||
@@ -303,8 +303,7 @@
|
|||||||
{ label: '受控动作', prop: 'action_type' },
|
{ label: '受控动作', prop: 'action_type' },
|
||||||
{ label: '生效时间', prop: 'effective_time' },
|
{ label: '生效时间', prop: 'effective_time' },
|
||||||
{ label: '版本', prop: 'version' },
|
{ label: '版本', prop: 'version' },
|
||||||
{ label: '创建人', prop: 'creator' },
|
{ label: '创建人', prop: 'creator_name' },
|
||||||
{ label: '最近更新人', prop: 'updater' },
|
|
||||||
{ label: '最近更新时间', prop: 'updated_at' }
|
{ label: '最近更新时间', prop: 'updated_at' }
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -408,16 +407,10 @@
|
|||||||
},
|
},
|
||||||
{ prop: 'version', label: '版本', width: 70 },
|
{ prop: 'version', label: '版本', width: 70 },
|
||||||
{
|
{
|
||||||
prop: 'creator',
|
prop: 'creator_name',
|
||||||
label: '创建人',
|
label: '创建人',
|
||||||
width: 90,
|
width: 120,
|
||||||
formatter: (row: H5PopupConfiguration) => String(row.creator || 0)
|
formatter: (row: H5PopupConfiguration) => row.creator_name || '-'
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'updater',
|
|
||||||
label: '最近更新人',
|
|
||||||
width: 110,
|
|
||||||
formatter: (row: H5PopupConfiguration) => String(row.updater || 0)
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'updated_at',
|
prop: 'updated_at',
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
v-model="form.provider_type"
|
v-model="form.provider_type"
|
||||||
:disabled="formMode === 'edit'"
|
:disabled="formMode === 'edit'"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
|
@change="handleProviderTypeChange"
|
||||||
>
|
>
|
||||||
<ElOption
|
<ElOption
|
||||||
v-for="item in providerOptions"
|
v-for="item in providerOptions"
|
||||||
@@ -111,17 +112,15 @@
|
|||||||
<template v-if="showCredentialEditor">
|
<template v-if="showCredentialEditor">
|
||||||
<ElDivider content-position="left">写入支付凭证</ElDivider>
|
<ElDivider content-position="left">写入支付凭证</ElDivider>
|
||||||
<div class="credential-tip">
|
<div class="credential-tip">
|
||||||
必填字段:{{ credentialFieldSpec.required.join('、') || '-' }}
|
字段名已按所选服务商预置,请填写对应的凭证值。必填字段:{{
|
||||||
|
credentialFieldSpec.required.join('、') || '-'
|
||||||
|
}}
|
||||||
<template v-if="credentialFieldSpec.optional.length">
|
<template v-if="credentialFieldSpec.optional.length">
|
||||||
;可选字段:{{ credentialFieldSpec.optional.join('、') }}
|
;可选字段:{{ credentialFieldSpec.optional.join('、') }}
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div class="credential-list">
|
<div class="credential-list">
|
||||||
<div
|
<div v-for="entry in form.credentials" :key="entry.localId" class="credential-row">
|
||||||
v-for="entry in form.credentials"
|
|
||||||
:key="entry.localId"
|
|
||||||
class="credential-row"
|
|
||||||
>
|
|
||||||
<ElInput
|
<ElInput
|
||||||
v-model="entry.key"
|
v-model="entry.key"
|
||||||
placeholder="凭证字段名"
|
placeholder="凭证字段名"
|
||||||
@@ -135,7 +134,11 @@
|
|||||||
placeholder="凭证值(不可回显)"
|
placeholder="凭证值(不可回显)"
|
||||||
autocomplete="new-password"
|
autocomplete="new-password"
|
||||||
aria-label="凭证值"
|
aria-label="凭证值"
|
||||||
/>
|
>
|
||||||
|
<template v-if="credentialFieldSpec.optional.includes(entry.key)" #prefix>
|
||||||
|
<ElTag size="small" type="info" effect="plain">可选</ElTag>
|
||||||
|
</template>
|
||||||
|
</ElInput>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template v-if="form.provider_type === 'wechat_v2'">
|
<template v-if="form.provider_type === 'wechat_v2'">
|
||||||
@@ -144,8 +147,9 @@
|
|||||||
<ElFormItem label="客户端证书内容">
|
<ElFormItem label="客户端证书内容">
|
||||||
<ElInput
|
<ElInput
|
||||||
:model-value="refundCredentialValue('wx_client_cert_content')"
|
:model-value="refundCredentialValue('wx_client_cert_content')"
|
||||||
type="textarea"
|
type="password"
|
||||||
:rows="4"
|
show-password
|
||||||
|
autocomplete="new-password"
|
||||||
placeholder="选填,PEM 格式客户端证书内容(仅原路退款需要)"
|
placeholder="选填,PEM 格式客户端证书内容(仅原路退款需要)"
|
||||||
@update:model-value="setRefundCredentialValue('wx_client_cert_content', $event)"
|
@update:model-value="setRefundCredentialValue('wx_client_cert_content', $event)"
|
||||||
/>
|
/>
|
||||||
@@ -153,8 +157,9 @@
|
|||||||
<ElFormItem label="客户端私钥内容">
|
<ElFormItem label="客户端私钥内容">
|
||||||
<ElInput
|
<ElInput
|
||||||
:model-value="refundCredentialValue('wx_client_key_content')"
|
:model-value="refundCredentialValue('wx_client_key_content')"
|
||||||
type="textarea"
|
type="password"
|
||||||
:rows="4"
|
show-password
|
||||||
|
autocomplete="new-password"
|
||||||
placeholder="选填,PEM 格式客户端私钥内容(仅原路退款需要)"
|
placeholder="选填,PEM 格式客户端私钥内容(仅原路退款需要)"
|
||||||
@update:model-value="setRefundCredentialValue('wx_client_key_content', $event)"
|
@update:model-value="setRefundCredentialValue('wx_client_key_content', $event)"
|
||||||
/>
|
/>
|
||||||
@@ -187,7 +192,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, h, onMounted, onUnmounted, reactive, ref } from 'vue'
|
import { computed, h, onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { Delete, Plus } from '@element-plus/icons-vue'
|
import { Plus } from '@element-plus/icons-vue'
|
||||||
import { ElButton, ElMessage, ElMessageBox, ElTag } from 'element-plus'
|
import { ElButton, ElMessage, ElMessageBox, ElTag } from 'element-plus'
|
||||||
import type { FormInstance, FormRules } from 'element-plus'
|
import type { FormInstance, FormRules } from 'element-plus'
|
||||||
import { PaymentMerchantPoolsService } from '@/api/modules'
|
import { PaymentMerchantPoolsService } from '@/api/modules'
|
||||||
@@ -293,7 +298,8 @@
|
|||||||
? h(
|
? h(
|
||||||
'span',
|
'span',
|
||||||
{
|
{
|
||||||
style: 'color: var(--el-color-primary); cursor: pointer; text-decoration: underline;',
|
style:
|
||||||
|
'color: var(--el-color-primary); cursor: pointer; text-decoration: underline;',
|
||||||
onClick: (event: MouseEvent) => {
|
onClick: (event: MouseEvent) => {
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
handleNameClick(row)
|
handleNameClick(row)
|
||||||
@@ -416,7 +422,6 @@
|
|||||||
const formRef = ref<FormInstance>()
|
const formRef = ref<FormInstance>()
|
||||||
const showCredentialEditor = ref(false)
|
const showCredentialEditor = ref(false)
|
||||||
const credentialError = ref('')
|
const credentialError = ref('')
|
||||||
const credentialTemplateKeys = ref<string[]>([])
|
|
||||||
|
|
||||||
const initialFormState = () => ({
|
const initialFormState = () => ({
|
||||||
id: 0,
|
id: 0,
|
||||||
@@ -440,6 +445,13 @@
|
|||||||
|
|
||||||
// 当前服务商组合下的凭证必填/可选字段枚举
|
// 当前服务商组合下的凭证必填/可选字段枚举
|
||||||
const credentialFieldSpec = computed(() => getPaymentCredentialFieldSpec(form.provider_type))
|
const credentialFieldSpec = computed(() => getPaymentCredentialFieldSpec(form.provider_type))
|
||||||
|
const isRefundCredentialKey = (key: string) =>
|
||||||
|
form.provider_type === 'wechat_v2' &&
|
||||||
|
['wx_client_cert_content', 'wx_client_key_content'].includes(key)
|
||||||
|
const credentialTemplateKeys = computed(() => [
|
||||||
|
...credentialFieldSpec.value.required,
|
||||||
|
...credentialFieldSpec.value.optional.filter((key) => !isRefundCredentialKey(key))
|
||||||
|
])
|
||||||
|
|
||||||
const formRules = reactive<FormRules>({
|
const formRules = reactive<FormRules>({
|
||||||
name: [
|
name: [
|
||||||
@@ -461,7 +473,6 @@
|
|||||||
form.credentials = []
|
form.credentials = []
|
||||||
showCredentialEditor.value = false
|
showCredentialEditor.value = false
|
||||||
credentialError.value = ''
|
credentialError.value = ''
|
||||||
credentialTemplateKeys.value = []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearSensitiveForm = () => {
|
const clearSensitiveForm = () => {
|
||||||
@@ -488,34 +499,25 @@
|
|||||||
const showCreateDrawer = () => {
|
const showCreateDrawer = () => {
|
||||||
if (!canCreateMerchant.value) return
|
if (!canCreateMerchant.value) return
|
||||||
Object.assign(form, initialFormState())
|
Object.assign(form, initialFormState())
|
||||||
credentialTemplateKeys.value = []
|
|
||||||
formDrawerVisible.value = true
|
formDrawerVisible.value = true
|
||||||
formMode.value = 'create'
|
formMode.value = 'create'
|
||||||
showCredentialEditor.value = true
|
showCredentialEditor.value = true
|
||||||
addCredential()
|
resetCredentialEntries()
|
||||||
}
|
}
|
||||||
|
|
||||||
const startCredentialReplacement = () => {
|
const startCredentialReplacement = () => {
|
||||||
if (!canEditMerchant.value) return
|
if (!canEditMerchant.value) return
|
||||||
form.credentials = []
|
resetCredentialEntries()
|
||||||
if (credentialTemplateKeys.value.length > 0) {
|
|
||||||
form.credentials = credentialTemplateKeys.value.map((key) => ({
|
|
||||||
localId: generateLocalId(),
|
|
||||||
key,
|
|
||||||
value: ''
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
addCredential()
|
|
||||||
}
|
|
||||||
showCredentialEditor.value = true
|
showCredentialEditor.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const addCredential = () => {
|
const resetCredentialEntries = () => {
|
||||||
form.credentials.push({ localId: generateLocalId(), key: '', value: '' })
|
form.credentials = credentialTemplateKeys.value.map((key) => ({
|
||||||
}
|
localId: generateLocalId(),
|
||||||
|
key,
|
||||||
const removeCredential = (index: number) => {
|
value: ''
|
||||||
form.credentials.splice(index, 1)
|
}))
|
||||||
|
credentialError.value = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const refundCredentialValue = (key: string): string => {
|
const refundCredentialValue = (key: string): string => {
|
||||||
@@ -550,9 +552,15 @@
|
|||||||
const firstMatch = PAYMENT_PROVIDER_OPTIONS.find((option) => option.paymentMethod === value)
|
const firstMatch = PAYMENT_PROVIDER_OPTIONS.find((option) => option.paymentMethod === value)
|
||||||
if (firstMatch) {
|
if (firstMatch) {
|
||||||
form.provider_type = firstMatch.value
|
form.provider_type = firstMatch.value
|
||||||
|
if (showCredentialEditor.value) resetCredentialEntries()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleProviderTypeChange = (value: PaymentMerchantProviderType) => {
|
||||||
|
form.provider_type = value
|
||||||
|
if (showCredentialEditor.value) resetCredentialEntries()
|
||||||
|
}
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (formMode.value === 'create' ? !canCreateMerchant.value : !canEditMerchant.value) return
|
if (formMode.value === 'create' ? !canCreateMerchant.value : !canEditMerchant.value) return
|
||||||
if (!formRef.value) return
|
if (!formRef.value) return
|
||||||
@@ -737,7 +745,7 @@
|
|||||||
|
|
||||||
.credential-row {
|
.credential-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr auto;
|
grid-template-columns: 1fr 1fr;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
@@ -758,7 +766,7 @@
|
|||||||
|
|
||||||
.refund-credential-fields {
|
.refund-credential-fields {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user