2025-10-13 01:27:37 +08:00
|
|
|
<template>
|
2025-11-16 22:13:57 +08:00
|
|
|
<Modal :class="'w-[550px]'" :title="t('updateAlipay')">
|
|
|
|
|
<BaseForm />
|
2025-10-13 01:27:37 +08:00
|
|
|
|
|
|
|
|
<el-form-item :label="t('appId')" prop="config.app_id">
|
|
|
|
|
<el-input v-model.trim="formData.config.app_id" :placeholder="t('appIdPlaceholder')" class="input-width" maxlength="32" show-word-limit clearable />
|
|
|
|
|
<div class="form-tip">{{ t('appIdTips') }}</div>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="t('appSecretCert')" prop="config.app_secret_cert">
|
|
|
|
|
<el-input v-model.trim="formData.config.app_secret_cert" :placeholder="t('appSecretCertPlaceholder')" class="input-width" type="textarea" rows="4" clearable />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
2025-11-16 22:13:57 +08:00
|
|
|
<el-form-item :label="t('appPublicCertPath')">
|
2025-10-13 01:27:37 +08:00
|
|
|
<div class="input-width">
|
2025-11-16 22:13:57 +08:00
|
|
|
<upload-file v-model.trim="formModel.config.app_public_cert_path" api="sys/document/aliyun" />
|
2025-10-13 01:27:37 +08:00
|
|
|
</div>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
2025-11-16 22:13:57 +08:00
|
|
|
<el-form-item :label="t('alipayPublicCertPath')">
|
2025-10-13 01:27:37 +08:00
|
|
|
<div class="input-width">
|
2025-11-16 22:13:57 +08:00
|
|
|
<upload-file v-model="formModel.config.alipay_public_cert_path" api="sys/document/aliyun" />
|
2025-10-13 01:27:37 +08:00
|
|
|
</div>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
2025-11-16 22:13:57 +08:00
|
|
|
<el-form-item :label="t('alipayRootCertPath')">
|
2025-10-13 01:27:37 +08:00
|
|
|
<div class="input-width">
|
2025-11-16 22:13:57 +08:00
|
|
|
<upload-file v-model="formModel.config.alipay_root_cert_path" api="sys/document/aliyun" />
|
2025-10-13 01:27:37 +08:00
|
|
|
</div>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
<el-button @click="cancel">{{ t('cancel') }}</el-button>
|
2025-11-16 22:13:57 +08:00
|
|
|
<el-button type="primary" :loading="loading" @click="confirm()">{{t('confirm')}}</el-button>
|
2025-10-13 01:27:37 +08:00
|
|
|
</span>
|
|
|
|
|
</template>
|
2025-11-16 22:13:57 +08:00
|
|
|
</Modal>
|
2025-10-13 01:27:37 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2025-11-16 22:13:57 +08:00
|
|
|
import { ref, reactive } from 'vue'
|
2025-10-13 01:27:37 +08:00
|
|
|
import { t } from '@/lang'
|
|
|
|
|
import Test from '@/utils/test'
|
|
|
|
|
import { cloneDeep } from 'lodash-es'
|
2025-11-16 22:13:57 +08:00
|
|
|
import { useVbenModal } from '@vben/common-ui'
|
|
|
|
|
import { useVbenForm } from '@/_env/adapter/form'
|
2025-10-13 01:27:37 +08:00
|
|
|
|
2025-11-16 22:13:57 +08:00
|
|
|
const [Modal, modalApi] = useVbenModal()
|
2025-10-13 01:27:37 +08:00
|
|
|
const loading = ref(true)
|
|
|
|
|
const initData = ref<any>(null)
|
|
|
|
|
/**
|
|
|
|
|
* 表单数据
|
|
|
|
|
*/
|
|
|
|
|
const initialFormData = {
|
|
|
|
|
type: 'alipay',
|
|
|
|
|
app_id: '',
|
|
|
|
|
config: {
|
|
|
|
|
app_secret_cert: '',
|
|
|
|
|
app_public_cert_path: '',
|
|
|
|
|
alipay_public_cert_path: '',
|
|
|
|
|
alipay_root_cert_path: ''
|
|
|
|
|
},
|
|
|
|
|
channel: '',
|
|
|
|
|
status: 0,
|
|
|
|
|
is_default: 0
|
|
|
|
|
}
|
2025-11-16 22:13:57 +08:00
|
|
|
const formModel: Record<string, any> = reactive({ ...initialFormData })
|
|
|
|
|
const [BaseForm, formApi] = useVbenForm({
|
|
|
|
|
commonConfig: { componentProps: { class: 'w-full' } },
|
|
|
|
|
handleSubmit: async (values) => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
const merged = { ...values, config: { ...formModel.config } }
|
|
|
|
|
emit('complete', merged)
|
|
|
|
|
loading.value = false
|
|
|
|
|
modalApi.close()
|
|
|
|
|
},
|
|
|
|
|
layout: 'horizontal',
|
|
|
|
|
schema: [
|
|
|
|
|
{ component: 'Input', fieldName: 'config.app_id', label: t('appId'), rules: [{ required: true }] },
|
|
|
|
|
{ component: 'Textarea', fieldName: 'config.app_secret_cert', label: t('appSecretCert'), rules: [{ required: true }], componentProps: { rows: 4 } }
|
|
|
|
|
],
|
|
|
|
|
wrapperClass: 'grid-cols-1'
|
2025-10-13 01:27:37 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['complete'])
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 确认
|
|
|
|
|
* @param formEl
|
|
|
|
|
*/
|
2025-11-16 22:13:57 +08:00
|
|
|
const confirm = async () => { if (loading.value) return; formApi.submit() }
|
2025-10-13 01:27:37 +08:00
|
|
|
|
|
|
|
|
const cancel = () => {
|
2025-11-16 22:13:57 +08:00
|
|
|
Object.assign(formModel, initialFormData)
|
2025-10-13 01:27:37 +08:00
|
|
|
if (initData.value) {
|
2025-11-16 22:13:57 +08:00
|
|
|
Object.keys(formModel).forEach((key: string) => {
|
|
|
|
|
if (initData.value[key] != undefined) formModel[key] = initData.value[key]
|
2025-10-13 01:27:37 +08:00
|
|
|
})
|
2025-11-16 22:13:57 +08:00
|
|
|
formModel.channel = initData.value.redio_key.split('_')[0]
|
|
|
|
|
formModel.status = Number(formModel.status)
|
2025-10-13 01:27:37 +08:00
|
|
|
}
|
2025-11-16 22:13:57 +08:00
|
|
|
emit('complete', formModel)
|
|
|
|
|
modalApi.close()
|
2025-10-13 01:27:37 +08:00
|
|
|
}
|
|
|
|
|
const setFormData = async (data: any = null) => {
|
|
|
|
|
initData.value = cloneDeep(data)
|
|
|
|
|
loading.value = true
|
2025-11-16 22:13:57 +08:00
|
|
|
Object.assign(formModel, initialFormData)
|
2025-10-13 01:27:37 +08:00
|
|
|
if (data) {
|
2025-11-16 22:13:57 +08:00
|
|
|
Object.keys(formModel).forEach((key: string) => {
|
|
|
|
|
if (data[key] != undefined) formModel[key] = data[key]
|
2025-10-13 01:27:37 +08:00
|
|
|
})
|
2025-11-16 22:13:57 +08:00
|
|
|
formModel.channel = data.redio_key.split('_')[0]
|
|
|
|
|
formModel.status = Number(formModel.status)
|
2025-10-13 01:27:37 +08:00
|
|
|
}
|
2025-11-16 22:13:57 +08:00
|
|
|
formApi.setModel({ ...formModel })
|
2025-10-13 01:27:37 +08:00
|
|
|
loading.value = false
|
2025-11-16 22:13:57 +08:00
|
|
|
modalApi.open()
|
2025-10-13 01:27:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const enableVerify = () => {
|
|
|
|
|
let verify = true
|
2025-11-16 22:13:57 +08:00
|
|
|
if (Test.empty(formModel.config.app_id) || Test.empty(formModel.config.app_secret_cert) || Test.empty(formModel.config.app_public_cert_path) || Test.empty(formModel.config.alipay_public_cert_path) || Test.empty(formModel.config.alipay_root_cert_path)) verify = false
|
2025-10-13 01:27:37 +08:00
|
|
|
return verify
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
|
setFormData,
|
|
|
|
|
enableVerify
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|