Compare commits

...

10 Commits

28 changed files with 550 additions and 103 deletions

6
.env
View File

@@ -2,9 +2,9 @@
# if use a sub directory, it must be end with "/", like "/admin/" but not "/admin"
VITE_BASE_URL=/
VITE_APP_TITLE=SoybeanAdmin
VITE_APP_TITLE=RiwsanAdmin
VITE_APP_DESC=SoybeanAdmin is a fresh and elegant admin template
VITE_APP_DESC=RiwsanAdmin is trade palatform admin system
# the prefix of the icon name
VITE_ICON_PREFIX=icon
@@ -17,7 +17,7 @@ VITE_ICON_LOCAL_PREFIX=icon-local
VITE_AUTH_ROUTE_MODE=static
# static auth route home
VITE_ROUTE_HOME=home
VITE_ROUTE_HOME=asset
# default menu icon
VITE_MENU_ICON=mdi:menu

View File

@@ -1,5 +1,5 @@
# backend service base url, prod environment
VITE_SERVICE_BASE_URL=http://192.168.1.7:9527
VITE_SERVICE_BASE_URL=https://riwa-api.riwsan1.com
# other backend service base url, prod environment
VITE_OTHER_SERVICE_BASE_URL= `{}`

View File

@@ -1,5 +1,5 @@
# backend service base url, test environment
VITE_SERVICE_BASE_URL=http://192.168.1.7:9528
VITE_SERVICE_BASE_URL=https://riwa-api.riwsan1.com
# other backend service base url, test environment
VITE_OTHER_SERVICE_BASE_URL= `{}`

View File

@@ -36,6 +36,7 @@
"cleanup": "sa cleanup",
"commit": "sa git-commit",
"commit:zh": "sa git-commit -l=zh-cn",
"deploy:cloudflare": "wrangler pages deploy dist --project-name=riwa-admin --branch=main",
"dev": "vite --mode test",
"dev:prod": "vite --mode prod",
"gen-route": "sa gen-route",
@@ -50,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.7:9528/api/riwa-eden-0.0.135.tgz",
"@riwa/api-types": "http://192.168.1.7:9528/api/riwa-eden-0.0.145.tgz",
"@sa/axios": "workspace:*",
"@sa/color": "workspace:*",
"@sa/hooks": "workspace:*",

12
pnpm-lock.yaml generated
View File

