Przeglądaj źródła

feat: 修改筛选条件,配置新data

ljc 2 miesięcy temu
rodzic
commit
685a9854f9
5 zmienionych plików z 89 dodań i 63 usunięć
  1. 2 2
      .env.development
  2. 16 12
      src/service/vault.ts
  3. 3 0
      src/types/api.ts
  4. 6 0
      src/types/page.ts
  5. 62 49
      src/views/Vault/vaultList.vue

+ 2 - 2
.env.development

@@ -1,5 +1,5 @@
 # 与 gypsy-crm-frontend-admin 开发环境默认 Host 对齐,可按环境修改
 # VITE_API_HOST82=https://ad.44a5c8109e4.com
-VITE_API_HOST82=http://103.158.191.66:9300
-#VITE_API_HOST82=http://192.168.0.25:9300
+#VITE_API_HOST82=http://103.158.191.66:9300
+VITE_API_HOST82=http://192.168.0.25:9300
 VITE_API_HOST80=https://secure.44a5c8109e4.com

+ 16 - 12
src/service/vault.ts

@@ -10,34 +10,38 @@ export function fetchVaultsList() {
 export interface FetchVaultTransactionsBody {
   vaultId?: string | number | null
   status?: string | null
-  senderIsVaultAddress?: string | null
-  recipientIsVaultAddress?: string | null
+  senderLabel?: string | null
+  recipientLabel?: string | null
+  senderAddress?: string | null
+  recipientAddress?: string | null
   /** 页码,从 1 开始 */
-  page?: number
-  pageSize?: number
-}
-
-export interface VaultTransactionsResult {
-  list: VaultTransactionItem[]
-  /** 总条数,用于分页;若后端暂未返回可先不传,前端会按当前页条数展示 */
-  total?: number
+  page?: {
+    current?: number
+    row?: number
+  }
 }
 
 function buildVaultTransactionsPayload(body: FetchVaultTransactionsBody): Record<string, unknown> {
   const payload: Record<string, unknown> = {}
   if (body.vaultId != null) payload.vaultId = body.vaultId
   if (body.status != null && String(body.status).trim() !== '') payload.status = body.status
+  if (body.senderLabel != null && String(body.senderLabel).trim() !== '') payload.senderLabel = body.senderLabel
+  if (body.recipientLabel != null && String(body.recipientLabel).trim() !== '')
+    payload.recipientLabel = body.recipientLabel
+  if (body.senderAddress != null && String(body.senderAddress).trim() !== '')
+    payload.senderAddress = body.senderAddress
+  if (body.recipientAddress != null && String(body.recipientAddress).trim() !== '')
+    payload.recipientAddress = body.recipientAddress
   // if (body.senderIsVaultAddress != null && String(body.senderIsVaultAddress).trim() !== '')
   //   payload.senderIsVaultAddress = body.senderIsVaultAddress
   // if (body.recipientIsVaultAddress != null && String(body.recipientIsVaultAddress).trim() !== '')
   //   payload.recipientIsVaultAddress = body.recipientIsVaultAddress
   if (body.page != null) payload.page = body.page
-  if (body.pageSize != null) payload.pageSize = body.pageSize
   return payload
 }
 
 export function fetchVaultTransactions(body: FetchVaultTransactionsBody = {}) {
-  return postJson<VaultTransactionsResult>('/vaultody/transaction/search/list', buildVaultTransactionsPayload(body))
+  return postJson<VaultTransactionItem[]>('/vaultody/transaction/search/list', buildVaultTransactionsPayload(body))
 }
 
 function parseFilenameFromContentDisposition(cd: string | undefined): string | null {

+ 3 - 0
src/types/api.ts

@@ -1,5 +1,8 @@
+import type { Page } from './page'
+
 export interface ApiResponse<T = unknown> {
   code: number
   msg?: string
   data: T
+  page?: Page
 }

+ 6 - 0
src/types/page.ts

@@ -0,0 +1,6 @@
+export interface Page {
+  current: number
+  pageTotal: number
+  row: number
+  rowTotal: number
+}

+ 62 - 49
src/views/Vault/vaultList.vue

@@ -34,32 +34,17 @@ const ETH_TX_BASE_URL = 'https://etherscan.io/tx/'
 const TRON_TX_BASE_URL = 'https://tronscan.org/#/transaction/'
 
 const filters = reactive<{
-  status: string | null
-  // senderIsVaultAddress: string | null
-  // recipientIsVaultAddress: string | null
+  senderLabel: string | null
+  recipientLabel: string | null
+  senderAddress: string | null
+  recipientAddress: string | null
 }>({
-  status: null,
-  // senderIsVaultAddress: null,
-  // recipientIsVaultAddress: null,
+  senderLabel: null,
+  recipientLabel: null,
+  senderAddress: null,
+  recipientAddress: null,
 })
 
-const statusOptions = computed(() => [
-  { label: t('vaultTx.filterAll'), value: null },
-  { label: t('vaultTx.status_unconfirmed'), value: 'unconfirmed' },
-  { label: t('vaultTx.status_confirming'), value: 'confirming' },
-  { label: t('vaultTx.status_confirmed'), value: 'confirmed' },
-  { label: t('vaultTx.status_finalized'), value: 'finalized' },
-  { label: t('vaultTx.status_dropped'), value: 'dropped' },
-  { label: t('vaultTx.status_replaced'), value: 'replaced' },
-  { label: t('vaultTx.status_failed'), value: 'failed' },
-])
-
-// const boolFilterOptions = computed(() => [
-//   { label: t('vaultTx.filterAll'), value: null },
-//   { label: t('vaultTx.boolYes'), value: 'true' },
-//   { label: t('vaultTx.boolNo'), value: 'false' },
-// ])
-
 function formatDash(v: unknown): string {
   if (v == null || v === '') return '—'
   return String(v)
@@ -91,11 +76,11 @@ function formatTimestamp(v: string | number | undefined): string {
   return Number.isNaN(d.getTime()) ? String(v) : format(d)
 }
 
-function boolText(v: boolean | undefined): string {
-  if (v === true) return t('vaultTx.boolYes')
-  if (v === false) return t('vaultTx.boolNo')
-  return '—'
-}
+// function boolText(v: boolean | undefined): string {
+//   if (v === true) return t('vaultTx.boolYes')
+//   if (v === false) return t('vaultTx.boolNo')
+//   return '—'
+// }
 
 /** 各列 width 之和,供 scroll-x 使用,保证超出视口时可横向滚动看全列 */
 const VAULT_TX_COL_WIDTHS = [
@@ -229,15 +214,15 @@ const columns = computed<DataTableColumns<VaultTransactionItem>>(() => [
     render: (row) =>
       h('span', { class: 'vault-tx__cell-text' }, formatDash(row.blockchain)),
   },
-  {
-    title: () => t('vaultTx.colBlockHeight'),
-    key: 'minedInBlockHeight',
-    width: 112,
-    titleAlign: 'center',
-    align: 'center',
-    render: (row) =>
-      h('span', { class: 'vault-tx__cell-num' }, formatDash(row.minedInBlockHeight)),
-  },
+  // {
+  //   title: () => t('vaultTx.colBlockHeight'),
+  //   key: 'minedInBlockHeight',
+  //   width: 112,
+  //   titleAlign: 'center',
+  //   align: 'center',
+  //   render: (row) =>
+  //     h('span', { class: 'vault-tx__cell-num' }, formatDash(row.minedInBlockHeight)),
+  // },
   {
     title: () => t('vaultTx.colFee'),
     key: 'feeAmount',
@@ -293,7 +278,10 @@ async function load(): Promise<void> {
   try {
     const res = await fetchVaultTransactions({
       vaultId: vault.currentVaultId,
-      status: filters.status,
+      senderLabel: filters.senderLabel,
+      recipientLabel: filters.recipientLabel,
+      senderAddress: filters.senderAddress,
+      recipientAddress: filters.recipientAddress,
       // senderIsVaultAddress: filters.senderIsVaultAddress,
       // recipientIsVaultAddress: filters.recipientIsVaultAddress,
       page: {
@@ -305,7 +293,7 @@ async function load(): Promise<void> {
     })
     if (res.code === ApiCode.StatusOK && Array.isArray(res.data)) {
       rows.value = res.data
-      const total = res.page.pageTotal
+      const total = res.page?.rowTotal
       pagination.itemCount =
         typeof total === 'number' && Number.isFinite(total) ? total : res.data.length
     } else {
@@ -327,7 +315,7 @@ watch(
 )
 
 watch(
-  () => [filters.status],
+  () => [filters.senderLabel, filters.recipientLabel, filters.senderAddress, filters.recipientAddress],
   () => {
     pagination.page = 1
     void load()
@@ -354,11 +342,16 @@ async function onExport(): Promise<void> {
   try {
     const res = await exportVaultTransactions({
       vaultId: vault.currentVaultId,
-      status: filters.status,
+      senderLabel: filters.senderLabel,
+      recipientLabel: filters.recipientLabel,
+      senderAddress: filters.senderAddress,
+      recipientAddress: filters.recipientAddress,
       // senderIsVaultAddress: filters.senderIsVaultAddress,
       // recipientIsVaultAddress: filters.recipientIsVaultAddress,
-      page: pagination.page,
-      pageSize: pagination.pageSize,
+      page: {
+        current: pagination.page,
+        row: pagination.pageSize,
+      },
     })
     if ('error' in res) {
       message.error(res.error || t('vaultTx.exportFail'))
@@ -375,7 +368,10 @@ async function onExport(): Promise<void> {
 }
 
 function onResetFilters(): void {
-  filters.status = null
+  filters.senderLabel = null
+  filters.recipientLabel = null
+  filters.senderAddress = null
+  filters.recipientAddress = null
   // filters.senderIsVaultAddress = null
   // filters.recipientIsVaultAddress = null
 }
@@ -404,12 +400,29 @@ function onResetFilters(): void {
         <div v-else class="vault-panel__body">
           <div class="vault-panel__toolbar">
             <div class="vault-panel__filters">
-              <n-select
-                v-model:value="filters.status"
-                :options="statusOptions"
-                :placeholder="t('vaultTx.colStatus')"
+              <n-input
+                v-model:value="filters.senderLabel"
+                :placeholder="t('vaultTx.colSenderLabel')"
+                clearable
+                style="width: 200px"
+              />
+              <n-input
+                v-model:value="filters.senderAddress"
+                :placeholder="t('vaultTx.colSenderAddr')"
+                clearable
+                style="width: 260px"
+              />
+              <n-input
+                v-model:value="filters.recipientLabel"
+                :placeholder="t('vaultTx.colRecipientLabel')"
+                clearable
+                style="width: 200px"
+              />
+              <n-input
+                v-model:value="filters.recipientAddress"
+                :placeholder="t('vaultTx.colRecipientAddr')"
                 clearable
-                style="width: 180px"
+                style="width: 260px"
               />
 <!--              <n-select-->
 <!--                v-model:value="filters.senderIsVaultAddress"-->