更新表格组件,新增过滤功能,调整数据获取逻辑,优化界面布局

This commit is contained in:
2025-12-17 23:24:18 +07:00
parent 8a9d617129
commit 63ca414f2b
7 changed files with 225 additions and 85 deletions

View File

@@ -1,18 +1,20 @@
<script lang="ts" setup>
import { h, ref, useTemplateRef } from 'vue';
import { NInputNumber, useDialog, useMessage } from 'naive-ui';
import { useTemplateRef } from 'vue';
import { NDatePicker, useDialog, useMessage } from 'naive-ui';
import { client, safeClient } from '@/service/api';
import { DepositTypeEnum } from '@/enum';
import type { TableBaseColumns, TableFetchData, TableInst } from '@/components/table';
import type { TableBaseColumns, TableFetchData, TableFilterColumns, TableInst } from '@/components/table';
const dialog = useDialog();
const message = useMessage();
const tableInst = useTemplateRef<TableInst>('tableInst');
const fetchData: TableFetchData = () => {
const fetchData: TableFetchData = ({ pagination, filter }) => {
return safeClient(() =>
client.api.admin.rwa.issuance.products.get({
query: {}
query: {
...pagination,
...filter
}
})
);
};
@@ -23,7 +25,7 @@ const columns: TableBaseColumns = [
key: 'id'
},
{
title: 'code',
title: 'Code',
key: 'code'
},
{
@@ -31,64 +33,99 @@ const columns: TableBaseColumns = [
key: 'name'
},
{
title: 'description',
key: 'description'
},
{
title: 'estimatedValue',
title: '估值',
key: 'estimatedValue'
},
{
title: 'categoryId',
title: '产品分类',
key: 'categoryId'
},
{
title: 'createdBy',
title: '创建人',
key: 'createdBy'
},
{
title: '创建时间',
key: 'createdAt',
render: (row: any) => {
return new Date(row.createdAt).toLocaleDateString();
}
},
{
title: '状态',
key: 'status'
},
{
title: '描述',
key: 'description'
},
{
title: '操作',
fixed: 'right',
key: 'operation',
width: 160,
width: 230,
operations: (row: any) => [
{
contentText: '编辑',
type: 'primary',
onClick: () => {
contentText: '批准',
size: 'small',
onClick: async () => {
safeClient(() =>
client.api.admin.rwa.issuance.approve.post({
productId: row.id as string
})
);
tableInst.value?.reload();
}
},
{
contentText: '删除',
type: 'error',
ghost: true,
contentText: '拒绝',
size: 'small',
onClick: async () => {
dialog.create({
title: '提示',
positiveText: '是',
negativeText: '否',
content: '确认删除该银行信息?',
onPositiveClick: async () => {
safeClient(() =>
client.api.admin.deposit.reject({ orderId: row.id as string }).post({
reviewNote: '管理员拒绝充值'
})
);
// tableInst.value?.reload();
message.success('删除成功');
}
});
safeClient(() =>
client.api.admin.rwa.issuance.reject.post({
productId: row.id as string,
rejectionReason: '不符合要求'
})
);
tableInst.value?.reload();
}
},
{
contentText: '编辑',
size: 'small',
onClick: () => {
tableInst.value?.reload();
}
}
]
}
];
const filterColumns: TableFilterColumns = [
{
title: '产品名称',
key: 'name'
},
{
title: '产品Code',
key: 'Code'
},
{
title: '创建时间',
key: 'createdAt',
component: NDatePicker
}
];
</script>
<template>
<TableBase ref="tableInst" :columns="columns" :fetch-data="fetchData" />
<TableBase
ref="tableInst"
show-header-operation
:columns="columns"
:filter-columns="filterColumns"
:fetch-data="fetchData"
/>
</template>
<style lang="css" scoped></style>