@@ -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.7:9528/api/riwa-eden-0.0.135.tgz
version: '@riwa/eden@http://192.168.1.7:9528/api/riwa-eden-0.0.135.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.7:9528/api/riwa-eden-0.0.145.tgz
version: '@riwa/eden@http://192.168.1.7:9528/api/riwa-eden-0.0.145.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
@@ -1230,9 +1230,9 @@ packages:
'@quansync/fs@0.1.6':
resolution: {integrity: sha512-zoA8SqQO11qH9H8FCBR7NIbowYARIPmBz3nKjgAaOUDi/xPAAu1uAgebtV7KXHTc6CDZJVRZ1u4wIGvY5CWYaw==}
'@riwa/eden@http://192.168.1.7:9528/api/riwa-eden-0.0.135.tgz':
resolution: {tarball: http://192.168.1.7:9528/api/riwa-eden-0.0.135.tgz}
version: 0.0.135
'@riwa/eden@http://192.168.1.7:9528/api/riwa-eden-0.0.145.tgz':
resolution: {tarball: http://192.168.1.7:9528/api/riwa-eden-0.0.145.tgz}
version: 0.0.145
peerDependencies:
'@elysiajs/eden': ^1.4.5
@@ -5651,7 +5651,7 @@ snapshots:
dependencies:
quansync: 0.3.0
'@riwa/eden@http://192.168.1.7:9528/api/riwa-eden-0.0.135.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)))':
'@riwa/eden@http://192.168.1.7:9528/api/riwa-eden-0.0.145.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))

View File

@@ -40,7 +40,7 @@ export type TableFilterColumn = {
key: string;
title: string;
component?: Component | VNode;
componentProps?: Record<string, any>;
componentProps?: Record<string, any> | ((form: Record<string, any>) => Record<string, any>);
};
export type TableFilterColumns = Array<TableFilterColumn>;

View File

@@ -25,11 +25,13 @@ const props = withDefaults(
columns?: boolean;
};
filterColumns?: TableFilterColumns;
filterColumnsCount?: number;
title?: string;
}>(),
{
title: '',
showHeaderOperation: true,
filterColumnsCount: 4,
filterColumns: () => [],
headerOperations: () => ({
add: true,
@@ -124,7 +126,12 @@ defineExpose({} as Expose);
<template>
<div class="space-y-5">
<TableFilter v-if="filterColumns.length > 0" :columns="filterColumns" @confirm="handleSearch" />
<TableFilter
v-if="filterColumns.length > 0"
:columns="filterColumns"
:filter-columns-count="filterColumnsCount"
@confirm="handleSearch"
/>
<div class="rounded-lg bg-white p-5 space-y-5 dark:bg-container">
<TableHeaderOperation
@@ -139,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
@@ -149,9 +159,10 @@ defineExpose({} as Expose);
:data="tableData"
:pagination="pagination"
:bordered="false"
:on-update:page="handlePageChange"
:on-update:page-size="handlePageSizeChange"
:remote="true"
v-bind="$attrs"
@update:page="handlePageChange"
@update:page-size="handlePageSizeChange"
/>
</div>
</div>

View File

@@ -1,10 +1,11 @@
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { NInput } from 'naive-ui';
import type { TableFilterColumns } from '.';
import type { TableFilterColumn, TableFilterColumns } from '.';
const props = defineProps<{
columns?: TableFilterColumns;
filterColumnsCount?: number;
}>();
const emit = defineEmits<{
(e: 'confirm', form: Record<string, any>): void;
@@ -14,8 +15,22 @@ const inlineForm: Record<string, any> = {};
const form = ref<Record<string, any>>({});
function transformProps(col: TableFilterColumn) {
if (typeof col.componentProps === 'object') {
return col.componentProps;
} else if (typeof col.componentProps === 'function') {
return col.componentProps(form.value);
}
}
onMounted(() => {
props.columns?.forEach(col => {
if (col.key.includes(',')) {
col.key.split(',').forEach(k => {
inlineForm[k] = null;
form.value[k] = null;
});
return;
}
inlineForm[col.key] = null;
form.value[col.key] = null;
});
@@ -33,14 +48,14 @@ function handleConfirm() {
<template>
<div class="rounded-lg bg-white p-5 dark:bg-container">
<NForm :label-width="80" label-align="left" label-placement="left">
<NGrid x-gap="20" :cols="4">
<NForm :label-width="80" label-align="left" label-placement="left" :show-feedback="false">
<NGrid x-gap="20" y-gap="10" :cols="filterColumnsCount || 4">
<NGi v-for="col in columns" :key="col.key">
<NFormItem :label="col.title" :path="col.key">
<component
:is="col.component || NInput"
:value="form[col.key]"
v-bind="col.componentProps"
v-bind="transformProps(col)"
@update:value="(val: any) => (form[col.key] = val)"
/>
</NFormItem>

View File

@@ -102,13 +102,12 @@ async function handleCustomRequest({ file, onProgress, onFinish, onError }: Uplo
onProgress({ percent });
}
});
// 直接修改 file 对象的 idNaiveUI 会自动同步到 fileList
file.id = fileId;
file.status = 'finished';
file.url = fileId;
const newFileIds = [...props.modelValue, fileId];
const newFileIds = [...props.modelValue, fileId].filter(Boolean);
emit('update:modelValue', newFileIds);
onFinish();

View File

@@ -248,7 +248,9 @@ const local: App.I18n.Schema = {
tokenization: 'Tokenization Management',
tokenization_product: 'Tokenization Product',
notification: 'Notification Management',
news: 'News Management'
news: 'News Management',
robot: 'Robot Management',
robot_spot: 'Spot Robot'
},
page: {
login: {

View File

@@ -244,7 +244,9 @@ const local: App.I18n.Schema = {
tokenization: '代币化管理',
tokenization_product: '代币化产品',
notification: '通知管理',
news: '新闻管理'
news: '新闻管理',
robot: '机器人管理',
robot_spot: '现货机器人'
},
page: {
login: {

View File

@@ -26,13 +26,13 @@ export const views: Record<LastLevelRouteKey, RouteComponent | (() => Promise<Ro
home: () => import("@/views/home/index.vue"),
news: () => import("@/views/news/index.vue"),
notification: () => import("@/views/notification/index.vue"),
robot_spot: () => import("@/views/robot/spot/index.vue"),
rwa_product: () => import("@/views/rwa/product/index.vue"),
rwa_producttype: () => import("@/views/rwa/productType/index.vue"),
rwa_producttype: () => import("@/views/rwa/producttype/index.vue"),
rwa_subscribe: () => import("@/views/rwa/subscribe/index.vue"),
tokenization_product: () => import("@/views/tokenization/product/index.vue"),
"tokenization_trading-pairs": () => import("@/views/tokenization/trading-pairs/index.vue"),
transfer: () => import("@/views/transfer/index.vue"),
user_bankcard: () => import("@/views/user/bankcard/index.vue"),
user_list: () => import("@/views/user/list/index.vue"),
withdraw_approved: () => import("@/views/withdraw/approved/index.vue"),
withdraw_fiat: () => import("@/views/withdraw/fiat/index.vue"),

View File

@@ -133,9 +133,30 @@ export const generatedRoutes: GeneratedRoute[] = [
meta: {
title: 'notification',
i18nKey: 'route.notification',
order: 7
order: 9
}
},
{
name: 'robot',
path: '/robot',
component: 'layout.base',
meta: {
title: 'robot',
i18nKey: 'route.robot',
order: 7
},
children: [
{
name: 'robot_spot',
path: '/robot/spot',
component: 'view.robot_spot',
meta: {
title: 'robot_spot',
i18nKey: 'route.robot_spot'
}
}
]
},
{
name: 'rwa',
path: '/rwa',
@@ -164,15 +185,15 @@ export const generatedRoutes: GeneratedRoute[] = [
i18nKey: 'route.rwa_producttype'
}
},
// {
// name: 'rwa_subscribe',
// path: '/rwa/subscribe',
// component: 'view.rwa_subscribe',
// meta: {
// title: 'rwa_subscribe',
// i18nKey: 'route.rwa_subscribe'
// }
// }
{
name: 'rwa_subscribe',
path: '/rwa/subscribe',
component: 'view.rwa_subscribe',
meta: {
title: 'rwa_subscribe',
i18nKey: 'route.rwa_subscribe'
}
}
]
},
{
@@ -225,15 +246,6 @@ export const generatedRoutes: GeneratedRoute[] = [
order: 4
},
children: [
{
name: 'user_bankcard',
path: '/user/bankcard',
component: 'view.user_bankcard',
meta: {
title: 'user_bankcard',
i18nKey: 'route.user_bankcard'
}
},
{
name: 'user_list',
path: '/user/list',

View File

@@ -175,6 +175,8 @@ const routeMap: RouteMap = {
"login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?",
"news": "/news",
"notification": "/notification",
"robot": "/robot",
"robot_spot": "/robot/spot",
"rwa": "/rwa",
"rwa_product": "/rwa/product",
"rwa_producttype": "/rwa/producttype",
@@ -184,7 +186,6 @@ const routeMap: RouteMap = {
"tokenization_trading-pairs": "/tokenization/trading-pairs",
"transfer": "/transfer",
"user": "/user",
"user_bankcard": "/user/bankcard",
"user_list": "/user/list",
"withdraw": "/withdraw",
"withdraw_approved": "/withdraw/approved",

View File

@@ -42,7 +42,6 @@ declare module 'vue' {
LookForward: typeof import('./../components/custom/look-forward.vue')['default']
MarkdownEditor: typeof import('./../components/markdown-editor/index.vue')['default']
MenuToggler: typeof import('./../components/common/menu-toggler.vue')['default']
NAlert: typeof import('naive-ui')['NAlert']
NBadge: typeof import('naive-ui')['NBadge']
NBreadcrumb: typeof import('naive-ui')['NBreadcrumb']
NBreadcrumbItem: typeof import('naive-ui')['NBreadcrumbItem']
@@ -137,7 +136,6 @@ declare global {
const LookForward: typeof import('./../components/custom/look-forward.vue')['default']
const MarkdownEditor: typeof import('./../components/markdown-editor/index.vue')['default']
const MenuToggler: typeof import('./../components/common/menu-toggler.vue')['default']
const NAlert: typeof import('naive-ui')['NAlert']
const NBadge: typeof import('naive-ui')['NBadge']
const NBreadcrumb: typeof import('naive-ui')['NBreadcrumb']
const NBreadcrumbItem: typeof import('naive-ui')['NBreadcrumbItem']

View File

@@ -29,6 +29,8 @@ declare module "@elegant-router/types" {
"login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?";
"news": "/news";
"notification": "/notification";
"robot": "/robot";
"robot_spot": "/robot/spot";
"rwa": "/rwa";
"rwa_product": "/rwa/product";
"rwa_producttype": "/rwa/producttype";
@@ -38,7 +40,6 @@ declare module "@elegant-router/types" {
"tokenization_trading-pairs": "/tokenization/trading-pairs";
"transfer": "/transfer";
"user": "/user";
"user_bankcard": "/user/bankcard";
"user_list": "/user/list";
"withdraw": "/withdraw";
"withdraw_approved": "/withdraw/approved";
@@ -85,6 +86,7 @@ declare module "@elegant-router/types" {
| "login"
| "news"
| "notification"
| "robot"
| "rwa"
| "tokenization"
| "transfer"
@@ -117,13 +119,13 @@ declare module "@elegant-router/types" {
| "home"
| "news"
| "notification"
| "robot_spot"
| "rwa_product"
| "rwa_producttype"
| "rwa_subscribe"
| "tokenization_product"
| "tokenization_trading-pairs"
| "transfer"
| "user_bankcard"
| "user_list"
| "withdraw_approved"
| "withdraw_fiat"

View File

@@ -18,10 +18,6 @@ const fetchData: TableFetchData = ({ pagination, filter }) => {
};
const columns: TableBaseColumns = [
{
title: 'ID',
key: 'id'
},
{
title: '用户ID',
key: 'userId'
@@ -57,8 +53,8 @@ const columns: TableBaseColumns = [
{
contentText: '通过',
type: 'primary',
strong: true,
secondary: true,
ghost: true,
size: 'small',
visible: row.status !== 'approved',
onClick: async () => {
dialog.create({
@@ -82,6 +78,7 @@ const columns: TableBaseColumns = [
contentText: '拒绝',
type: 'error',
ghost: true,
size: 'small',
onClick: async () => {
dialog.create({
title: '提示',
@@ -134,6 +131,7 @@ const filterColumns: TableFilterColumns = [
:fetch-data="fetchData"
show-header-operation
:filter-columns="filterColumns"
:scroll-x="800"
/>
</template>

View File

@@ -17,24 +17,6 @@ const selectedIcon = ref('');
<template>
<NSpace vertical :size="16">
<!-- Icon Picker 测试区域 -->
<NCard title="Icon Picker 测试" :bordered="false" class="card-wrapper">
<NSpace vertical :size="12">
<div class="flex items-center gap-3">
<span class="text-sm">选择图标</span>
<IconPicker v-model="selectedIcon" />
</div>
<div v-if="selectedIcon" class="flex items-center gap-3 rounded bg-gray-100 p-3 dark:bg-gray-800">
<SvgIcon :icon="selectedIcon" class="text-2xl" />
<code class="text-sm text-primary">{{ selectedIcon }}</code>
</div>
<div v-else class="text-sm text-gray-400">未选择图标</div>
</NSpace>
</NCard>
<NAlert :title="$t('common.tip')" type="warning">
{{ $t('page.home.branchDesc') }}
</NAlert>
<HeaderBanner />
<CardData />
<NGrid :x-gap="gap" :y-gap="16" responsive="screen" item-responsive>

View File

@@ -104,13 +104,13 @@ const columns: TableBaseColumns = [
render: (row: any) => {
return useDateFormat(row.createdAt, 'YYYY-MM-DD HH:mm:ss').value;
}
},
{
title: '操作',
key: 'operations',
fixed: 'right',
width: 120
}
// {
// title: '操作',
// key: 'operations',
// fixed: 'right',
// width: 120
// }
];
function handleAdd() {

View File

@@ -0,0 +1,230 @@
<script lang="ts" setup>
import { computed, ref, useTemplateRef } from 'vue';
import type { FormInst, FormRules } from 'naive-ui';
import type { Treaty } from '@elysiajs/eden';
import { client, safeClient } from '@/service/api';
defineOptions({ name: 'EditSpotRobotConfig' });
type Data = Treaty.Data<typeof client.api.admin.spot_robot_trader.configs.get>['data'][number];
const props = defineProps<{
data: Data;
}>();
const emit = defineEmits<{
(e: 'close'): void;
}>();
const formRef = useTemplateRef<FormInst | null>('formRef');
const { data: assets } = safeClient(client.api.admin.assets.get({ query: { pageIndex: 1, pageSize: 100 } }));
const { data: users } = safeClient(client.api.admin.users.get({ query: { pageIndex: 1, pageSize: 200 } }));
const { data: tradingPairs } = safeClient(
client.api.admin.trading_pairs.get({ query: { pageIndex: 1, pageSize: 100 } })
);
const assetOptions = computed(
() =>
assets.value?.data.map(asset => ({
label: `${asset.code} - ${asset.name}`,
value: asset.code
})) || []
);
const form = ref({
baseAsset: props.data.baseAsset,
quoteAsset: props.data.quoteAsset,
robotUserId: props.data.robotUserId,
symbol: props.data.symbol,
baseTopUpAmount: props.data.baseTopUpAmount ? Number(props.data.baseTopUpAmount) : 0,
enabled: props.data.enabled,
operatorUserId: props.data.operatorUserId || '',
buyPriceMax: props.data.buyPriceMax ? Number(props.data.buyPriceMax) : 0,
buyPriceMin: props.data.buyPriceMin ? Number(props.data.buyPriceMin) : 0,
buyPriceStep: props.data.buyPriceStep ? Number(props.data.buyPriceStep) : 0
});
const rules: FormRules = {
baseAsset: [
{
required: true,
message: '请输入基础资产',
trigger: ['blur', 'input']
}
],
quoteAsset: [
{
required: true,
message: '请输入计价资产',
trigger: ['blur', 'input']
}
],
robotUserId: [
{
required: true,
message: '请输入机器人用户ID',
trigger: ['blur', 'input']
}
],
symbol: [
{
required: true,
message: '请输入交易对',
trigger: ['blur', 'input']
}
],
baseTopUpAmount: [
{
required: true,
type: 'number',
message: '请输入基础资产单次充值金额',
trigger: ['blur', 'change']
}
],
buyPriceMax: [
{
required: true,
type: 'number',
message: '请输入买入价格上限',
trigger: ['blur', 'change']
}
],
buyPriceMin: [
{
required: true,
type: 'number',
message: '请输入买入价格下限',
trigger: ['blur', 'change']
}
],
buyPriceStep: [
{
required: true,
type: 'number',
message: '请输入买入价格步长',
trigger: ['blur', 'change']
}
]
};
async function handleSubmit() {
formRef.value?.validate(async errors => {
if (!errors) {
const { data } = await safeClient(() =>
client.api.admin.spot_robot_trader.config.put({
id: props.data.id,
baseAsset: form.value.baseAsset,
operatorUserId: form.value.operatorUserId,
quoteAsset: form.value.quoteAsset,
robotUserId: form.value.robotUserId,
symbol: form.value.symbol,
baseTopUpAmount: String(form.value.baseTopUpAmount),
enabled: form.value.enabled,
buyPriceMax: String(form.value.buyPriceMax),
buyPriceMin: String(form.value.buyPriceMin),
buyPriceStep: String(form.value.buyPriceStep)
})
);
if (data) {
window.$message?.success('现货机器人配置更新成功');
emit('close');
}
}
});
}
</script>
<template>
<NForm
ref="formRef"
:model="form"
:rules="rules"
label-width="140px"
label-placement="left"
require-mark-placement="left"
>
<NFormItem label="基础资产" path="baseAsset">
<NSelect v-model:value="form.baseAsset" :options="assetOptions" placeholder="请选择基础资产" filterable />
</NFormItem>
<NFormItem label="计价资产" path="quoteAsset">
<NSelect v-model:value="form.quoteAsset" :options="assetOptions" placeholder="请选择计价资产" filterable />
</NFormItem>
<NFormItem label="机器人用户ID" path="robotUserId">
<NSelect
v-model:value="form.robotUserId"
:options="users?.data.map(user => ({ label: `${user.nickname || user.user.name}`, value: user.userId })) || []"
placeholder="请选择机器人用户"
filterable
/>
</NFormItem>
<NFormItem label="交易对" path="symbol">
<NSelect
v-model:value="form.symbol"
:options="tradingPairs?.data.map(tp => ({ label: tp.symbol, value: tp.symbol })) || []"
placeholder="请选择交易对"
filterable
/>
</NFormItem>
<NFormItem label="基础资产单次充值金额" path="baseTopUpAmount">
<NInputNumber
v-model:value="form.baseTopUpAmount"
:min="0"
:step="0.01"
:precision="8"
placeholder="请输入充值金额"
class="w-full"
/>
</NFormItem>
<NFormItem label="买入价格上限" path="buyPriceMax">
<NInputNumber
v-model:value="form.buyPriceMax"
:min="0"
:step="0.01"
:precision="8"
placeholder="请输入买入价格上限"
class="w-full"
/>
</NFormItem>
<NFormItem label="买入价格下限" path="buyPriceMin">
<NInputNumber
v-model:value="form.buyPriceMin"
:min="0"
:step="0.01"
:precision="8"
placeholder="请输入买入价格下限"
class="w-full"
/>
</NFormItem>
<NFormItem label="买入价格步长" path="buyPriceStep">
<NInputNumber
v-model:value="form.buyPriceStep"
:min="0"
:step="0.01"
:precision="8"
placeholder="请输入买入价格步长"
class="w-full"
/>
</NFormItem>
<NFormItem label="是否启用" path="enabled">
<NSwitch v-model:value="form.enabled">
<template #checked>启用</template>
<template #unchecked>禁用</template>
</NSwitch>
</NFormItem>
<NSpace justify="end" class="mt-4">
<NButton @click="$emit('close')">取消</NButton>
<NButton type="primary" @click="handleSubmit">更新配置</NButton>
</NSpace>
</NForm>
</template>
<style lang="css" scoped></style>

View File

@@ -0,0 +1,143 @@
<script lang="ts" setup>
import { h, useTemplateRef } from 'vue';
import { useDateFormat } from '@vueuse/core';
import { useDialog } from 'naive-ui';
import { client, safeClient } from '@/service/api';
import type { TableBaseColumns, TableFetchData, TableInst } from '@/components/table';
import Edit from './components/edit.vue';
const dialog = useDialog();
const tableInst = useTemplateRef<TableInst>('tableInst');
const fetchData: TableFetchData = ({ pagination, filter }) => {
return safeClient(() =>
client.api.admin.spot_robot_trader.configs.get({
query: {
...pagination,
...filter
}
})
);
};
const columns: TableBaseColumns = [
{
key: 'selection',
title: '序号',
type: 'selection',
width: 60
},
{
key: 'id',
title: 'ID',
width: 100
},
{
key: 'baseAsset',
title: '基础资产',
width: 120
},
{
key: 'quoteAsset',
title: '计价资产',
width: 120
},
{
key: 'robotUserId',
title: '机器人用户ID',
width: 150
},
{
key: 'symbol',
title: '交易对',
width: 100
},
{
key: 'baseTopUpAmount',
title: '基础资产单次充值金额',
width: 160
},
{
key: 'buyPriceMax',
title: '买入价格上限',
width: 140
},
{
key: 'buyPriceMin',
title: '买入价格下限',
width: 140
},
{
key: 'buyPriceStep',
title: '买入价格步长',
width: 140
},
{
key: 'createdAt',
title: '创建时间',
width: 180,
render: (row: any) => {
return useDateFormat(row.createdAt, 'YYYY-MM-DD HH:mm:ss').value;
}
},
{
key: 'enabled',
title: '是否启用',
width: 100,
render: (row: any) => (row.enabled ? '是' : '否')
},
{
key: 'operations',
title: '操作',
fixed: 'right',
width: 150,
operations: (row: any) => [
{
contentText: row.enabled ? '禁用' : '启用',
type: 'primary',
ghost: true,
size: 'small',
onClick: async () => {
await safeClient(
client.api.admin.spot_robot_trader.config.enable.post({
id: row.id
})
);
tableInst.value?.reload();
}
},
{
contentText: '编辑',
type: 'primary',
ghost: true,
size: 'small',
onClick: () => {
handleEdit(row);
}
}
]
}
];
function handleEdit(row: any) {
const dialogInstance = dialog.create({
title: '编辑现货机器人配置',
content: () =>
h(Edit, {
data: row,
onClose: () => {
dialogInstance.destroy();
tableInst.value?.reload();
}
}),
style: { width: '600px' },
showIcon: false
});
}
</script>
<template>
<TableBase ref="tableInst" show-header-operation :columns="columns" :fetch-data="fetchData" :scroll-x="1000" />
</template>
<style lang="css" scoped></style>

View File

@@ -21,6 +21,7 @@ const { data } = safeClient(
);
const form = ref<Body>({
iconifyIcon: '',
name: '',
code: '',
categoryId: '',
@@ -31,6 +32,7 @@ const form = ref<Body>({
});
const rules: FormRules = {
iconifyIcon: [{ required: true, message: '请选择产品图标', trigger: ['blur', 'input'] }],
name: [{ required: true, message: '请输入产品名称', trigger: ['blur', 'input'] }],
code: [
{ required: true, message: '请输入产品编号', trigger: ['blur', 'input'] },
@@ -93,6 +95,9 @@ function handleCreateDraftAndSubmit() {
:rules="rules"
require-mark-placement="left"
>
<NFormItem path="iconifyIcon" label="产品图标 ">
<IconPicker v-model="form.iconifyIcon" />
</NFormItem>
<NFormItem path="name" label="产品名称">
<NInput v-model:value="form.name" />
</NFormItem>

View File

@@ -27,6 +27,7 @@ const { data: categories } = safeClient(
const form = ref<Body>({
id: props.data.id,
iconifyIcon: props.data.iconifyIcon,
name: props.data.name,
code: props.data.code,
categoryId: props.data.categoryId,
@@ -37,6 +38,7 @@ const form = ref<Body>({
});
const rules: FormRules = {
iconifyIcon: [{ required: true, message: '请选择产品图标', trigger: ['blur', 'input'] }],
name: [{ required: true, message: '请输入产品名称', trigger: ['blur', 'input'] }],
code: [
{ required: true, message: '请输入产品编号', trigger: ['blur', 'input'] },
@@ -88,6 +90,9 @@ function handleSubmit() {
:rules="rules"
require-mark-placement="left"
>
<NFormItem path="iconifyIcon" label="产品图标 ">
<IconPicker v-model="form.iconifyIcon" />
</NFormItem>
<NFormItem path="name" label="产品名称">
<NInput v-model:value="form.name" />
</NFormItem>

View File

@@ -5,6 +5,7 @@ import { NDatePicker, useDialog, useMessage } from 'naive-ui';
import { client, safeClient } from '@/service/api';
import type { TableBaseColumns, TableFetchData, TableFilterColumns, TableInst } from '@/components/table';
import { RwaStatusEnum } from '@/enum';
import SvgIcon from '@/components/custom/svg-icon.vue';
import Add from './components/add.vue';
import Edit from './components/edit.vue';
import Editions from './components/editions.vue';
@@ -32,6 +33,13 @@ const columns: TableBaseColumns = [
type: 'selection',
width: 60
},
{
title: '产品图标',
key: 'iconifyIcon',
render: (row: any) => {
return h(SvgIcon, { icon: row.iconifyIcon });
}
},
{
title: '产品代码',
key: 'code'

View File

@@ -28,6 +28,7 @@ const form = ref<Body>({
minOrderQuantity: props.data.minOrderQuantity,
makerFeeRate: props.data.makerFeeRate,
takerFeeRate: props.data.takerFeeRate,
pricePrecision: props.data.pricePrecision,
iconUrl: props.data.iconUrl,
isActive: props.data.isActive,
marginEnabled: props.data.marginEnabled,
@@ -151,6 +152,12 @@ function handleSubmit() {
</NFormItemGi>
</NGrid>
<NFormItem path="pricePrecision" label="价格小数位数">
<NInputNumber v-model:value="form.pricePrecision" :min="0" :max="8" :precision="0" class="w-full">
<template #suffix></template>
</NInputNumber>
</NFormItem>
<NFormItem path="description" label="交易对描述">
<NInput v-model:value="form.description" type="textarea" placeholder="请输入交易对描述" />
</NFormItem>

View File

@@ -1,18 +1,24 @@
<script lang="ts" setup>
import { h, useTemplateRef } from 'vue';
import { useDialog, useMessage } from 'naive-ui';
import { client, safeClient } from '@/service/api';
import type { TableBaseColumns, TableFetchData, TableFilterColumns, TableInst } from '@/components/table';
import Edit from './components/edit.vue';
import Edit from './bankcard-edit.vue';
defineOptions({
name: 'UserBankCard'
});
const props = defineProps<{
userId?: string;
}>();
const dialog = useDialog();
const message = useMessage();
const tableInst = useTemplateRef<TableInst>('tableInst');
const fetchData: TableFetchData = ({ pagination, filter }) => {
return safeClient(() =>
client.api.admin.bank_account.get({
query: {
userId: props.userId,
...pagination,
...filter
}
@@ -21,10 +27,6 @@ const fetchData: TableFetchData = ({ pagination, filter }) => {
};
const columns: TableBaseColumns = [
{
title: 'ID',
key: 'userId'
},
{
title: '持卡人姓名',
key: 'accountName'
@@ -46,11 +48,16 @@ const columns: TableBaseColumns = [
key: 'isVerified',
render: (row: any) => (row.isVerified ? '是' : '否')
},
{
title: '是否默认',
key: 'isDefault',
render: (row: any) => (row.isDefault ? '是' : '否')
},
{
title: '操作',
fixed: 'right',
key: 'operation',
width: 160,
width: 150,
operations: (row: any) => [
{
contentText: '编辑',
@@ -67,7 +74,7 @@ const columns: TableBaseColumns = [
ghost: true,
size: 'small',
onClick: async () => {
dialog.create({
window.$dialog?.create({
title: '提示',
positiveText: '是',
negativeText: '否',
@@ -79,7 +86,7 @@ const columns: TableBaseColumns = [
})
);
tableInst.value?.reload();
message.success('删除成功');
window.$message?.success('删除成功');
}
});
}
@@ -100,17 +107,17 @@ const filterColumns: TableFilterColumns = [
];
function handleEdit(row: any) {
const dialogInstance = dialog.create({
const dialogInstance = window.$dialog?.create({
title: '编辑银行卡信息',
content: () =>
h(Edit, {
data: row,
onClose: () => {
dialogInstance.destroy();
dialogInstance?.destroy();
tableInst.value?.reload();
}
}),
style: { width: '800px' },
style: { width: '600px' },
showIcon: false
});
}
@@ -119,16 +126,12 @@ function handleEdit(row: any) {
<template>
<TableBase
ref="tableInst"
show-header-operation
:show-header-operation="false"
:columns="columns"
:filter-columns="filterColumns"
:filter-columns-count="3"
:fetch-data="fetchData"
:scroll-x="800"
:header-operations="{
add: false,
refresh: true,
columns: true
}"
:scroll-x="1000"
/>
</template>

View File

@@ -5,6 +5,7 @@ import { client, safeClient } from '@/service/api';
import { DepositTypeEnum } from '@/enum';
import type { TableBaseColumns, TableFetchData, TableInst } from '@/components/table';
import EditForm from './components/edit.vue';
import UserBankCard from './components/bankcard.vue';
const dialog = useDialog();
const message = useMessage();
@@ -58,16 +59,23 @@ const columns: TableBaseColumns = [
title: '操作',
fixed: 'right',
key: 'operation',
width: 100,
width: 200,
operations: (row: any) => [
{
contentText: '编辑',
type: 'primary',
ghost: true,
size: 'small',
onClick: () => {
handleEdit(row);
}
},
{
contentText: '银行卡',
ghost: true,
size: 'small',
onClick: () => {
handleBankCard(row);
}
}
]
}
@@ -111,6 +119,21 @@ function handleEdit(row: any) {
showIcon: false
});
}
function handleBankCard(row: any) {
const dialogInstance = dialog.create({
title: '用户银行卡',
content: () =>
h(UserBankCard, {
userId: row.userId,
onClose: () => {
dialogInstance.destroy();
tableInst.value?.reload();
}
}),
style: { width: '1000px' },
showIcon: false
});
}
</script>
<template>