🐛 毛利分析增加查询条件校验
This commit is contained in:
@@ -5,13 +5,13 @@
|
|||||||
<el-row :gutter="16">
|
<el-row :gutter="16">
|
||||||
<el-col :xs="24" :sm="12" :lg="8">
|
<el-col :xs="24" :sm="12" :lg="8">
|
||||||
<el-form-item label="客户区域" class="filter-item">
|
<el-form-item label="客户区域" class="filter-item">
|
||||||
<el-select v-model="query.customerArea" placeholder="请选择客户区域" class="filter-control" @change="handleSearch">
|
<el-select v-model="query.customerArea" placeholder="请选择客户区域" class="filter-control">
|
||||||
<el-option v-for="area in customer_area" :key="area.value" :label="area.label" :value="area.value" />
|
<el-option v-for="area in customer_area" :key="area.value" :label="area.label" :value="area.value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="12" :lg="8">
|
<el-col :xs="24" :sm="12" :lg="8">
|
||||||
<el-form-item label="计费日期" class="filter-item">
|
<el-form-item label="计费日期" class="filter-item" required>
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="dateRange"
|
v-model="dateRange"
|
||||||
type="daterange"
|
type="daterange"
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="12" :lg="8">
|
<el-col :xs="24" :sm="12" :lg="8">
|
||||||
<el-form-item label="客户名称" class="filter-item">
|
<el-form-item label="客户名称" class="filter-item" required>
|
||||||
<customer-select
|
<customer-select
|
||||||
v-model="query.customerCode"
|
v-model="query.customerCode"
|
||||||
:fetch-options="listProfitCustomerOptions"
|
:fetch-options="listProfitCustomerOptions"
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<el-col v-if="dimension === 'order'" :xs="24" :sm="12" :lg="8">
|
<el-col v-if="dimension === 'order'" :xs="24" :sm="12" :lg="8">
|
||||||
<el-form-item label="应收状态" class="filter-item">
|
<el-form-item label="应收状态" class="filter-item">
|
||||||
<el-select v-model="arBillStatus" clearable placeholder="全部状态" class="filter-control">
|
<el-select v-model="arBillStatus" clearable placeholder="全部状态" class="filter-control" @change="clearReportResults">
|
||||||
<el-option label="未出账" value="UNBILLED" />
|
<el-option label="未出账" value="UNBILLED" />
|
||||||
<el-option label="部分出账" value="PARTIAL" />
|
<el-option label="部分出账" value="PARTIAL" />
|
||||||
<el-option label="已出账" value="BILLED" />
|
<el-option label="已出账" value="BILLED" />
|
||||||
@@ -142,7 +142,7 @@
|
|||||||
icon="Download"
|
icon="Download"
|
||||||
v-hasPermi="['report:profit:export']"
|
v-hasPermi="['report:profit:export']"
|
||||||
:loading="exporting"
|
:loading="exporting"
|
||||||
:disabled="!hasProfitRule()"
|
:disabled="!hasProfitRule() || !hasSearched"
|
||||||
@click="handleExport"
|
@click="handleExport"
|
||||||
>导出当前维度</el-button>
|
>导出当前维度</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -199,7 +199,7 @@
|
|||||||
<template #default="{ row }">{{ arBillStatusLabel(row.arBillStatus) }}</template>
|
<template #default="{ row }">{{ arBillStatusLabel(row.arBillStatus) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</template>
|
</template>
|
||||||
<template #empty><el-empty description="暂无符合条件的数据" /></template>
|
<template #empty><el-empty :description="hasSearched ? '暂无符合条件的数据' : '请选择计费日期和客户名称后点击搜索'" /></template>
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -339,6 +339,7 @@ let summaryRequestVersion = 0
|
|||||||
const rows = ref([])
|
const rows = ref([])
|
||||||
let rowsRequestVersion = 0
|
let rowsRequestVersion = 0
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
const hasSearched = ref(false)
|
||||||
const exporting = ref(false)
|
const exporting = ref(false)
|
||||||
const exportLogVisible = ref(false)
|
const exportLogVisible = ref(false)
|
||||||
const exportLogLoading = ref(false)
|
const exportLogLoading = ref(false)
|
||||||
@@ -427,8 +428,24 @@ function hasProfitRule() {
|
|||||||
return hasCustomerArea() && !!currentRule.value
|
return hasCustomerArea() && !!currentRule.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasCompleteDateRange() {
|
||||||
|
return Array.isArray(dateRange.value) && !!dateRange.value[0] && !!dateRange.value[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateRequiredFilters(showMessage = true) {
|
||||||
|
if (!hasCompleteDateRange()) {
|
||||||
|
if (showMessage) ElMessage.warning('请选择完整的计费日期')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!query.customerCode) {
|
||||||
|
if (showMessage) ElMessage.warning('请选择客户名称')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
function loadSummary() {
|
function loadSummary() {
|
||||||
if (!hasProfitRule() || !validateMultiValueFilters(false)) return Promise.resolve()
|
if (!hasSearched.value || !validateRequiredFilters(false) || !hasProfitRule() || !validateMultiValueFilters(false)) return Promise.resolve()
|
||||||
const requestVersion = ++summaryRequestVersion
|
const requestVersion = ++summaryRequestVersion
|
||||||
summaryLoaded.value = false
|
summaryLoaded.value = false
|
||||||
return listProfitSummary(buildQuery(false)).then(res => {
|
return listProfitSummary(buildQuery(false)).then(res => {
|
||||||
@@ -439,7 +456,7 @@ function loadSummary() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadRows() {
|
function loadRows() {
|
||||||
if (!hasProfitRule() || !validateMultiValueFilters()) return Promise.resolve()
|
if (!hasSearched.value || !validateRequiredFilters(false) || !hasProfitRule() || !validateMultiValueFilters()) return Promise.resolve()
|
||||||
const requestVersion = ++rowsRequestVersion
|
const requestVersion = ++rowsRequestVersion
|
||||||
const requestDimension = dimension.value
|
const requestDimension = dimension.value
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@@ -454,6 +471,7 @@ function loadRows() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clearReportResults() {
|
function clearReportResults() {
|
||||||
|
hasSearched.value = false
|
||||||
summaryRequestVersion++
|
summaryRequestVersion++
|
||||||
rowsRequestVersion++
|
rowsRequestVersion++
|
||||||
orderListRequestVersion++
|
orderListRequestVersion++
|
||||||
@@ -471,7 +489,9 @@ function clearReportResults() {
|
|||||||
|
|
||||||
function handleSearch() {
|
function handleSearch() {
|
||||||
clearReportResults()
|
clearReportResults()
|
||||||
|
if (!validateRequiredFilters()) return
|
||||||
if (!hasProfitRule() || !validateMultiValueFilters()) return
|
if (!hasProfitRule() || !validateMultiValueFilters()) return
|
||||||
|
hasSearched.value = true
|
||||||
pageNum.value = 1
|
pageNum.value = 1
|
||||||
Promise.all([loadSummary(), loadRows()])
|
Promise.all([loadSummary(), loadRows()])
|
||||||
}
|
}
|
||||||
@@ -481,7 +501,8 @@ function handleReset() {
|
|||||||
query.customerArea = customer_area.value[0]?.value ?? ''
|
query.customerArea = customer_area.value[0]?.value ?? ''
|
||||||
arBillStatus.value = ''
|
arBillStatus.value = ''
|
||||||
dateRange.value = [formatLocalDate(-30), formatLocalDate(0)]
|
dateRange.value = [formatLocalDate(-30), formatLocalDate(0)]
|
||||||
handleSearch()
|
hasSearched.value = false
|
||||||
|
clearReportResults()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDimensionChange() {
|
function handleDimensionChange() {
|
||||||
@@ -489,10 +510,12 @@ function handleDimensionChange() {
|
|||||||
pageNum.value = 1
|
pageNum.value = 1
|
||||||
rows.value = []
|
rows.value = []
|
||||||
total.value = 0
|
total.value = 0
|
||||||
|
if (!hasSearched.value || !validateRequiredFilters(false)) return
|
||||||
Promise.all([loadSummary(), loadRows()])
|
Promise.all([loadSummary(), loadRows()])
|
||||||
}
|
}
|
||||||
|
|
||||||
function openOrderList(row) {
|
function openOrderList(row) {
|
||||||
|
if (!hasSearched.value || !validateRequiredFilters()) return
|
||||||
if (!validateMultiValueFilters()) return
|
if (!validateMultiValueFilters()) return
|
||||||
if (!row.orderCount) return
|
if (!row.orderCount) return
|
||||||
orderListTitle.value = '订单列表'
|
orderListTitle.value = '订单列表'
|
||||||
@@ -511,7 +534,7 @@ function openOrderList(row) {
|
|||||||
|
|
||||||
function loadOrderList() {
|
function loadOrderList() {
|
||||||
if (!orderListContext.value) return
|
if (!orderListContext.value) return
|
||||||
if (!hasProfitRule() || !validateMultiValueFilters()) return
|
if (!hasSearched.value || !validateRequiredFilters(false) || !hasProfitRule() || !validateMultiValueFilters()) return
|
||||||
const requestVersion = ++orderListRequestVersion
|
const requestVersion = ++orderListRequestVersion
|
||||||
orderListLoading.value = true
|
orderListLoading.value = true
|
||||||
const params = {
|
const params = {
|
||||||
@@ -565,6 +588,7 @@ function arBillStatusLabel(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleExport() {
|
async function handleExport() {
|
||||||
|
if (!hasSearched.value || !validateRequiredFilters()) return
|
||||||
if (!hasProfitRule() || !validateMultiValueFilters()) return
|
if (!hasProfitRule() || !validateMultiValueFilters()) return
|
||||||
exporting.value = true
|
exporting.value = true
|
||||||
const exporter = dimension.value === 'product' ? exportProfitProducts : exportProfitOrders
|
const exporter = dimension.value === 'product' ? exportProfitProducts : exportProfitOrders
|
||||||
@@ -679,7 +703,6 @@ function handleDeleteRate(row) {
|
|||||||
|
|
||||||
listProfitAreaRules().then(res => {
|
listProfitAreaRules().then(res => {
|
||||||
areaRules.value = res.data || {}
|
areaRules.value = res.data || {}
|
||||||
handleSearch()
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
areaRules.value = {}
|
areaRules.value = {}
|
||||||
areaRulesFailed.value = true
|
areaRulesFailed.value = true
|
||||||
@@ -694,9 +717,20 @@ watch(customer_area, options => {
|
|||||||
}
|
}
|
||||||
if (!options.some(area => area.value === query.customerArea)) {
|
if (!options.some(area => area.value === query.customerArea)) {
|
||||||
query.customerArea = options[0].value
|
query.customerArea = options[0].value
|
||||||
handleSearch()
|
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
|
watch(() => [
|
||||||
|
query.customerArea,
|
||||||
|
query.orderNo,
|
||||||
|
query.customerCode,
|
||||||
|
query.belongSalerCode,
|
||||||
|
query.productCode,
|
||||||
|
dateRange.value?.[0],
|
||||||
|
dateRange.value?.[1]
|
||||||
|
], () => {
|
||||||
|
if (hasSearched.value) clearReportResults()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
Reference in New Issue
Block a user