diff --git a/apps/daxpay-admin/src/views/payment/channel/alipay/manage/mch/AlipayAppAuthTokenUpdate.vue b/apps/daxpay-admin/src/views/payment/channel/alipay/manage/mch/AlipayAppAuthTokenUpdate.vue index 3d0b4c222..54dac1e77 100644 --- a/apps/daxpay-admin/src/views/payment/channel/alipay/manage/mch/AlipayAppAuthTokenUpdate.vue +++ b/apps/daxpay-admin/src/views/payment/channel/alipay/manage/mch/AlipayAppAuthTokenUpdate.vue @@ -25,8 +25,14 @@ const channelMchNo = ref(''); // 服务商通道商户配置(用于展示当前令牌 / 子商户号) const isvConfig = ref({}); - // 新令牌输入 - const newAuthToken = ref(''); + // 手动设置表单 + const formRef = ref(); + const formState = ref({ appAuthToken: '' }); + const formRules = { + appAuthToken: [ + { required: true, whitespace: true, message: $t('payment.merchant.channelMerchant.appAuthTokenRequired') }, + ], + }; // 当前 Tab: manual | agent const activeTab = ref<'agent' | 'manual'>('manual'); // 代运营授权链接 @@ -67,7 +73,7 @@ /** 打开抽屉 */ function open(mchNo: string) { channelMchNo.value = mchNo; - newAuthToken.value = ''; + formState.value = { appAuthToken: '' }; authUrl.value = ''; callbackUrl.value = ''; activeTab.value = 'manual'; @@ -82,9 +88,11 @@ } /** 保存新令牌(二次确认后提交) */ - function handleSave() { - if (!newAuthToken.value.trim()) { - message.warning($t('payment.merchant.channelMerchant.appAuthTokenRequired')); + async function handleSave() { + try { + await formRef.value?.validate(); + } catch { + // 校验失败: 表单已显示错误提示 return; } confirm({ @@ -96,7 +104,7 @@ saving.value = true; return AlipayIsvChannelMerchantApi.updateAppAuthToken({ channelMchNo: channelMchNo.value, - appAuthToken: newAuthToken.value.trim(), + appAuthToken: formState.value.appAuthToken.trim(), }) .then(() => { message.success($t('payment.merchant.channelMerchant.appAuthTokenUpdateSuccess')); @@ -177,7 +185,7 @@ - +
@@ -185,9 +193,9 @@
- + diff --git a/apps/daxpay-admin/src/views/payment/develop/auth/ChannelAuth.vue b/apps/daxpay-admin/src/views/payment/develop/auth/ChannelAuth.vue index c3452d672..87387cfc5 100644 --- a/apps/daxpay-admin/src/views/payment/develop/auth/ChannelAuth.vue +++ b/apps/daxpay-admin/src/views/payment/develop/auth/ChannelAuth.vue @@ -36,11 +36,17 @@ const authResult = ref({}); /** 微信支付表单 */ + const formRef = ref(); const form = reactive({ - mchNo: '', - channelMchNo: '', - capability: '', + mchNo: undefined as string | undefined, + channelMchNo: undefined as string | undefined, + capability: undefined as string | undefined, }); + const formRules = { + mchNo: [{ required: true, message: $t('payment.develop.auth.form.rule.mchNo') }], + channelMchNo: [{ required: true, message: $t('payment.develop.auth.form.rule.channelMchNo') }], + capability: [{ required: true, message: $t('payment.develop.auth.form.rule.capability') }], + }; /** 微信小程序表单(端类型: merchant 商户端 / admin 运营端) */ const wechatMiniForm = reactive({ @@ -136,8 +142,8 @@ /** 商户变更: 刷新通道商户候选 */ function merchantChange() { - form.channelMchNo = ''; - form.capability = ''; + form.channelMchNo = undefined; + form.capability = undefined; channelMchNoOptions.value = []; capabilityOptions.value = []; if (!form.mchNo) return; @@ -147,7 +153,7 @@ /** 通道商户变更: 重置能力并重载能力候选 */ function channelMchNoChange() { - form.capability = ''; + form.capability = undefined; capabilityOptions.value = []; if (form.channelMchNo) { loadCapabilityCandidates(form.channelMchNo); @@ -181,16 +187,10 @@ } // 微信支付: 表单校验 if (authType.value === 'wechatChannel') { - if (!form.mchNo) { - message.warning($t('payment.develop.auth.form.rule.mchNo')); - return; - } - if (!form.channelMchNo) { - message.warning($t('payment.develop.auth.form.rule.channelMchNo')); - return; - } - if (!form.capability) { - message.warning($t('payment.develop.auth.form.rule.capability')); + try { + await formRef.value?.validate(); + } catch { + // 校验失败: 表单已显示错误提示 return; } } @@ -303,8 +303,14 @@
- - + + - + - + ('route'); + // 私钥独立存储(标签+弹窗交互, 校验通过 form 自定义规则挂接) + const privateKey = ref(''); + const privateKeyVisible = ref(false); + const privateKeyInput = ref(''); + const loading = ref(false); + // ===== 表单校验规则(按模式动态生成) ===== const formRules = computed>(() => { // 通用必填字段 @@ -38,6 +44,16 @@ bizOrderNo: [{ required: true, message: $t('payment.develop.trade.rule.bizOrderNo') }], amount: [{ required: true, message: $t('payment.develop.trade.rule.amount') }], title: [{ required: true, message: $t('payment.develop.trade.rule.title') }], + // 私钥存独立 ref, 用自定义校验挂到 form 上 + privateKey: [ + { + validator: async () => { + if (!privateKey.value) { + return Promise.reject(new Error($t('payment.develop.trade.msg.inputPrivateKey'))); + } + }, + }, + ], }; // 路由模式: 支付方式必填 if (routeMode.value === 'route') { @@ -62,11 +78,6 @@ capability: '', description: '', }); - - const privateKey = ref(''); - const privateKeyVisible = ref(false); - const privateKeyInput = ref(''); - const loading = ref(false); const signPreviewLoading = ref(false); // ===== 下拉选项 ===== @@ -203,6 +214,8 @@ localStorage.removeItem(PRIVATE_KEY_STORAGE_KEY); } privateKeyVisible.value = false; + // 清除私钥字段校验态 + formRef.value?.clearValidate?.(['privateKey']); message.success($t('payment.develop.trade.privateKey.savedTip')); } @@ -214,6 +227,7 @@ onOk() { privateKey.value = ''; localStorage.removeItem(PRIVATE_KEY_STORAGE_KEY); + formRef.value?.clearValidate?.(['privateKey']); message.success($t('payment.develop.trade.privateKey.clearedTip')); }, }); @@ -247,8 +261,10 @@ /** 生成签名预览(内联展示, 不弹结果) */ async function handleSignPreview() { - if (!privateKey.value) { - message.warning($t('payment.develop.trade.msg.inputPrivateKey')); + try { + await formRef.value?.validateFields(['privateKey']); + } catch { + // 校验失败: 表单已显示错误提示 return; } signPreviewLoading.value = true; @@ -279,17 +295,13 @@ // ===== 提交 ===== /** 发起真实支付调试 */ async function handlePay() { - // 表单字段校验 + // 表单字段校验(含私钥自定义规则) try { await formRef.value?.validate(); } catch { // 校验未通过,字段错误已由表单自动展示 return; } - if (!privateKey.value) { - message.warning($t('payment.develop.trade.msg.inputPrivateKey')); - return; - } loading.value = true; try { const { data } = await DevelopTradeApi.pay({ @@ -380,8 +392,8 @@
- - + +
diff --git a/apps/daxpay-admin/src/views/payment/device/qrcode/DeviceQrCode.vue b/apps/daxpay-admin/src/views/payment/device/qrcode/DeviceQrCode.vue index 788ea2d71..72d43b2ad 100644 --- a/apps/daxpay-admin/src/views/payment/device/qrcode/DeviceQrCode.vue +++ b/apps/daxpay-admin/src/views/payment/device/qrcode/DeviceQrCode.vue @@ -290,7 +290,18 @@ @checkbox-all="handleCheckboxChange" > - + + + + + - - - @@ -346,19 +348,12 @@ :min-width="180" formatter="formatDateTime" /> - +