chore: push latest changes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-dialog v-model="showDialog" :title="t('updateAlipay')" width="550px" :destroy-on-close="true">
|
||||
<el-form :model="formData" label-width="110px" ref="formRef" :rules="formRules" class="page-form" v-loading="loading">
|
||||
<Modal :class="'w-[550px]'" :title="t('updateAlipay')">
|
||||
<BaseForm />
|
||||
|
||||
<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 />
|
||||
@@ -10,43 +10,42 @@
|
||||
<el-input v-model.trim="formData.config.app_secret_cert" :placeholder="t('appSecretCertPlaceholder')" class="input-width" type="textarea" rows="4" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="t('appPublicCertPath')" prop="config.app_public_cert_path">
|
||||
<el-form-item :label="t('appPublicCertPath')">
|
||||
<div class="input-width">
|
||||
<upload-file v-model.trim="formData.config.app_public_cert_path" api="sys/document/aliyun" />
|
||||
<upload-file v-model.trim="formModel.config.app_public_cert_path" api="sys/document/aliyun" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="t('alipayPublicCertPath')" prop="config.alipay_public_cert_path">
|
||||
<el-form-item :label="t('alipayPublicCertPath')">
|
||||
<div class="input-width">
|
||||
<upload-file v-model="formData.config.alipay_public_cert_path" api="sys/document/aliyun" />
|
||||
<upload-file v-model="formModel.config.alipay_public_cert_path" api="sys/document/aliyun" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="t('alipayRootCertPath')" prop="config.alipay_root_cert_path">
|
||||
<el-form-item :label="t('alipayRootCertPath')">
|
||||
<div class="input-width">
|
||||
<upload-file v-model="formData.config.alipay_root_cert_path" api="sys/document/aliyun" />
|
||||
<upload-file v-model="formModel.config.alipay_root_cert_path" api="sys/document/aliyun" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="cancel">{{ t('cancel') }}</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="confirm(formRef)">{{t('confirm')}}</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="confirm()">{{t('confirm')}}</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { t } from '@/lang'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import Test from '@/utils/test'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { useVbenModal } from '@vben/common-ui'
|
||||
import { useVbenForm } from '@/_env/adapter/form'
|
||||
|
||||
const showDialog = ref(false)
|
||||
const [Modal, modalApi] = useVbenModal()
|
||||
const loading = ref(true)
|
||||
const initData = ref<any>(null)
|
||||
/**
|
||||
@@ -65,29 +64,22 @@ const initialFormData = {
|
||||
status: 0,
|
||||
is_default: 0
|
||||
}
|
||||
const formData: Record<string, any> = reactive({ ...initialFormData })
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 表单验证规则
|
||||
const formRules = computed(() => {
|
||||
return {
|
||||
'config.app_id': [
|
||||
{ required: true, message: t('appIdPlaceholder'), trigger: 'blur' }
|
||||
],
|
||||
'config.app_secret_cert': [
|
||||
{ required: true, message: t('appSecretCertPlaceholder'), trigger: 'blur' }
|
||||
],
|
||||
'config.app_public_cert_path': [
|
||||
{ required: true, message: t('appPublicCertPathPlaceholder'), trigger: 'blur' }
|
||||
],
|
||||
'config.alipay_public_cert_path': [
|
||||
{ required: true, message: t('alipayPublicCertPathPlaceholder'), trigger: 'blur' }
|
||||
],
|
||||
'config.alipay_root_cert_path': [
|
||||
{ required: true, message: t('alipayRootCertPathPlaceholder'), trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
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'
|
||||
})
|
||||
|
||||
const emit = defineEmits(['complete'])
|
||||
@@ -96,50 +88,43 @@ const emit = defineEmits(['complete'])
|
||||
* 确认
|
||||
* @param formEl
|
||||
*/
|
||||
const confirm = async (formEl: FormInstance | undefined) => {
|
||||
if (loading.value || !formEl) return
|
||||
await formEl.validate(async (valid) => {
|
||||
if (valid) {
|
||||
emit('complete', formData)
|
||||
showDialog.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
const confirm = async () => { if (loading.value) return; formApi.submit() }
|
||||
|
||||
const cancel = () => {
|
||||
Object.assign(formData, initialFormData)
|
||||
Object.assign(formModel, initialFormData)
|
||||
if (initData.value) {
|
||||
Object.keys(formData).forEach((key: string) => {
|
||||
if (initData.value[key] != undefined) formData[key] = initData.value[key]
|
||||
Object.keys(formModel).forEach((key: string) => {
|
||||
if (initData.value[key] != undefined) formModel[key] = initData.value[key]
|
||||
})
|
||||
formData.channel = initData.value.redio_key.split('_')[0]
|
||||
formData.status = Number(formData.status)
|
||||
formModel.channel = initData.value.redio_key.split('_')[0]
|
||||
formModel.status = Number(formModel.status)
|
||||
}
|
||||
emit('complete', formData)
|
||||
showDialog.value = false
|
||||
emit('complete', formModel)
|
||||
modalApi.close()
|
||||
}
|
||||
const setFormData = async (data: any = null) => {
|
||||
initData.value = cloneDeep(data)
|
||||
loading.value = true
|
||||
Object.assign(formData, initialFormData)
|
||||
Object.assign(formModel, initialFormData)
|
||||
if (data) {
|
||||
Object.keys(formData).forEach((key: string) => {
|
||||
if (data[key] != undefined) formData[key] = data[key]
|
||||
Object.keys(formModel).forEach((key: string) => {
|
||||
if (data[key] != undefined) formModel[key] = data[key]
|
||||
})
|
||||
formData.channel = data.redio_key.split('_')[0]
|
||||
formData.status = Number(formData.status)
|
||||
formModel.channel = data.redio_key.split('_')[0]
|
||||
formModel.status = Number(formModel.status)
|
||||
}
|
||||
formApi.setModel({ ...formModel })
|
||||
loading.value = false
|
||||
modalApi.open()
|
||||
}
|
||||
|
||||
const enableVerify = () => {
|
||||
let verify = true
|
||||
if (Test.empty(formData.config.app_id) || Test.empty(formData.config.app_secret_cert) || Test.empty(formData.config.app_public_cert_path) || Test.empty(formData.config.alipay_public_cert_path) || Test.empty(formData.config.alipay_root_cert_path)) verify = false
|
||||
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
|
||||
return verify
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
showDialog,
|
||||
setFormData,
|
||||
enableVerify
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user