From 6c3499b470732c2860079dc4e32ad96cc31f1e8c Mon Sep 17 00:00:00 2001 From: zhongzm Date: Tue, 17 Jun 2025 18:40:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=B4=A6=E5=8D=95=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/axios/src/index.ts | 2 +- src/locales/langs/en-us.ts | 25 +++ src/locales/langs/zh-cn.ts | 31 +++ src/router/elegant/routes.ts | 11 + src/service/api/auth.ts | 13 +- src/typings/api.d.ts | 21 +- src/typings/components.d.ts | 3 - src/views/billing/bill/index.vue | 337 +++++++++++++++++++++++++++++++ 8 files changed, 430 insertions(+), 13 deletions(-) create mode 100644 src/views/billing/bill/index.vue diff --git a/packages/axios/src/index.ts b/packages/axios/src/index.ts index 1d5f81c..bb4a57c 100644 --- a/packages/axios/src/index.ts +++ b/packages/axios/src/index.ts @@ -61,7 +61,7 @@ function createCommonRequest( return Promise.resolve(response); } - if (opts.isBackendSuccess(response)) { + if (opts.isBackendSuccess(response) || response.config?.responseType === "blob") { return Promise.resolve(response); } diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index cba3098..5c62906 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -7,6 +7,7 @@ const viewEn: any = { "view.endpoint_access": "Current Connection", "view.endpoint_records": "Past Connection", "view.endpoint_cdrlrecords":"Internet Records", + "view.endpoint_bill":"Bill Records", "view.billing": "Billing", "view.billing_histories": "Historical", "view.billing_Rechargehistory":"Recharge History", @@ -740,6 +741,30 @@ const local: any = { confirm:'Confirm', insufficientBalance:'Insufficient balance' }, + bill:{ + loading:'Loading', + tipTitle:'Bill DownLoad', + exportTip:'Sure to download?', + total:'Total', + invoiceNumber:'Bill Number', + title: 'Bill List', + billDate: 'Bill Date', + amount: 'Amount', + billType: 'Bill Type', + statu: 'Status', + actions: 'Action', + download: 'Download', + preview: 'Preview', + exportOk: 'Download Success', + exportFail: 'Download Fail', + previewTitle: 'Bill Preview', + previewFailed: 'Preview fail', + noFile: 'No billing documents available', + types: { + recharge:'Recharge', + package: 'Package', + }, + }, kyc:{ rejectReason:'Reject Reason:', drive:'Driving license', diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index 79da9e7..b4bdf6d 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -7,6 +7,7 @@ const viewZh: any = { "view.endpoint_access": "当前设备", "view.endpoint_records": "历史设备", "view.endpoint_cdrlrecords":"上网记录", + "view.endpoint_bill":"账单记录", "view.billing": "账单", "view.billing_billservice":"账单服务", "view.billing_histories": "历史查询", @@ -602,6 +603,36 @@ const local:any = { Paid:'已支付', Unpaid:'未支付', }, + bill:{ + loading:'加载中', + tipTitle:'账单下载', + exportTip:'确定下载吗?', + total:'共', + invoiceNumber:'账单编号', + title: '账单列表', + billDate: '账单日期', + amount: '金额', + billType: '账单类型', + statu: '状态', + actions: '操作', + download: '下载', + preview: '预览', + status: { + pending: '待支付', + paid: '已支付', + failed: '支付失败', + unknown: '未知状态' + }, + exportOk: '下载成功', + exportFail: '下载失败', + previewTitle: '账单预览', + previewFailed: '预览失败', + noFile: '暂无账单文件', + types: { + recharge:'余额充值', + package: '套餐费用', + }, + }, Internetdetails:{ title:"上网详单", month:"月", diff --git a/src/router/elegant/routes.ts b/src/router/elegant/routes.ts index 9b7d804..0a1047b 100644 --- a/src/router/elegant/routes.ts +++ b/src/router/elegant/routes.ts @@ -415,6 +415,17 @@ export const customRoutes: GeneratedRoute[] = [ order: 4 }, }, + { + name: 'billing_bill', + path: '/billing/bill', + component: 'view.billing_bill', + meta: { + title: '上网记录', + i18nKey: 'view.endpoint_bill', + icon: 'ant-design:book-outlined', + order: 5 + }, + }, { name: 'billing_wxpay', path: '/billing/wxpay', diff --git a/src/service/api/auth.ts b/src/service/api/auth.ts index 29167ed..3a0cfa3 100644 --- a/src/service/api/auth.ts +++ b/src/service/api/auth.ts @@ -1,5 +1,5 @@ -import { request } from '../request'; +import { request, rawRequest } from '../request'; /** * Login * @@ -206,6 +206,15 @@ export function resetPasswordByEmail(data: { email: string; code: string; passwo data }); } - +/** 下载账单 PDF 文件 */ +/** 下载账单 PDF 文件(使用 axios 直连) */ +/** 下载账单 PDF 文件(使用 rawRequest,避免 transformBackendResponse 破坏 blob) */ +export function downloadBill(id: string) { + return request({ + url: `/u/bill/download/${id}`, + method: 'get', + responseType: 'blob' + }); +} diff --git a/src/typings/api.d.ts b/src/typings/api.d.ts index 069ceb2..a05b3fe 100644 --- a/src/typings/api.d.ts +++ b/src/typings/api.d.ts @@ -676,13 +676,20 @@ declare namespace Api { namespace Bill { /** Bill record information */ interface BillRecord { - id: string; - startTime: string | null; - endTime: string | null; - traffic: string | null; - amount: string; - status: number; - createTime: string; + /** 账单编号 */ + invoiceNumber: string; + /** 账单金额 */ + amount: number; + /** 账单类型:0-购买套餐,1-余额充值 */ + type: 0 | 1; + /** 账单时间 */ + invoiceTime: string; + /** 账单状态:0-待支付,1-已支付,2-支付失败 */ + status: 0 | 1 | 2; + /** 账单文件URL */ + fileUrl?: string; + /** 发票文件URL */ + invoiceFile?: string; } /** Bill list response */ diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index 40a5c02..a936c39 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -34,14 +34,12 @@ declare module 'vue' { AMenu: typeof import('ant-design-vue/es')['Menu'] AMenuItem: typeof import('ant-design-vue/es')['MenuItem'] AModal: typeof import('ant-design-vue/es')['Modal'] - APagination: typeof import('ant-design-vue/es')['Pagination'] APopconfirm: typeof import('ant-design-vue/es')['Popconfirm'] APopover: typeof import('ant-design-vue/es')['Popover'] AppLoading: typeof import('./../components/common/app-loading.vue')['default'] AppProvider: typeof import('./../components/common/app-provider.vue')['default'] ARadio: typeof import('ant-design-vue/es')['Radio'] ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup'] - ARangePicker: typeof import('ant-design-vue/es')['RangePicker'] ARow: typeof import('ant-design-vue/es')['Row'] ASegmented: typeof import('ant-design-vue/es')['Segmented'] ASelect: typeof import('ant-design-vue/es')['Select'] @@ -80,7 +78,6 @@ declare module 'vue' { LookForward: typeof import('./../components/custom/look-forward.vue')['default'] MenuToggler: typeof import('./../components/common/menu-toggler.vue')['default'] OrderConfirmModal: typeof import('./../components/order-confirm/orderConfirmModal.vue')['default'] - Pay: typeof import('./../components/pay/pay.vue')['default'] PaypalButton: typeof import('./../components/payment/paypal-button.vue')['default'] PinToggler: typeof import('./../components/common/pin-toggler.vue')['default'] ReloadButton: typeof import('./../components/common/reload-button.vue')['default'] diff --git a/src/views/billing/bill/index.vue b/src/views/billing/bill/index.vue new file mode 100644 index 0000000..7b41be1 --- /dev/null +++ b/src/views/billing/bill/index.vue @@ -0,0 +1,337 @@ + + + + +