✨ 毛利分析合并订单明细及产品筛选

This commit is contained in:
caojia
2026-11-16 20:24:27 +08:00
parent f9038c62ac
commit f00f8c619a
3 changed files with 78 additions and 193 deletions
@@ -33,7 +33,9 @@ public class PrcProfitReportQuery extends BaseEntity
private List<String> customerNames;
private String belongSalerCode;
private String productCode;
private String productName;
private String countryCode;
private String countryName;
private String currency;
/** 订单维度应收状态筛选:UNBILLED、PARTIAL、BILLED。 */
private String arBillStatus;
@@ -197,6 +197,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</otherwise>
</choose>
<if test="productName != null and productName != ''">
and p.product_name like concat('%', #{productName}, '%')
</if>
<if test="countryName != null and countryName != ''">
and p.country_name like concat('%', #{countryName}, '%')
</if>
</where>
</sql>
+70 -193
View File
@@ -46,6 +46,28 @@
<el-input v-model="query.productCode" clearable placeholder="输入产品代码" class="filter-control" @keyup.enter="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :lg="8">
<el-form-item label="产品名称" class="filter-item">
<el-input v-model="query.productName" clearable placeholder="输入产品名称" class="filter-control" @keyup.enter="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :lg="8">
<el-form-item label="国家/地区" class="filter-item">
<el-input v-model="query.countryName" clearable placeholder="输入国家/地区名称" class="filter-control" @keyup.enter="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :lg="8">
<el-form-item label="国家代码" class="filter-item">
<el-input v-model="query.countryCode" clearable placeholder="输入国家代码" class="filter-control" @keyup.enter="handleSearch" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :lg="8">
<el-form-item label="币种" class="filter-item">
<el-select v-model="query.currency" clearable filterable allow-create default-first-option placeholder="选择或输入币种" class="filter-control">
<el-option v-for="item in bms_currency" :key="item.value" :label="item.label || item.value" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :lg="8">
<el-form-item label="订单号" class="filter-item">
<el-input
@@ -59,7 +81,7 @@
/>
</el-form-item>
</el-col>
<el-col v-if="dimension === 'order'" :xs="24" :sm="12" :lg="8">
<el-col :xs="24" :sm="12" :lg="8">
<el-form-item label="应收状态" class="filter-item">
<el-select v-model="arBillStatus" clearable placeholder="全部状态" class="filter-control" @change="clearReportResults">
<el-option label="未出账" value="UNBILLED" />
@@ -119,10 +141,7 @@
<el-card shadow="never" class="table-card">
<div class="table-heading">
<el-tabs v-model="dimension" @tab-change="handleDimensionChange">
<el-tab-pane label="产品维度" name="product" />
<el-tab-pane label="订单维度" name="order" />
</el-tabs>
<span class="table-title">订单明细</span>
<div class="table-toolbar">
<!-- 提成功能暂停使用。
<el-button
@@ -144,61 +163,37 @@
:loading="exporting"
:disabled="!hasProfitRule() || !hasSearched"
@click="handleExport"
>导出当前维度</el-button>
>导出订单明细</el-button>
</div>
</div>
<div v-text-drag-copy="true" class="report-table-copy-area">
<el-table :key="dimension + '-' + currentRule" v-loading="loading" :data="rows" border stripe :row-key="rowKey">
<template v-if="dimension === 'product'">
<el-table-column prop="productCode" label="产品代码" min-width="120" show-overflow-tooltip />
<el-table-column prop="productName" label="产品名称" min-width="180" show-overflow-tooltip />
<el-table-column prop="countryName" label="国家/地区" min-width="120" show-overflow-tooltip />
<el-table-column prop="countryCode" label="国家代码" width="100" align="center" />
<el-table-column prop="currency" label="币种" width="80" align="center" />
<el-table-column prop="orderCount" label="订单数" width="100" align="right">
<template #default="{ row }"><span class="success-value order-count-link" :class="{ 'is-disabled': !row.orderCount }" @click.stop="openOrderList(row)">{{ row.orderCount }}</span></template>
</el-table-column>
<el-table-column v-if="!isGuangzhou" prop="costAmount" label="产品价" min-width="130" align="right"><template #default="{ row }">{{ money(row.costAmount) }}</template></el-table-column>
<el-table-column prop="redlineAmount" label="红线价" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineAmount) }}</template></el-table-column>
<el-table-column v-if="!isGuangzhou" prop="redlineGrossProfit" label="红线毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineGrossProfit) }}</template></el-table-column>
<el-table-column v-if="!isGuangzhou" prop="redlineGrossMarginRate" label="红线毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.redlineGrossMarginRate) }}</template></el-table-column>
<el-table-column prop="salesAmount" label="销售价" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesAmount) }}</template></el-table-column>
<el-table-column prop="salesGrossProfit" label="销售毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesGrossProfit) }}</template></el-table-column>
<el-table-column prop="salesGrossMarginRate" label="销售毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.salesGrossMarginRate) }}</template></el-table-column>
<!-- 提成功能暂停使用。
<el-table-column prop="commissionAmount" label="提成金额" min-width="120" align="right"><template #default="{ row }">{{ money(row.commissionAmount) }}</template></el-table-column>
<el-table-column prop="commissionMissingOrderCount" label="提成未计算订单" width="150" align="right">
<template #default="{ row }"><span class="success-value order-count-link" :class="{ 'is-disabled': !row.commissionMissingOrderCount }" @click.stop="openOrderList(row, 'COMMISSION_MISSING', '提成未计算订单')">{{ row.commissionMissingOrderCount }}</span></template>
</el-table-column>
-->
</template>
<template v-else>
<el-table-column prop="bizDate" label="计费时间" width="170" align="center"><template #default="{ row }">{{ parseTime(row.bizDate) }}</template></el-table-column>
<el-table-column prop="orderNo" label="订单号" min-width="160" show-overflow-tooltip />
<el-table-column prop="customerCode" label="客户代码" width="120" />
<el-table-column prop="customerName" label="客户名称" min-width="160" show-overflow-tooltip />
<el-table-column prop="belongSalerCode" label="业务员编码" min-width="150" show-overflow-tooltip />
<el-table-column prop="belongSaler" label="业务员" min-width="110" show-overflow-tooltip />
<el-table-column prop="productCode" label="产品代码" width="120" />
<el-table-column prop="productName" label="产品名称" min-width="160" show-overflow-tooltip />
<el-table-column prop="countryName" label="国家/地区" min-width="110" show-overflow-tooltip />
<el-table-column prop="currency" label="币种" width="80" align="center" />
<el-table-column v-if="!isGuangzhou" prop="costAmount" label="产品价" min-width="130" align="right"><template #default="{ row }">{{ money(row.costAmount) }}</template></el-table-column>
<el-table-column prop="redlineAmount" label="红线价" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineAmount) }}</template></el-table-column>
<el-table-column v-if="!isGuangzhou" prop="redlineGrossProfit" label="红线毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineGrossProfit) }}</template></el-table-column>
<el-table-column v-if="!isGuangzhou" prop="redlineGrossMarginRate" label="红线毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.redlineGrossMarginRate) }}</template></el-table-column>
<el-table-column prop="salesAmount" label="销售价" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesAmount) }}</template></el-table-column>
<el-table-column prop="salesGrossProfit" label="销售毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesGrossProfit) }}</template></el-table-column>
<el-table-column prop="salesGrossMarginRate" label="销售毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.salesGrossMarginRate) }}</template></el-table-column>
<!-- 提成功能暂停使用。
<el-table-column prop="commissionRate" label="提成比例" width="110" align="right"><template #default="{ row }">{{ commissionRateFormat(row.commissionRate) }}</template></el-table-column>
<el-table-column prop="commissionAmount" label="提成金额" min-width="120" align="right"><template #default="{ row }">{{ money(row.commissionAmount) }}</template></el-table-column>
-->
<el-table-column prop="arBillStatus" label="应收状态" width="110" align="center">
<template #default="{ row }">{{ arBillStatusLabel(row.arBillStatus) }}</template>
</el-table-column>
</template>
<el-table :key="currentRule" v-loading="loading" :data="rows" border stripe row-key="orderNo">
<el-table-column prop="bizDate" label="计费时间" width="170" align="center"><template #default="{ row }">{{ parseTime(row.bizDate) }}</template></el-table-column>
<el-table-column prop="orderNo" label="订单号" min-width="160" show-overflow-tooltip />
<el-table-column prop="customerCode" label="客户代码" width="120" />
<el-table-column prop="customerName" label="客户名称" min-width="160" show-overflow-tooltip />
<el-table-column prop="belongSalerCode" label="业务员编码" min-width="150" show-overflow-tooltip />
<el-table-column prop="belongSaler" label="业务员" min-width="110" show-overflow-tooltip />
<el-table-column prop="productCode" label="产品代码" width="120" />
<el-table-column prop="productName" label="产品名称" min-width="160" show-overflow-tooltip />
<el-table-column prop="countryName" label="国家/地区" min-width="110" show-overflow-tooltip />
<el-table-column prop="countryCode" label="国家代码" width="100" align="center" />
<el-table-column prop="currency" label="币种" width="80" align="center" />
<el-table-column v-if="!isGuangzhou" prop="costAmount" label="产品价" min-width="130" align="right"><template #default="{ row }">{{ money(row.costAmount) }}</template></el-table-column>
<el-table-column prop="redlineAmount" label="红线价" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineAmount) }}</template></el-table-column>
<el-table-column v-if="!isGuangzhou" prop="redlineGrossProfit" label="红线毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineGrossProfit) }}</template></el-table-column>
<el-table-column v-if="!isGuangzhou" prop="redlineGrossMarginRate" label="红线毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.redlineGrossMarginRate) }}</template></el-table-column>
<el-table-column prop="salesAmount" label="销售价" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesAmount) }}</template></el-table-column>
<el-table-column prop="salesGrossProfit" label="销售毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesGrossProfit) }}</template></el-table-column>
<el-table-column prop="salesGrossMarginRate" label="销售毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.salesGrossMarginRate) }}</template></el-table-column>
<!-- 提成功能暂停使用。
<el-table-column prop="commissionRate" label="提成比例" width="110" align="right"><template #default="{ row }">{{ commissionRateFormat(row.commissionRate) }}</template></el-table-column>
<el-table-column prop="commissionAmount" label="提成金额" min-width="120" align="right"><template #default="{ row }">{{ money(row.commissionAmount) }}</template></el-table-column>
-->
<el-table-column prop="arBillStatus" label="应收状态" width="110" align="center">
<template #default="{ row }">{{ arBillStatusLabel(row.arBillStatus) }}</template>
</el-table-column>
<template #empty><el-empty :description="hasSearched ? '暂无符合条件的数据' : '请选择计费日期后点击搜索'" /></template>
</el-table>
</div>
@@ -212,35 +207,6 @@
/>
</el-card>
<el-dialog v-model="orderListDialogVisible" :title="orderListTitle" width="1280px" append-to-body>
<el-table v-loading="orderListLoading" :data="orderListRows" border stripe>
<el-table-column prop="bizDate" label="计费时间" width="170" align="center"><template #default="{ row }">{{ parseTime(row.bizDate) }}</template></el-table-column>
<el-table-column prop="orderNo" label="订单号" min-width="170" show-overflow-tooltip />
<el-table-column prop="customerCode" label="客户代码" width="120" />
<el-table-column prop="customerName" label="客户名称" min-width="160" show-overflow-tooltip />
<el-table-column prop="belongSalerCode" label="业务员编码" width="130" />
<el-table-column prop="productCode" label="产品代码" width="120" />
<el-table-column prop="productName" label="产品名称" min-width="160" show-overflow-tooltip />
<el-table-column prop="countryName" label="国家/地区" width="110" />
<el-table-column prop="currency" label="币种" width="80" align="center" />
<el-table-column v-if="!isGuangzhou" prop="costAmount" label="产品价" width="110" align="right"><template #default="{ row }">{{ money(row.costAmount) }}</template></el-table-column>
<el-table-column prop="redlineAmount" label="红线价" width="110" align="right"><template #default="{ row }">{{ money(row.redlineAmount) }}</template></el-table-column>
<el-table-column prop="salesAmount" label="销售价" width="110" align="right"><template #default="{ row }">{{ money(row.salesAmount) }}</template></el-table-column>
<el-table-column v-if="isGuangzhou" prop="salesGrossProfit" label="销售毛利" width="110" align="right"><template #default="{ row }">{{ money(row.salesGrossProfit) }}</template></el-table-column>
<el-table-column v-if="isGuangzhou" prop="salesGrossMarginRate" label="销售毛利率" width="110" align="right"><template #default="{ row }">{{ rate(row.salesGrossMarginRate) }}</template></el-table-column>
<el-table-column prop="arBillStatus" label="应收状态" width="100" align="center"><template #default="{ row }">{{ arBillStatusLabel(row.arBillStatus) }}</template></el-table-column>
<template #empty><el-empty description="暂无符合条件的订单" /></template>
</el-table>
<pagination
v-show="orderListTotal > 0"
v-model:page="orderListPageNum"
v-model:limit="orderListPageSize"
:total="orderListTotal"
@pagination="loadOrderList"
/>
<template #footer><el-button @click="orderListDialogVisible = false">关闭</el-button></template>
</el-dialog>
<el-dialog v-model="exportLogVisible" title="毛利分析导出日志" width="1000px" append-to-body>
<el-table v-loading="exportLogLoading" :data="exportLogs" border stripe>
<el-table-column prop="fileName" label="文件名" min-width="280" show-overflow-tooltip />
@@ -309,15 +275,14 @@
</template>
<script setup name="ProfitReport">
import { downloadProfitExport, exportProfitOrders, exportProfitProducts, listProfitAreaRules, listProfitCustomerOptions, listProfitExports, listProfitOrders, listProfitProducts, listProfitSummary } from '@/api/report/profit'
import { downloadProfitExport, exportProfitOrders, listProfitAreaRules, listProfitCustomerOptions, listProfitExports, listProfitOrders, listProfitSummary } from '@/api/report/profit'
// 提成功能暂停使用:import { deleteProfitCommissionRate, listProfitCommissionRates, saveProfitCommissionRate } from '@/api/report/profit'
import { parseTime } from '@/utils/bms'
import { ElMessage } from 'element-plus'
import { saveAs } from 'file-saver'
// 提成功能暂停使用:import { ElMessageBox } from 'element-plus'
const dimension = ref('product')
const { customer_area } = useDict('customer_area')
const { customer_area, bms_currency } = useDict('customer_area', 'bms_currency')
const multiValueFilterLimit = 2000
const dateRange = ref([formatLocalDate(-30), formatLocalDate(0)])
const arBillStatus = ref('')
@@ -326,7 +291,11 @@ const query = reactive({
orderNo: '',
customerCode: '',
belongSalerCode: '',
productCode: ''
productCode: '',
productName: '',
countryName: '',
countryCode: '',
currency: ''
})
const areaRules = ref(null)
const areaRulesFailed = ref(false)
@@ -350,15 +319,6 @@ const exportLogTotal = ref(0)
const pageNum = ref(1)
const pageSize = ref(10)
const total = ref(0)
const orderListDialogVisible = ref(false)
const orderListTitle = ref('订单列表')
const orderListLoading = ref(false)
const orderListRows = ref([])
const orderListTotal = ref(0)
const orderListPageNum = ref(1)
const orderListPageSize = ref(10)
const orderListContext = ref(null)
let orderListRequestVersion = 0
/* 提成表单状态与初始化暂停使用,保留代码便于恢复。
const commissionDialogVisible = ref(false)
const commissionLoading = ref(false)
@@ -394,9 +354,9 @@ function formatLocalDate(offset) {
return `${year}-${month}-${day}`
}
function buildQuery(paged = true, includeArBillStatus = dimension.value === 'order') {
function buildQuery(paged = true) {
const params = { ...query }
if (includeArBillStatus && arBillStatus.value) params.arBillStatus = arBillStatus.value
if (arBillStatus.value) params.arBillStatus = arBillStatus.value
if (dateRange.value?.[0]) params.beginBizDate = dateRange.value[0] + ' 00:00:00'
if (dateRange.value?.[1]) params.endBizDate = dateRange.value[1] + ' 23:59:59'
if (paged) {
@@ -454,11 +414,9 @@ function loadSummary() {
function loadRows() {
if (!hasSearched.value || !validateRequiredFilters(false) || !hasProfitRule() || !validateMultiValueFilters()) return Promise.resolve()
const requestVersion = ++rowsRequestVersion
const requestDimension = dimension.value
loading.value = true
const api = requestDimension === 'product' ? listProfitProducts : listProfitOrders
return api(buildQuery()).then(res => {
if (requestVersion !== rowsRequestVersion || requestDimension !== dimension.value) return
return listProfitOrders(buildQuery()).then(res => {
if (requestVersion !== rowsRequestVersion) return
rows.value = res.rows || []
total.value = res.total || 0
}).finally(() => {
@@ -470,17 +428,11 @@ function clearReportResults() {
hasSearched.value = false
summaryRequestVersion++
rowsRequestVersion++
orderListRequestVersion++
summaryList.value = []
summaryLoaded.value = false
rows.value = []
total.value = 0
loading.value = false
orderListDialogVisible.value = false
orderListLoading.value = false
orderListRows.value = []
orderListTotal.value = 0
orderListContext.value = null
}
function handleSearch() {
@@ -501,59 +453,6 @@ function handleReset() {
clearReportResults()
}
function handleDimensionChange() {
if (dimension.value !== 'order') arBillStatus.value = ''
pageNum.value = 1
rows.value = []
total.value = 0
if (!hasSearched.value || !validateRequiredFilters(false)) return
Promise.all([loadSummary(), loadRows()])
}
function openOrderList(row) {
if (!hasSearched.value || !validateRequiredFilters()) return
if (!validateMultiValueFilters()) return
if (!row.orderCount) return
orderListTitle.value = '订单列表'
orderListContext.value = {
productDrilldown: true,
productCode: row.productCode,
countryCode: row.countryCode,
currency: row.currency
}
orderListPageNum.value = 1
orderListTotal.value = 0
orderListRows.value = []
orderListDialogVisible.value = true
loadOrderList()
}
function loadOrderList() {
if (!orderListContext.value) return
if (!hasSearched.value || !validateRequiredFilters(false) || !hasProfitRule() || !validateMultiValueFilters()) return
const requestVersion = ++orderListRequestVersion
orderListLoading.value = true
const params = {
...buildQuery(false),
...orderListContext.value,
pageNum: orderListPageNum.value,
pageSize: orderListPageSize.value
}
listProfitOrders(params).then(res => {
if (requestVersion !== orderListRequestVersion) return
orderListRows.value = res.rows || []
orderListTotal.value = res.total || 0
}).finally(() => {
if (requestVersion === orderListRequestVersion) orderListLoading.value = false
})
}
function rowKey(row) {
return dimension.value === 'product'
? [row.productCode, row.countryCode, row.currency].join('|')
: row.orderNo
}
function money(value) {
if (value === null || value === undefined || value === '') return '-'
const number = Number(value)
@@ -587,9 +486,8 @@ async function handleExport() {
if (!hasSearched.value || !validateRequiredFilters()) return
if (!hasProfitRule() || !validateMultiValueFilters()) return
exporting.value = true
const exporter = dimension.value === 'product' ? exportProfitProducts : exportProfitOrders
try {
const response = await exporter(buildQuery(false))
const response = await exportProfitOrders(buildQuery(false))
const exportLog = response.data
const file = await downloadProfitExport(exportLog.exportId)
if (file.type?.includes('json')) {
@@ -722,6 +620,10 @@ watch(() => [
query.customerCode,
query.belongSalerCode,
query.productCode,
query.productName,
query.countryName,
query.countryCode,
query.currency,
dateRange.value?.[0],
dateRange.value?.[1]
], () => {
@@ -830,23 +732,6 @@ watch(() => [
color: var(--el-color-primary);
}
.success-value {
color: var(--el-color-success);
}
.order-count-link {
cursor: pointer;
}
.order-count-link:hover {
text-decoration: underline;
}
.order-count-link.is-disabled {
cursor: default;
text-decoration: none;
}
.table-heading {
display: flex;
align-items: center;
@@ -856,17 +741,9 @@ watch(() => [
border-bottom: 1px solid var(--el-border-color-light);
}
.table-heading :deep(.el-tabs) {
flex: 1;
min-width: 180px;
}
.table-heading :deep(.el-tabs__header) {
margin: 0;
}
.table-heading :deep(.el-tabs__nav-wrap::after) {
display: none;
.table-title {
font-weight: 600;
padding-bottom: 8px;
}
.table-toolbar {