mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-06-23 02:20:23 +08:00
优化财务相关功能
This commit is contained in:
25
seller/src/api/finance.js
Normal file
25
seller/src/api/finance.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 商家端财务 API。
|
||||
* 所有接口由后端强制限定为当前登录店铺,无需前端传 storeId。
|
||||
*/
|
||||
import { getRequest } from "@/libs/axios";
|
||||
|
||||
/** 导出本店流水明细 */
|
||||
export const exportStoreFlow = (params) => {
|
||||
return getRequest("/finance/store-flow/export", params, "blob");
|
||||
};
|
||||
|
||||
/** 导出本店结算单列表 */
|
||||
export const exportBillList = (params) => {
|
||||
return getRequest("/finance/bill-list/export", params, "blob");
|
||||
};
|
||||
|
||||
/** 本店周期财务汇总查询 */
|
||||
export const getStoreSummary = (params) => {
|
||||
return getRequest("/finance/report/store-summary", params);
|
||||
};
|
||||
|
||||
/** 导出本店周期财务汇总 */
|
||||
export const exportStoreSummary = (params) => {
|
||||
return getRequest("/finance/report/store-summary/export", params, "blob");
|
||||
};
|
||||
@@ -169,14 +169,12 @@ export const otherRouter = {
|
||||
name: "coupon-receive",
|
||||
component: () => import("@/views/promotion/coupon/coupon-receive.vue"),
|
||||
},
|
||||
// {
|
||||
// path: "/*",
|
||||
// name: "error-404",
|
||||
// meta: {
|
||||
// title: "404-页面不存在"
|
||||
// },
|
||||
// component: () => import("@/views/error-page/404.vue")
|
||||
// }
|
||||
{
|
||||
path: "shop-finance-summary",
|
||||
title: "财务汇总",
|
||||
name: "shop-finance-summary",
|
||||
component: () => import("@/views/shop/finance/summary.vue")
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
15
seller/src/utils/downloadBlob.js
Normal file
15
seller/src/utils/downloadBlob.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 触发浏览器下载 blob 响应
|
||||
*/
|
||||
export function downloadBlob(blob, filename) {
|
||||
if (!blob) return;
|
||||
const link = document.createElement("a");
|
||||
link.style.display = "none";
|
||||
const url = window.URL.createObjectURL(new Blob([blob]));
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
@@ -126,8 +126,6 @@ export function unixSellerBillStatus(status_code) {
|
||||
return "已出账";
|
||||
case "CHECK":
|
||||
return "已对账";
|
||||
case "EXAMINE":
|
||||
return "已审核";
|
||||
case "PAY":
|
||||
return "已结算";
|
||||
case "COMPLETE":
|
||||
|
||||
@@ -109,11 +109,11 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
billStatusText(v) {
|
||||
const map = { OUT: "已出账", CHECK: "已对账", EXAMINE: "已审核", COMPLETE: "已付款" };
|
||||
const map = { OUT: "已出账", CHECK: "已对账", COMPLETE: "已付款" };
|
||||
return map[v] || "已付款";
|
||||
},
|
||||
billStatusTagType(v) {
|
||||
const map = { OUT: "primary", CHECK: "", EXAMINE: "warning", COMPLETE: "success" };
|
||||
const map = { OUT: "primary", CHECK: "warning", COMPLETE: "success" };
|
||||
return map[v] || "success";
|
||||
},
|
||||
init() {
|
||||
|
||||
@@ -436,11 +436,11 @@ export default {
|
||||
API_Shop.downloadBill(this.id)
|
||||
.then((res) => {
|
||||
const blob = new Blob([res], {
|
||||
type: "application/vnd.ms-excel;charset=utf-8",
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
});
|
||||
if ("download" in document.createElement("a")) {
|
||||
const link = document.createElement("a");
|
||||
link.download = "结算单-" + this.id + ".xls";
|
||||
link.download = "结算单-" + this.id + ".xlsx";
|
||||
link.style.display = "none";
|
||||
link.href = URL.createObjectURL(blob);
|
||||
document.body.appendChild(link);
|
||||
@@ -448,7 +448,7 @@ export default {
|
||||
URL.revokeObjectURL(link.href);
|
||||
document.body.removeChild(link);
|
||||
} else {
|
||||
navigator.msSaveBlob(blob, "结算单-" + this.id + ".xls");
|
||||
navigator.msSaveBlob(blob, "结算单-" + this.id + ".xlsx");
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<el-form-item>
|
||||
<el-button type="primary" class="search-btn" @click="handleSearch">搜索</el-button>
|
||||
<el-button class="search-btn" @click="handleReset">重置</el-button>
|
||||
<el-button class="search-btn" @click="handleExport">导出列表</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
@@ -59,7 +60,6 @@
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.billStatus === 'OUT'" type="primary">已出账</el-tag>
|
||||
<el-tag v-else-if="row.billStatus === 'CHECK'" type="info">已对账</el-tag>
|
||||
<el-tag v-else-if="row.billStatus === 'EXAMINE'" type="warning">已审核</el-tag>
|
||||
<el-tag v-else type="success">已付款</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -88,6 +88,8 @@
|
||||
|
||||
<script>
|
||||
import * as API_Shop from "@/api/shops";
|
||||
import * as API_Finance from "@/api/finance";
|
||||
import { downloadBlob } from "@/utils/downloadBlob";
|
||||
|
||||
export default {
|
||||
name: "storeBill",
|
||||
@@ -149,6 +151,12 @@ export default {
|
||||
query: { id: v.id },
|
||||
});
|
||||
},
|
||||
handleExport() {
|
||||
const params = { ...this.searchForm };
|
||||
API_Finance.exportBillList(params).then((blob) => {
|
||||
downloadBlob(blob, "结算单列表.xlsx");
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
|
||||
71
seller/src/views/shop/finance/summary.vue
Normal file
71
seller/src/views/shop/finance/summary.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<div class="search">
|
||||
<el-card>
|
||||
<el-form inline>
|
||||
<el-form-item label="日期范围">
|
||||
<el-date-picker v-model="dateRange" type="daterange" value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="loadData">查询</el-button>
|
||||
<el-button @click="handleExport">导出</el-button>
|
||||
<el-button @click="exportFlow">导出流水</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="mt_10" v-if="summary">
|
||||
<el-descriptions title="本店周期汇总" :column="2" border>
|
||||
<el-descriptions-item label="店铺">{{ summary.storeName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单实付">{{ summary.orderPrice }}</el-descriptions-item>
|
||||
<el-descriptions-item label="退款">{{ summary.refundPrice }}</el-descriptions-item>
|
||||
<el-descriptions-item label="平台服务费">{{ summary.commissionPrice }}</el-descriptions-item>
|
||||
<el-descriptions-item label="分销佣金">{{ summary.distributionCommission }}</el-descriptions-item>
|
||||
<el-descriptions-item label="券补贴">{{ summary.siteCouponCommission }}</el-descriptions-item>
|
||||
<el-descriptions-item label="礼品卡补贴">{{ summary.giftCardSubsidy }}</el-descriptions-item>
|
||||
<el-descriptions-item label="应结金额">{{ summary.billPrice }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as API_Finance from "@/api/finance";
|
||||
import { downloadBlob } from "@/utils/downloadBlob";
|
||||
|
||||
export default {
|
||||
name: "shop-finance-summary",
|
||||
data() {
|
||||
return {
|
||||
dateRange: [],
|
||||
summary: null,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.loadData();
|
||||
},
|
||||
methods: {
|
||||
buildParams() {
|
||||
const p = {};
|
||||
if (this.dateRange?.length === 2) {
|
||||
p.startDate = this.dateRange[0];
|
||||
p.endDate = this.dateRange[1];
|
||||
}
|
||||
return p;
|
||||
},
|
||||
loadData() {
|
||||
API_Finance.getStoreSummary(this.buildParams()).then((res) => {
|
||||
if (res.success) this.summary = res.result;
|
||||
});
|
||||
},
|
||||
handleExport() {
|
||||
API_Finance.exportStoreSummary(this.buildParams()).then((blob) => {
|
||||
downloadBlob(blob, "店铺周期汇总.xlsx");
|
||||
});
|
||||
},
|
||||
exportFlow() {
|
||||
API_Finance.exportStoreFlow(this.buildParams()).then((blob) => {
|
||||
downloadBlob(blob, "店铺流水.xlsx");
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user