feat 钱包和储值卡适配多商户

This commit is contained in:
xxm1995
2023-07-25 20:28:39 +08:00
parent 74de6b10f2
commit 9e4e509814
26 changed files with 282 additions and 918 deletions

View File

@@ -1,7 +1,10 @@
1.0.1
- 钱包配置
- x 钱包配置
- x 储值卡日志信息
- 钱包支持多商户和多应用
- 钱包批量开通
-
- 钱包批量开通适配
- 个人自助开通适配
- 储值卡支持多商户和多应用
- x 生成储值卡适配
- 使用适配
- 储值卡多卡支付和退款演示

View File

@@ -70,7 +70,10 @@
multiple?: boolean
// 宽度
width?: number | string
// 数据源
/**
* 数据源
* 返回的格式需要为 Result<PageResult<T>>
*/
dataSource?: Function
}
const props = withDefaults(defineProps<Props>(), {

View File

@@ -44,7 +44,7 @@
<script lang="ts" setup>
import { $ref } from 'vue/macros'
import { combinationPay, findStatusByBusinessId } from '/@/views/demo/payment/cashier/Cashier.api'
import { Voucher } from '/src/views/modules/payment/channel/voucher/list/Voucher.api'
import { Voucher } from '/@/views/modules/payment/channel/voucher/list/Voucher.api'
import { useMessage } from '/@/hooks/web/useMessage'
import { FormInstance } from 'ant-design-vue/lib/form'
import { useIntervalFn } from '@vueuse/core'
@@ -54,7 +54,7 @@
import { payWayEnum } from '/@/enums/payment/payWayEnum'
import { findByParamKey } from '/@/api/common/Parameter'
import { PayStatus } from '/@/enums/payment/PayStatus'
import { findByUser as findWalletByUser, Wallet } from '/src/views/modules/payment/channel/wallet/Wallet.api'
import { findByUser as findWalletByUser, Wallet } from '/@/views/modules/payment/channel/wallet/Wallet.api'
const { createMessage } = useMessage()

View File

@@ -48,13 +48,13 @@
import { FormInstance } from 'ant-design-vue/lib/form'
import { useIntervalFn } from '@vueuse/core'
import { useMessage } from '/@/hooks/web/useMessage'
import { getAndJudgeVoucher, Voucher } from '/src/views/modules/payment/channel/voucher/list/Voucher.api'
import { getAndJudgeVoucher, Voucher } from '/@/views/modules/payment/channel/voucher/list/Voucher.api'
import CashierQrCode from './CashierQrCode.vue'
import { payChannelEnum } from '/@/enums/payment/payChannelEnum'
import { findByParamKey } from '/@/api/common/Parameter'
import { payWayEnum } from '/@/enums/payment/payWayEnum'
import { PayStatus } from '/@/enums/payment/PayStatus'
import { findByUser as findWalletByUser, Wallet } from '/src/views/modules/payment/channel/wallet/Wallet.api'
import { findByUser as findWalletByUser, Wallet } from '/@/views/modules/payment/channel/wallet/Wallet.api'
const { createMessage } = useMessage()

View File

@@ -1,6 +1,6 @@
import { defHttp } from '/@/utils/http/axios'
import { PageResult, Result } from '/#/axios'
import { BaseEntity } from '/#/web'
import { BaseEntity, KeyValue } from "/#/web";
/**
* 分页
@@ -21,6 +21,16 @@ export function findAll() {
})
}
/**
* 下拉列表, 通过商户Code
*/
export function dropdown(mchCode) {
return defHttp.get<Result<KeyValue[]>>({
url: '/mch/app/dropdown',
params: { mchCode },
})
}
/**
* 关联支付配置列表
*/

View File

@@ -62,7 +62,6 @@
import { FormEditType } from '/@/enums/formTypeEnum'
import { BasicDrawer } from '/@/components/Drawer'
import { dropdown } from '/@/views/modules/payment/merchant/MerchantInfo.api'
import { dropdownTranslate } from '/@/utils/dataUtil'
import { LabeledValue } from 'ant-design-vue/lib/select'
import { useDict } from '/@/hooks/bootx/useDict'
const {
@@ -121,7 +120,7 @@
}
// 列表
dropdown().then(({ data }) => {
mchList = dropdownTranslate(data, 'value', 'key')
mchList = data
})
}

View File

@@ -63,7 +63,7 @@
import { del, page } from './MchApplication.api'
import useTablePage from '/@/hooks/bootx/useTablePage'
import MchApplicationEdit from './MchApplicationEdit.vue'
import MchAppPayConfigList from './mchAppPayConfigList.vue'
import MchAppPayConfigList from './config/MchAppPayConfigList.vue'
import { VxeTableInstance, VxeToolbarInstance, VxeTable, VxeColumn, VxePager, VxeToolbar } from 'vxe-table'
import BQuery from '/@/components/Bootx/Query/BQuery.vue'
import { FormEditType } from '/@/enums/formTypeEnum'

View File

@@ -5,7 +5,7 @@
</template>
<script setup lang="ts">
import { $ref } from 'vue/macros'
import { MchAppPayConfigResult } from './MchApplication.api'
import { MchAppPayConfigResult } from '../MchApplication.api'
import MchAppAlipayConfigEdit from '/@/views/modules/payment/channel/alipay/MchAppAlipayConfigEdit.vue'
import MchAppWechatPayConfigEdit from '/@/views/modules/payment/channel/wechat/MchAppWechatPayConfigEdit.vue'
import MchAppWalletConfigEdit from '/@/views/modules/payment/channel/wallet/config/MchAppWalletConfigEdit.vue'

View File

@@ -41,7 +41,7 @@
<script setup lang="ts">
import { BasicDrawer } from '/@/components/Drawer'
import { $ref } from 'vue/macros'
import { findAllConfig, MchApplication, MchAppPayConfigResult } from './MchApplication.api'
import { findAllConfig, MchApplication, MchAppPayConfigResult } from '../MchApplication.api'
import { getFilePreviewUrlPrefix } from '/@/api/common/FileUpload'
import MchAppPayConfigEdit from './MchAppPayConfigEdit.vue'

View File

@@ -1,226 +0,0 @@
<template>
<basic-drawer
showFooter
v-bind="$attrs"
:title="title"
:width="modalWidth"
:visible="visible"
:maskClosable="false"
@close="handleCancel"
>
<a-spin :spinning="confirmLoading">
<a-form
class="small-from-item"
ref="formRef"
:model="form"
:rules="rules"
:validate-trigger="['blur', 'change']"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-item label="主键" name="id" :hidden="true">
<a-input v-model:value="form.id" :disabled="showable" />
</a-form-item>
<a-form-item label="名称" name="name">
<a-input v-model:value="form.name" :disabled="showable" placeholder="请输入名称" />
</a-form-item>
<a-form-item label="AppId" name="appId">
<a-input v-model:value="form.appId" :disabled="showable" placeholder="请输入支付宝商户AppId" />
</a-form-item>
<a-form-item label="异步通知URL" name="notifyUrl">
<a-input v-model:value="form.notifyUrl" :disabled="showable" placeholder="请输入异步通知URL" />
</a-form-item>
<a-form-item label="同步通知URL" name="returnUrl">
<a-input v-model:value="form.returnUrl" :disabled="showable" placeholder="请输入同步通知URL" />
</a-form-item>
<a-form-item label="支付网关URL" name="serverUrl">
<a-input v-model:value="form.serverUrl" :disabled="showable" placeholder="请输入支付网关URL" />
</a-form-item>
<a-form-item label="默认支付超时配置(分钟)" name="expireTime">
<a-input-number
:min="1"
:max="12000"
:step="1"
:disabled="showable"
placeholder="请输入超时配置"
v-model:value="form.expireTime"
/>
</a-form-item>
<a-form-item label="支持支付方式" name="payWayList">
<a-select
allowClear
mode="multiple"
v-model:value="form.payWayList"
:disabled="showable"
:options="payWayList"
style="width: 100%"
placeholder="选择支付方式"
/>
</a-form-item>
<a-form-item label="沙箱环境" name="sandbox">
<a-switch checked-children="" un-checked-children="" v-model:checked="form.sandbox" :disabled="showable" />
</a-form-item>
<a-form-item v-show="showable" label="是否启用" name="activity">
<a-tag>{{ form.activity ? '启用' : '未启用' }}</a-tag>
</a-form-item>
<a-form-item label="认证方式" name="authType">
<a-select allowClear :disabled="showable" v-model:value="form.authType" style="width: 100%" placeholder="选择认证方式">
<a-select-option :key="1">公钥模式</a-select-option>
<a-select-option :key="2">证书模式</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="签名类型" name="signType">
<a-select allowClear :disabled="showable" v-model:value="form.signType" style="width: 100%" placeholder="选择签名类型">
<a-select-option key="RSA2">RSA2秘钥</a-select-option>
</a-select>
</a-form-item>
<a-form-item v-show="form.authType === 1" label="支付宝公钥" name="alipayPublicKey">
<a-textarea v-model:value="form.alipayPublicKey" :disabled="showable" placeholder="请输入支付宝公钥" />
</a-form-item>
<a-form-item v-show="form.authType === 2" label="应用公钥证书" name="appCert">
<a-textarea v-model:value="form.appCert" :disabled="showable" placeholder="请输入应用公钥证书内容" />
</a-form-item>
<a-form-item v-show="form.authType === 2" label="支付宝公钥证书" name="alipayCert">
<a-textarea v-model:value="form.alipayCert" :disabled="showable" placeholder="请输入支付宝公钥证书内容" />
</a-form-item>
<a-form-item v-show="form.authType === 2" label="支付宝CA根证书" name="alipayRootCert">
<a-textarea v-model:value="form.alipayRootCert" :disabled="showable" placeholder="请输入支付宝CA根证书" />
</a-form-item>
<a-form-item label="应用私钥" name="privateKey">
<a-textarea v-model:value="form.privateKey" :disabled="showable" placeholder="请输入应用私钥" />
</a-form-item>
<a-form-item label="备注" name="remark">
<a-textarea v-model:value="form.remark" :disabled="showable" placeholder="请输入备注" />
</a-form-item>
</a-form>
</a-spin>
<template #footer>
<a-space>
<a-button key="cancel" @click="handleCancel">取消</a-button>
<a-button v-if="!showable" key="forward" :loading="confirmLoading" type="primary" @click="handleOk">保存</a-button>
</a-space>
</template>
</basic-drawer>
</template>
<script lang="ts" setup>
import { computed, nextTick, reactive } from 'vue'
import { $ref } from 'vue/macros'
import useFormEdit from '/@/hooks/bootx/useFormEdit'
import { add, get, update, AlipayConfig, findPayWayList } from './AlipayConfig.api'
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
import { FormEditType } from '/@/enums/formTypeEnum'
import { BasicDrawer } from '/@/components/Drawer'
import { KeyValue } from '/#/web'
const {
initFormEditType,
handleCancel,
search,
diffForm,
labelCol,
wrapperCol,
modalWidth,
title,
confirmLoading,
visible,
editable,
showable,
formEditType,
} = useFormEdit()
// 表单
const formRef = $ref<FormInstance>()
let payWayList = $ref<KeyValue[]>([])
let form = $ref({
name: '',
appId: '',
notifyUrl: '',
returnUrl: '',
serverUrl: '',
authType: 1,
signType: 'RSA2',
alipayPublicKey: '',
appCert: '',
alipayCert: '',
alipayRootCert: '',
privateKey: '',
expireTime: 15,
payWayList: [],
sandbox: false,
remark: '',
} as AlipayConfig)
let rawForm
// 校验
const rules = computed(() => {
return {
name: [{ required: true, message: '请输入配置名称' }],
appId: [{ required: true, message: '请输入AppId' }],
notifyUrl: [{ required: true, message: '请输入异步通知页面地址' }],
returnUrl: [{ required: true, message: '请输入同步通知页面地址' }],
serverUrl: [{ required: true, message: '请输入请求网关地址' }],
authType: [{ required: true, message: '请选择认证方式' }],
signType: [{ required: true, message: '请选择加密类型' }],
alipayPublicKey: [{ required: form.authType === 1, message: '请输入支付宝公钥' }],
appCert: [{ required: form.authType === 2, message: '请输入应用证书' }],
alipayCert: [{ required: form.authType === 2, message: '请输入支付宝证书' }],
alipayRootCert: [{ required: form.authType === 2, message: '请输入支付宝CA根证书' }],
privateKey: [{ required: true, message: '请输入支付私钥' }],
sandbox: [{ required: true, message: '请选择是否为沙箱环境' }],
expireTime: [{ required: true, message: '请输入默认超时配置' }],
payWayList: [{ required: true, message: '请选择支持的支付类型' }],
} as Record<string, Rule[]>
})
// 事件
const emits = defineEmits(['ok'])
// 入口
function init(id, editType: FormEditType) {
findPayWayList().then(({ data }) => {
payWayList = data
})
initFormEditType(editType)
resetForm()
getInfo(id, editType)
}
// 获取信息
function getInfo(id, editType: FormEditType) {
if ([FormEditType.Edit, FormEditType.Show].includes(editType)) {
confirmLoading.value = true
get(id).then(({ data }) => {
rawForm = { ...data }
form = data
confirmLoading.value = false
})
} else {
confirmLoading.value = false
}
}
// 保存
function handleOk() {
formRef?.validate().then(async () => {
confirmLoading.value = true
if (formEditType.value === FormEditType.Add) {
await add(form)
} else if (formEditType.value === FormEditType.Edit) {
await update({
...form,
...diffForm(rawForm, form, 'appId', 'alipayPublicKey', 'appCert', 'alipayCert', 'alipayRootCert', 'privateKey'),
})
}
confirmLoading.value = false
handleCancel()
emits('ok')
})
}
// 重置表单
function resetForm() {
nextTick(() => {
formRef?.resetFields()
})
}
defineExpose({
init,
})
</script>
<style lang="less" scoped></style>

View File

@@ -1,174 +0,0 @@
<template>
<div>
<div class="m-3 p-3 pt-5 bg-white">
<b-query :query-params="model.queryParam" :fields="fields" @query="queryPage" @reset="resetQueryParams" />
</div>
<div class="m-3 p-3 bg-white">
<vxe-toolbar ref="xToolbar" custom :refresh="{ queryMethod: queryPage }">
<template #buttons>
<a-space>
<a-button type="primary" pre-icon="ant-design:plus-outlined" @click="add">新建</a-button>
</a-space>
</template>
</vxe-toolbar>
<vxe-table row-id="id" ref="xTable" :data="pagination.records" :loading="loading">
<vxe-column type="seq" width="60" />
<vxe-column field="name" title="名称" />
<vxe-column field="appId" title="商户appId" />
<vxe-column field="authType" title="认证方式">
<template #default="{ row }">
<a-tag v-show="row.authType === 1">公钥</a-tag>
<a-tag v-show="row.authType === 2">证书</a-tag>
</template>
</vxe-column>
<vxe-column field="signType" title="签名类型" />
<vxe-column field="sandbox" title="沙箱">
<template #default="{ row }">
<a-tag v-if="row.sandbox"></a-tag>
<a-tag v-else></a-tag>
</template>
</vxe-column>
<vxe-column field="activity" title="活动状态">
<template #default="{ row }">
<a-tag color="green" v-if="row.activity">启用</a-tag>
<a-tag color="red" v-else>未启用</a-tag>
</template>
</vxe-column>
<vxe-column fixed="right" width="180" :showOverflow="false" title="操作">
<template #default="{ row }">
<a-link @click="show(row)">查看</a-link>
<a-divider type="vertical" />
<a-link @click="edit(row)">编辑</a-link>
<a-divider type="vertical" />
<a-dropdown>
<a> 更多 <icon icon="ant-design:down-outlined" :size="12" /></a>
<template #overlay>
<a-menu>
<a-menu-item>
<a-link v-if="!row.activity" @click="setup(row)">启用</a-link>
<a-link v-else danger @click="clear(row)">停用</a-link>
</a-menu-item>
<a-menu-item>
<a-link @click="remove(row)" style="color: red">删除</a-link>
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</template>
</vxe-column>
</vxe-table>
<vxe-pager
size="medium"
:loading="loading"
:current-page="pagination.current"
:page-size="pagination.size"
:total="pagination.total"
@page-change="handleTableChange"
/>
<alipay-config-edit ref="alipayConfigEdit" @ok="queryPage" />
</div>
</div>
</template>
<script lang="ts" setup>
import { onMounted } from 'vue'
import { $ref } from 'vue/macros'
import { clearActivity, del, page, setUpActivity } from './AlipayConfig.api'
import useTablePage from '/@/hooks/bootx/useTablePage'
import AlipayConfigEdit from './AlipayConfigEdit.vue'
import { VxeTableInstance, VxeToolbarInstance } from 'vxe-table'
import BQuery from '/@/components/Bootx/Query/BQuery.vue'
import { FormEditType } from '/@/enums/formTypeEnum'
import { useMessage } from '/@/hooks/web/useMessage'
import { QueryField } from '/@/components/Bootx/Query/Query'
import ALink from '/@/components/Link/Link.vue'
// 使用hooks
const { handleTableChange, pageQueryResHandel, resetQueryParams, pagination, pages, model, loading } = useTablePage(queryPage)
const { notification, createMessage, createConfirm } = useMessage()
// 查询条件
const fields = [
{ field: 'name', type: 'string', name: '名称', placeholder: '请输入名称' },
{ field: 'appId', type: 'string', name: 'AppId', placeholder: '请输入AppId' },
] as QueryField[]
const xTable = $ref<VxeTableInstance>()
const xToolbar = $ref<VxeToolbarInstance>()
const alipayConfigEdit = $ref<any>()
onMounted(() => {
vxeBind()
queryPage()
})
function vxeBind() {
xTable?.connect(xToolbar as VxeToolbarInstance)
}
// 分页查询
function queryPage() {
loading.value = true
page({
...model.queryParam,
...pages,
}).then(({ data }) => {
pageQueryResHandel(data)
})
return Promise.resolve()
}
// 新增
function add() {
alipayConfigEdit.init(null, FormEditType.Add)
}
// 编辑
function edit(record) {
alipayConfigEdit.init(record.id, FormEditType.Edit)
}
// 查看
function show(record) {
alipayConfigEdit.init(record.id, FormEditType.Show)
}
// 删除
function remove(record) {
createConfirm({
iconType: 'warning',
title: '警告',
content: '是否删除该数据',
onOk: () => {
del(record.id).then(() => {
createMessage.success('删除成功')
queryPage()
})
},
})
}
function setup(record) {
createConfirm({
iconType: 'warning',
title: '警告',
content: '是否启用此配置',
onOk: () => {
loading.value = true
setUpActivity(record.id).then(() => {
queryPage()
})
},
})
}
function clear(record) {
createConfirm({
iconType: 'warning',
title: '警告',
content: '是否停用此配置',
onOk: () => {
loading.value = true
clearActivity(record.id).then(() => {
queryPage()
})
},
})
}
</script>
<style lang="less" scoped></style>

View File

@@ -160,7 +160,6 @@
import { FormEditType } from '/@/enums/formTypeEnum'
import { BasicDrawer } from '/@/components/Drawer'
import { MchAppPayConfigResult } from '/@/views/modules/payment/app/MchApplication.api'
import { dropdownTranslate } from '/@/utils/dataUtil'
import { LabeledValue } from 'ant-design-vue/lib/select'
import { useUpload } from '/@/hooks/bootx/useUpload'
import { useMessage } from '/@/hooks/web/useMessage'
@@ -232,7 +231,7 @@
// 入口
function init(record: MchAppPayConfigResult) {
findPayWayList().then(({ data }) => {
payWayList = dropdownTranslate(data, 'value', 'key')
payWayList = data
})
editType = record.configId ? FormEditType.Edit : FormEditType.Add
initFormEditType(editType)

View File

@@ -17,6 +17,12 @@
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-item label="商户号" name="mchCode">
<a-select allow-clear :options="mchList" v-model:value="form.mchCode" placeholder="请选择商户" @change="mchAppChange" />
</a-form-item>
<a-form-item label="应用号" name="mchAppCode" v-show="form.mchCode">
<a-select allow-clear :options="mchAppList" v-model:value="form.mchAppCode" placeholder="请选择商户应用" />
</a-form-item>
<a-form-item label="面值" name="faceValue">
<a-input-number
:precision="2"
@@ -66,13 +72,22 @@
import BasicModal from '/@/components/Modal/src/BasicModal.vue'
import { generationBatch } from './Voucher.api'
import { VoucherEnum } from '/@/enums/payment/voucherEnum'
import { dropdown as mchDrop } from '/@/views/modules/payment/merchant/MerchantInfo.api'
import { dropdown as mchAppDrop } from '/@/views/modules/payment/app/MchApplication.api'
import { LabeledValue } from 'ant-design-vue/lib/select'
const { handleCancel, labelCol, wrapperCol, modalWidth, title, confirmLoading, visible, editable, showable, formEditType } = useFormEdit()
const { createMessage } = useMessage()
// 商户和应用下拉列表
let mchList = $ref<LabeledValue[]>()
let mchAppList = $ref<LabeledValue[]>()
// 表单
const formRef = $ref<FormInstance>()
const form = $ref({
mchCode: undefined,
mchAppCode: undefined,
count: 1,
faceValue: 1,
dataTime: null,
@@ -82,25 +97,43 @@
status: VoucherEnum.STATUS_NORMAL,
})
const rules = computed<Record<string, Rule[]>>(() => {
return {
count: [{ required: true, message: '请输入要生成的数量' }],
faceValue: [{ required: true, message: '请输入储值卡的面值' }],
enduring: [{ required: true, message: '请选择储值卡有效期类型' }],
dataTime: [{ required: form.enduring, message: '请选择有效时间范围' }],
status: [{ required: true, message: '请选择默认状态' }],
}
})
const rules = {
mchCode: [{ required: true, message: '请选择商户' }],
mchAppCode: [{ required: true, message: '请选择商户对应的应用' }],
count: [{ required: true, message: '请输入要生成的数量' }],
faceValue: [{ required: true, message: '请输入储值卡的面值' }],
enduring: [{ required: true, message: '请选择储值卡有效期类型' }],
dataTime: [{ required: form.enduring, message: '请选择有效时间范围' }],
status: [{ required: true, message: '请选择默认状态' }],
} as Record<string, Rule[]>
const emits = defineEmits(['ok'])
/**
* 初始化
*/
function init() {
visible.value = true
resetForm()
// 商户下拉列表
mchDrop().then(({ data }) => {
mchList = data
})
confirmLoading.value = false
}
// 时间范围变动
/**
* 商户应用下拉列表
*/
function mchAppChange() {
mchAppDrop(form.mchCode).then(({ data }) => {
mchAppList = data
})
}
/**
* 时间范围变动
*/
function changeTime(_, times) {
form.startTime = (times[0] + ' 00:00:00') as any
form.endTime = (times[1] + ' 23:59:59') as any

View File

@@ -15,6 +15,12 @@
<a-descriptions-item label="生成批次号">
{{ form.batchNo }}
</a-descriptions-item>
<a-descriptions-item label="商户号">
{{ form.mchCode }}
</a-descriptions-item>
<a-descriptions-item label="应用号">
{{ form.mchAppCode }}
</a-descriptions-item>
<a-descriptions-item label="面值">
{{ form.faceValue }}
</a-descriptions-item>
@@ -27,10 +33,10 @@
<a-descriptions-item label="状态">
{{ form.status === VoucherEnum.STATUS_NORMAL ? '正常' : '停用' }}
</a-descriptions-item>
<a-descriptions-item label="开始时间">
<a-descriptions-item label="有效期(开始时间)">
{{ form.startTime }}
</a-descriptions-item>
<a-descriptions-item label="结束时间">
<a-descriptions-item label="有效期(结束时间)">
{{ form.endTime }}
</a-descriptions-item>
</a-descriptions>

View File

@@ -17,8 +17,6 @@
<vxe-column field="batchNo" title="生成批次号" />
<vxe-column field="faceValue" title="面值" />
<vxe-column field="balance" title="余额" />
<vxe-column field="startTime" title="开始时间" />
<vxe-column field="endTime" title="结束时间" />
<vxe-column field="enduring" title="长期有效">
<template #default="{ row }">
<a-tag>{{ row.enduring ? '长期' : '期限' }}</a-tag>
@@ -29,6 +27,8 @@
{{ dictConvert('VoucherStatus', row.status) }}
</template>
</vxe-column>
<vxe-column field="mchCode" title="商户号" />
<vxe-column field="mchAppCode" title="应用号" />
<vxe-column field="createTime" title="创建时间" />
<vxe-column fixed="right" width="120" :showOverflow="false" title="操作">
<template #default="{ row }">
@@ -41,7 +41,7 @@
<template #overlay>
<a-menu>
<a-menu-item>
<a-link @click="showLogs(row.id)">日志</a-link>
<a-link @click="showLogs(row)">日志</a-link>
</a-menu-item>
<a-menu-item>
<a-link danger v-if="row.status === 'normal'" @click="lockConfirm(row.id, true)">停用</a-link>
@@ -63,7 +63,7 @@
/>
<voucher-info ref="voucherInfo" />
<voucher-generation ref="voucherGeneration" @ok="queryPage" />
<!-- <voucher-log-list ref="voucherLogList" />-->
<voucher-log-list ref="voucherLogList" />
</div>
</div>
</template>
@@ -79,6 +79,7 @@
import { QueryField, STRING } from '/@/components/Bootx/Query/Query'
import { useDict } from '/@/hooks/bootx/useDict'
import VoucherInfo from './VoucherInfo.vue'
import VoucherLogList from '../log/VoucherLogList.vue'
import VoucherGeneration from './VoucherGeneration.vue'
// 使用hooks

View File

@@ -1,19 +1,14 @@
<template>
<basic-drawer forceRender showFooter v-bind="$attrs" title="钱包日志列表" width="60%" :visible="visible" @close="visible = false">
<basic-drawer forceRender showFooter v-bind="$attrs" title="储值卡日志" width="60%" :visible="visible" @close="visible = false">
<vxe-toolbar ref="xToolbar" custom :refresh="{ queryMethod: queryPage }" />
<vxe-table row-id="id" ref="xTable" :data="pagination.records" :loading="loading">
<vxe-column type="seq" title="序号" width="60" />
<vxe-column field="type" title="类型">
<template #default="{ row }">
{{ dictConvert('WalletLogType', row.type) }}
{{ dictConvert('VoucherLogType', row.type) }}
</template>
</vxe-column>
<vxe-column field="amount" title="金额" />
<vxe-column field="operationSource" title="操作类型">
<template #default="{ row }">
{{ dictConvert('WalletLogOperation', row.operationSource) }}
</template>
</vxe-column>
<vxe-column field="createTime" title="操作时间" />
<vxe-column field="remark" title="备注" />
<template #footer>
@@ -37,7 +32,7 @@
import { useMessage } from '/@/hooks/web/useMessage'
import { useDict } from '/@/hooks/bootx/useDict'
import { QueryField } from '/@/components/Bootx/Query/Query'
import { VxeTableInstance, VxeToolbarInstance } from 'vxe-table'
import { VxeTableInstance, VxeToolbarInstance, VxeTable, VxeColumn, VxePager, VxeToolbar } from 'vxe-table'
import { nextTick } from 'vue'
import { pageByVoucherId } from './VoucherLog.api'
@@ -78,6 +73,12 @@
pageQueryResHandel(data)
})
}
/**
* 关闭
*/
function handleCancel() {
visible = false
}
defineExpose({ init })
</script>

