diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/vo/PrcProfitReportQuery.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/vo/PrcProfitReportQuery.java index 8a9b4a09..170b3f3a 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/vo/PrcProfitReportQuery.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/vo/PrcProfitReportQuery.java @@ -24,6 +24,8 @@ public class PrcProfitReportQuery extends BaseEntity private String customerCode; /** 客户代码拆分后的多值查询条件。 */ private List customerCodes; + /** 按客户当前区域筛选。 */ + private String customerArea; private String customerName; /** 客户名称拆分后的多值查询条件。 */ private List customerNames; diff --git a/bms-back/bms-system/src/main/resources/mapper/price/PrcProfitReportMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/PrcProfitReportMapper.xml index 3320fc3d..75861a98 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/PrcProfitReportMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/PrcProfitReportMapper.xml @@ -119,6 +119,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from prc_income_bill i inner join prc_order_bill p on p.bill_id = i.bill_id + + left join ctr_customer c on c.customer_id = p.customer_id and c.del_flag = '0' + and (p.billing_fail_status is null or p.billing_fail_status not in (1, 2, 3)) + + and c.customer_area = #{customerArea} + and p.biz_date >= #{beginBizDate} diff --git a/bms-front/src/views/report/profit/index.vue b/bms-front/src/views/report/profit/index.vue index 95a8abbd..571b625e 100644 --- a/bms-front/src/views/report/profit/index.vue +++ b/bms-front/src/views/report/profit/index.vue @@ -3,6 +3,13 @@ + + + + + + +
- 搜索 + 搜索 重置
@@ -132,6 +139,7 @@ icon="Download" v-hasPermi="['report:profit:export']" :loading="exporting" + :disabled="!hasCustomerArea()" @click="handleExport" >导出当前维度 @@ -304,16 +312,19 @@ import { saveAs } from 'file-saver' // 提成功能暂停使用:import { ElMessageBox } from 'element-plus' const dimension = ref('product') +const { customer_area } = useDict('customer_area') const multiValueFilterLimit = 2000 const dateRange = ref([formatLocalDate(-30), formatLocalDate(0)]) const arBillStatus = ref('') const query = reactive({ + customerArea: '', orderNo: '', customerCode: '', belongSalerCode: '', productCode: '' }) const summaryList = ref([]) +let summaryRequestVersion = 0 const rows = ref([]) let rowsRequestVersion = 0 const loading = ref(false) @@ -397,15 +408,21 @@ function validateMultiValueFilters(showMessage = true) { return true } +function hasCustomerArea() { + return query.customerArea !== '' && query.customerArea !== null && query.customerArea !== undefined +} + function loadSummary() { - if (!validateMultiValueFilters(false)) return Promise.resolve() + if (!hasCustomerArea() || !validateMultiValueFilters(false)) return Promise.resolve() + const requestVersion = ++summaryRequestVersion return listProfitSummary(buildQuery(false)).then(res => { + if (requestVersion !== summaryRequestVersion) return summaryList.value = res.data || [] }) } function loadRows() { - if (!validateMultiValueFilters()) return Promise.resolve() + if (!hasCustomerArea() || !validateMultiValueFilters()) return Promise.resolve() const requestVersion = ++rowsRequestVersion const requestDimension = dimension.value loading.value = true @@ -419,14 +436,31 @@ function loadRows() { }) } +function clearReportResults() { + summaryRequestVersion++ + rowsRequestVersion++ + orderListRequestVersion++ + summaryList.value = [] + rows.value = [] + total.value = 0 + loading.value = false + orderListDialogVisible.value = false + orderListLoading.value = false + orderListRows.value = [] + orderListTotal.value = 0 + orderListContext.value = null +} + function handleSearch() { - if (!validateMultiValueFilters()) return + clearReportResults() + if (!hasCustomerArea() || !validateMultiValueFilters()) return pageNum.value = 1 Promise.all([loadSummary(), loadRows()]) } function handleReset() { Object.keys(query).forEach(key => { query[key] = '' }) + query.customerArea = customer_area.value[0]?.value ?? '' arBillStatus.value = '' dateRange.value = [formatLocalDate(-30), formatLocalDate(0)] handleSearch() @@ -459,7 +493,7 @@ function openOrderList(row) { function loadOrderList() { if (!orderListContext.value) return - if (!validateMultiValueFilters()) return + if (!hasCustomerArea() || !validateMultiValueFilters()) return const requestVersion = ++orderListRequestVersion orderListLoading.value = true const params = { @@ -513,7 +547,7 @@ function arBillStatusLabel(value) { } async function handleExport() { - if (!validateMultiValueFilters()) return + if (!hasCustomerArea() || !validateMultiValueFilters()) return exporting.value = true const exporter = dimension.value === 'product' ? exportProfitProducts : exportProfitOrders try { @@ -625,7 +659,17 @@ function handleDeleteRate(row) { } */ -handleSearch() +watch(customer_area, options => { + if (!options?.length) { + query.customerArea = '' + clearReportResults() + return + } + if (!options.some(area => area.value === query.customerArea)) { + query.customerArea = options[0].value + handleSearch() + } +}, { immediate: true })