feat: 更新依赖版本,添加调整钱包组件及其在用户页面的集成
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
"@better-scroll/core": "2.5.1",
|
||||
"@elysiajs/eden": "^1.4.5",
|
||||
"@iconify/vue": "5.0.0",
|
||||
"@riwa/api-types": "http://192.168.1.2:9538/api/capp-eden-0.0.41.tgz",
|
||||
"@riwa/api-types": "http://192.168.1.2:9538/api/capp-eden-0.0.43.tgz",
|
||||
"@sa/axios": "workspace:*",
|
||||
"@sa/color": "workspace:*",
|
||||
"@sa/hooks": "workspace:*",
|
||||
|
||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@@ -18,8 +18,8 @@ importers:
|
||||
specifier: 5.0.0
|
||||
version: 5.0.0(vue@3.5.25(typescript@5.9.3))
|
||||
'@riwa/api-types':
|
||||
specifier: http://192.168.1.2:9538/api/capp-eden-0.0.41.tgz
|
||||
version: '@capp/eden@http://192.168.1.2:9538/api/capp-eden-0.0.41.tgz(@elysiajs/eden@1.4.5(elysia@1.4.19(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))'
|
||||
specifier: http://192.168.1.2:9538/api/capp-eden-0.0.43.tgz
|
||||
version: '@capp/eden@http://192.168.1.2:9538/api/capp-eden-0.0.43.tgz(@elysiajs/eden@1.4.5(elysia@1.4.19(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))'
|
||||
'@sa/axios':
|
||||
specifier: workspace:*
|
||||
version: link:packages/axios
|
||||
@@ -496,9 +496,9 @@ packages:
|
||||
'@borewit/text-codec@0.1.1':
|
||||
resolution: {integrity: sha512-5L/uBxmjaCIX5h8Z+uu+kA9BQLkc/Wl06UGR5ajNRxu+/XjonB5i8JpgFMrPj3LXTCPA0pv8yxUvbUi+QthGGA==}
|
||||
|
||||
'@capp/eden@http://192.168.1.2:9538/api/capp-eden-0.0.41.tgz':
|
||||
resolution: {tarball: http://192.168.1.2:9538/api/capp-eden-0.0.41.tgz}
|
||||
version: 0.0.41
|
||||
'@capp/eden@http://192.168.1.2:9538/api/capp-eden-0.0.43.tgz':
|
||||
resolution: {tarball: http://192.168.1.2:9538/api/capp-eden-0.0.43.tgz}
|
||||
version: 0.0.43
|
||||
peerDependencies:
|
||||
'@elysiajs/eden': ^1.4.6
|
||||
|
||||
@@ -4871,7 +4871,7 @@ snapshots:
|
||||
|
||||
'@borewit/text-codec@0.1.1': {}
|
||||
|
||||
'@capp/eden@http://192.168.1.2:9538/api/capp-eden-0.0.41.tgz(@elysiajs/eden@1.4.5(elysia@1.4.19(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))':
|
||||
'@capp/eden@http://192.168.1.2:9538/api/capp-eden-0.0.43.tgz(@elysiajs/eden@1.4.5(elysia@1.4.19(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))':
|
||||
dependencies:
|
||||
'@elysiajs/eden': 1.4.5(elysia@1.4.19(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3))
|
||||
|
||||
|
||||
@@ -47,8 +47,9 @@ function refresh() {
|
||||
<template>
|
||||
<NSpace :align="itemAlign" justify="space-between" wrap class="lt-sm:w-200px">
|
||||
<slot name="prefix"></slot>
|
||||
<div class="space-x-5">
|
||||
<div class="flex items-center space-x-5">
|
||||
<slot name="default">
|
||||
<slot name="suffix"></slot>
|
||||
<NButton v-if="operations?.add" size="small" ghost type="primary" @click="add">
|
||||
<template #icon>
|
||||
<icon-ic-round-plus class="text-icon" />
|
||||
@@ -78,7 +79,6 @@ function refresh() {
|
||||
</NButton>
|
||||
<TableColumnSetting v-if="operations?.columns" v-model:columns="columns" />
|
||||
</div>
|
||||
<slot name="suffix"></slot>
|
||||
</NSpace>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -146,6 +146,9 @@ defineExpose({} as Expose);
|
||||
<template #prefix>
|
||||
<div class="text-lg font-bold">{{ title }}</div>
|
||||
</template>
|
||||
<template #suffix>
|
||||
<slot name="header-operation-suffix" />
|
||||
</template>
|
||||
</TableHeaderOperation>
|
||||
|
||||
<NDataTable
|
||||
|
||||
@@ -124,6 +124,16 @@ export const generatedRoutes: GeneratedRoute[] = [
|
||||
order: 9
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'subscription',
|
||||
path: '/subscription',
|
||||
component: 'layout.base$view.subscription',
|
||||
meta: {
|
||||
title: 'subscription',
|
||||
i18nKey: 'route.subscription',
|
||||
order: 9
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'user',
|
||||
path: '/user',
|
||||
@@ -153,15 +163,5 @@ export const generatedRoutes: GeneratedRoute[] = [
|
||||
i18nKey: 'route.withdraw',
|
||||
order: 8
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'subscription',
|
||||
path: '/subscription',
|
||||
component: 'layout.base$view.subscription',
|
||||
meta: {
|
||||
title: 'subscription',
|
||||
i18nKey: 'route.subscription',
|
||||
order: 9
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
126
src/views/user/components/adjust-wallet.vue
Normal file
126
src/views/user/components/adjust-wallet.vue
Normal file
@@ -0,0 +1,126 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import type { FormInst, FormRules, SelectOption } from 'naive-ui';
|
||||
import { client, safeClient } from '@/service/api';
|
||||
|
||||
defineOptions({
|
||||
name: 'AdjustWallet'
|
||||
});
|
||||
|
||||
const props = defineProps<{
|
||||
userIds: string[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'close'): void;
|
||||
}>();
|
||||
|
||||
interface AdjustForm {
|
||||
amount: number;
|
||||
walletTypeId: string | undefined;
|
||||
}
|
||||
|
||||
const formRef = ref<FormInst | null>(null);
|
||||
const loading = ref(false);
|
||||
const { data: wallets } = safeClient(client.api.admin.wallet_types.get());
|
||||
|
||||
const walletOptions = computed<SelectOption[]>(() => {
|
||||
if (!wallets.value?.data) return [];
|
||||
return wallets.value.data.map((item: any) => ({
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}));
|
||||
});
|
||||
|
||||
const formModel = ref<AdjustForm>({
|
||||
amount: 0,
|
||||
walletTypeId: undefined
|
||||
});
|
||||
|
||||
const rules: FormRules = {
|
||||
amount: [
|
||||
{ required: true, type: 'number', message: '请输入充值金额', trigger: 'blur' },
|
||||
{
|
||||
validator: (rule, value) => {
|
||||
if (value === null || value === undefined) {
|
||||
return new Error('请输入充值金额');
|
||||
}
|
||||
const num = Number(value);
|
||||
if (Number.isNaN(num)) {
|
||||
return new Error('请输入有效的数字');
|
||||
}
|
||||
if (num <= 0) {
|
||||
return new Error('充值金额必须大于0');
|
||||
}
|
||||
return true;
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
walletTypeId: [{ required: true, message: '请选择钱包类型', trigger: 'change' }]
|
||||
};
|
||||
|
||||
async function handleSubmit() {
|
||||
await formRef.value?.validate();
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const result = await safeClient(() =>
|
||||
client.api.admin.wallet.adjust.batch.post({
|
||||
userIds: props.userIds,
|
||||
amount: String(formModel.value.amount),
|
||||
walletTypeId: formModel.value.walletTypeId!
|
||||
})
|
||||
);
|
||||
|
||||
if (result.data) {
|
||||
window.$message?.success('充值成功');
|
||||
emit('close');
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-6">
|
||||
<NForm ref="formRef" :model="formModel" :rules="rules" label-placement="left" :label-width="100">
|
||||
<NFormItem label="钱包类型" path="walletTypeId">
|
||||
<NSelect
|
||||
v-model:value="formModel.walletTypeId"
|
||||
:options="walletOptions"
|
||||
placeholder="请选择钱包类型"
|
||||
clearable
|
||||
/>
|
||||
</NFormItem>
|
||||
|
||||
<NFormItem label="充值金额" path="amount">
|
||||
<NInputNumber
|
||||
v-model:value="formModel.amount"
|
||||
placeholder="请输入充值金额"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
class="w-full"
|
||||
>
|
||||
<template #suffix>元</template>
|
||||
</NInputNumber>
|
||||
</NFormItem>
|
||||
|
||||
<NFormItem label="充值用户">
|
||||
<div class="text-gray-500">
|
||||
已选择
|
||||
<span class="text-primary font-semibold">{{ userIds.length }}</span>
|
||||
个用户
|
||||
</div>
|
||||
</NFormItem>
|
||||
|
||||
<NSpace justify="end" class="mt-4">
|
||||
<NButton @click="emit('close')">取消</NButton>
|
||||
<NButton type="primary" :loading="loading" @click="handleSubmit">确认充值</NButton>
|
||||
</NSpace>
|
||||
</NForm>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { h, useTemplateRef } from 'vue';
|
||||
import { h, ref, useTemplateRef } from 'vue';
|
||||
import { useDialog, useMessage } from 'naive-ui';
|
||||
import dayjs from 'dayjs';
|
||||
import { authClient, client, safeClient } from '@/service/api';
|
||||
@@ -14,6 +14,7 @@ import Kyc from './components/kyc.vue';
|
||||
import Ledger from './components/ledger.vue';
|
||||
import Deposit from './components/deposit.vue';
|
||||
import Subscription from './components/subscription.vue';
|
||||
import AdjustWallet from './components/adjust-wallet.vue';
|
||||
|
||||
const dialog = useDialog();
|
||||
const message = useMessage();
|
||||
@@ -31,6 +32,12 @@ const fetchData: TableFetchData = ({ pagination, filter }) => {
|
||||
};
|
||||
|
||||
const columns: TableBaseColumns = [
|
||||
{
|
||||
key: 'selection',
|
||||
type: 'selection',
|
||||
title: '',
|
||||
width: 60
|
||||
},
|
||||
{
|
||||
key: 'userProfile.uid',
|
||||
title: 'UID',
|
||||
@@ -266,11 +273,34 @@ const filterColumns: TableFilterColumns = [
|
||||
title: '姓名'
|
||||
}
|
||||
];
|
||||
|
||||
const checkedRowKeys = ref<string[]>([]);
|
||||
function handleAdjustWallet() {
|
||||
if (checkedRowKeys.value.length === 0) {
|
||||
message.warning('请先选择用户');
|
||||
return;
|
||||
}
|
||||
const d = dialog.create({
|
||||
title: '一键上分',
|
||||
showIcon: false,
|
||||
style: { width: '600px' },
|
||||
content: () =>
|
||||
h(AdjustWallet, {
|
||||
userIds: checkedRowKeys.value,
|
||||
onClose: () => {
|
||||
d.destroy();
|
||||
tableInst.value?.reload();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TableBase
|
||||
ref="tableInst"
|
||||
v-model:checked-row-keys="checkedRowKeys"
|
||||
:row-key="row => row.id"
|
||||
:fetch-data="fetchData"
|
||||
:columns="columns"
|
||||
:filter-columns="filterColumns"
|
||||
@@ -280,7 +310,11 @@ const filterColumns: TableFilterColumns = [
|
||||
refresh: true,
|
||||
columns: true
|
||||
}"
|
||||
/>
|
||||
>
|
||||
<template #header-operation-suffix>
|
||||
<NButton size="small" type="primary" @click="handleAdjustWallet">一键上分</NButton>
|
||||
</template>
|
||||
</TableBase>
|
||||
</template>
|
||||
|
||||
<style lang="css" scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user