View File

@@ -84,10 +84,11 @@ export function getWalletInfo(walletId) {
/**
* 批量开通钱包
*/
export function createWalletBatch(obj) {
export function createWalletBatch(params, data) {
return defHttp.post({
url: '/wallet/admin/createWalletBatch',
data: obj,
params: params,
data: data,
})
}

View File

@@ -35,13 +35,13 @@
</template>
<script lang="ts" setup>
import useFormEdit from '/src/hooks/bootx/useFormEdit'
import { useMessage } from '/src/hooks/web/useMessage'
import useFormEdit from '/@/hooks/bootx/useFormEdit'
import { useMessage } from '/@/hooks/web/useMessage'
import { $ref } from 'vue/macros'
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
import { nextTick } from 'vue'
import { changerBalance } from '/src/views/modules/payment/channel/wallet/Wallet.api'
import BasicModal from '/src/components/Modal/src/BasicModal.vue'
import { changerBalance } from '/@/views/modules/payment/channel/wallet/Wallet.api'
import BasicModal from '/@/components/Modal/src/BasicModal.vue'
const { handleCancel, labelCol, wrapperCol, modalWidth, title, confirmLoading, visible, editable, showable, formEditType } = useFormEdit()
const { createMessage } = useMessage()

View File

@@ -0,0 +1,133 @@
<template>
<basic-modal
v-bind="$attrs"
title="开通钱包"
:width="modalWidth"
:loading="confirmLoading"
:visible="visible"
:mask-closable="false"
@cancel="handleCancel"
>
<a-form
class="small-from-item"
ref="formRef"
:model="form"
:rules="rules"
:validate-trigger="['blur', 'change']"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-item label="商户号" name="mchCode">
<a-select allow-clear :options="mchList" v-model:value="form.mchCode" placeholder="请选择商户" @change="mchAppChange" />
</a-form-item>
<a-form-item label="应用号" name="mchAppCode" v-show="form.mchCode">
<a-select allow-clear :options="mchAppList" v-model:value="form.mchAppCode" placeholder="请选择商户应用" />
</a-form-item>
</a-form>
<template #footer>
<a-button key="cancel" @click="handleCancel">取消</a-button>
<a-button key="forward" :loading="confirmLoading" type="primary" @click="handleOk">下一步</a-button>
</template>
</basic-modal>
<b-user-select-modal ref="userSelectModal" multiple :data-source="userPageByNotWallet" @ok="createBatchWallet" />
</template>
<script setup lang="ts">
import { createWalletBatch, pageByNotWallet, Wallet } from '/@/views/modules/payment/channel/wallet/Wallet.api'
import BUserSelectModal from '/@/components/Bootx/UserSelectModal/BUserSelectModal.vue'
import { BasicModal } from '/@/components/Modal'
import useFormEdit from '/@/hooks/bootx/useFormEdit'
import { $ref } from 'vue/macros'
import { LabeledValue } from 'ant-design-vue/lib/select'
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
import { dropdown as mchDrop } from '/@/views/modules/payment/merchant/MerchantInfo.api'
import { dropdown as mchAppDrop } from '/@/views/modules/payment/app/MchApplication.api'
import { PageResult, Result } from '/#/axios'
import { nextTick } from 'vue'
import { useMessage } from '/@/hooks/web/useMessage'
const { handleCancel, labelCol, wrapperCol, modalWidth, title, confirmLoading, visible, editable, showable, formEditType } = useFormEdit()
const { createMessage } = useMessage()
// 商户和应用下拉列表
let mchList = $ref<LabeledValue[]>()
let mchAppList = $ref<LabeledValue[]>()
const userSelectModal = $ref<any>()
// 表单
const formRef = $ref<FormInstance>()
const form = $ref({
mchCode: undefined,
mchAppCode: undefined,
})
const rules = {
mchCode: [{ required: true, message: '请选择商户' }],
mchAppCode: [{ required: true, message: '请选择商户对应的应用' }],
} as Record<string, Rule[]>
const emits = defineEmits(['ok'])
/**
* 初始化
*/
function init() {
visible.value = true
resetForm()
// 商户下拉列表
mchDrop().then(({ data }) => {
mchList = data
})
confirmLoading.value = false
}
/**
* 商户应用下拉列表
*/
function mchAppChange() {
mchAppDrop(form.mchCode).then(({ data }) => {
mchAppList = data
})
}
/**
* 待开通的用户列表
*/
async function userPageByNotWallet(param): Promise<Result<PageResult<Wallet>>> {
return await pageByNotWallet({ ...param, ...form })
}
/**
* 下一步
*/
function handleOk() {
formRef?.validate().then(async () => {
visible.value = false
userSelectModal.init()
})
}
/**
* 获取选中的用户并进行创建
*/
function createBatchWallet(userIds: string[]) {
createMessage.success('批量开通钱包中')
createWalletBatch({ mchCode: form.mchCode, mchAppCode: form.mchAppCode }, userIds)
.then(() => emits('ok'))
}
/**
* 重置表单
*/
function resetForm() {
mchAppList = undefined
nextTick(() => {
formRef?.resetFields()
})
}
defineExpose({ init })
</script>
<style scoped lang="less"></style>

View File

@@ -28,12 +28,12 @@
<script lang="ts" setup>
import { $ref } from 'vue/macros'
import useFormEdit from '/src/hooks/bootx/useFormEdit'
import useFormEdit from '/@/hooks/bootx/useFormEdit'
import { add, get, getWalletInfo, update, Wallet } from '../Wallet.api'
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
import { FormEditType } from '/src/enums/formTypeEnum'
import { BasicModal } from '/src/components/Modal'
import { useDict } from '/src/hooks/bootx/useDict'
import { FormEditType } from '/@/enums/formTypeEnum'
import { BasicModal } from '/@/components/Modal'
import { useDict } from '/@/hooks/bootx/useDict'
const { initFormEditType, handleCancel, modalWidth, title, confirmLoading, visible } = useFormEdit()
const { dictConvert } = useDict()

View File

@@ -14,7 +14,6 @@
<vxe-table row-id="id" ref="xTable" :data="pagination.records" :loading="loading">
<vxe-column type="seq" width="60" />
<vxe-column field="userId" title="用户ID" />
<vxe-column field="id" title="钱包ID" />
<vxe-column field="balance" title="余额" />
<vxe-column field="freezeBalance" title="冻结额度" />
<vxe-column field="payStatus" title="状态">
@@ -22,6 +21,8 @@
{{ dictConvert('WalletStatus', row.status) }}
</template>
</vxe-column>
<vxe-column field="mchCode" title="商户号" />
<vxe-column field="mchAppCode" title="应用号" />
<vxe-column field="createTime" title="创建时间" />
<vxe-column fixed="right" width="120" :showOverflow="false" title="操作">
<template #default="{ row }">
@@ -60,7 +61,7 @@
<wallet-info ref="walletInfo" />
<wallet-changer ref="walletChanger" @ok="queryPage" />
<wallet-log-list ref="walletLogList" />
<b-user-select-modal ref="userSelectModal" multiple :data-source="pageByNotWallet" @ok="createBatchWallet" />
<wallet-create ref="walletCreate" multiple :data-source="pageByNotWallet" @ok="queryPage" />
</div>
</div>
</template>
@@ -68,18 +69,20 @@
<script lang="ts" setup>
import { onMounted } from 'vue'
import { $ref } from 'vue/macros'
import { createWalletBatch, del, lock, page, pageByNotWallet, unlock } from '../Wallet.api'
import useTablePage from '/src/hooks/bootx/useTablePage'
import { lock, page, pageByNotWallet, unlock } from '../Wallet.api'
import useTablePage from '/@/hooks/bootx/useTablePage'
import WalletInfo from './WalletInfo.vue'
import { VxeTableInstance, VxeToolbarInstance } from 'vxe-table'
import BQuery from '/src/components/Bootx/Query/BQuery.vue'
import { useMessage } from '/src/hooks/web/useMessage'
import { QueryField, STRING } from '/src/components/Bootx/Query/Query'
import { useDict } from '/src/hooks/bootx/useDict'
import BUserSelectModal from '/src/components/Bootx/UserSelectModal/BUserSelectModal.vue'
import WalletLogList from './WalletLogList.vue'
import BQuery from '/@/components/Bootx/Query/BQuery.vue'
import { useMessage } from '/@/hooks/web/useMessage'
import { QueryField, STRING } from '/@/components/Bootx/Query/Query'
import { useDict } from '/@/hooks/bootx/useDict'
import BUserSelectModal from '/@/components/Bootx/UserSelectModal/BUserSelectModal.vue'
import WalletLogList from '../log/WalletLogList.vue'
import WalletChanger from './WalletChanger.vue'
import { WalletEnum } from '/src/enums/payment/walletEnum'
import { WalletEnum } from '/@/enums/payment/walletEnum'
import WalletCreate from './WalletCreate.vue'
// 使用hooks
const { handleTableChange, pageQueryResHandel, resetQueryParams, pagination, pages, model, loading } = useTablePage(queryPage)
const { notification, createMessage, createConfirm } = useMessage()
@@ -88,12 +91,14 @@
const fields = [
{ field: 'walletId', type: STRING, name: '钱包ID', placeholder: '请输入钱包ID' },
{ field: 'userId', type: STRING, name: '用户ID', placeholder: '请输入用户ID' },
{ field: 'mchCode', type: STRING, name: '商户编码', placeholder: '请输入商户编码' },
{ field: 'mchAppCode', type: STRING, name: '应用编码', placeholder: '请输入应用编码' },
] as QueryField[]
const xTable = $ref<VxeTableInstance>()
const xToolbar = $ref<VxeToolbarInstance>()
const walletInfo = $ref<any>()
const userSelectModal = $ref<any>()
const walletCreate = $ref<any>()
const walletLogList = $ref<any>()
const walletChanger = $ref<any>()
@@ -116,25 +121,27 @@
})
return Promise.resolve()
}
// 开通钱包
/**
* 开通钱包
*/
function add() {
userSelectModal.init()
walletCreate.init()
}
// 查看
/**
* 查看
*/
function show(record) {
walletInfo.init(record.id)
}
// 批量开通钱包
function createBatchWallet(userIds: string[]) {
loading.value = true
createMessage.success('批量开通钱包中')
createWalletBatch(userIds).then(() => queryPage())
}
// 钱包日志
/**
* 钱包日志
*/
function showLog(walletId) {
walletLogList.init(walletId)
}
// 调整余额
/**
* 调整余额
*/
function recharge(walletId) {
walletChanger.init(walletId)
}

View File

@@ -32,15 +32,15 @@
</template>
<script lang="ts" setup>
import BasicDrawer from '/src/components/Drawer/src/BasicDrawer.vue'
import useTablePage from '/src/hooks/bootx/useTablePage'
import { useMessage } from '/src/hooks/web/useMessage'
import { QueryField } from '/src/components/Bootx/Query/Query'
import BasicDrawer from '/@/components/Drawer/src/BasicDrawer.vue'
import useTablePage from '/@/hooks/bootx/useTablePage'
import { useMessage } from '/@/hooks/web/useMessage'
import { QueryField } from '/@/components/Bootx/Query/Query'
import { $ref } from 'vue/macros'
import { VxeTableInstance, VxeToolbarInstance } from 'vxe-table'
import { nextTick } from 'vue'
import { pageByWalletId } from '/src/views/modules/payment/channel/wallet/WalletLog.api'
import { useDict } from '/src/hooks/bootx/useDict'
import { pageByWalletId } from '/@/views/modules/payment/channel/wallet/WalletLog.api'
import { useDict } from '/@/hooks/bootx/useDict'
// 使hooks
const { handleTableChange, pageQueryResHandel, resetQueryParams, pagination, pages, model, loading } = useTablePage(queryPage)
@@ -64,6 +64,9 @@
walletId = id
queryPage()
}
function handleCancel() {
visible = false
}
//
function queryPage() {
pageByWalletId({

View File

@@ -29,10 +29,10 @@
<script setup lang="ts">
import { $ref } from 'vue/macros'
import { createWallet, findByUser, Wallet } from '../Wallet.api'
import { useMessage } from '/src/hooks/web/useMessage'
import BasicTitle from '/src/components/Basic/src/BasicTitle.vue'
import { useMessage } from '/@/hooks/web/useMessage'
import BasicTitle from '/@/components/Basic/src/BasicTitle.vue'
import { onMounted } from 'vue'
import { useDict } from '/src/hooks/bootx/useDict'
import { useDict } from '/@/hooks/bootx/useDict'
const { notification, createMessage, createConfirm } = useMessage()
const { dictConvert } = useDict()

View File

@@ -113,7 +113,6 @@
import { useUpload } from '/@/hooks/bootx/useUpload'
import { useMessage } from '/@/hooks/web/useMessage'
import { MchAppPayConfigResult } from '/@/views/modules/payment/app/MchApplication.api'
import { dropdownTranslate } from '/@/utils/dataUtil'
import { LabeledValue } from 'ant-design-vue/lib/select'
import BasicTitle from '/@/components/Basic/src/BasicTitle.vue'
@@ -181,7 +180,7 @@
// 入口
function init(record: MchAppPayConfigResult) {
findPayWayList().then(({ data }) => {
payWayList = dropdownTranslate(data, 'value', 'key')
payWayList = data
})
editType = record.configId ? FormEditType.Edit : FormEditType.Add
initFormEditType(editType)

View File

@@ -1,257 +0,0 @@
<template>
<basic-drawer
showFooter
v-bind="$attrs"
:title="title"
:width="modalWidth"
:visible="visible"
:maskClosable="false"
@close="handleCancel"
>
<a-spin :spinning="confirmLoading">
<a-form
class="small-from-item"
ref="formRef"
:model="form"
:rules="rules"
:validate-trigger="['blur', 'change']"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-item label="主键" name="id" :hidden="true">
<a-input v-model:value="form.id" :disabled="showable" />
</a-form-item>
<a-form-item label="名称" name="name">
<a-input v-model:value="form.name" :disabled="showable" placeholder="请输入名称" />
</a-form-item>
<a-form-item label="商户号" name="mchId">
<a-input v-model:value="form.mchId" :disabled="showable" placeholder="请输入商户号" />
</a-form-item>
<a-form-item label="应用编号" name="appId">
<a-input v-model:value="form.appId" :disabled="showable" placeholder="请输入微信应用AppId" />
</a-form-item>
<a-form-item label="AppSecret" name="appSecret">
<a-input v-model:value="form.appSecret" :disabled="showable" placeholder="APPID对应的接口密码用于获取接口调用凭证时使用" />
</a-form-item>
<a-form-item label="超时配置" name="expireTime">
<a-input-number :min="1" :max="12000" :step="1" :disabled="showable" v-model:value="form.expireTime" />
</a-form-item>
<a-form-item label="支持支付方式" name="payWayList">
<a-select
allowClear
mode="multiple"
:disabled="showable"
:options="payWayList"
v-model:value="form.payWayList"
style="width: 100%"
placeholder="选择支付方式"
/>
</a-form-item>
<a-form-item label="是否沙箱环境" name="sandbox">
<a-switch checked-children="" un-checked-children="" v-model:checked="form.sandbox" :disabled="showable" />
</a-form-item>
<a-form-item label="是否启用" v-show="showable" name="activity">
<a-tag>{{ form.activity ? '启用' : '未启用' }}</a-tag>
</a-form-item>
<a-form-item label="p12证书" name="p12">
<a-upload
v-if="!form.p12"
:disabled="showable"
name="file"
:multiple="false"
:action="uploadAction"
:headers="tokenHeader"
:showUploadList="false"
@change="handleChange"
>
<a-button type="primary" preIcon="carbon:cloud-upload"> p12证书上传 </a-button>
</a-upload>
<a-input v-else v-model:value="form.p12" disabled>
<template #addonAfter v-if="!showable">
<a-tooltip>
<template #title> 删除上传的证书文件 </template>
<icon @click="form.p12 = null" icon="ant-design:close-circle-outlined" :size="20" />
</a-tooltip>
</template>
</a-input>
</a-form-item>
<a-form-item label="APIv2密钥" name="apiKeyV2">
<a-textarea :disabled="showable" v-model:value="form.apiKeyV2" placeholder="请输入APIv2密钥" />
</a-form-item>
<a-form-item label="APIv3密钥" name="apiKeyV3">
<a-textarea :disabled="showable" v-model:value="form.apiKeyV3" placeholder="请输入APIv3密钥" />
</a-form-item>
<a-form-item label="证书(cert.pem)" name="certPem">
<a-textarea :disabled="showable" v-model:value="form.certPem" placeholder="请填入证书内容" />
</a-form-item>
<a-form-item label="私钥(key.pem)" name="keyPem">
<a-input v-model:value="form.keyPem" :disabled="showable" placeholder="请填入私钥内容" />
</a-form-item>
<a-form-item label="异步通知UR" name="notifyUrl">
<a-input v-model:value="form.notifyUrl" :disabled="showable" placeholder="请输入服务器异步通知页面路径" />
</a-form-item>
<a-form-item label="同步通知URL" name="returnUrl">
<a-input v-model:value="form.returnUrl" :disabled="showable" placeholder="请输入页面跳转同步通知页面路径" />
</a-form-item>
<a-form-item label="应用域名" name="domain">
<a-input v-model:value="form.domain" :disabled="showable" placeholder="请输入应用域名,回调中会使用此参数" />
</a-form-item>
<a-form-item label="备注" name="remark">
<a-textarea v-model:value="form.remark" :disabled="showable" placeholder="请输入备注" />
</a-form-item>
</a-form>
</a-spin>
<template #footer>
<a-space>
<a-button key="cancel" @click="handleCancel">取消</a-button>
<a-button v-if="!showable" key="forward" :loading="confirmLoading" type="primary" @click="handleOk">保存</a-button>
</a-space>
</template>
</basic-drawer>
</template>
<script lang="ts" setup>
import { computed, nextTick, reactive } from 'vue'
import { $ref } from 'vue/macros'
import useFormEdit from '/@/hooks/bootx/useFormEdit'
import { add, get, update, findPayWayList, WechatPayConfig } from './WechatPayConfig.api'
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
import { FormEditType } from '/@/enums/formTypeEnum'
import { BasicDrawer } from '/@/components/Drawer'
import { KeyValue } from '/#/web'
import Icon from '/@/components/Icon/src/Icon.vue'
import { useUpload } from '/@/hooks/bootx/useUpload'
import { useMessage } from '/@/hooks/web/useMessage'
const {
initFormEditType,
handleCancel,
search,
diffForm,
labelCol,
wrapperCol,
modalWidth,
title,
confirmLoading,
visible,
editable,
showable,
formEditType,
} = useFormEdit()
const { tokenHeader, uploadAction } = useUpload('/file/upload')
const { createMessage } = useMessage()
// 表单
const formRef = $ref<FormInstance>()
let rawForm
let form = $ref({
id: null,
name: '',
mchId: '',
appId: '',
appSecret: '',
apiVersion: 'api_v2',
p12: null,
apiKeyV2: '',
apiKeyV3: '',
keyPem: '',
certPem: '',
domain: '',
notifyUrl: '',
returnUrl: '',
expireTime: 15,
payWayList: [],
sandbox: false,
remark: '',
} as WechatPayConfig)
// 校验
const rules = computed(() => {
return {
name: [{ required: true, message: '请输入配置名称' }],
mchId: [{ required: true, message: '请输入商户号' }],
appId: [{ required: true, message: '请输入应用编号' }],
notifyUrl: [{ required: true, message: '请输入异步通知页面地址' }],
returnUrl: [{ required: true, message: '请输入同步通知页面地址' }],
domain: [{ required: true, message: '请输入请求应用域名' }],
// apiVersion: [ { required: true, message: '请选择API版本' } ],
apiKeyV2: [{ required: form.apiVersion === 'api_v2', message: '请输入V2秘钥' }],
apiKeyV3: [{ required: form.apiVersion === 'api_v3', message: '请输入V3秘钥' }],
// keyPem: [ { required: true, message: '请填入私钥内容' } ],
// certPem: [ { required: true, message: '请填入证书内容' } ],
sandbox: [{ required: true, message: '请选择是否为沙箱环境' }],
expireTime: [{ required: true, message: '请输入默认超时配置' }],
payWayList: [{ required: true, message: '请选择支持的支付类型' }],
} as Record<string, Rule[]>
})
let payWayList = $ref<KeyValue[]>([])
// 事件
const emits = defineEmits(['ok'])
// 入口
function init(id, editType: FormEditType) {
findPayWayList().then(({ data }) => {
payWayList = data
console.log(payWayList)
})
initFormEditType(editType)
resetForm()
getInfo(id, editType)
}
// 获取信息
function getInfo(id, editType: FormEditType) {
if ([FormEditType.Edit, FormEditType.Show].includes(editType)) {
confirmLoading.value = true
get(id).then(({ data }) => {
rawForm = { ...data }
form = data
confirmLoading.value = false
})
} else {
confirmLoading.value = false
}
}
// 保存
function handleOk() {
formRef?.validate().then(async () => {
confirmLoading.value = true
if (formEditType.value === FormEditType.Add) {
await add(form)
} else if (formEditType.value === FormEditType.Edit) {
await update({ ...form, ...diffForm(rawForm, form, 'mchId', 'appId', 'appSecret', 'apiKeyV2', 'apiKeyV3', 'keyPem', 'certPem') })
}
confirmLoading.value = false
handleCancel()
emits('ok')
})
}
// 重置表单
function resetForm() {
nextTick(() => {
formRef?.resetFields()
})
}
/**
* 文件上传
*/
function handleChange(info) {
// 上传完毕
if (info.file.status === 'done') {
const res = info.file.response
if (!res.code) {
form.p12 = res.data.id
createMessage.success(`${info.file.name} 上传成功!`)
} else {
createMessage.error(`${res.msg}`)
}
} else if (info.file.status === 'error') {
createMessage.error('上传失败')
}
}
defineExpose({
init,
})
</script>
<style lang="less" scoped></style>

View File

@@ -1,177 +0,0 @@
<template>
<div>
<div class="m-3 p-3 pt-5 bg-white">
<b-query :query-params="model.queryParam" :fields="fields" @query="queryPage" @reset="resetQueryParams" />
</div>
<div class="m-3 p-3 bg-white">
<vxe-toolbar ref="xToolbar" custom :refresh="{ queryMethod: queryPage }">
<template #buttons>
<a-space>
<a-button type="primary" pre-icon="ant-design:plus-outlined" @click="add">新建</a-button>
</a-space>
</template>
</vxe-toolbar>
<vxe-table row-id="id" ref="xTable" :data="pagination.records" :loading="loading">
<vxe-column type="seq" width="60" />
<vxe-column field="name" title="名称" />
<vxe-column field="mchId" title="商户号" />
<vxe-column field="appId" title="应用编号" />
<!-- <vxe-column field="apiVersion" title="API版本" >-->
<!-- <template v-slot="{row}">-->
<!-- {{ dictConvert('wechatApiVersion',row.apiVersion) }}-->
<!-- </template>-->
<!-- </vxe-column>-->
<vxe-column field="sandbox" title="沙箱">
<template #default="{ row }">
<a-tag v-if="row.sandbox"></a-tag>
<a-tag v-else></a-tag>
</template>
</vxe-column>
<vxe-column field="activity" title="活动状态">
<template #default="{ row }">
<a-tag color="green" v-if="row.activity">启用</a-tag>
<a-tag color="red" v-else>未启用</a-tag>
</template>
</vxe-column>
<vxe-column field="createTime" title="创建时间" />
<vxe-column fixed="right" width="180" :showOverflow="false" title="操作">
<template #default="{ row }">
<span>
<a-link @click="show(row)">查看</a-link>
</span>
<a-divider type="vertical" />
<span>
<a-link @click="edit(row)">编辑</a-link>
</span>
<a-divider type="vertical" />
<a-dropdown>
<a> 更多 <icon icon="ant-design:down-outlined" :size="12" /></a>
<template #overlay>
<a-menu>
<a-menu-item>
<a-link v-if="!row.activity" @click="setup(row)">启用</a-link>
<a-link v-else danger @click="clear(row)">停用</a-link>
</a-menu-item>
<a-menu-item>
<a-link danger @click="remove(row)">删除</a-link>
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</template>
</vxe-column>
</vxe-table>
<vxe-pager
size="medium"
:loading="loading"
:current-page="pagination.current"
:page-size="pagination.size"
:total="pagination.total"
@page-change="handleTableChange"
/>
<wechat-pay-config-edit ref="wechatPayConfigEdit" @ok="queryPage" />
</div>
</div>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import { $ref } from 'vue/macros'
import { del, page, clearActivity, setUpActivity } from './WechatPayConfig.api'
import useTablePage from '/@/hooks/bootx/useTablePage'
import WechatPayConfigEdit from './WechatPayConfigEdit.vue'
import { VxeTableInstance, VxeToolbarInstance } from 'vxe-table'
import BQuery from '/@/components/Bootx/Query/BQuery.vue'
import { FormEditType } from '/@/enums/formTypeEnum'
import { useMessage } from '/@/hooks/web/useMessage'
import { QueryField, STRING } from '/@/components/Bootx/Query/Query'
// 使用hooks
const { handleTableChange, pageQueryResHandel, resetQueryParams, pagination, pages, model, loading } = useTablePage(queryPage)
const { notification, createMessage, createConfirm } = useMessage()
// 查询条件
const fields = [
{ field: 'name', type: STRING, name: '名称', placeholder: '请输入名称' },
{ field: 'appId', type: STRING, name: 'AppId', placeholder: '请输入AppId' },
{ field: 'mchId', type: STRING, name: '商户号', placeholder: '请输入商户号' },
] as QueryField[]
const xTable = $ref<VxeTableInstance>()
const xToolbar = $ref<VxeToolbarInstance>()
const wechatPayConfigEdit = $ref<any>()
onMounted(() => {
vxeBind()
queryPage()
})
function vxeBind() {
xTable?.connect(xToolbar as VxeToolbarInstance)
}
// 分页查询
function queryPage() {
loading.value = true
page({
...model.queryParam,
...pages,
}).then(({ data }) => {
pageQueryResHandel(data)
})
return Promise.resolve()
}
// 新增
function add() {
wechatPayConfigEdit.init(null, FormEditType.Add)
}
// 编辑
function edit(record) {
wechatPayConfigEdit.init(record.id, FormEditType.Edit)
}
// 查看
function show(record) {
wechatPayConfigEdit.init(record.id, FormEditType.Show)
}
// 删除
function remove(record) {
createConfirm({
iconType: 'warning',
title: '警告',
content: '是否删除该数据',
onOk: () => {
del(record.id).then(() => {
createMessage.success('删除成功')
queryPage()
})
},
})
}
function setup(record) {
createConfirm({
iconType: 'warning',
title: '警告',
content: '是否启用此配置',
onOk: () => {
loading.value = true
setUpActivity(record.id).then(() => {
queryPage()
})
},
})
}
function clear(record) {
createConfirm({
iconType: 'warning',
title: '警告',
content: '是否停用此配置',
onOk: () => {
loading.value = true
clearActivity(record.id).then(() => {
queryPage()
})
},
})
}
</script>
<style lang="less" scoped></style>